15
\$\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\$
  • 2
    \$\begingroup\$ Related, closed question: codegolf.stackexchange.com/q/23808/67312 \$\endgroup\$ – Giuseppe Nov 5 '18 at 1:56
  • 2
    \$\begingroup\$ Vaguely related: Are you lost yet? \$\endgroup\$ – Dennis Nov 5 '18 at 1:57
  • 1
    \$\begingroup\$ Do we have to print them in that order? \$\endgroup\$ – Titus Nov 5 '18 at 5:38
  • 5
    \$\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\$ – Arnauld Nov 5 '18 at 11:07

45 Answers 45

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\$

APL(Dyalog Unicode), 18/2 = 9 bytes

×/⎕UCS'𩦦湡'

Just boring old character multiplication.

Try it online!

\$\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\$

Wolfram Language (Mathematica), 68 bytes (score 34)

#&@@@"distinctive pattern nothing is known about"~StringPosition~"t"

Try it online!

Prints the list {4,8,15,16,23,42}.

\$\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\$

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\$
0
\$\begingroup\$

brainfuck, 55 bytes

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

Try it online!

\$\endgroup\$
  • \$\begingroup\$ I assume you used brainfuck constants, correct me if I am wrong. Please calculate your score and add it to your answer. \$\endgroup\$ – Jonathan Frech Feb 26 at 2:20
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\$
  • \$\begingroup\$ Err! yeah you are correct. wth am I thinking. Thanks! :D \$\endgroup\$ – remoel Mar 1 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\$ – Taylor Scott Mar 1 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\$ – Taylor Scott Mar 2 at 15:26

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.