Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
words = [ 'tim', 'for', 'print', '1234567890', '321', '000', ] def check_word(operator: str): probability_map = {} for word in words: coincidence = 0 len_word = len(word) len_operator = len(operator) if len_word == len_operator: for op_symbol, w_symbol in zip(operator, word): if w_symbol == op_symbol: coincidence += 1 else: continue if coincidence == 0: continue probability_map[word] = 100 / len_word * coincidence, coincidence if probability_map: possible_word = sorted(probability_map)[0] percent_probability, coincidence = probability_map[possible_word] if percent_probability > 75 or len(possible_word) - coincidence <= 2: return possible_word else: return if __name__ == '__main__': for word in ['ti2', 'fi2', '123', '1234567990', 'prinr', 'Ti2', 'ris', 'qqq']: possible_word = check_word(word) if possible_word is not None: print(f'Вы написали: "{word}", возможно Вы имели ввиду: {possible_word}') else: print(f'Слова {word} нет в словаре!')
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)