Skip to content

Instantly share code, notes, and snippets.

@maestroviktorin
Created January 29, 2023 19:23
Show Gist options
  • Select an option

  • Save maestroviktorin/205baed895294fadb8297675dcae6e33 to your computer and use it in GitHub Desktop.

Select an option

Save maestroviktorin/205baed895294fadb8297675dcae6e33 to your computer and use it in GitHub Desktop.
Solution to the problem #4322 by /dev/inf from kompege.ru
"""
Solution to the problem No. 4322 by /dev/inf from kompege.ru
`10.txt` is a text file in which the beginning and each line of type `Глава \d+`
must be deleted manually in the Notebook for example.
"""
import re
with open('10.txt') as file:
rows = (tuple(re.sub(r'\W', '', word).lower()
for word in row.split()) for row in file)
c = 0
for row in rows:
for word in row:
c += ('в' in word) and all(char not in word for char in ('а', 'о'))
print(c)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment