34
7
This is a repost of Evolution of “Hello World!”, originally written by user Helka Homba
It should not be closed as a duplicated, due to meta consensus here.
The original was asked over two years ago and was last active more than six months ago. I have permission from Helka Homba to post this here
Since the original, many languages have been invented, and many people have joined the site who have never had an opportunity to answer the original, so I feel that this repost is acceptable.
The challenge is to make a program that prints 2^n
to stdout, where n
is the number of your program. The catch is that your program must have a Levenshtein distance of 10 or less from the program in the answer submitted before yours.
How This Will Work
Below I will submit the first answer using C#, which prints 2^(n=1)=2
.
The next person to answer must modify the code with up to 10 single character insertions, deletions, or substitutions so that when it is run in the language of the new answer, it prints 2^n
(with n
being the answer number). For example, the 25th answer (let's say it's in Pyth) would print 2^25, or 33554432.
This will continue on until everyone get stuck because there is no new language the last answer's program can be made to run in by only changing 10 characters. The communal goal is to see how long we can keep this up, so try not to make any obscure or unwarranted character edits (this is not a requirement however).
Formatting
Please format your post like this:
#Answer N - [language]
[code]
[notes, explanation, observations, whatever]
Where N is the answer number (increases incrementally, N = 1, 2, 3,...).
You do not have to tell which exact characters were changed. Just make sure the Levenshtein distance is from 0 to 10.
If you answer in some language or the resulting code is just a mess, do please explain what you did and why it works, though this isn't required.
Rules
The key thing to understand about this challenge is that only one person can answer at a time and each answer depends on the one before it.
There should never be two answers with the same N. If two people happen to simultaneously answer for some N, the one who answered later (even if it's a few seconds difference) should graciously delete their answer.
Furthermore...
- A user may not submit two answers in a row. (e.g. since I submitted answer 1 I can't do answer 2, but I could do 3.)
- Try to avoid posting too many answers in a short time frame.
- Each answer must be in a different programming language.
- You may use different major versions of a language, like Python 2/3
- Languages count as distinct if they are traditionally called by two different names. (There may be some ambiguities here but don't let that ruin the contest.)
- You do not have to stick to ASCII, you can use any characters you want. Levenshtein distance will be measured in unicode characters.
- The output should only be
2^n
and no other characters. (Leading/trailing whitespace is fine, as is unsuppressible output like>>>
orans=
) - If your language doesn't have stdout use whatever is commonly used for quickly outputting text (e.g.
console.log
oralert
in JavaScript). - When the power of two you have to output gets very large, you may assume infinite memory, but not an infinite integer size. Please be wary of integer overflows.
- You may make use of scientific notation or whatever your languages most natural way of representing numbers is. (Except for unary, DO NOT output in unary)
Please make sure your answer is valid. We don't want to realize there's a break in the chain five answers up. Invalid answers should be fixed quickly or deleted before there are additional answers.
Don't edit answers unless absolutely necessary.
Scoring
Once things settle down, the user who submits the most (valid) answers wins. Ties go to the user with the most cumulative up-votes.
Edit these when you post an answer:
Leaderboard
13 languages
Okx
8 languages
zeppelin
4 languages
Pavel
Jonathan Allan
Kritixi Lithos
Riker3 languages
boboquack
2 languages
bmarks
Conor O'Brien
Destructible Watermelon
ovs
Tom Carpenter1 language
ATaco
Blocks
Dennis
dzaima
Erik the Outgolfer
ETHproductions
ghosts_in_the_code
Leo
Lynn
Matheus Avellar
Nathaniel
Qwerp-Derp
R. Kap
Taylor Scott
nimi
Mistah Figgins
PidgeyUsedGust
steenbergh
Languages used so far:
- C# (Pavel)
- /// (boboquack)
- Retina (Dennis)
- Jelly (Jonathon Allan)
- Pyth (boboquack)
- ><> (Destructible Watermelon)
- Minkolang (Kritixi Lithos)
- Perl (Pavel)
- Python (Qwerp-Derp)
- dc (R. Kap)
- Charcoal (Jonathon Allan)
- Self Modifying BrainFuck (Leo)
- SOGL (dzaima)
- ShapeScript (Jonathon Allan)
- Pyke (boboquack)
- Ruby (Nathaniel)
- 05AB1E (ovs)
- STATA (bmarks)
- bc (Kritixi Lithos)
- Japt (Okx)
- 2sable (Kritixi Lithos)
- Cheddar (Jonathon Allan)
- Pylons (Okx)
- Bash (zeppelin)
- Pushy (Okx)
- CJam (Erik the Outgolfer)
- MATL (Okx)
- MATLAB (Tom Carpenter)
- Octave (Kritixi Lithos)
- R (ovs)
- JavaScript ES7 (Tom Carpenter)
- Convex (Okx)
- Mathematica (ghosts_in_the_code)
- Pip (Okx)
- Stacked (Conor O'Brien)
- GolfScript (Okx)
- Actually (Lynn)
- RProgN (Okx)
- Scheme (bmarks)
- Element (Okx)
- J (Blocks)
- Cubix (ETHproductions)
- zsh (zeppelin)
- VBA (Taylor Scott)
- Fish (zeppelin)
- Reticular (Okx)
- Perl 6 (Pavel)
- RProgN2 (ATaco)
- PHP (Matheus Avellar)
- Jolf (Conor O'Brien)
- Haskell (nimi)
- Befunge-98 (Mistah Figgins)
- Gnuplot (zeppelin)
- QBIC (steenbergh)
- FOG (Riker)
- Qwerty-RPN (Okx)
- Korn Shell (ksh) (zeppelin)
- Julia (Riker)
- Python 3 (Pavel)
- Vimscript (Riker)
- Dash (zeppelin)
- Vitsy (Okx)
- csh (zeppelin)
- Ohm (Okx)
- Bosh (zeppelin)
- es-shell (Riker)
- Gol><> (PidgeyUsedGust)
This question works best when you sort by oldest.
2A snippet would really be nice – user41805 – 2017-02-26T06:58:20.433
@KritixiLithos I don't know how to do those, feel free to edit one in though! – Pavel – 2017-02-26T06:59:24.127
For a snippet, you'd need to specify a default answer heading format – boboquack – 2017-02-26T07:06:38.073
Does it matter if there is
– Tom Carpenter – 2017-02-26T11:42:43.870ans =
in the output - i.e. like: https://i.stack.imgur.com/Asn1g.png? I should have checked that before I posted and subsequently deleted 26 (apologies Okx). If it doesn't then 26/27 could be put back unless somebody does another one before we find out.@TomCarpenter the question states that
The output should only be 2^n and no other characters. (Leading/trailing whitespace is fine)
– Okx – 2017-02-26T12:55:33.277Can the output be like so:
1.07374e9
instead of instead of a really long number? – Blocks – 2017-02-26T18:44:20.400@Blocks That is acceptable, I'm editing the question to reflect that. – Pavel – 2017-02-26T18:53:28.983
1@TomCarpenter that is acceptable, I'm going to make the edit. – Pavel – 2017-02-26T18:53:49.607
1Does "Levenshtein distance will be measured in UTF-8 characters" mean that the edit distance is computed between strings of Unicode codepoints (and the "UTF-8" is a red herring, since in this sense it doesn't matter whether you use UTF-8, UTF-16, UCS4 or something else)? – Sami Liedes – 2017-02-27T17:19:53.577
1@SamiLiedes pavel responded in chat, it's just unicode codepoints yeah. (i.e. if the code point is different, it's a character difference) – Rɪᴋᴇʀ – 2017-02-28T23:17:33.013
I extracted the codes. I believe the edit distance of #18 is 12 and that of #44, #47, #52, #57, #60 and #66 is 11. Turns out computing edit distances by hand is error prone. – Sami Liedes – 2017-03-02T22:25:43.883
@SamiLiedes why is 18 a distance of 12? 10 chars were added. I think your code borked. – Rɪᴋᴇʀ – 2017-03-13T23:56:46.847
@TomCarpenter also, I know it's much belated, but meta says that's ok as long as it's part of your default answer format. (i.e. you can't print 'ans =', but if returning a value automatically outputs that it's ok) – Rɪᴋᴇʀ – 2017-03-14T00:03:12.960
@Riker: Yeah, it counted whitespace differences at ends of line too. – Sami Liedes – 2017-03-14T14:23:46.480
@SamiLiedes ah, though I'm pretty sure that's unintentional. Oh well. – Rɪᴋᴇʀ – 2017-03-14T14:24:54.667