Advertisement
Guest User

Untitled

a guest
Sep 30th, 2016
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. #!/usr/bin/env ruby
  2. class PegCar
  3. PEG = 'Peg'
  4. CAR = 'Car'
  5.  
  6. def initialize
  7. (1..100).map do |b|
  8. if b % 35 == 0
  9. puts "#{PEG}#{CAR}"
  10. elsif b % 5 == 0 && b % 7 != 0
  11. puts PEG
  12. elsif b % 7 == 0 && b % 5 != 0
  13. puts CAR
  14. else
  15. puts b
  16. end
  17. end
  18. end
  19. end
  20.  
  21. PegCar.new
  22.  
  23. # output
  24. 1
  25. 2
  26. 3
  27. 4
  28. Peg
  29. 6
  30. Car
  31. 8
  32. 9
  33. Peg
  34. 11
  35. 12
  36. 13
  37. Car
  38. Peg
  39. 16
  40. 17
  41. 18
  42. 19
  43. Peg
  44. Car
  45. 22
  46. 23
  47. 24
  48. Peg
  49. 26
  50. 27
  51. Car
  52. 29
  53. Peg
  54. 31
  55. 32
  56. 33
  57. 34
  58. PegCar
  59. 36
  60. 37
  61. 38
  62. 39
  63. Peg
  64. 41
  65. Car
  66. 43
  67. 44
  68. Peg
  69. 46
  70. 47
  71. 48
  72. Car
  73. Peg
  74. 51
  75. 52
  76. 53
  77. 54
  78. Peg
  79. Car
  80. 57
  81. 58
  82. 59
  83. Peg
  84. 61
  85. 62
  86. Car
  87. 64
  88. Peg
  89. 66
  90. 67
  91. 68
  92. 69
  93. PegCar
  94. 71
  95. 72
  96. 73
  97. 74
  98. Peg
  99. 76
  100. Car
  101. 78
  102. 79
  103. Peg
  104. 81
  105. 82
  106. 83
  107. Car
  108. Peg
  109. 86
  110. 87
  111. 88
  112. 89
  113. Peg
  114. Car
  115. 92
  116. 93
  117. 94
  118. Peg
  119. 96
  120. 97
  121. Car
  122. 99
  123. Peg
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement