Initial release
This commit is contained in:
29
SW V Joue avec Yoda.py
Normal file
29
SW V Joue avec Yoda.py
Normal file
@@ -0,0 +1,29 @@
|
||||
import random
|
||||
|
||||
input = "sassai eaux-de-vie cessaient acerbité eaux sceau tiendra hasard acéphale auxiliairement vesce eurafricaine hâtai saignant entachassent alentie césar vieillerie messéant taillable ives testacé dracéna ardentes ensablant blessas entachasses ioniens antarctique sessiles ineffaçables quercitrine besace lessivasses acerbes descellaient entachas lessive gestation lessivâtes antécédentes énamourâmes antécédent entachât inefficace testacelles sarabandes entachant rieur itérâmes antécédences messages sesquioxydes testacés"
|
||||
|
||||
input = input.split()
|
||||
|
||||
table = input.copy()
|
||||
solution = [table[0], ]
|
||||
table.pop(0)
|
||||
|
||||
while len(table) > 0:
|
||||
for mot in table:
|
||||
if mot[:3] == solution[-1][-3:]:
|
||||
solution.append(mot)
|
||||
table.remove(mot)
|
||||
break
|
||||
if mot[-3:] == solution[0][:3]:
|
||||
solution = [mot,] + solution
|
||||
table.remove(mot)
|
||||
break
|
||||
else:
|
||||
print("Pas trouvé, il restait {} éléments. Je retente en mélangeant...".format(len(table)))
|
||||
table = input.copy()
|
||||
random.shuffle(table)
|
||||
solution = [table[0], ]
|
||||
|
||||
print(len(solution))
|
||||
print('"' + '", "'.join(solution) + '"')
|
||||
|
||||
Reference in New Issue
Block a user