fork download
  1. # 99 bottles of beer in Brainf*ck
  2. # Copyright (C) 2008 Raphael Bois
  3. # 1671 brainf*ck instructions.
  4. # Published under GPL v2
  5.  
  6. Initialization
  7. ++ Counter for loop (a)
  8. >+ unused
  9. >++ Counter for loop (b)
  10. > Flag for 'no more'
  11. >+ Flag for not 'no more'
  12. >>> (5) to (7) : temporary values
  13. ++++++++++[->+>+>++++++++++<<<]>>> 10 10 100 in (8) (9) (10)
  14. >++++++++++ 10 in (11)
  15. [-
  16. >+++++ 50 in (12)
  17. >++++++++++ 100 in (13)
  18. >+++++++++++ 110 in (14)
  19. >++++++++ 80 in (15)
  20. >++++++++ 80 in (16)
  21. >+++ 30 in (17)
  22. >++++ 40 in (18)
  23. >+ 10 in (19)
  24. <<<<<<<<]
  25. +
  26. >-- + 48 '0' plus 1 in (12)
  27. >++ + 102 'f' plus 1 in (13)
  28. >+++++ + 115 's' plus 1 in (14)
  29. >-- + 78 'N' plus 1 in (15)
  30. >++++ + 84 'T' plus 1 in (16)
  31. >++ + 32 ' ' plus 1 in (17)
  32. >++++ + 44 comma plus 1 in (18)
  33. > + 10 LF plus 1 in (19)
  34.  
  35. stuff for writing parts of the song
  36. >+ select stuff
  37. >+ select stuff
  38. >+ write song part 3
  39. >++ write song part 1
  40. >+ write song part 2
  41. >+ Flag for 'end of song'
  42. >++ Flag for not 'end of song'
  43.  
  44. All bytes are at val plus 1
  45. Go back to (7) with final initialization step (remove 1 to all bytes)
  46. [-<]
  47.  
  48. <<<<<<< at (0)
  49. [ loop (a)
  50. -
  51.  
  52. >> at (2)
  53. [ loop (b)
  54.  
  55. >>>>>>>> at (10)
  56. [ start loop
  57.  
  58. <<<<<<< at (3)
  59. [->[-]
  60. print '(N|n)o more'
  61. >>>>>>>>>>>. '(N|n)'
  62. <----. 'o'
  63. >>>. ' '
  64. <<<--. 'm'
  65. ++. 'o'
  66. +++.+ 'r'
  67. <-.+ 'e'
  68. <<+<<<<<<<<
  69. ]+> at (4)
  70. [-<[-]>>>>> at (9)
  71. prints number (using (9) and (10))
  72. [>>>+<<<<+<+<+>>>-]<<<[->>>+<<<]> at (6)
  73. [>>>>>>+<<<<<<-]>>>>>[[-]>.<]<<<<[>>>>>-<<<<<-]>> at (9)
  74. [<<+<+<+>>>>-]<<<<[->>>>+<<<<]> at (6)
  75. [>>>>>>+<<<<<<-]>>>>>>.<<<<<[>>>>>-<<<<<-] at (7)
  76.  
  77. memorize in (11) if (10) not 1
  78. >>>[-<<<+<+>>>>]<<<<[->>>>+<<<<]>-[[-]>>>>+<<<<]<<< at (4)
  79. ]+
  80.  
  81. >>>>>>>> at (12)
  82. print ' bottle(s) of beer'
  83. >>>>>. ' '
  84. <<<<----. 'b'
  85. >----. 'o'
  86. +++++..- 'tt'
  87. <++++++++++. 'l'
  88. -------. 'e'
  89. <<[[-]>>>.<<<]>> 's' if (11)==1 ie if (10)!=1
  90. >>>>. ' '
  91. <<<----. 'o'
  92. <+. 'f'
  93. >>>>. ' '
  94. <<<<----. 'b'
  95. +++..+ 'ee'
  96. >+++.+ 'r'
  97.  
  98. [>] at (20)
  99.  
  100. +>+>[->+<<-<-
  101. print ' on the wall' DOT LF LF
  102. <<<. ' '
  103. <<<----. 'o'
  104. -. 'n'
  105. >>>. ' '
  106. <<<++++++. 't'
  107. <++. 'h'
  108. ---. 'e'
  109. >>>>. ' '
  110. <<<+++. 'w'
  111. <----. 'a'
  112. +++++++++++.. 'll'
  113. ------>---- reset to 'f' and 's'
  114. >---------- ---------- ---------- -- sets (15) to 'N'
  115.  
  116. >>>++.-- DOT
  117. >.. LF LF
  118. >>>] at (22)
  119.  
  120. >>>[->[-]<<<<<<<[<]<[-]>>[>]>>>>>]+ if end of song reset bottles counter
  121. >[-<[-] at (25)
  122. <<<< at (21)
  123. [->>[->+<<<<-
  124. print ' on the wall' COMMA ' '
  125. <<<. ' '
  126. <<<----. 'o'
  127. -. 'n'
  128. >>>. ' '
  129. <<<++++++. 't'
  130. <++. 'h'
  131. ---. 'e'
  132. >>>>. ' '
  133. <<<+++. 'w'
  134. <----. 'a'
  135. +++++++++++.. 'll'
  136.  
  137. ------>---- reset (13) and (14) to 'f' and 's'
  138. >++++++++++ ++++++++++ ++++++++++ ++ sets (15) to 'n'
  139.  
  140. >>>. comma
  141. <. ' '
  142. >>>>>>]<<]< at (20)
  143.  
  144. [->>>>[-<<+< at (21)
  145. <<<++.-- DOT
  146. >. LF
  147.  
  148. [<]<<<<<<<< at (3)
  149. [->[-]<]+> at (4)
  150. [-<[-]>
  151. >>>>>>>>>>>>. 'T'
  152. <<<-----. 'a'
  153. ++++++++++. 'k'
  154. ------. 'e'
  155. >>>>. ' '
  156. <<<----. 'o'
  157. -. 'n'
  158. <. 'e'
  159. >>>>. ' '
  160. <<<<-. 'd'
  161. >+. 'o'
  162. ++++++++. 'w'
  163. ---------. 'n'
  164. >>>. ' '
  165. <<<<---. 'a'
  166. >. 'n'
  167. <+++. 'd'
  168. >>>>. ' '
  169. <<<++. 'p'
  170. <---. 'a'
  171. >+++.. 'ss'
  172. >>>. ' '
  173. <<<<++++++++. 'i'
  174. >+. 't'
  175. >>>. ' '
  176. <<<<--------. 'a'
  177. >--. 'r'
  178. ---. 'o'
  179. ++++++. 'u'
  180. -------. 'n'
  181. <+++. 'd'
  182. ++>+++++ reset (13) and (14) to 'f' and 's'
  183. >>>>. comma
  184. <. ' '
  185.  
  186. [<]<<<<<<< at (4)
  187. ]+
  188.  
  189. >>>>>> at (10)
  190. decrements values
  191. -<<<+>>[<<[-]<+<+>>>>-]<<<<[>-<[-]]>[->>>+<<<]>[->->+++++++++<<]>>> at (10)
  192.  
  193. >>[>]>>>>] at (24)
  194. <<<<] at (20)
  195.  
  196. >>>>>>]+ at (26)
  197.  
  198. <<<<<<<[<]< at (10)
  199. ]
  200. +<+
  201. <<<<<<+< at (2)
  202. -
  203. ]
  204.  
  205. print 'Go to the store and buy some more' comma ' '
  206.  
  207. >>>>>>>>>>[>]>>>>> at (25)
  208. [->[-]<]+> at (26)
  209. [-<[-]
  210. <<<<<<<<< at (16)
  211. -------------. 'G'
  212. <<----. 'o'
  213. >>>. ' '
  214. <<<+++++. 't'
  215. -----. 'o'
  216. >>>. ' '
  217. <<<+++++. 't'
  218. <++. 'h'
  219. ---. 'e'
  220. >>>>. ' '
  221. <<<-. 's'
  222. +. 't'
  223. -----. 'o'
  224. +++. 'r'
  225. <. 'e'
  226. >>>>. ' '
  227. <<<<----. 'a'
  228. >----. 'n'
  229. <+++. 'd'
  230. >>>>. ' '
  231. <<<<--. 'b'
  232. >+++++++. 'u'
  233. ++++. 'y'
  234. >>>. ' '
  235. <<<------. 's'
  236. ----. 'o'
  237. --. 'm'
  238. <+++. 'e'
  239. >>>>. ' '
  240. <<<. 'm'
  241. ++. 'o'
  242. +++.+ 'r'
  243. <.+ 'e'
  244. >>>>>. coma
  245. <. ' '
  246. >>>>>>>>>
  247. ]+
  248.  
  249. Initialize last loop to print final '99 bottles of beer on the wall' DOT
  250. <[-]+<[-]<[-]<[-]+<<< at (19)
  251. [<]<[-]<[-]<[-]<[-] at (7)
  252. ++++++++++[->+>+>++++++++++<<<]>->->-
  253. <<<<<<[-]+<[-]<+<< at (0)
Runtime error #stdin #stdout 0.01s 1700KB
stdin
Standard input is empty
stdout
Standard output is empty