fork download
  1. def ConvertListToElement(l):
  2.  
  3.  
  4. temp = map(lambda a, b: a << b, l, range(len(l)-1,-1,-1))
  5. return reduce(lambda a, b: a | b, temp)
  6. gPrimitivePolys = {}
  7. gPrimitivePolysCondensed = {
  8. 1 : (1,0),
  9. 2 : (2,1,0),
  10. 3 : (3,1,0),
  11. 4 : (4,1,0),
  12. 5 : (5,2,0),
  13. 6 : (6,4,3,1,0),
  14. 7 : (7,1,0),
  15. 8 : (8,4,3,2,0),
  16. 9 : (9,4,0),
  17. 10 : (10,6,5,3,2,1,0),
  18. 11 : (11,2,0),
  19. 12 : (12,7,6,5,3,1,0),
  20. 13 : (13,4,3,1,0),
  21. 14 : (14,7,5,3,0),
  22. 15 : (15,5,4,2,0),
  23. 16 : (16,5,3,2,0),
  24. 17 : (17,3,0),
  25. 18 : (18,12,10,1,0),
  26. 19 : (19,5,2,1,0),
  27. 20 : (20,10,9,7,6,5,4,1,0),
  28. 21 : (21,6,5,2,0),
  29. 22 : (22,12,11,10,9,8,6,5,0),
  30. 23 : (23,5,0),
  31. 24 : (24,16,15,14,13,10,9,7,5,3,0),
  32. 25 : (25,8,6,2,0),
  33. 26 : (26,14,10,8,7,6,4,1,0),
  34. 27 : (27,12,10,9,7,5,3,2,0),
  35. 28 : (28,13,7,6,5,2,0),
  36. 29 : (29,2,0),
  37. 30 : (30,17,16,13,11,7,5,3,2,1,0),
  38. 31 : (31,3,0),
  39. 32 : (32,15,9,7,4,3,0),
  40. 33 : (33,13,12,11,10,8,6,3,0),
  41. 34 : (34,16,15,12,11,8,7,6,5,4,2,1,0),
  42. 35 : (35, 11, 10, 7, 5, 2, 0),
  43. 36 : (36, 23, 22, 20, 19, 17, 14, 13, 8, 6, 5, 1, 0),
  44. 37 : (37, 5, 4, 3, 2, 1, 0),
  45. 38 : (38, 14, 10, 9, 8, 5, 2, 1, 0),
  46. 39 : (39, 15, 12, 11, 10, 9, 7, 6, 5, 2 , 0),
  47. 40 : (40, 23, 21, 18, 16, 15, 13, 12, 8, 5, 3, 1, 0),
  48. 97 : (97,6,0),
  49. 100 : (100,15,0)
  50. }
  51.  
  52. for n in gPrimitivePolysCondensed.keys():
  53. gPrimitivePolys[n] = [0]*(n+1)
  54. unity = 1
  55. for index in gPrimitivePolysCondensed[n]:
  56. gPrimitivePolys[n][index] = unity
  57. gPrimitivePolys[n].reverse()
  58. print(ConvertListToElement(gPrimitivePolys[n]))
Runtime error #stdin #stdout #stderr 0.16s 23608KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Traceback (most recent call last):
  File "./prog.py", line 58, in <module>
  File "./prog.py", line 5, in ConvertListToElement
NameError: name 'reduce' is not defined