mirror of
https://github.com/NohamR/puzzel-solver.git
synced 2026-11-25 23:08:01 +00:00
Add files via upload
This commit is contained in:
1 file changed
+33
@@ -0,0 +1,33 @@
|
||||
from pprint import pprint
|
||||
import json
|
||||
|
||||
def decode_sentence(sentence):
|
||||
decoded_words = []
|
||||
words = sentence.split()
|
||||
for word in words:
|
||||
try:
|
||||
decoded_word = word.encode('latin1').decode('utf-8')
|
||||
decoded_words.append(decoded_word)
|
||||
except UnicodeDecodeError:
|
||||
decoded_words.append(word)
|
||||
return ' '.join(decoded_words)
|
||||
|
||||
dict = {"t":"d","d":{"r":7,"b":{"s":"ok","d":{"grid":{"0":{"0":"@","1":"@","2":"@","3":"@","4":"@","5":"@","6":"@","7":"@","8":"@","9":"@","10":"@","11":"@","12":"@","13":"@","14":"@","15":"@","16":"@","17":"@","18":"@","19":"@","20":"@","21":"@","22":"@","23":"@","24":"@","25":"é","26":"@","27":"@","28":"@","29":"@","30":"@","31":"@","32":"@","33":"@","34":"@","35":"@","36":"@","37":"@","38":"@","39":"@","40":"@"},"1":{"0":"@","1":"@","2":"@","3":"@","4":"@","5":"@","6":"@","7":"@","8":"@","9":"@","10":"@","11":"@","12":"@","13":"@","14":"@","15":"@","16":"@","17":"@","18":"@","19":"d","20":"@","21":"@","22":"@","23":"@","24":"@","25":"q","26":"@","27":"@","28":"@","29":"@","30":"a","31":"@","32":"@","33":"@","34":"@","35":"@","36":"@","37":"@","38":"p","39":"@","40":"i"},"2":{"0":"@","1":"@","2":"@","3":"@","4":"@","5":"@","6":"@","7":"@","8":"@","9":"@","10":"@","11":"@","12":"@","13":"@","14":"@","15":"@","16":"@","17":"@","18":"@","19":"é","20":"@","21":"@","22":"@","23":"a","24":"@","25":"u","26":"@","27":"@","28":"@","29":"@","30":"m","31":"@","32":"@","33":"@","34":"@","35":"@","36":"@","37":"@","38":"r","39":"@","40":"n"},"3":{"0":"@","1":"@","2":"@","3":"@","4":"@","5":"@","6":"@","7":"@","8":"@","9":"@","10":"@","11":"@","12":"@","13":"@","14":"@","15":"@","16":"@","17":"@","18":"@","19":"f","20":"@","21":"r","22":"e","23":"s","24":"p","25":"i","26":"r","27":"a","28":"t","29":"i","30":"o","31":"n","32":"@","33":"@","34":"@","35":"@","36":"f","37":"@","38":"o","39":"@","40":"d"},"4":{"0":"@","1":"@","2":"@","3":"@","4":"@","5":"@","6":"@","7":"@","8":"@","9":"@","10":"@","11":"@","12":"@","13":"@","14":"@","15":"@","16":"@","17":"@","18":"@","19":"o","20":"@","21":"@","22":"@","23":"t","24":"@","25":"l","26":"@","27":"@","28":"@","29":"@","30":"r","31":"@","32":"@","33":"@","34":"@","35":"@","36":"o","37":"@","38":"t","39":"@","40":"i"},"5":{"0":"@","1":"@","2":"d","3":"i","4":"o","5":"x","6":"y","7":"d","8":"e","9":"d","10":"e","11":"c","12":"a","13":"r","14":"b","15":"o","16":"n","17":"e","18":"@","19":"r","20":"@","21":"m","22":"@","23":"h","24":"@","25":"i","26":"@","27":"@","28":"@","29":"@","30":"t","31":"@","32":"p","33":"@","34":"@","35":"@","36":"r","37":"@","38":"o","39":"@","40":"c"},"6":{"0":"@","1":"@","2":"@","3":"@","4":"@","5":"@","6":"@","7":"@","8":"@","9":"@","10":"@","11":"@","12":"s","13":"@","14":"@","15":"@","16":"@","17":"@","18":"@","19":"e","20":"@","21":"u","22":"@","23":"m","24":"@","25":"b","26":"@","27":"@","28":"@","29":"@","30":"i","31":"@","32":"é","33":"@","34":"@","35":"@","36":"ç","37":"@","38":"c","39":"@","40":"a"},"7":{"0":"@","1":"@","2":"p","3":"a","4":"l","5":"é","6":"o","7":"c","8":"l","9":"i","10":"m","11":"a","12":"t","13":"@","14":"@","15":"m","16":"@","17":"@","18":"@","19":"s","20":"@","21":"t","22":"@","23":"a","24":"@","25":"r","26":"@","27":"@","28":"@","29":"@","30":"s","31":"@","32":"t","33":"@","34":"f","35":"@","36":"a","37":"@","38":"o","39":"@","40":"t"},"8":{"0":"@","1":"@","2":"@","3":"@","4":"@","5":"@","6":"@","7":"@","8":"@","9":"@","10":"@","11":"@","12":"é","13":"@","14":"@","15":"i","16":"@","17":"@","18":"@","19":"t","20":"@","21":"a","22":"@","23":"t","24":"@","25":"é","26":"@","27":"@","28":"@","29":"@","30":"s","31":"@","32":"r","33":"@","34":"o","35":"@","36":"g","37":"@","38":"l","39":"@","40":"e"},"9":{"0":"@","1":"@","2":"@","3":"l","4":"i","5":"t","6":"h","7":"o","8":"s","9":"p","10":"h","11":"è","12":"r","13":"e","14":"@","15":"c","16":"@","17":"@","18":"@","19":"a","20":"@","21":"g","22":"@","23":"i","24":"@","25":"s","26":"@","27":"@","28":"v","29":"i","30":"e","31":"h","32":"o","33":"r","34":"s","35":"d","36":"e","37":"l","38":"e","39":"a","40":"u"},"10":{"0":"@","1":"@","2":"@","3":"@","4":"@","5":"@","6":"@","7":"z","8":"@","9":"@","10":"@","11":"@","12":"o","13":"@","14":"@","15":"r","16":"@","17":"@","18":"@","19":"t","20":"@","21":"è","22":"@","23":"q","24":"@","25":"@","26":"@","27":"@","28":"@","29":"@","30":"u","31":"@","32":"l","33":"@","34":"s","35":"@","36":"r","37":"@","38":"d","39":"@","40":"r"},"11":{"0":"c","1":"@","2":"@","3":"@","4":"@","5":"@","6":"@","7":"o","8":"@","9":"@","10":"@","11":"d","12":"i","13":"s","14":"s","15":"o","16":"l","17":"u","18":"t","19":"i","20":"o","21":"n","22":"@","23":"u","24":"@","25":"@","26":"@","27":"@","28":"@","29":"@","30":"r","31":"@","32":"e","33":"@","34":"i","35":"@","36":"a","37":"@","38":"e","39":"@","40":"c"},"12":{"0":"e","1":"@","2":"@","3":"@","4":"@","5":"@","6":"@","7":"n","8":"@","9":"@","10":"@","11":"@","12":"d","13":"@","14":"@","15":"p","16":"@","17":"@","18":"@","19":"o","20":"@","21":"e","22":"@","23":"e","24":"@","25":"@","26":"@","27":"@","28":"@","29":"@","30":"@","31":"@","32":"@","33":"@","34":"l","35":"@","36":"d","37":"@","38":"m","39":"@","40":"l"},"13":{"0":"n","1":"@","2":"@","3":"@","4":"@","5":"@","6":"@","7":"e","8":"@","9":"@","10":"@","11":"@","12":"e","13":"@","14":"@","15":"a","16":"@","17":"@","18":"@","19Line truncated
|
||||
# pprint(dict)
|
||||
|
||||
# with open('file.json','w') as f:
|
||||
# json.dump(dict, f, indent=2)
|
||||
|
||||
answers = dict['d']['b']['d']['grid']
|
||||
|
||||
def getanswer(x,y):
|
||||
return answers[f'{y}'][f'{x}'].encode('latin1').decode('utf-8')
|
||||
|
||||
words = dict['d']['b']['d']['wordsPlaced']
|
||||
for i in range(45):
|
||||
desc = words[f'{i}']['description']
|
||||
word = ''
|
||||
for j in range(len(words[f'{i}']['coords'])):
|
||||
word += getanswer(words[f'{i}']['coords'][f'{j}']['1'], words[f'{i}']['coords'][f'{j}']['0'])
|
||||
|
||||
print(f'{i+1} : {decode_sentence(desc)} : ||{word}||')
|
||||
Reference in new issue
Block a user