fork(1) download
  1. fail_strings = r"""
  2. ami
  3. café
  4. chapeau
  5. concert
  6. crayon
  7. garage
  8. garçon
  9. lit
  10. livre
  11. mari
  12. musée
  13. oncle
  14. ordinateur
  15. pantalon
  16. piano
  17. pique-nique
  18. portable
  19. père
  20. sandwich
  21. saxophone
  22. stade
  23. stylo
  24. théâtre
  25. téléphone
  26. voisin
  27. """.strip().split()
  28.  
  29. pass_strings = r"""
  30. botte
  31. boum
  32. chaise
  33. chaussette
  34. chemise
  35. clarinette
  36. copine
  37. femme
  38. fille
  39. glace
  40. heure
  41. lampe
  42. maison
  43. montagne
  44. personne
  45. piscine
  46. pizza
  47. radio
  48. raquette
  49. salade
  50. souris
  51. sœur
  52. table
  53. télé
  54. voiture
  55. """.strip().split()
  56.  
  57. def convert(strings):
  58. def f(s):
  59. n = 1
  60.  
  61. for c in s:
  62. n*=ord(c)
  63.  
  64. return n
  65.  
  66. return list(map(f, strings))
  67.  
  68. a = convert(pass_strings)
  69. b = convert(fail_strings)
  70.  
  71. def solve(list1, list2, x=[]):
  72. found = True
  73.  
  74. for i in range(1, min(256, max(list1), max(list2))):
  75. f = lambda x: x%i
  76.  
  77. set1 = set(map(f, list1))
  78. set2 = set(map(f, list2))
  79.  
  80. if not set1 & set2:
  81. solve(set1, set2, x+[i])
  82. found = False
  83.  
  84. if found:
  85. if min(len(list1), len(list2)) < 4:
  86. print(list1, list2, x)
  87.  
  88. solve(a, b)
Time limit exceeded #stdin #stdout 15s 9440KB
stdin
Standard input is empty
stdout
Standard output is empty