]> Git — Sourcephile - haskell/symantic-parser.git/blob - tests/Golden/Parser/G13/P3.input.txt
impl: remove dead code: `unLeft`
[haskell/symantic-parser.git] / tests / Golden / Parser / G13 / P3.input.txt
1 >,[
2 [
3 ----------[
4 >>>[>>>>]+[[-]+<[->>>>++>>>>+[>>>>]++[->+<<<<<]]<<<]
5 ++++++[>------<-]>--[>>[->>>>]+>+[<<<<]>-],<
6 ]>
7 ]>>>++>+>>[
8 <<[>>>>[-]+++++++++<[>-<-]+++++++++>[-[<->-]+[<<<<]]<[>+<-]>]
9 >[>[>>>>]+[[-]<[+[->>>>]>+<]>[<+>[<<<<]]+<<<<]>>>[->>>>]+>+[<<<<]]
10 >[[>+>>[<<<<+>>>>-]>]<<<<[-]>[-<<<<]]>>>>>>>
11 ]>>+[[-]++++++>>>>]<<<<[[<++++++++>-]<.[-]<[-]<[-]<]<,
12 ]
13
14 [The Collatz problem or 3n+1 problem is as follows. Take a natural number n.
15 If it's even, halve it; if odd, triple it and add one. Repeat the process with
16 the resulting number, and continue indefinitely. If n is 0, the resulting
17 sequence is 0, 0, 0, 0... It is conjectured but not proven that for any
18 positive integer n, the resulting sequence will end in 1, 4, 2, 1...
19 See also http://www.research.att.com/projects/OEIS?Anum=A006577
20
21 This program takes a series of decimal numbers, followed by linefeeds (10).
22 The entire series is terminated by an EOF (0 or "no change"). For each number
23 input, the program outputs, in decimal, the number of steps from that number
24 to zero or one, when following the rule above. It's quite fast; on a Sun
25 machine, it took three seconds for a random 640-digit number.
26
27 One more note. This program was originally written for Tristan Parker's
28 Brainfuck Texas Holdem contest, and won by default (it was the only entry);
29 the version I submitted before the contest deadline is at
30 http://www.hevanet.com/cristofd/brainfuck/oldcollatz.b
31
32 SPDX-FileCopyrightText: 2023 Daniel B Cristofani (cristofd@hevanet.com)
33 SPDX-License-Identifier: CC-BY-SA-4.0
34 http://www.hevanet.com/cristofd/brainfuck/]