25
\$\begingroup\$

(Inspired by ASCII's 95 Characters...95 Movie Quotes)

The Challenge

Given input n, output the nth Fibonacci number. You can use either 0 or 1 indexing, please state which in your submission. Simple, yeah? The catch is you must take the character set of the immediate previous answer, remove two characters from it, and add a separate character. The separate character must

  • not be from the immediate previous answer's character set
  • be from the set of (printable ASCII, space, newline, horizontal tab)

and thus your total character set size will be exactly one smaller than the immediate previous answer's set.

The initial answer

The first submission must contain a subset of (all printable ASCII, space, newline, and horizontal tab) with two characters removed. Every submission thereafter must restrict their answers to this original ASCII-only format (meaning you can't add a Unicode or extended-ASCII character ... sorry Jelly, APL, et al.).

Examples and Clarifications

  • Suppose the first answer is in C and contains (almost all printable ASCII, newline, and horizontal tab), and omits the % and ^ from its character set. The second submission, then, must remove two characters from the previous (almost all printable ASCII, newline, and horizontal tab) character set and add in either the % or ^. Perhaps it's a one-liner PowerShell answer that omits the newline. And so on.
  • If the previous answer had print(){}!*+ as its character set (12 characters), your submission could have print(){}! (10 characters) and one additional character, print(){!+ (10 characters) and one additional character, etc.
  • If the previous answer had print(){}!*+ as its character set (12 characters), your submission could not have print() and & (8 characters) as its character set, since 12 - 8 > 1.
  • If the previous answer had print(){}!*+ as its character set (12 characters), your submission could not have print(){}! (10 characters) plus additional character * as its character set, since even though that's 11 characters, the * is included in the previous set.
  • Not every character in your character set must do something useful for your submission. For example, if the previous answer had print(){}!*+ as its character set, and your language has a built-in ! that calculates the Fibonacci sequence and # that starts a comment, your submission could be !#print(){} and still be valid.
  • You can use the same character from your character set multiple times. For example, suppose your character set was !*#_, your answer could be !!!**#**#_!! and would be acceptable.
  • In addition to your code (and an explanation is nice, too!) please also explicitly list your character set, to make it easier for future submissions.

Winning

The winner of the challenge will be the person who posted the second most-recent submission (i.e., not the person who posted last, since they broke the chain).

Final Rules

Usual rules apply:

  • The same person can't post twice in a row
  • If an answer is deemed invalid (for example, it used a forbidden character, or doesn't calculate correctly), it needs to be deleted (and any subsequent answers that chain off of it also)
  • Two users who post "at the same time" will have to let the earlier submission stand
  • The same language cannot be posted twice in a row. For the purposes of this rule, languages of the same family (e.g., Python 2 and Python 3) count as "the same language."

Final things:

  • This post works best if you sort by "Oldest" so that the answers are in proper order.
  • Kyle Gullion constructed a code checker in Python here to verify if you're missing or using wrong characters.
\$\endgroup\$
8
  • \$\begingroup\$ Just a few quick clarifications: 1) Does our program have to actually contain the full set we're using, or we can use a smaller set of characters? (Important for minimalist languages, like brain(fuck|flak), unary, etc.) 2) You say that the same language cannot be posted twice in a row. Can the same language be posted any number of times as long as it's not in a row? \$\endgroup\$
    – DJMcMayhem
    Apr 6, 2017 at 17:30
  • 1
    \$\begingroup\$ I suggest you add the first one, because one can destroy this challenge if it posts the first one \$\endgroup\$
    – Mr. Xcoder
    Apr 6, 2017 at 17:37
  • 1
    \$\begingroup\$ @DeadPossum It's based on character set, not overall character count. Removing two and adding one ensures that the eventual pool of available characters dwindles and forces creativity on future answers. \$\endgroup\$ Apr 6, 2017 at 17:39
  • 3
    \$\begingroup\$ @Mr.Xcoder I have faith in the PPCG community, and if someone purposefully messes it up I reserve the right to call them a doody-head in chat. \$\endgroup\$ Apr 6, 2017 at 17:39
  • 3
    \$\begingroup\$ Threw a code checker up to make life a bit easier for anyone interested. \$\endgroup\$
    – Kyle G
    Apr 7, 2017 at 1:58

42 Answers 42

1
2
1
\$\begingroup\$

19. 05AB1E

Added }. Removed Zz. Contains no {:`*%01AEIPQfrdZz, tab, space, newline.

Xs2<<sFUX+Xs}q!"#$&'()+,-./23456789;<=>?@BCDFGHJKLMNORSTUVWXY[\]^_abceghijklmnopqstuvwxy|~

Try it online!

\$\endgroup\$
1
\$\begingroup\$

20. CJam

Added {, removed M and m. Doesn't contain %*01:AEIMPQZ`dfmrz, tab, space, or linefeed.

q~[XX]{_(j\((j+}je#!"$&'),-./23456789;<=>?@BCDFGHJKLNORSTUVWY^abcghiklnopstuvwxy|

0-indexed.

Try it online!

\$\endgroup\$
1
\$\begingroup\$

17. Standard ML (mosml)

Added space, removed rd. Contains no {}:;`*%01AEIPQrd, tab, or newline.

fun f s = #2("!#$&\\',.23456789<>?@BCDFGHJKLMNORSTUVWXYZ[]^_abcgjkmopqvwxyz|~", if s = 2-2 then 2-2 else if s = 3-2 then 3-2 else f (s-4+2) + f (s-3+2))

Again, a copy from my previous answers, but instead of a comment a string literal that gets discarded. And good bye, sqrt and round.

\$\endgroup\$
1
\$\begingroup\$

22. PHP

Added f, removed & and L. Doesn't use %&*+01:AEILMPQZ`dmrzM{, tab, or linefeed.

$a=aRRay(3-2,3-2);$i=ReaDline();$c=3-2;while(($c=$c- -3-2)<=$i)$a[$c]=$a[$c- -2-3]- -$a[$c-2];echo $a[count($a)- -2-3];#!"'+./456789>?@BCFGHJKNOSTUVWXY\^_bfgjkpqsvx|}~

0-indexed.

Try it online!

\$\endgroup\$
1
\$\begingroup\$

24. ><>

Added :. Removed Ww. Doesn't use %&*+01AEILMPZ`dmrzM{}]Ww, tab or newline

Uses the -v flag.

55-54-:@55-$--@@54--:54-54-p@555-54-54-g?.~~~n; !"#'(),/236789<=>BCDFGHJKNOQRSTUVXY[\^_abcefhijkloqstuvxy|

Try it online!

As we really needed to add : in order to duplicate values.
So we can't include the newline, requiring a one liner.
The only control flow we have while using 1 line is jump (.).
Utilizing this, the trick is mostly about keeping the values in the correct order on the stack.
Unfortunately we can't use }, so we use a workaround with g and p instead.

\$\endgroup\$
1
\$\begingroup\$

31. CoffeeScript

Added + and removed /\. Solution contains no !&'/\-01?AEIKLMNPSTWZ`dmrwz{}, no tab, no newline, and no space characters.

f=(x)=>if(x<2)then(x)else(f(x+(~2|2))+f(x+(~3|2)))#"$%*,.456789:;@BCDFGHJOQRUVXY[]^_abcgjkopquvy

Basic recursive solution. Try it online!

\$\endgroup\$
1
\$\begingroup\$

35. MATL

Added 0, removed [ and ]. Doesn't use !&'()/\1?AEIKLMNPSTWZ`dmntwz{}[]|~ , tab, or space.

5X^Hq+G^Hq5X^-G^-HG^5X^*Hqqq^*Yo%"#$,.2346789:;<=>@BCDFJOQRUV_abcefghijklprsuvxy0
<newline>
 

Try it online

\$\endgroup\$
1
  • \$\begingroup\$ @Poke thanks. It gets harder to do this every time \$\endgroup\$ Apr 13, 2017 at 11:35
1
\$\begingroup\$

40. Aceto (line-mode)

Added d. Removed u\. Doesn't use !^&'()/1?@AEIMNPSTWZmntuwz{}|~\[] `, tab, or newline.

Use command-line option -l (which I counted in the used characters)

ridd32-532-2:F+sFs32-532-2:F-sF-s2sF532-2:F*:ipX"#$%,.046789;<=>BCDGHJKLOQRUVY_abcefghjkloqvxy

I'm using Binet's formula for the nth fibonacci number. Since I can't really use more than one stack (as []{}() are banned), I do it all on one, which is a bit annoying since the register is also blocked by the ban of M. Duplication and swapping still works, though. Instead of the number one I substract two from three (32-).

After printing, I exit with X and then just append the remaining characters (Aceto knows no comments).

\$\endgroup\$
1
\$\begingroup\$

41. Alphuck, 366 bytes

Added ! and removed +.. Solution doesn't contain !^&'()+./1?@AEIMNPSTWZmntuwz{}|~\[] `, tab, or newline characters.

pisapiseppisapisopepiiiiiiiiiiipapiseeeeeepciiiiiiaisciiccpiaaeeeeeeeeeeccsaapicceaasceassscscaecpaaapisccpaaeccisapceaisapceaiscpceaaecisapceaiscccisaaapiscpiscpaaeaecccisaaapccceaaaiscceapciapaeeeeeeeeeecpiaipaeaasapepiceasaeaascccccsapiseeeeeeeepceeeeeeaisapcceaaisapcceaaisccsascpiaaeeeeeeeepceeeeeeaisscpjpiscsc!"#$%*-023456789:;<=>BCDFGHJKLOQRUVXY_bdfghklqrvxy

Try it online!

\$\endgroup\$
1
\$\begingroup\$

42. Headsecks

Added ^ and removed Q_. Solution doesn't contain &'()+./1?@AEIMNPQSTWZ[\]_`mntuwz{|}~, space, tab, or newline characters.

U6y#OH;0:jFqCsfic8JoB^!kp2G3KVa*xbh#;gr"R7Csl>YOvX9,4dLD$<e5=-%o

Below is a Python3 function to transpiles Headsecks to brainf***

transpiler = lambda hs:"".join("+-<>.,[]"[ord(cmd)%8] for cmd in hs)

Code based on answer 34.

Let's see if we can get this chain going again! I added ^ to try and enable something like 38. Hopefully we can restore some stuff for other languages too.

\$\endgroup\$
0
\$\begingroup\$

21. 05AB1E

Xs2<<sFUX+Xs}q!"#$&'(),-./23456789<=>?@BCDFGHJKLNORSTUVWXY[\]^_abceghijklnopqstuvwxy|~ 

Added space, removed + and {. Doesn't contain %*01:AEIMPQZ`dfmrzM{, tab, or linefeed. I removed the bracket to make it harder Try it online!

\$\endgroup\$
0
\$\begingroup\$

29. Octave

Added ] and removed !:. Solution contains no &'-!:01AEIKLMNPSTZ`dmrz{}Ww, no tab, no newline, and no space characters.

f=@(x)([length("l"),length("l");length("l"),length("")]^x)(3)#$%*+./2456789<>?BCDFGHJOQRUVXY\_abcijkopqsuvy|~

Same idea as answer 8

\$\endgroup\$
1
2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.