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.

30 Answers 30

Lost, 29 27/2 = 13.5 bytes

%?\>>>>>>>>>>
>>\"*"@"

Try it online! or verify that it is deterministic

Seemed like the right language to use.

Explanation:

Lost is a 2D language where the pointer starts anywhere, going in any direction. This generally leads to a lot of double checking that the pointer hasn't entered a section early.

...>>>>>>>>>>  These arrows filter all pointers that appear on the top line
.............  Or going vertically


%............  This flips the flag so that the program can end
.............  This stops premature termination

.?\..........  Clear the stack by skipping if a value popped from the stack is positive
.............  When the stack is empty, the \ directs the pointer down

.............  The \ directs the pointer right
..\"*"..  The string literal pushes all the Lost values to the stack

..\..........  The @ terminates the program if the % flag is switched
>>\........@.  Otherwise it clears the stack and repeats

.............  The quote here is to prevent the pointer getting stuck
............"  This happens when the pointer starts between the other quotes

Jelly, 7/2 = 3.5 bytes

“ƲÞIȥ’Ḥ

Prints the numbers without separator, i.e., the integer \$4815162342\$.

Try it online!

How it works

“ƲÞIȥ’ is bijective base-250 integer literal.
Ʋ, Þ, I, and ȥ have (1-based) indices \$154\$, \$21\$, \$74\$, and \$171\$ in Jelly's code page, so they encode the integer \$250^3\cdot154+250^2\cdot21+250\cdot74+171=2407581171\$.

Finally, (unhalve) doubles the integer, yielding \$2\cdot2407581171=4815162342\$.

Doubling is necessary, because encoding the output directly leads to “¡9)Ƙ[’, which contains a digit.

Neim, 6 5 bytes, 3 2.5 points

Jσς§A

Explanation:

J     Push 48
 σ    Push 15
  ς   Push 16
   §  Push 23
    A Push 42
      Implicitly join the contents 
      of the stack together and print

Try it online!

05AB1E, score: 10 9 7 bytes / 2 = 3.5

•‘o]Ê•·

Try it online.

Or 7 bytes alternative:

•’µ[%•R

Try it online.

Both outputting the integer 4815162342.

Explanation:

•‘o]Ê•     # Compressed integer 2407581171
      ·    # Doubled

•’µ[%•     # Compressed integer 2432615184
      R    # Reversed

See this 05AB1E tip of mine (section How to compress large integers?) to understand why •‘o]Ê• is 2407581171 and •’µ[%• is 2432615184.


Old 9 bytes answer outputting the list [4,8,15,16,23,42]:

•ΓƒÇ²•т;в

-1 byte (and therefore -0.5 score) thanks to @Emigna.

Longer than the other 05AB1E answer, but this outputs the list [4,8,15,16,23,42] instead of the integer 4815162342.

Try it online.

Explanation:

•ΓƒÇ²•       # Compressed integer 1301916192
      т;     # Integer 50 (100 halved)
        в    # Convert the first integer to Base-50 (arbitrary): [4,8,15,16,23,42]

See this 05AB1E tip of mine (sections How to compress large integers? and How to compress integer-lists?) to understand why •ΓƒÇ²• is 1301916192, and •ΓƒÇ²•50в is [4,8,15,16,23,42].

  • 1
    You could have •ΓƒÇ²•т;в for 4.5 as post-script numbers are okay for the bonus. – Emigna Nov 5 at 9:50
  • @Emigna Ah, nice! Thanks. – Kevin Cruijssen Nov 5 at 9:56

Python 3, 25 bytes, 12.5 points

print(*map(ord,'ዏٗ*'))

Try it online!

𩦦(髒, ⿰馬葬), 𧨦(謚, ⿰言⿱⿵八一皿) cost 4 bytes, but U+0657 only cost 2 bytes...


Python 3, 29 bytes, 14.5 points

print(ord('𩦦')*ord('湡'))

Try it online!

𩦦 (⿰馬葬) is variant character of 髒 which means "dirty". 湡 is the name of a river. And they are nothing related to this question as I known.

  • I asked about separator rules and we can use any individual separator which makes 4815 162342 valid. Thus print(*map(ord,'ዏ𧨦')) saves 1.5 points :) (print(*map(ord,'밗')) would save 2 points but has been specified as invalid). – Jonathan Allan Nov 5 at 19:13

JavaScript (ES7), 34/2 = 17 bytes

_=>eval(atob`NjUwNTgxMDErNDEqKjY`)

Try it online!

This decodes and evaluates the expression "65058101+41**6", which does not contain any digit once encoded in base-64.

$$65058101+41^6=65058101+4750104241=4815162342$$


JavaScript (ES6), 13 bytes

Boring obvious solution.

_=>4815162342

Try it online!

Java 8, score: 12 11.9 (70% of 17 bytes)

v->767*6277917L+3

-0.1 score thanks to @RickHitchcock.

Try it online.

Explanation:

v->               // Method with empty unused parameter and long return-type
  767             //  767
     *6277917L    //  multiplied by 6277917 (as long)
              +3  //  And then 3 is added

Old answer with a score of: 12 (50% of 24 bytes):

v->(long)''*'Ⓥ'*'䧶'

Contains an unprintable character 0x1B.

Try it online.

Explanation:

v->                   // Method with empty unused parameter and long return-type
  (long)              //  Cast the character (and therefore the result) to a long
        ''            //  27
           *'Ⓥ'       //  Multiplied by 9419
                *'䧶'  //  Multiplied by 18934

In Java, characters can be autoboxed to integers holding their unicode value. Unfortunately, the maximum supported unicode for characters is 65,535, so I can't use just two characters to multiply (since the largest two numbers that divide the expected 4,815,162,342 are 56,802 and 84,771, where the 84,771 unfortunately exceeds the maximum 65,535.
In addition, since the maximum size of an int is 322-1 (2,147,483,647) and the result 4,815,162,342 is larger than that, an explicit cast to long, which can hold up to 642-1 (9,223,372,036,854,775,807), is required.


Boring answer would have been 14 bytes without any bonuses:

v->4815162341L

Try it online.

  • 1
    I like this one. Pretty short for being Java :) – Emigna Nov 5 at 9:58
  • @Emigna Thanks. It's too bad it requires the cast to long and doesn't support very large unicode characters. If it weren't for those two restrictions mentioned, just v->'𩦦'*'湡' (15 bytes, score 7.5) would have been enough. But it's still very short indeed. :) Although Java mostly has many, many weaknesses in terms of codegolfing (duhh..), calculating with characters because we aren't allowed to use digits is one of its few strengths. Was also pretty useful in this rather similar answer of mine. – Kevin Cruijssen Nov 5 at 10:02
  • 1
    11.9 bytes: v->767*6277917L+3 – Rick Hitchcock Nov 5 at 23:04
  • 3
    @RickHitchcock It's not every day we see a 0.1 byte saving. ;) – Arnauld Nov 5 at 23:23
  • @RickHitchcock Thanks! And I agree with Arnauld's comment above. :D – Kevin Cruijssen Nov 6 at 8:55

Brain-Flak, 52/2 == 26 bytes

(((((((((()()()())){})){}[()])())[]()()())){}[[]]())

Try it online!

05AB1E, 6*0.7 = 4.2 bytes

•1Z&ð“

Try it online!

Prints the number uncompressed from base-255

7, 10 bytes, 27 characters

115160723426754314105574033

Try it online!

The packed representation of this program on disk is (xxd format):

00000000: 269c 3a71 6f63 308b 7c0d                 &.:qoc0.|.

Explanation

We've seen this sequence of numbers before, in Automate Saving the World, which was about printing the numbers at regular intervals, making it interesting via requiring the use of a very old language. Much newer languages can have their own twists that make this challenge interesting, though. (Yes, this paragraph, and in fact the reason I started writing this answer, is effectively just a way to get all the related challenges to show up together in the sidebar; normally people do that using comments but I don't have enough rep.)

The first thing to note is that 7 is made entirely of digits, so going for the bonuses here is unlikely to work (although if you view the program as a sequence of octets, none of them correspond to ASCII representations of any of the original numbers, so you could claim the bonus in that sense). The next thing to note is that 7 has commands to recreate the command sequence likely to have produced a specific piece of data; so could we possibly interpret the Lost numbers 4815162342 as a section of a 7 program itself?

The answer is "not quite". The most problematic part is that second number, 8. 7 programs are written in octal; there's no such number as 8. So the very start of the string will have to be printed differently.

The base of the program is therefore based on the 7 "Hello world" program:

5431410557403
543141055          string literal
         7         separate data from code
          4        rearrange stack: {program's source}, empty element, {literal}
           0       escape {the literal}, appending it to {the empty element}
            3      output {the escaped literal}, pop {the program's source}

with the escaped literal being in a domain-specific language that's interpreted as follows:

5                  output format: US-TTY using pairs of digits in the string
 43                select character set: digits and common symbols
   14              "4"
     10            "8"
       55          forget the set output format

After this comes an extra 3, which outputs the remaining stack element (and exits due to insufficient remaining stack). That element is specified at the start of the program, and to avoid the unmatched 6 (which works a bit like a closing bracket), we generate it using code, rather than writing it directly as data. (Note that there are two implied 7 characters at the start of the program, which is relevant here):

{77}115160723426
 7                 empty stack element
  7 11516          append "1151"
         0         append "6"
          723246   append "2324"

That produces the following literal:

115162324
1                  set output format: literally as octal
 15162324          "15162324"

which gets printed out.

  • It feels weird that you've got no reputation, despite posting some pretty good answers. I've read your reasoning behind posting only community answers, and I fully support you in that, but it must get annoying sometimes to not be able to comment :( – Jo King Nov 9 at 12:40
  • @JoKing: Well, it inspired me to actually post an answer to this question, and it turned out to be much more interesting than I expected. So I guess this is more evidence for my hypothesis that if you aren't seeking reputation, your contributions end up more beneficial for the site than otherwise. (Actually, the major frustration I have with being permanently stuck at 11 reputation is that I can't suggest edits on Meta, meaning that if I see misinformation there, I have no way to correct it.) – ais523 Nov 9 at 18:08

Charcoal, 13 bytes / 2 = 6.5

IETPIHA.⁻⁸⁸℅ι

Try it online! Link is to verbose version of code. Works by subtracting the ASCII codes of the string TPIHA. from 88 and casting to string.

JavaScript, 143 bytes (not sure how to score)

(g=`${2*2}`)=>g.repeat(6).replace(/(.)/g,(m,p,i,k='')=>
  (k=m*[g-3,g-2,g,g,+g+2,g*3-1][i]
  ,RegExp(`${g-2}|${g}`).test(i)?k-1:i==+g+1?k-(g/2):k))

Try it online!

Start with six 4's, multiply, add, subtract by, to, from 4 to derive output.

  • 2
    Ok, you were trying to get the bonus, but with a code this size, it didn't compensate. Why not simply '4815162342'? – Eduardo Hoefel Nov 5 at 2:24
  • @EduardoHoefel Do not gather the "score" or "bonus" system, did not try to get the bonus, just tried to not use any of the numbers required at output. The code outputs the numbers without hardcoding any of the numbers. The number 4, with addition, subtraction, multiplication and the index of the number 4 within a string (or array) can be used to derive the required numbers. – guest271314 Nov 5 at 2:30
  • Your score is 143*0.7=100.1 – Jo King Nov 5 at 2:45

PHP, 35/2=17.5

<?=zzzzzzzzzzzzzzz^NVBVKOVKLVHIVNH;

a digital approach: 40*.7=28

<?=2+2,_,5+3,_,17-2,_,17-1,_,17+6,_,7*6;

no digits, no strings: 68/2 = 34

<?=$p++,!$p++,$p+=$p,_,$p+=$p,_,~-$q=$p+$p,_,$q,_,--$p+$q,_,$p*~-$p;

Try them online.

  • 1
    Or just 14 bytes for <?=4815162342; – Jo King Nov 5 at 8:09
  • 1
    OP hasn´t replied to wether we can omit the delimiters or not; but yeah. Why not just 10 bytes: 4815162342. Or <?=~ + 10 unprintables -> 15/2=7.5 – Titus Nov 5 at 14:31

Japt, 10 bytes / 2 = 5

"óT"mc w

Test it

JavaScript (SpiderMonkey), 67 bytes / 2 = 33.5 60 bytes / 2 = 30 58 bytes / 2 = 29 48 bytes / 2 = 24

-7 bytes/3.5, -2 bytes/1 courtesy of @JoKing, -10 bytes/5 courtesy of @tsh

print(a=-~-~-~-~[],a+=a,b=a+~-a,a+a,a+b,--b+b+b)

Try it online!

  • 1
    print(a=-~-~-~-~[],a+=a,b=a+~-a,a+a,a+b,--b+b+b) – tsh Nov 5 at 7:34
  • 2
    Or just print(4815162342) for 17 bytes – Jo King Nov 5 at 8:11

JavaScript (ES6), 16 * 0.7 = 11.2 bytes

_=>767*6277917+3

Outputs the digits with no delimiters.

Try It Online!

Whitespace, score: 49 41 bytes / 2 = 20.5

[S S S T    S S S T T   T   T   T   S S S S S S S T T   S S S T S T T   T   T   T   S S T   T   S N
_Push_4815162342][T N
S T _Print_number]

Letters S (space), T (tab), and N (new-line) added as highlighting only.
[..._some_action] added as explanation only.

Try it online (with raw spaces, tabs and new-lines only).

Pseudo-code:

Integer i = 4815162342
Print i as number to STDOUT

Explanation:

In whitespace, a number is pushed as follows:

  • S: Enable Stack Manipulation
  • S: Push number
  • S/T: Positive/negative respectively
  • Some T/S followed by a single N: Decimal as binary, where T is 1 and S is 0

After that it is simply printed with TNST:

  • TN: Enable I/O
  • S: Output the top of the stack
  • T: As number
  • Is just pushing the number itself longer than having the extra multiply and push integer instructions? – Jo King Nov 5 at 22:58
  • @JoKing I usually use the vii5ard online Whitespace compiler, since it has highlighting and showing the commands at the left. But apparently it works similar as Java integers in that the maximum is 32-bits, and it wraps around to the negative above that.. So the number was too big to be pushed in one go. When I push the number in TIO it works fine though, I now realize. – Kevin Cruijssen Nov 6 at 8:00

R, 18x0.7 = 12.6 score

cat(9*2*267509019)

Fairly self explanatory, just does some arithmetic avoiding the numbers in question.

Python 2, 16 bytes

print 4815162342

Try it online!

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__

Red, 50 bytes / 2 = 25

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

Try it online!

Prints the numbers without separator

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

×/⎕UCS'𩦦湡'

Just boring old character multiplication.

Try it online!

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

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}.

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

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!

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!

F#, 45 bytes = 22.5 points

Just a run-of-the-mill for loop that prints the digits:

for c in"DHOPWj"do printf"%d"(int c-int '@')

The above is a complete program that can be compiled into an executable.

In a REPL (read-eval-print loop), e.g. FSI (F# Interactive), the following shorter version will work, as the REPL will output a representation of the expression evaluated; it has 35 bytes = 17.5 points:

[for c in"DHOPWj"->int c-int '@'];;

Python 3, 44 38 bytes

-6 bytes thanks to @Jo King

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

Try it online!

New contributor
glietz is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

Pyke, 3 points

77 91 f8 86 98 06

Try it here!

The first byte signals to read in base 128 until a byte without the high bit is set.

Finally, 32 is subtracted from the result (for historical reasons).

This allows for the generation of large numbers in very small amounts of space

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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