58
2
As is well known,
Chuck Norris counted to infinity. Twice
Chuck Norris can count to infinity backwards.
Also, although perhaps less known, Chuck Norris can speak a little Spanish in addition to English.
The challenge
Write a program (or function) that can be run in two different languages. In one language the program should output the sequence
1, 1, 2, 2, 3, 3, 4, 4, ...
and in the other language it should produce the sequence (including leading zeros)
1, 2, ..., 9, 01, 11, 21, 31, ..., 89, 99, 001, 101, 201, ...
Rules
- Programs or functions are allowed, in any programming language. Standard loopholes are forbidden.
- Different versions of the same language (such as Python 2/3) don't count as different languages. Related languages (such as C/C++ or Matlab/Octave) do count as different.
- No input will be taken.
- The program should continue to output terms of the sequence until stopped by the user. Since the program will not stop by itself, output cannot be produced at the end. It must be produced while the program runs, either continuously or in batches.
- Output can use STDOUT or equivalent, or can be displayed in a graphic window. Any non-numeric separator between sequence terms is allowed, as long as each term can be clearly distinguished from its neighbouring terms. It is also acceptable if the screen is cleared between terms.
- Either sequence can start at
0
instead of1
. In that case, in the "twice" sequence the0
should be repeated, just like the other numbers. - Leading zeros are significant in the "backwards" sequence. For example, the tenth term is
01
; neither1
nor001
are acceptable. - If the two languages use different character encodings, the program is defined by its bytes, not its characters. That is, the bytes should be the same in the two languages.
- Shortest code in bytes wins.
8Downvoters, any suggestion for improvement? – Luis Mendo – 2017-06-16T21:10:06.240
29Chuck Norris is too powerful to count, if he did, the first number he'd count would exceed infinity and shatter the realm of known mathematics. Therefore, I refuse to compete. – Magic Octopus Urn – 2017-06-16T21:55:34.303
11@carusocomputing, very wise given the world-wide shortage of push-ups since Chuck Norris did them all. – Wossname – 2017-06-16T22:17:18.290
1Chuck Norris' counting strategy:
0. 1/0.
manages to kill counting. – Magic Octopus Urn – 2017-06-16T22:44:56.52733Chuck Norris can complete this challenge in 0 bytes. He can just look at the computer and the computer does whatever he wants. – Kodos Johnson – 2017-06-17T00:47:35.070
1Chuck Norris/sirroN kcuhC, 5 bytes:
count
– Erik the Outgolfer – 2017-06-17T08:22:11.78017Chuck Norris didn't try to win this challenge, he just allowed you to lose. – Nat – 2017-06-17T13:10:48.720
6@LuisMendo they don't like that people think computers can count as well as Chuck Norris – bleh – 2017-06-17T19:00:43.110
3“should continue to output terms of the sequence until stopped by the user” The user definitely cannot stop Chuck Norris. BTW counting Octave and Matlab as different is a bit risky I would say given that they are mostly compatible. – Andrea Lazzarotto – 2017-06-18T18:24:05.360
Why does the second sequence not start with 0, when the tenth/twentieth/etc terms all represent the respective zero? – 1Darco1 – 2017-06-18T20:12:58.810
@Andrea Yes, what languages to consider different and which the same is always tricky – Luis Mendo – 2017-06-18T21:06:56.323
@1Darco1 The second sequence is 1, 2, 3,..., 9,10, 11,... with the digits of each number in reverse order. As the rules indicate, you can start at 0 instead of 1 – Luis Mendo – 2017-06-18T21:08:54.463
4Chuck Norris already submitted a solution in BrainF*** and Malbolge, but due to it F***ing the Brains of the first person who read it then sending them to Malbolge hell, he roundhouse kicked the answer straight out of the Stack Exchange servers. – Ken Y-N – 2017-06-19T04:25:53.953
1
I can't wait for somebody to do this in ChuckScript https://github.com/angrykoala/chuckscript
– Daniel – 2017-06-19T12:49:02.870Can I really use any separator? Is
\nint main(i){for(;;i++)printf("%d %d ",i,i);}//
a valid separator? – Business Cat – 2017-06-23T13:46:18.680@BusinessCat I should have limited the acceptable separators more, but yes, that's valid. Some answers are using similar weird separators – Luis Mendo – 2017-06-23T13:59:53.393