source: trunk/Examples/Others/196.b

Last change on this file was 11, checked in by chronos, 12 years ago
  • Added: Some other examples from web.
File size: 2.8 KB
Line 
1[
2 The 196-algorithm implemented in brainfuck by Mats Linander.
3
4 This program reads a number in the form of a string of decimal digits
5 terminated by a unix style newline (0x10) and tries to determine if the
6 entered number is a lychrel number.
7
8 A lychrel number is a number which never yields a palindrome when iteratively
9 added with its own reversal. The process of iteratively reversing and adding
10 until a palindromic number is obtained, is often called the 196-algorithm.
11 The smallest number believed to be a lychrel is 196. Hence the name of the
12 algorithm.
13
14 This program will keep reversing and adding until a palindromic numbers is
15 obtained or it runs out of memory. Given x bytes of memory, an approximately
16 x/5 digits long number can be calculated.
17
18----------------------------------------------------------------------------
19 "THE BEER-WARE LICENSE" (Revision 42):
20 <matslina (at) kth (dot) se> wrote this file. As long as you retain this
21 notice you can do whatever you want with this stuff. If we meet some day,
22 and you think this stuff is worth it, you can buy me a beer in return.
23 Mats Linander 2004-06-15
24----------------------------------------------------------------------------
25
26]
27
28 ++++++++++[->++++++++++>+++++++++++>+++<<<]>+.>.++++++.<.>--.>++.<---
29 -.+++++++.--------.<---.+++.[-]>+++++.++[--<+>]<.[-]>>.[-]<<<+>>->,--
30 -- --
31 -- --[-->++++++[-<------>]<[->+>+<<]<+>+>>>>>,----------]<<<<<<[ <<
32 << <]>-<<<[>>>>>>>[<<[->>[>>>>>]<+<<<<[<<<<<]>>>]>>[>>>>>]<<[-<< <[
33 << <<<]>>>+>>[>>>>>]<<]>[-<+>]<<<<-<<<<<[<<<<<]>>>>>[-]>>>>>]<<< <[
34 << <<<]<<+>>>>> >>[<+>>> >>>]<+[- <<[->+>+<<]<[ ->
35 +> -<<]>[-<+> ]>>[-< <+>>]< [[-] <<<[<<<<<]<<[-]>> >>
36 >> [>>>>>]< ]<<<<] <[-<-> ]< [>>>>>>>>[<<+++++++ +[
37 -< ++++++>]<.>> >>>>>> ]+++++ ++ +[-<+++++<++++<++++ ++
38 >> >]<<<.>.>+++ .<.<.>>+ ++ ++[-<<->>]< [-
39 ]< <<[<<<.>++++ ++++[-<------>]< << ]+++++ +++++[-<+ ++
40 <+ +++++>>]<++. <+.[-]>.[-]>>>>> >[ >>>>>] +[<<<<<]> >>
41 >> [<<<[-<+>]>+ <<[>>-<<[->+<]]> [- <+>]>[ >>-<<-]<+ ++
42 ++ ++++[>>+<<-< -[>>>-<<<[->>+ <<]] >>[-<< +>>]>[->[ -]
43 <] <<]<->>> +>[- <->>+<]+ <[-<<<+++++ ++
44 ++ +>>>]>>>>>>]<<<<<[-]>[-<+>>+<]>[-<+>]<<<<<<<[<<<<<]>>>>>[>>>> >]
45 << <<<[>[->+>+>+<<<]>>[-<<+>>]++++++++[->++++++<]>.[-]<<<<<<<<<] >[
46 -> +>+>+<<<]>>[-<<+>>]++++++++[->++++++<]>.[-]>[>>>>>]<<<<<[<+<< <<
47 ]< <<
48 +++++++++.--------->+<-]>[-<+>]<]++++++++++[->++++++++>+++++++++++>++
49 ++++<<<]>.<++++[->++++<]>+.>--.---.+++++.<+++.>++++.---.--.<+.>>--.++
50 [--<<<+>>>]<<<++.>>>+[>>>++++++++[-<++++++>]<.>>>]++++++++++.
Note: See TracBrowser for help on using the repository browser.