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

29
\$\begingroup\$

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
\$\endgroup\$
11
\$\begingroup\$

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.

\$\endgroup\$
9
\$\begingroup\$

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!

\$\endgroup\$
6
\$\begingroup\$

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

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

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.

\$\endgroup\$
  • \$\begingroup\$ 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). \$\endgroup\$ – Jonathan Allan Nov 5 '18 at 19:13
5
\$\begingroup\$

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!

\$\endgroup\$
4
\$\begingroup\$

Brain-Flak, 52/2 == 26 bytes

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

Try it online!

\$\endgroup\$
4
\$\begingroup\$

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.

\$\endgroup\$
  • 1
    \$\begingroup\$ I like this one. Pretty short for being Java :) \$\endgroup\$ – Emigna Nov 5 '18 at 9:58
  • \$\begingroup\$ @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. \$\endgroup\$ – Kevin Cruijssen Nov 5 '18 at 10:02
  • 1
    \$\begingroup\$ 11.9 bytes: v->767*6277917L+3 \$\endgroup\$ – Rick Hitchcock Nov 5 '18 at 23:04
  • 3
    \$\begingroup\$ @RickHitchcock It's not every day we see a 0.1 byte saving. ;) \$\endgroup\$ – Arnauld Nov 5 '18 at 23:23
  • \$\begingroup\$ @RickHitchcock Thanks! And I agree with Arnauld's comment above. :D \$\endgroup\$ – Kevin Cruijssen Nov 6 '18 at 8:55
4
\$\begingroup\$

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.

\$\endgroup\$
  • \$\begingroup\$ 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 :( \$\endgroup\$ – Jo King Nov 9 '18 at 12:40
  • \$\begingroup\$ @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.) \$\endgroup\$ – ais523 Nov 9 '18 at 18:08
3
\$\begingroup\$

05AB1E, 6*0.7 = 4.2 bytes

•1Z&ð“

Try it online!

Prints the number uncompressed from base-255

\$\endgroup\$
  • \$\begingroup\$ You beat me to it. ;) \$\endgroup\$ – Kevin Cruijssen Nov 5 '18 at 9:05
3
\$\begingroup\$

R, 18x0.7 = 12.6 score

cat(9*2*267509019)

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

\$\endgroup\$
2
\$\begingroup\$

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.

\$\endgroup\$
2
\$\begingroup\$

Aheui (esotope), 45 bytes(15 chars) * 0.5 = 22.5 points

반밤밪박밭빠따받발따밣뱣히망어

Try it online!


Explanation:

See this also; Aheui Reference(English)

Aheui program starts with default stack '아'(or none)

반: push 2, move cursor right by 1(→).
밤: push 4, →
밪: push 3, →
박: push 2, →
밭: push 4, →
빠: dup, →
따: pop 2, push mul result(16).
받: push 3, →
발: push 5, →
따: pop 2, push mul result(15).
밣: push 8, →
뱣: push 4, move cursor right by 2(→→).
히: end.
망: pop 1, print, → (if stack is empty, move cursor left by 1.)
어: move cursor left by 1(←).

Note that ㅁ(print instruction) moves cursor by reverse direction if stack(or queue) is empty.

\$\endgroup\$
2
\$\begingroup\$

Perl 5, 16 bytes - 30% = 11.2

say 0x5FAB2EA2*3

Try it online!

\$\endgroup\$
2
\$\begingroup\$

MASM 8088 Assembly source, (93 bytes - 50%) = 46.5 bytes

Using no numbers or the sequence in the source:

MOV AH,'P'-'G'
LEA DX,L
INT '!'
RET
T EQU '-'-'+'
L DW 'ph'/T,'jb'/T,'lb'/T,'fd'/T,'dh'/T,'$'

Output:

A>LOST.COM
4815162342
\$\endgroup\$
2
\$\begingroup\$

PowerShell, 12 bytes * 0.7 = 8.4

0x5FAB2EA2*3

Try it online!

"Port" of Xcali's answer to have a better Powershell answer.

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

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.

\$\endgroup\$
  • 2
    \$\begingroup\$ Ok, you were trying to get the bonus, but with a code this size, it didn't compensate. Why not simply '4815162342'? \$\endgroup\$ – Eduardo Hoefel Nov 5 '18 at 2:24
  • \$\begingroup\$ @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. \$\endgroup\$ – guest271314 Nov 5 '18 at 2:30
  • \$\begingroup\$ Your score is 143*0.7=100.1 \$\endgroup\$ – Jo King Nov 5 '18 at 2:45
1
\$\begingroup\$

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.

\$\endgroup\$
  • 1
    \$\begingroup\$ Or just 14 bytes for <?=4815162342; \$\endgroup\$ – Jo King Nov 5 '18 at 8:09
  • 1
    \$\begingroup\$ 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 \$\endgroup\$ – Titus Nov 5 '18 at 14:31
1
\$\begingroup\$

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!

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

JavaScript (ES6), 16 * 0.7 = 11.2 bytes

_=>767*6277917+3

Outputs the digits with no delimiters.

Try It Online!

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

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
\$\endgroup\$
  • \$\begingroup\$ Is just pushing the number itself longer than having the extra multiply and push integer instructions? \$\endgroup\$ – Jo King Nov 5 '18 at 22:58
  • \$\begingroup\$ @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. \$\endgroup\$ – Kevin Cruijssen Nov 6 '18 at 8:00
1
\$\begingroup\$

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 '@'];;
\$\endgroup\$
1
\$\begingroup\$

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

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

MathGolf, 7 bytes * 0.5 = 3.5

ÿ≤┼ÇÅ$∞

Try it online!

Explanation

Note that this code doesn't yet work on TIO. I have made some changes to MathGolf recently, including adding the $ operator. Once it gets pulled to TIO you can run it there, I'll make an update to this answer then. It runs perfectly in the terminal

ÿ≤┼ÇÅ     Push "≤┼ÇÅ"
     $    pop(a), push ord(a) (pushes 2407581171)
      ∞   pop a, push 2*a

I utilize the fact that MathGolf has 1-byte literals for creating strings of up to length 4. If I wanted to convert the entire number from a base-256 string, I would have needed to use two ", and the string would have been 5 characters. This way, I save 2 bytes, but I lose one byte by having the doubling operator in the end.

\$\endgroup\$
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\$
1
\$\begingroup\$

Japt, 10 9 bytes / 2 = 4.5

"0¢*"mc

Test it

\$\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
    \$\begingroup\$ 17 (*.7) \$\endgroup\$ – ASCII-only Feb 26 at 1:48

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.