Last active
February 10, 2022 07:33
-
-
Save sudarshang/28cb53a44d879354a8101575cc011bbb to your computer and use it in GitHub Desktop.
Word challenge
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
from itertools import chain | |
telepad = [ | |
["1"], | |
["2", "a", "b", "c"], | |
["3", "d", "e", "f"], | |
["4", "g", "h", "i" ], | |
["5", "j", "k", "l"], | |
["6", "m", "n", "o"], | |
["7", "p", "q", "r", "s"], | |
["8", "t", "u", "v"], | |
["9", "w", "x", "y", "z"], | |
] | |
contigous_sets = [set(chain(*telepad[i:i+3])) for i in range(len(telepad) - 3 + 1)] | |
for line in sys.stdin: | |
word = line.strip() | |
for set in contigous_sets: | |
if all(l in set for l in word.lower()): | |
print word | |
break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment