16
\$\begingroup\$

As a big fan of the Lost TV series, I always got intrigued by the sequence of numbers that repetitively appears on the episodes. These numbers are:

\$ 4, 8, 15, 16, 23, 42\$ (A104101)

Using any programming language, write a code that outputs these numbers.

Scoring:

  • Shortest answer wins

  • The output must not contain any other numbers or letters. You may use any other character as separator, or even no separator at all.

  • You cannot separate digits of the same number. \$ 48\_15162342 \$ is a valid answer, but \$481\_5162342\$ is not.

  • You must respect the order.

  • If your code does not contain any of the numbers from the sequence, reduce your score by 30%. This rule does allow you to enter the digits separately. E.g.:

    abcde1fg5h 

    Is a valid candidate because the answer does not contain the number \$15\$, only its digits. However, any \$4\$ or \$8\$ will invalidate the bonus.

  • If the code does not contain any digit at all, reduce your score by 50%. Other characters like \$¹\$, \$²\$ or \$³\$ are still valid for this bonus.

\$\endgroup\$
5
  • 2
    \$\begingroup\$ Related, closed question: codegolf.stackexchange.com/q/23808/67312 \$\endgroup\$ Commented Nov 5, 2018 at 1:56
  • 3
    \$\begingroup\$ Vaguely related: Are you lost yet? \$\endgroup\$ Commented Nov 5, 2018 at 1:57
  • 1
    \$\begingroup\$ Do we have to print them in that order? \$\endgroup\$ Commented Nov 5, 2018 at 5:38
  • 8
    \$\begingroup\$ For future reference, we have a restricted-source tag that could have been used here: although most answers are avoiding obvious solutions, I think the challenge would have been slightly more interesting if using digits were forbidden altogether. \$\endgroup\$ Commented Nov 5, 2018 at 11:07
  • \$\begingroup\$ Can the two reducers stack? \$\endgroup\$ Commented Feb 9, 2022 at 15:46

59 Answers 59

1
2
1
\$\begingroup\$

Python 3 34 Points

b=len(" ");c=b*b;d=c*b;e=d*b;g=e+d-b//b;print(c,d,e-b//b,e,g,g*b-c) 
\$\endgroup\$
1
\$\begingroup\$

Python 3, 44 38 19 18.5 bytes

-6 bytes thanks to @Jo King
-50% bytes thanks to @ouflak for pointing out the 50% bonus
-1 byte thanks to @Dennis

for i in'밗ɯ*':print(ord(i),end='') 

Try it online!

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

Japt, 10 9 bytes / 2 = 4.5

"0¢*"mc 

Test it

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

SmileBASIC, 13 - 30% = 9.1 bytes

?&h1CB35ACA;2 

Uses a hexadecimal number to avoid any of the numbers in the sequence. The final 2 needs to be printed separately because 4815162342 doesn't fit into a 32 bit signed integer.

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

Befunge-98 (FBBI), 15 bytes / 2 = 7.5 points

"*H/!k-"*.*+..@ 

Try it online!

Explanation:

First push the ASCII values of the characters '*+H/!k- (42, 72, 47, 33, 107, 45) in this order to the stack. Then compute \$4815 = 45 \cdot 107\$ and \$1623 = 33\cdot 47+72\$, and output.

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

Runic Enchantments, 15/2 = 7.5

\>`*` Rn$!; 

Try it online!

Simply encodes the values in as few bytes as possible. 42, 16, 15, 8, and 4, coerces them to numerical values, and prints them in reverse order. 4 8 15 16 42 without any spaces, as 48151642 was an acceptable output format.

4 and 8 could not be combined (48) as that is a numerical 0 and was not allowed to be used. It is possible to combine the 15, 16, and 42 into 2 characters (instead of 3) ʂ at the expense of +1 byte, which wasn't worth it.

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

C# (.NET Core), 17 bytes *.7 = 11.9 bytes.

Ascii-Only's version.

()=>0x5FAB2EA2l*3 

Try it online!

C# (.NET Core), 42 bytes, score = 42/2 = 21

Uses the F386 and BC17 characters.

()=>{return $"{(int)'밗'}{(int)''}";}; 

Try it online!

\$\endgroup\$
1
  • 1
    \$\begingroup\$ 17 (*.7) \$\endgroup\$ Commented Feb 26, 2019 at 1:48
1
\$\begingroup\$

Keg, 8 - 50% = 4 bytes

밗.. 

Try it online!

Answer History

10 - 50% = 5 bytes

🄅🄉🄂🄆🄂🄇🄃🄄🄅🄃 

Try it online!

Literally just prints the number 4815162342 using the push'n'print method.

\$\endgroup\$
5
  • 1
    \$\begingroup\$ 밗.. isn't 4 bytes is it? \$\endgroup\$ Commented Dec 19, 2019 at 8:34
  • 1
    \$\begingroup\$ @Adám, it's 4 bytes after the bonus is applied. \$\endgroup\$ Commented Dec 19, 2019 at 8:51
  • \$\begingroup\$ the old answer certainly was not eligible for either bonus \$\endgroup\$ Commented Feb 9, 2022 at 13:40
  • 1
    \$\begingroup\$ @thejonymyster it was - those aren't classified as digits by the challenge \$\endgroup\$ Commented Feb 9, 2022 at 22:12
  • \$\begingroup\$ @lyxal oh wow ok no yeah ive just never seen those unicode symbols before, i really thought it was regular ascii numbers with commas after then \$\endgroup\$ Commented Feb 10, 2022 at 2:25
1
\$\begingroup\$

Intcode, 33 bytes

4,0,104,8,104,16,104,23,104,42,99 

Basic hardcoded answer (104 means "output the number after this in the sequence"). Getting the bonus would be very hard (although probably possible), given that 4 is the output instruction ...

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

><>, 29/2 = 14.5 bytes

','a+'a''a'*a+:f+f+f+f+c-**n; 

Forms on the stack 3 numbers 54 9419 9467, multiplies them and outputs 4815162342.

Try it online!

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

Kona, 20 Bytes => 10 score

(_ic">BIJQd")-_ic":"

Try it online!

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

Zsh, 16 * 0.7 = 11.2 bytes

<<<$[36#27mtn1i] 

Try it online!

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

Python 2, 16 bytes

print 4815162342 

Try it online!

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

perl -M5.010 -Mre=eval, 32/2 == 16 bytes

This program is mostly unprintable characters -- characters which aren't even Unicode characters. Here is a hexdump of the program:

$ od -x solution 0000000 2727 7e3d 277e c0d7 8c84 869e cbd8 c7d3 0000020 ced3 d3ca c9ce cdd3 d3cc cdcb 82d8 27d6 0000040 $ 

And here's the program to create the solution:

#!/opt/perl/bin/perl use 5.026; use strict; use warnings; no warnings 'syntax'; use experimental 'signatures'; my $q = ~"(?{say'4,8,15,16,23,42'})"; print "''=~~'$q'"; __END__ 
\$\endgroup\$
0
\$\begingroup\$

Red, 50 bytes / 2 = 25

foreach c"abcdcefgaf"[prin index? find"cfgade.b"c] 

Try it online!

Prints the numbers without separator

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

Z80Golf, 17 bytes * 0.5 = 8.5

00000000: 1b17 1e1a 1e19 1d1c 1b1d 2676 0a03 c5ee ..........&v.... 00000010: 2f / 

Try it online!

Assembly:

db 0x2F ^ '4'	;1b dec de db 0x2F ^ '8'	;17 rla db 0x2F ^ '1'	;1e ld e, db 0x2F ^ '5'	;1a 0x1a db 0x2F ^ '1'	;1e ld e,  db 0x2F ^ '6'	;19 0x19 db 0x2F ^ '2'	;1d dec e db 0x2F ^ '3'	;1c inc e db 0x2F ^ '4'	;1b dec de db 0x2F ^ '2'	;1d dec e ld h, 0x76	;halt ld a, (bc)	;load the next digit. The first char in addr in 0x0 inc bc		;get next digit push bc		;return to the next digit which is basically a nop xor 0x2F	;decode the digit 		;fall through into putchar. Putchar (0x8000), prints the char in register a 

Assembly

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

T-SQL, 20 bytes - 30% bonus = 14

PRINT 2.*9*267509019 

Contains none of the sequence directly. Factored via this web site. The period is in there as an implicit conversion to float so we don't overflow an INT.

This is just slightly better that the trivial solution (16 bytes, no bonus):

PRINT 4815162342 
\$\endgroup\$
0
\$\begingroup\$

Perl 6, 17 bytes * 0.5 = 8.5

say ords "*" 

Try it online!

This gets the ordinal values of a lot of unprintables and gets the no digits bonus. Using the no numbers from the sequence bonus, we can get 16 * 0.7 = 11.2 points:

say 0x5FAB2EA2*3 

Try it online!

Which in turn beats the plain solution of 14 bytes:

say 4815162342 

Try it online!

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

Python 2, 38 * 0.5 = 19 score 34 bytes * 0.5 = 17 score

print map(`int`.find,"ent t'ypey") 

Try it online!

Outputs a list of the digits in the sequence; i.e. the list [4, 8, 1, 5, 1, 6, 2, 3, 4, 2].

Because it's more interesting to satisfy the 'no digits' approach, regardless of the score.

Python 2, 23 bytes - 30% = 16.1 score

print int('27mtn1i',36) 

Try it online!

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

Lua, 69 bytes / 2 = 34.5 points

a={"","","","","","*"}s=" "for i=#s,#a do print(s.byte(a[i]))end 

Try it online!

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

Powershell, 10 bytes, score 10

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

brainfuck, 55 bytes

-[>+<-----]>+.++++.-------.++++.----.+++++.----.+.+.--. 

Try it online!

\$\endgroup\$
2
  • \$\begingroup\$ I assume you used brainfuck constants, correct me if I am wrong. Please calculate your score and add it to your answer. \$\endgroup\$ Commented Feb 26, 2019 at 2:20
  • \$\begingroup\$ This answer's pretty old, but you can reduce this by creating an extra copy in memory. Here's a 46 bytes version. \$\endgroup\$ Commented Jan 21 at 14:03
0
\$\begingroup\$

Gol><>, 12 bytes, score 6

"*"lRn; 

Pretty simple, I just used whitespace to encode and outputted it in order, I believe the score is correct, since it said to set it to 50% if you don't use any numbers, and this only has ascii characters!

Try it online!

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

VBA (Excel), 38 66 bytes - 50% = 33 points

Using Immediate Window

?Join(Split("4 8 1 5 1 6 2 3 4 2"),"")

a="         ":For Each x in Split(a):b=b &Asc(x):Next:?b
\$\endgroup\$
3
  • \$\begingroup\$ Err! yeah you are correct. wth am I thinking. Thanks! :D \$\endgroup\$ Commented Mar 1, 2019 at 7:07
  • \$\begingroup\$ You can rearrange this to get rid of both temporary variables a and b. For Each x in Split(" "):?Asc(x)&"";:Next --- I am not sure if it will keep the non-printing characters when I comment this, but if it does not, the string is the same as is held in a in your current version \$\endgroup\$ Commented Mar 1, 2019 at 16:08
  • \$\begingroup\$ Actually, looking at it a second time, you can drop the split entirely and iterate over the string to get it down further - 47 bytes, 23.5 points For i=1To 10:?Asc(Mid("",i))&"";:Next, where the string in the Mid statement holds the string string output by For i=1To 10:?Chr(Mid(4815162342,i,1));:Next \$\endgroup\$ Commented Mar 2, 2019 at 15:26
0
\$\begingroup\$

Bash, 23 17 bytes

echo $[64#4v0oLC] 

Try it online!  23bytes

Will try to score a bonus later. Uses this neat bash feature.

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

Tcl, 25 bytes; 22 chars; 12,5 points

puts [scan ዏٗ* %c%c%c] 

Try it online!

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

Perl 5 -M5.010, 31 bytes - 50% = 15.5

Wanted a solution containing no digits...

say-ord(A)+ord for EIPQXk=~/./g 

Try it online!

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

Lua, 37 bytes / 2 = 18.5

a="*"print((a:gsub(".",a.byte))) 

Try it online!

Based on Ouflak's Answer

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

ARBLE, 10 bytes

4815162342 

Try it online!

Polyglot with a bunch of languages that allow constant-only answers.

ARBLE, 23 bytes / 2 = 11.5 points

gsub("*",".",byte) 

Try it online!

Slightly more interesting, but worse scoring solution.

\$\endgroup\$
1
2

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.