fork download
  1. ** ずんだの1桁足し算問題(BF 367chars)
  2. ** prepare symbol characters
  3. +++[->+++++++<]
  4. >[->P++>E+++>C++++++<<<]
  5. >P+>E-->>
  6.  
  7. ** double loop
  8. i+++++++++[-
  9. >>j+++++++++[-
  10. ** main
  11. * memory layout: PECi_j
  12. * P E C: character code for PLUS EQUAL TILDE respectively
  13. * i j: loop counters from 8 downto 0
  14.  
  15. ** create several numbers from i j
  16. <<i[->+>>S->>I->>S-<<<<<<<]>[-<+>]
  17. >j[-<+>>S->>>J->S-<<<<<]
  18. ++++++++++[->S++>>I+>J+>S++<<<<<]
  19.  
  20. * memory layout: PECij_S_IJS
  21. * I J: 10 minus i/j
  22. * S : I plus J
  23.  
  24. ** divide by 10
  25. >>>>>>>R++++++++++<<S--[->>R-[<r+>>>>]<[r+[->R+<]>>q+>]<<<<]
  26.  
  27. * memory layout: PECij_S_IJ_rRq
  28. * r q: remainder and quotient ( result of the division )
  29. * R: 10 minus r
  30.  
  31. ** digit compaction and replacement
  32. >>>q[+[-<<<+>>>]<R[-]<r+>>] ( if q is not zero )
  33. <R[[-]<r+[-<+>]>] ( else )
  34.  
  35. * memory layout: PECij_S_IJD(D)
  36. * D: created digit(s) of S minus 2 through the division
  37. * notice: I J D are all larger by 1 than they are meant to be
  38.  
  39. ** convert numbers to characters and print
  40. <<<<<<S<++++++[->>>I[>]<[++++++++<]<<]
  41. >>>I-.<<<<<<<<P.>>>>>>>>>J-.<<<<<<<<E.>>>>>S--[-<<<<T.>>>>]>>>>D[-.>]
  42.  
  43. ** print newline and clear temporary characters I J D then move j back
  44. ++++++++++.[[-]<]<<<[->+<]
  45. >j]
  46. <<i]
Success #stdin #stdout 0s 4172KB
stdin
Standard input is empty
stdout
1+1=~~2
1+2=~~~3
1+3=~~~~4
1+4=~~~~~5
1+5=~~~~~~6
1+6=~~~~~~~7
1+7=~~~~~~~~8
1+8=~~~~~~~~~9
1+9=~~~~~~~~~~10
2+1=~~~3
2+2=~~~~4
2+3=~~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