fork(3) download
  1. def convert(x, v):
  2. characters = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
  3. numbers = range(27)
  4. numbers.remove(0)
  5. y = 0
  6. if v == "number":
  7. while y < 26:
  8. if characters[y] == x.lower():
  9. return numbers[y]
  10. y += 1
  11. elif v == "letter":
  12. while y < 26:
  13. if numbers[y] == x:
  14. return characters[y].upper()
  15. y += 1
  16.  
  17. def function(x):
  18. if x in range(convert("A", "number"), convert("E", "number") + 1):
  19. y = 2 * x
  20. elif x in range(convert("F", "number"), convert("J", "number") + 1):
  21. y = 5 * (x % 3)
  22. elif x in range(convert("K", "number"), convert("O", "number") + 1):
  23. y = 8 * (x / 4)
  24. elif x in range(convert("P", "number"), convert("T", "number") + 1):
  25. place = str(x)
  26. a = 0
  27. b = 0
  28. while b < len(place):
  29. a += int(place[b])
  30. b += 1
  31. y = 10 * a
  32. elif x in range(convert("U", "number"), convert("Z", "number") + 1):
  33. a = 2
  34. while a < x:
  35. if x % a == 0:
  36. b = a
  37. a += 1
  38. y = 12 * b
  39. y = y % 26
  40. if y == 0:
  41. y = 26
  42. return convert(y, "letter")
  43.  
  44. def main():
  45. inputs = []
  46. outputs = []
  47. a = 0
  48. while a < 5:
  49. inputs.append(raw_input())
  50. outputs.append(function(convert(inputs[a], "number")))
  51. a += 1
  52. a = 0
  53. while a < 5:
  54. print outputs[a]
  55. a += 1
  56.  
  57. main()
Success #stdin #stdout 0.01s 7856KB
stdin
E
H
M
P
V
stdout
J
J
X
R
B