Skip to content

Instantly share code, notes, and snippets.

@dzhulk
Last active August 29, 2015 14:00
Show Gist options
  • Select an option

  • Save dzhulk/11158335 to your computer and use it in GitHub Desktop.

Select an option

Save dzhulk/11158335 to your computer and use it in GitHub Desktop.
werty12?asdfg///?0987asdfghrexesx5
werty12/asdfg//!/0987asdfghrexesx
#!/usr/bin/env python
# -*- coding: utf-8 -*-
n = 25
russian_vowels = ['А', 'Е', 'Ё', 'И', 'О', 'У', 'Ы', 'Э', 'Ю', 'Я']
english_vowels = ['A','E','I','O','U']
vowels = russian_vowels + english_vowels
def clean(s):
return ''.join(ch for ch in s if ch.isalnum())
def remove_vowels(s):
if len(s) > n:
f1 = s[0:n]
f2 = s[n:]
f2 = ''.join(ch for ch in f2 if ch not in vowels)
return f1 + f2
else:
return s
def compare(str1, str2):
str1 = str1.upper()
str2 = str2.upper()
str1 = clean(str1)
str2 = clean(str2)
str1 = remove_vowels(str1)
str2 = remove_vowels(str2)
print(str1)
print(str2)
return str1 == str2
if __name__ == "__main__":
str1 = input("1st string: ")
str2 = input("2nd string: ")
print("Are strings equal? " + str(compare(str1, str2)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment