# 10 9 8 7 6 5 4 3 2 1... Print 2016 [closed]

As a spin-off to my challenge over at Puzzling, your goal is to output 2016.

Rules:

• You must include the numbers 10 9 8 7 6 5 4 3 2 1 in that order. They can be used as individual integers or concatenated together (like 1098), but the 10 may not be separated into 1 and 0 - no character(s) may be present between the digits. Note that, in some languages, 10 may not actually represent the integer literal 10, which is acceptable.
• Your code must not contain any other numbers or pre-defined number variables or constants (so T in Pyth is not allowed, since it is a numeric constant).
• You must calculate 2016 using numerics. Simply outputting 2016 without performing any operations on the required numbers (for example, by decoding an encoded string consisting of only alphabetic characters) is not allowed. Outputting 2016 in pieces (such as 20, then 16) is also not allowed; you must have a single output consisting of the numeric value 2016.
• The valid answer with the fewest bytes wins.
• @nicael I'm pretty sure solving the puzzle has been done. We've had several of these "insert operators to solve an equation" challenges, but they are exceptional hard to search for. Jan 6, 2016 at 13:40
• The previous revision (2) was more interesting actually. The new is just printing the string, the calculation was already made in your puzzling question... Jan 6, 2016 at 14:19
• Just a few questions based on what I can see on the current question: 1) Can we calculate 20 and 16 and print them one after the other or does the calculated number need to be 2016 before printing? 2) Are functions allowed? 3) Is concatenation of digits allowed? e.g. 1098 (I'm assuming yes by previous comments, but just to confirm) 4) Does "calculate 2016 using integers" mean that we can never have floats anywhere in an intermediate step? e.g. can I square root a number and round down? Jan 6, 2016 at 23:17
• 5) What happens if I have a language where "10" is not treated as the number ten, but rather a one followed by a zero and there was no way around it? Is such a language disqualified? (example language: Befunge) 6) Can we use a predefined number variable in place of 10, e.g. T987654321? Jan 6, 2016 at 23:19
• I’m voting to close this question because it has unobservable requirements of "using arithmetic" and "not allowing numeric constants". Feb 11 at 10:02

# Jelly, 1715 14 bytes

109876:54+3_21


Try it online!

### How it works

109876:54+3_21

109876            Initialize the left argument as 109876.
:54         Perform integer division by 54, yielding 2034.
_21    Subtract 21, yielding 2016.


# Hexagony, 61 bytes

Not gonna win, but I just wanted to do a challenge in Hexagony.

This uses a different method than other answers (much worse). It takes some factors of 2016 (2,3,6,7,8) and multiplies them all together.

Minified:

\109.8/7}_=\"6<}{>...$_5_4/*!@...../}3.."2\/="*=}<*...$1>"*"/


Unminified:

    \ 1 0 9 .
8 / 7 } _ =
\ " 6 < } { >
. . . $_ 5 _ 4 / * ! @ . . . . . / } 3 . . " 2 \ / = " * = } < * . . .$ 1
> " * " /


Explanation coming soon;

• "Explanation coming soon;" I think we have a different understanding of 'soon'. ;P Apr 5, 2017 at 14:03
• @KevinCruijssen Whoops, I completely forgot about this. ... And now I don't understand how it works anymore. Great.
– Blue
Apr 28, 2017 at 22:15

# Pyth, 16 bytes

+/109876 54-3 21


Does integer division, then adds (3-21).

Try it here.

## TI-BASIC, 17 15 bytes

int(109876/54-√(321


This uses @nicael's method.

17 bytes:

10+9*8-7+654*3-21


This solution from Puzzling can be directly translated into TI-BASIC.

• Also valid in Japt, and probably some others. Jan 6, 2016 at 19:02
• Also works in PowerShell, and Mathematica (Wolfram), and I would imagine many, many others. And probably works in dozens more with trivial modifications. Jan 6, 2016 at 19:19
• A lovely polyglot solution Jan 6, 2016 at 19:36
• If you want to take the other languages, I'll delete my community wiki one. Jan 6, 2016 at 19:39

# Japt, 17 16 bytes

Â(109876/54-321q


I hate this 17. Probably will find another solution. YAYZ.

Explanation:

• 321q is a square root of 321.
• ~~ floors the number.

Try it online!

• Â == ~~ :-) Jan 6, 2016 at 22:35
• 109876/54-321¬f is 15 :-D Jan 6, 2016 at 22:36
• @Eth but f doesn't work, no? Jan 6, 2016 at 22:37
• It should be fixed. But the interpreter is down for maintenance right now, I'll get it back up momentarily. Jan 6, 2016 at 22:38
• 109876/54-321q)f now works. The other suggestion doesn't. Jan 6, 2016 at 22:47

# Matlab / Octave, 23 bytes

(10-9+8-7)^(6-5+4)*3*21


Try it online

# bc, 14

109876/54+3-21


Nothing exciting here - borrows from other answers.

• The dc equivalent 109876 54/3+21-p scores 16, but doesn't warrant an answer of its own. Jan 8, 2016 at 8:55

[10,9*8*7+const 6 5..]!!4+3*2*1


Not the shortest, 10+9*8-7+654*3-21 like seen in other answers works in Haskell too, but something different.

This builds a list starting with 10 and 9*8*7+6 = 510, so the offset is 500 for the following elements. The whole list is [10,510,1010,1510,2010,2510 ...]. We pick the 4th element (index 0-based), i.e. 2010 and add 3*2*1 = 6. Voilà.

I use const 6 5 = 6 to get rid of the 5 which is not needed.

# Python 2, 20 bytes

print 109876/54+3-21


Again, that same boring 2016.(740). Makes use of the fact that if you don't have a decimal number in your expression it returns an integer.

# BotEngine, 423936 13x2=26

v109876543210
>ee   e@  eRP


# ><> (fish), 18 bytes

10987**r65r4*n;321


explaination:

multiplies 9 8 and 7 together to get 504, reverses the stack and reverses it again right before the 4 is added, then multiplies 504 and 4 to get 2016. Then prints the number and ends the program before the last 3 numbers (i could do it after too with no difference, if that matters rules-wise).

# Math++, 17 bytes

_(109876/54)+3-21


Actually, this prints 2016.0. But there's really no way to print the exact string 2016 in this language.

The 17-byte TI-BASIC solution would also work here.

# Polyglot, 17 Bytes

10+9*8-7+654*3-21

This code, first used in Thomas Kwa's TI-BASIC answer, also works in:

• AppleScript (full program)
• bc (full program)
• Math++ (expression or full program)
• Mathematica (function, therefore not valid)
• Powershell (full program)
• Japt (full program)
• JavaScript (console input, therefore not valid) Needs second verification
• Perl 5 (function, therefore not valid). Needs second verification
• Haskell (function, therefore not valid)
• Python REPL (expression, so REPL environment is needed to get the output)
• And, what's the point? Jan 6, 2016 at 19:34
• @nicael I'm ---going--- am planning (unless Thomas Kwa wishes to add the other answers to his as well) to add all of the answers that involve this answer (except TI-BASIC) that I can find. Marked as Community so that others can contribute. Jan 6, 2016 at 19:38
• Why the "function, therefore not valid" remarks? Functions are allowed by default.
– nimi
Jan 6, 2016 at 21:54
• I don't know about the other languages, but 10+9*8-7+654*3-21 is neither a JavaScript nor a Perl function. Jan 6, 2016 at 21:56
• @Sp3000: Oh these invalidating rule changes ...
– nimi
Jan 7, 2016 at 0:50

# 𝔼𝕊𝕄𝕚𝕟 2, 15 chars / 17 bytes

109876/54+3-21⍜


Try it here (Firefox only).

Translates to round(109876/54+3-21).

Thanks to @Dennis for saving 2 bytes!

# Java 7, 31 bytes

int c(){return 109876/54+3-21;}


Boring port from other answers, of which I believe @Dennis' Jelly answer was the first.

# PHP, 27 bytes

<?=~~(109876/54+3-21);


(22 bytes) was too boring,

so I used 10 to 9 as separate numbers:

<?=10*(9-8+7-6),5+4-3+2<<1;


other solutions, mostly with small cheats:

30: <?=10**(9+8-7-6)/5+4*3+(2<<1);
30: <?=10*trim(9*8,7),6+5+4+3-2*1;
29: <?=10*trim(9*8,76),5*4-3-2+1;
31: <?=10*trim(9*8,765),4+(3*2<<1);
31: <?=10*trim(9*8,765),4*3+(2<<1);
32: <?=ceil(1098*76/54)+321+ord(~j);
33: <?=(10<<9)/876*543/M_PI*2-M_E&~1;


# CJam, 15 bytes

109876 54/3+21-


Another port from Dennis' answer that I suspect works for many stack-based languages except 05AB1E, which seems to be the only stack-based answer besides Forth, which needs several more bytes.

# Milky Way 1.6.5, 28 25 bytes

10+9*(8)7;^*6*5/4*3/2*A!1


### Explanation

10+9*                       perform 10*9 (leaves 90 at TOS)
(8)7;^*                get rid of 8 and multiply the TOS by 7
6*5/4*3/2*A     perform TOS*6/5*4/3*2 (leaves 2016 at TOS)
!    output the TOS
1   push 1 to the stack


# 05AB1E, 15 bytes

109876 54÷3+21-


Try it online!

# Forth, 22 bytes

Same calculation seen in other answers.

109876 54 / 3 + 21 - .


Try it online

# C 37 bytes

main(){printf("%d",109876/54+3-21);}


Same theme as many present.

# VBA, 15 bytes

?109876\54+3-21


(calculation unashamedly stolen from Dennis)

# JavaScript (ES6), 21 bytes

f=

_=>~~(109876/54+3-21)

console.log(f())

If the "countdown" went to 0, it could be done in 19 bytes.

f=
_=>109876/54+3-21|0
console.log(f())

And, seeing as it's 2017 now, that can also be done in 21 bytes:

f=
_=>-~(109876/54+3-21)
console.log(f());`