26
\$\begingroup\$

If you think this could be fun, but too much work, consider participating in this much smaller challenge.


A bit of fun (and possibly frustration!) for 2016... Dyalog's "puzzle of the year". Enjoy!

The Objective

Find Dyalog APL (download) expressions (other languages are allowed, see Eligibility below) involving exactly the digits 2 0 1 6 in that order to equal the numbers 0 to 100. For example:

20=16
×2016
2⌊016
2+0+1*6
...

The aim is to use as few characters as possible in each expression (the minimum number of characters for an expression is 5 – the four digits 2 0 1 6 and a single primitive function/operator).

The Rules

  • Each expression must contain the digits 2 0 1 6 (in that order) and no other digits. Pre-set constants and variables are also not allowed.
  • In addition to the four digits 2 0 1 6, only built-in symbols and names, parentheses/braces, spaces, high minus signs and decimal points can be used. The resultant expressions must be deterministic (that is, give the same result on repeated evaluations). For non-APLs, functions/operators with a name are also allowed; same rules as here.
  • Assume all default settings for your language. For Dyalog APL, this means ⎕ML and ⎕IO are both 1, and ⎕PP is 10.
  • Each entry comprising correct expressions for all the numbers from 0 to 100 inclusive will be rated according to the number of characters used by those expressions excluding redundant spaces (minimum 505 for all 101 expressions).

Eligibility

Anyone can enter. You may answer in any language, but only APL answers will be considered for accepting. If you use another language than APL, you may use snippets, programs, functions, etc. as alternatives to expressions, and you may print, leave the number in an accessible memory location, or otherwise return the result, as long as your code directly evaluates to the desired number as any standard numeric data type for your language.

Closing Date

30 November 2016.

Prizes

  • Have your answer accepted
  • Be immortalised in Dyalog's 2016 Hall of Fame!

Submitting Your Entry

After 30 November 2016, I will accept the shortest answer, and submit your answer, in your name, to Dyalog's 2016 Hall of Fame.

FAQ

  • Is J (e.g. 37=⌈⍟!20J16) allowed?
  • No: In addition to the four digits 2 0 1 6, only only built-in symbols and names, parentheses/braces, spaces, high minus signs and decimal points can be used.

  • Is output as a string acceptable?
  • No: equal the numbers 0 to 100.

  • Physical digits, or data digits?
  • Data digits, as per OP: same rules as here, where one of the examples contain LOG10(.

  • Is assigning variables then using them as part of the expression (e.g. 56=a+16+a←20) allowed?
  • Yes, but you may not use an assignment from one expression in another one.

I have explicit written permission to post this challenge here from the original author of this challenge. Feel free to verify by following the provided link and contacting the author. I gave the original competition author the link to this page within the minute I posted it, so they can check if I submit someone's answer as my own.

\$\endgroup\$
  • \$\begingroup\$ Related: codegolf.stackexchange.com/q/48917/34718 \$\endgroup\$ – mbomb007 Mar 3 '16 at 17:04
  • \$\begingroup\$ So many answer and no one APL solution? \$\endgroup\$ – Akangka Sep 16 '16 at 14:45
  • 1
    \$\begingroup\$ @ChristianIrwan Right, that is to be expected: anyone doing it in APL may rather want to submit to the real competition instead of revealing his secrets here. \$\endgroup\$ – Adám Sep 16 '16 at 14:58
  • \$\begingroup\$ @Adám, this might be late, but would using ⎕ML and ⎕IO (assumed to be 1) be acceptable? \$\endgroup\$ – Zacharý Dec 3 '16 at 21:29
  • \$\begingroup\$ @ZacharyT You mean putting quad names into the expression? Sounds like a lot of extra characters for little win. Can you give me an example? \$\endgroup\$ – Adám Dec 4 '16 at 9:37

11 Answers 11

7
\$\begingroup\$

Jelly, 686 bytes

20=16
20>16
2+0%16
201%6
20%16
20%16‘
201a6
20>1+6
20%16Ḥ
2016DS
20Ho16
2016BL
20:1.6
20_1_6
20×1_6
20+1_6
20&16
20:+16
2+0+16
20+1^6
20|16
20|16‘
20|16‘‘
20%16!’
20%16!
20²:16
20H+16
20+1+6
20×1_6Ḥ
20×1_6Ḥ‘
20+1_6Ḥ
2016&½’
2016&½
201:6
201:6‘
20Cạ16
20+16
20+16‘
20+1^6Ḥ
20|16Ḥ’
20|16Ḥ
20|16Ḥ‘
20|16‘Ḥ
2016½Ḟ’
2016½Ḟ
2016½Ċ
2016½Ċ‘
20Ḥ+1+6
2r0×16S
201a6‘²
20²:16Ḥ
2r016+S
201ÆC+6
20&16ÆN
20H_1×6
20ạC+16
20Ḥ+16
20_1×6H
20_1×6H‘
20_1×6H‘‘
20+1_6ḤḤ
2+0+16ÆN
20:.16H
20+1×6H
2²+0×16
201:6Ḥ’
201:6Ḥ
201Ḥ:6
201Ḥ:6‘
20Cạ16Ḥ’
20Cạ16Ḥ
20+16Ḥ’
20+16Ḥ
20+16Ḥ‘
20+16Ḥ‘‘
20+ÆN_16
20+1^6ḤḤ
20+1^6ḤḤ‘
20×16HH’’
20×16HH’
20×16HH
20×16HH‘
20|16Ḥ‘Ḥ
20|16Ḥ‘Ḥ‘
20|16‘ḤḤ
201½×6Ḟ
201½×6Ċ
20ÆN+16
2016½ḞḤ
20Æn16¡
20r16S
20r16S‘
20r16S‘‘
20Ḥ+1+6Ḥ’
20Ḥ+1+6Ḥ
20ḤḤ+16’
20ḤḤ+16
20ḤḤ+16‘
201a6‘²Ḥ
201’Ho6’
201’Ho6

I wrote about 50 of these, then autogenerated the rest by appending (×2) and ‘’ (±1) as needed. I’ll improve them later!

\$\endgroup\$
  • \$\begingroup\$ 46 can become 201ÆCo6. I don't think you can use (which was implemented in February), but 20|16Ḥ‘Ḥ and 20|16‘ḤḤ’ are equally short. \$\endgroup\$ – Dennis Mar 9 '16 at 16:10
  • \$\begingroup\$ @Dennis Oops, my Python script actually erroneously preferred over ‘’ – 46, among with four other numbers, should have been one character shorter. I’ve replaced it with 2016½Ċ‘ which is as long as yours. \$\endgroup\$ – Lynn Mar 13 '16 at 21:39
9
\$\begingroup\$

Hexagony, 888 bytes

Okay, first some ground rules for Hexagony, in case anyone wants to beat this:

  • I'm interpreting "snippet" as a linear piece of code that can be dumped into any sufficiently large program, provided the current and adjacent memory edges are zero.
  • The snippet has to be entered from the left and exited from the right. I'd be able to save quite a bunch of bytes without that (e.g. 2|016 for 22), but it seems most in the spirit of the challenge.
  • The snippet "produces" a given number, if any memory edge (not necessarily the current one) holds that value after execution.
  • The rule forbidding any other numbers in the snippet affects both other digits as well as any letters, since they effectively act as integer literals in Hexagony. (Those would save a ton of bytes.)

So here is the list. I did test most of them but not all (some are trivial modifications of others), so I hope I didn't make any mistakes:

2016
20&1}6
2}016
2)}016
20{16'-
201}6(
201}6
201}6)
2}016":
2(0(}16
2(0}16
2(0)}16
)2}016
)2)}016
20}16((
20}16(
20}16
20}16)
20}16))
20(}16
20}16
20)}16
20))}16
20)))}16
20}1)6((
20}1)6(
20}1)6
20}1)6)
201{6)':
2)0(}16
2)0}16
2)0)}16
2{016'*
201{6':
2{016)'*
20}1))6(
20}1))6
20}1))6)
20}1))6))
2))0(}16
2))0}16
2))0)}16
2))0))}16
2))0)))}16
20)){1)'6*
2){016('*
2){016('*)
2){016'*(
2){016'*
2){016'*)
2)))0}16
2){016)'*
2){016)'*)
2{01)6)'*(
2{01)6)'*
2{01)6)'*)
2{01)6)'*))
2{01)6)'*)))
2))))0((}16
2))))0(}16
2))))0}16
2))))0)}16
2)0){1)'6*
2)){016'*(
2)){016'*
2)){016'*)
2)){016'*))
2)){016'*)))
2{01))6('*(
2{01))6('*
2{01))6'*((
2{01))6'*(
2{01))6'*
2{01))6'*)
2{01))6)'*
2){01)6('*
2){01)6'*((
2){01)6'*(
2){01)6'*
2){01)6'*)
20{1)))'6*
2){01)6)'*
2){01)6)'*)
2){01)6)'*))
2){01)6))'*
2){01)6))'*)
2){01)6))'*))
2){01)6)))'*
2{01)))6(('*
2{01)))6('*(
2{01)))6('*
2{01)))6'*(
2{01)))6'*
2{01)))6'*)
2{01)))6)'*
2{01)))6)'*)
2{01)))6))'*
2(01((((}16
2(01(((}16
2(01((}16
2(01(}16

I got a bit lazy towards the end, so I'm sure this isn't optimal. Might be interesting (and possible) to brute force these.

\$\endgroup\$
  • \$\begingroup\$ Very nice. Remember you have 10 months (or forever, really) to improve this. I suppose Hexagony has few enough commands that brute-forcing is reasonable. It took me a week of 100% single-core usage to brute-force 4 inserted APL chars. \$\endgroup\$ – Adám Jan 31 '16 at 14:58
  • \$\begingroup\$ So you have done it? Did you get an optimal solution? \$\endgroup\$ – jimmy23013 Jan 31 '16 at 15:01
  • \$\begingroup\$ @NBZ Since incrementing and decrementing the result is always possible, for a single byte it might be easiest for Hexagony to check programs for any numbers (instead of one number at a time), and if I find something shorter than the current best for that number and can shorten that and potentially a few numbers around it as well. And yes, once you remove the digits and letters (and some other characters that are useless here) it should be quite brute forcible. \$\endgroup\$ – Martin Ender Jan 31 '16 at 15:01
  • \$\begingroup\$ @jimmy23013 Almost done. Missing the optimal solution for two out of the 101 numbers. \$\endgroup\$ – Adám Feb 1 '16 at 15:57
  • \$\begingroup\$ @NBZ You only have to brute-force 4 character solutions to prove there isn't such a solution. I think it's likely you can write a 5 character solution by hand and that would be optimal. \$\endgroup\$ – jimmy23013 Feb 2 '16 at 1:22
8
\$\begingroup\$

J, 1041 ... 838 bytes

981 961 952 860 859

I got a little lazy to the end, but it should be more fixed than less. I don't think I'll ever overtake Hexagony, but you never know! beating hexagony! Saved 9 bytes thanks to Zgarb! and so much more to Lynn!

20=16
*2016
2[016
2+01[6
20-16
p:2[016
201]6
2+0-1-6
-:20]16
2+01+6
-:20[16
p:20-16
+/2$01]6
<:20-1]6
20-1]6
<:20]16
20]16
p:201]6
2+016
20-1[6
20[16
20+1[6
20++~1[6
+/q:2016
20-(+:1)-6
<:20+1]6
20+1]6
20+1+6
+:20-1]6
p:2+01+6
-2-+:016
<:2*016
2*016
>.201%6
<.201%6
<:20+16
20+16
20+>:16
+~20-1[6
-20-p:16
+:20[16
p:2*01*6
>:p:2*01*6
<:<.%:2016
<.%:2016
>.%:2016
+/q:*:2016
p:20-1]6
>:p:20-1]6
*:2+0-1-6
+:20-1-6
20++:16
<.%:20^%:1+6
20+#i:i:16
*/2,01]$~-:6
<:<.o.2+016
<.o.2+016
>.o.2+016
<:p:20]16
p:20]16
>:p:20]16
2+p:016
<.o.20[16
<:2^01]6
2^01]6
>:2^01]6
<:p:2+016
p:2+016
>:p:2+016
>:>:p:2+016
<:p:20-1[6
p:20-1[6
+/+~20 16
p:20[16
>:p:20[16
>:>:p:20[16
-:+/2+i.016
<:<:p:20+1[6
<:p:20+1[6
20+p:16
20*.16
*:2+01+6
>:*:2+01+6
p:20++~1[6
<.o.20+1+6
>.o.20+1+6
>:>.o.20+1+6
<.o.+:20-1]6
>.o.+:20-1]6
p:+/q:2016
>:p:+/q:2016
<.o.p:2+01+6
>.o.p:2+01+6
(*:-:20)-1+6
>:(*:-:20)-1+6
<:(++:)2*016
(++:)2*016
p:20-(+:1)-6
2**~p:-:01]6
<:*:-:20[16
*:-:20[16

Highlights and Notes

I used prime numbers a lot in this. In fact, I used p: (the Nth prime) function 37 times in this thing.

 *:-:20[16

90 was made using a fork. Yay! It's approximate to this:

(*+&1)2+01+6

Translated as

inc =: + &1
mul =: *
nin =: 2 + 1 + 6
NB. since (f g) y = y f (g y):
  (mul inc) nin   = nin mul (inc y)
                  =  9   *    9+1
                  =  90

54 uses a shaping ravel!

*/2,01]$~-:6

Is equivalent to

*/ 2 , $~ -:6
*/ 2 , -:6 $ -:6
*/ 2 , 3 $ 3
*/ 2 , 3 , 3 , 3
   2 * 3 * 3 * 3
   54
\$\endgroup\$
  • \$\begingroup\$ Well, you have 3/4 year to make improvements. \$\endgroup\$ – Adám Mar 2 '16 at 20:38
  • \$\begingroup\$ 24: !20-16 54: <.^20-16 55: >.^20-16 97: p:!20-16 \$\endgroup\$ – Lynn Mar 3 '16 at 19:42
  • \$\begingroup\$ Nice trick with the four factorial! \$\endgroup\$ – Conor O'Brien Mar 3 '16 at 19:45
  • \$\begingroup\$ That 94 seems suspiciously long... how about +:p:-2-016 (4 bytes shorter)? \$\endgroup\$ – Lynn Mar 3 '16 at 19:59
  • \$\begingroup\$ I think 7 can be 2]01+6, 8 can be 2%~016 and 12 can be 2*01]6. \$\endgroup\$ – Zgarb Mar 4 '16 at 18:29
7
\$\begingroup\$

JavaScript, 1021 bytes

Fixed and saved two bytes thanks to Charlie Wynn and ETHProductions.

201&6
-~!2016
2%016
201%6
20%16
2^0^1^6
2*0*1+6
2|0|1|6
2*01+6
2-~01+6
~2+016
~2+016
2^016
20-1-6
2|016
20+1-6
20&16
2-~016
2.0+16
20^1+6
20|16
-~20|16
20*1|6
20|1|6
-2*~01*6
20-1+6
20+1*6
20+1+6
2*016
-~(2*016)
2*-~016
~-(2.0*16)
2.0*16
-~(2.0*16)
2.0*-~16
~-20+16
20+16
-~20+16
-~-~20+16
-~2*~-016
20*-~1.6
~-(-~2*016)
-~2*016
~-~-(~2*~016)
~-(~2*~016)
~2*~016
20<<1|6
20*-~1-~6
~2*~-~016
-~(~2*~-~016)
~-~(~-~2*~-016)
~2*~-~-~016
-~-~2*~-016
20*-~-~1+~6
20*-~-~1-6
20*-~-~1-~-6
-~-~2*016
-~20*-~-~1-6
-~-~(-~-~2*016)
~-(20*~-~(1-6))
~-~2*~016
-~(20*~-~(1-6))
-~-~(20*~-~(1-6))
-~20*~-~(1-6)
~-~2*~-~016
20*-~-~1+~-6
20*-~-~1+6
20*-~-~1-~6
~-~2*~16
-~20*-~-~1+6
-~-~-~2*016
~-(~-~2*~-~16)
~-~2.0*~-~16
-~(~-~2*~-~16)
20*-~-~-~1-6
~-~-~2*~016
~-20*~(1-6)
-~(~-20*~(1-6))
~-~-(20*~(1-6))
~-(20*~(1-6))
20*~(1-6)
-~(20*~(1-6))
~-~-(~20*-~(1-6))
~-(~20*-~(1-6))
~20*-~(1-6)
20*-~-~-~1+~-6
20*-~-~-~1+6
20*-~-~-~1+-~6
20*-~-~-~1+-~-~6
~-(~-~-20*-(1-6))
~-~-20*-(1-6)
-~(~-~-20*-(1-6))
~-~-~-(~-20*-(1-6))
~-~-(~-20*-(1-6))
~-(~-20*-(1-6))
~-20*-(1-6)
-~(~-20*-(1-6))
~-~-~-(20*-(1-6))
~-~-(20*-(1-6))
~-(20*-(1-6))
20*-(1-6)
\$\endgroup\$
  • \$\begingroup\$ 20^1+6 saves one for 19 (is it ok if you put the number next to each entry?) \$\endgroup\$ – Charlie Wynn Mar 3 '16 at 16:46
  • \$\begingroup\$ 20<<1|6 saves one for 46 (should I just be editing your answer?) \$\endgroup\$ – Charlie Wynn Mar 3 '16 at 16:50
  • \$\begingroup\$ @CharlieWynn No. Use comment suggestions. There's a meta post on it. \$\endgroup\$ – mbomb007 Mar 3 '16 at 17:06
  • \$\begingroup\$ Testing on Firefox 44, your 1 is actually 2, and your 10 is 11. You can use your current 10 as 11 (it's three bytes shorter), 2-~01+6 as 10, and -~!2016 as 1. \$\endgroup\$ – ETHproductions Mar 3 '16 at 19:40
  • \$\begingroup\$ wow someone managed to beat my 5244-character solution \$\endgroup\$ – clamchowder314 Nov 27 '16 at 23:12
7
\$\begingroup\$

JavaScript (ES7), 836 bytes

Everything should work in any browser except 81, 88, and 97, which use the new ** operator.

Mostly everything here was done by hand. I've been working on a brute-forcer to improve anything that can be improved. Currently it has saved 103 bytes on various items.

  0: 201&6
  1: 2-01%6
  2: 2%016
  3: 201%6
  4: 20%16
  5: 201%~6
  6: 2%01+6
  7: 2-01+6
  8: 2*01+6
  9: 2+01+6
 10: 2-~01+6
 11: ~2+016
 12: 2^016
 13: 20-1-6
 14: 2|016
 15: 20+1-6
 16: 2+016
 17: 2-~016
 18: 2+0+16
 19: 20-1%6
 20: 20|16
 21: 20+1%6
 22: 20*1|6
 23: 20+1|6
 24: 20+~1+6
 25: 20-1+6
 26: 20*1+6
 27: 20+1+6
 28: 2*016
 29: 20-~1-~6
 30: -2*~016
 31: 20|~-16
 32: 20*1.6
 33: 20*~1^~6
 34: -20*~1-6
 35: 20+~-16
 36: 20+16
 37: 20-~16
 38: 20-~-~16
 39: -~2*~-016
 40: 20<<1%6
 41: -20*~1-~!6
 42: ~2*-016
 43: ~20^-1<<6
 44: ~20*~1^6
 45: ~2*~016
 46: 20<<1|6
 47: -20*~1-~6
 48: ~20*~1+6
 49: ~20*~1-~6
 50: ~2/.01/-6
 51: ~2.0*~16
 52: 20|1<<~-6
 53: -20*~-~1+~6
 54: ~2.0*~-~16
 55: -20*~-~1-~-6
 56: ~-~2*-016
 57: ~20*~-~1-6
 58: -20*~-~1^6
 59: ~(20/~1*6)
 60: -20/~1*6
 61: ~2^0-1<<6
 62: -2^0-1<<6
 63: ~20/~1*6
 64: 2-01<<6
 65: 2+~0|1<<6
 66: 2|01<<6
 67: 2-~0|1<<6
 68: 2*~!0*~16
 69: ~20*~-~1+6
 70: 20/~1*~6
 71: -~(20/~1*~6)
 72: 2+~0/.1*~6
 73: -20<<-~1^~6
 74: -20<<-~1^-6
 75: ~-~-~2*~016
 76: ~-20*(~1+6)
 77: ~-~20/~1*-~6
 78: ~-20<<-~1|6
 79: -20<<-~1^~!6
 80: 20*(~1+6)
 81: ~2*~0**(~1+6)
 82: ~-~-20|1<<6
 83: ~-20|1<<6
 84: 20|1<<6
 85: -~20|1<<6
 86: 20<<-~1|6
 87: 20<<-~1|-~6
 88: .2**~!0|1<<6
 89: ~20*~-~-~1+~-6
 90: ~2*~!0*~-16
 91: ~20*~-~-~1-~6
 92: ~-2/.01+~-~6
 93: ~-2/.01+~6
 94: ~-2/.01-6
 95: ~-20*1*~-6
 96: 2+01<<~-6
 97: ~2+.01**~.6
 98: ~-2/.01^6
 99: ~-2/.01+~.6
100: 20*1*~-6

Brute-forcer

It ain't the prettiest code, but that doesn't seem to matter around these parts.

WARNING: Do not run unless you are prepared for your browser/engine to freeze for a few minutes. Nobody likes to calculate 7 nested loops.

var a=new Array().fill("000000000000000000000000000"), // An array of non-solutions to start
    time=new Date(),                                   // For timing how long this takes
    o=["","+","-","*","/","%","&","|","^",".","<<"],   // Operators for between numbers
    p=["",".","~.","-","~","~-","-~","~-~","~-~-","~!"];        // Prefixes for each number
for(i=0;i<o.length;i++)
for(j=0;j<o.length;j++)
for(k=0;k<o.length;k++)
for(I=0;I<p.length;I++)
for(J=0;J<p.length;J++)
for(K=0;K<p.length;K++)
for(L=0;L<p.length;L++) {      // 7 nested loops = O(len(o)^3 * len(p)^4)
    z=      p[I]+2
      +o[i]+p[J]+0
      +o[j]+p[K]+1
      +o[k]+p[L]+6;            // Put all the current chars in one string. 
    try { v=eval(z) }          // Try setting v to the evaluated value of z.
    catch(e) { v=-1 }          // If an error occurs, set v to -1.
    if( (v === (v|0)) &&       // If v is an integer, and
        v>=0 && v<=100 &&      // v is between 0 and 100, inclusive, and
        z.length<a[v].length ) // z is shorter than the current entry,
        a[v]=z;                // overwrite the current entry.
}

console.log("time: " + ((new Date()-time)/1e3) + "seconds\n"
           + "length: " + (a.join("").length) + "\n"
           + a.map((x,y) => y + ": " + x).join("\n"))
\$\endgroup\$
  • 3
    \$\begingroup\$ Yeah, prettiness doesn't matter here. We are not CR. :P \$\endgroup\$ – Rɪᴋᴇʀ Mar 4 '16 at 19:12
  • \$\begingroup\$ wow someone managed to beat my 5244-character solution \$\endgroup\$ – clamchowder314 Nov 27 '16 at 23:12
4
\$\begingroup\$

PowerShell v3+, 1575 1499 bytes

2*0*16
2*0+1%6
2%016
201%6
20%16
2*0+-1+6
2*0+1*6
2*0+1+6
2+0*1+6
2+01+6
2*(0-1+6)                #10
2*($a=01)*6-$a           ################################## First variable
2*01*6
20-1-6
20*1-6
20+1-6
2*0+16
!!20+16                  ################################## First Boolean not
2+016
2+!0+16
20+!16                   #20
20+1+!6
!2+0x16                  ################################## First use of 0x16
(20+1)-bor6              ################################## First binary or
2+0x16
20-1+6
20*1+6
20+1+6
20+($a=1)+6+$a
20+($a=1)+6+$a+$a
2*-bnot-016              #30 ############################## First binary not
-bnot(-2*016)
2*016
-(-bnot(2*016))
-2*-bnot016
-bnot(-20)+16
20+16
20-(-bnot16)
-(-bnot20)-(-bnot16)
(20-shl1)-!!6            ################################## First binary shl
(20-shl1)+!6             #40
(20-shl1)+!!6
($a=2)*0x16-$a
($a=2)*0x16-$a/$a
2*0x16
-(-bnot2)*(-bnot-016)
(20-shl1)+6
$a=20;$b=1;$a+$a+$b+6
-(-bnot2*016)
2*0+($a=1+6)*$a
(20-shr($a=1))*(6-$a)    #50
(-bnot2)*(-bnot016)
20+($a=16)+$a
($b=20*($a=1)+6)+$b+$a
($a=20+1+6)+$a
($a=20+($b=1)+6)+$a+$b
($a=20)+16+$a
(($a=(2+!0))+16)*$a
(20-shr($a=1))*6-$a-$a
(20-shr($a=1))*6-$a
(20-shr1)*6              #60
(20-shr($a=1))*6+$a
(($a=2)*0+1-shl6)-$a
-bnot-(2*0+1-shl6)
2*0+1-shl6
(2*0+($a=1)-shl6)+$a
(-bnot2)*-0x16
($a=201)/($a%6)
20+($a=16)+$a+$a
20+($a=16)+$a+$a+$a/$a
-($a=2)*-bnot016*$a+$a   #70
2*01*($a=6)*$a-$a/$a
2*01*($a=6)*$a
($a=2+01+6)*$a-$a+$a/$a
($a=2)*01*($b=6)*$b+$a
($a=20)+16+$a+$a-$a/$a
($a=20)+16+$a+$a
($a=20)+16+$a+$a+$a/$a
2*01*($a=6)*$a+$a
($a=20)%16*$a-$a/$a
($a=20)%16*$a            #80
($a=2+01+6)*$a
($a=2)*0x16*$a-$a*$a-$a
20+(($a=1)-shl6)-$a
20+(1-shl6)
20+(($a=1)-shl6)+$a
($a=2)*0x16*$a-$a
($a=2)*0x16*$a-$a/$a
($a=2)*0x16*$a
($a=2)*0x16*$a+$a/$a
($a=2)*0x16*$a+$a        #90
($a=2)*0x16*$a+$a+$a/$a
($a=2)*0x16*$a+$a+$a
20*(-1+($a=6))-$a-$a/$a
20*(-1+($a=6))-$a
20*($a=-1+6)-$a
2*(!0+1+($a=6))*$a
20*(($a=-1)+6)+$a+$a+$a
($a=2)*($b=01+6)*$b
20*(($a=-1)+6)+$a
20*(-1+6)                #100

100% manually golfed - no brute force programs or other aids enlisted.
I feel that 1500 is maybe within reach
Sub-1500 achieved! Let's see how well I can do on getting this lower. (NB - This was only tested in v4, but should work in v3 and v5 without modification. Will not work in v2 or v1 as those versions did not have bitwise shift operators.)

Key points are marked with ##.hashes.## in the above code.

#11 is the first assignment to variable $a. Unlike some other languages, variables don't need to be pre-initialized for parsing, and it's only during execution that variables are resolved. Since the ($a=01) is surrounded by parens, it's evaluated first and so the second -$a is equivalent to -1. This is used rather extensively from here on out, and is one of the biggest things keeping the bytecount down.

#17 shows the first use of ! for Boolean not. In PowerShell, types are pretty loosely cast, so if casting can be implied, it'll work. Here, we're using the fact that !!20 equals !$false, which is $true, which can be implicitly cast as [int]1, which results in 17. This is used several times to either get another 1 or make a portion go to 0.

#22 Showcases the 0x hexadecimal cast operator, here turning 0x16 into 22. However, since 0x16 is the only number we can get, its usefulness is limited.

#23 has the -bor operator, for "binary or." However, since both -bor and -bxor have lower precedence than simple arithmetic operators, using them usually requires parens, which severely limits usefulness. This is the only one I've found where it's shorter to use the binary or operator (I eliminated the -bxor operator from 22).

#30 is the first time the -bnot operator is introduced. This is the "binary not" operator, and functions similarly to ~ in (e.g.) JavaScript. However, it usually needs parens, since the negation will show as --bnot and result in a parse/syntax error, and since it's five characters compared to one for ~, it gets used sparingly.

#39 is the first use of our binary shift operators, -shl and -shr. These are similar to << or >> in other languages, but are explicitly dyadic, meaning we need a number on both sides for them to work, which limits their usefulness in this challenge. Additionally, their precedence isn't explicitly called out in documentation, but testing shows them to be lower than simple arithmetic, meaning that parens need to be used liberally, so they don't make as much of an appearance as in other language answers.

\$\endgroup\$
  • \$\begingroup\$ Great answer. Thanks for explaining your techniques so thoroughly. \$\endgroup\$ – Adám Mar 9 '16 at 15:28
4
\$\begingroup\$

CJam, 792 791 bytes

I kind of got lazy near the end, a lot of them just ended up being increments and decrements (101 is a lot!), although I'm not sure if there is any other way for a few of the numbers. There's still plenty of time to golf it if I need to.

Around #40 there are some winky faces ;)

2016!          e# 0
2016g
2016g)
201 6%
20 16-
20)16-
20 1>6*
20 1>6+
201mQ6-
201mQ6-)
2 01 6*(*      e# 10
2 01*6*(
2 01*6*
2~016+
-2 016+
2)016(|
20;16
2(016+
2 016+
2)016+
20 16|         e# 20
20)16|
20 1*6|
20 1|6|
20 16mQ+
20_*16/
20 1 6*+
20 1+6+
20 1)6++
20)1)6++
2 016(*        e# 30
2 016*(
2 016*
201 6/
2 016)*
20(16+
20 16+
20)16+
20)16)+
20_+16;(
20_+16;        e# 40
20_+16;)
20)_+16;
20)_+16;)
20(1m<6+
2)016(*
20 1m<6+
2)016*(
2)016*
2)016*)
2)016)*(       e# 50
2)016)*
20 16_++
20)1 6(m<+
20(_16++
20_16++(
20_16++
20_16++)
20)_16++
20)_16++)
20 16mQ(*      e# 60
20 16mQ(*)
2 01*6#((
2 01*6#(
2 01*6#
2 01*6#)
201_+6/(
201_+6/
201_+6/)
201mQ6(*(
201mQ6(*       e# 70
20_16_+++(
20_16_+++
20_16_+++)
20)_16_+++
20(16mQ*(
20(16mQ*
20(16mQ*)
20_16^*((
20_16^*(
20_16^*        e# 80
2)016mQ#
201mQ6*((
201mQ6*(
201mQ6*
201mQ6*)
201mQ6*))
201mQ6*)))
[20_16__]:+
[20_16__]:+)   
[20)_16__]:+   e# 90
[20_16)__]:+
[20__16_]:+
20(1*6(*((
20(1*6(*(
20(1*6(*
20(1*6(*)
201mQ6)*(
201mQ6)*
20 1*6(*(
20 1*6(*       e# 100
\$\endgroup\$
  • \$\begingroup\$ Wanted to upvote for the winky faces, but I noticed you had exactly 1,000 rep, so I don't want to ruin it. ;) Will upvote later. :P \$\endgroup\$ – Kevin Cruijssen Aug 24 '16 at 14:33
  • \$\begingroup\$ and now its 1089 :P (another magic number for maths :P) \$\endgroup\$ – masterX244 Dec 5 '16 at 16:48
3
\$\begingroup\$

Mathematica, 2912 2502 2282 2180 bytes

Could definitely be golfed further. Mostly just solves a few separate Frobenius equations, which yields O(n) length solutions. The rest were generated by my brute-forcer.

2 0 16
2-01^6
2 01^6
2+01^6
20-16
2 0-1+6
201;6
2-01+6
2 01+6
2+01+6
a=2;01 6+a+a
2#-01&@6
2 01 6
20-1-6
20 1-6
20+1-6
20;16
2^0+16
2+016
20-1^6
20 1^6
20+1^6
a=2;b=016;a+a+a+b
a=2;b=01;c=6;a+a+b+c+c+c
201;a=6;a+a+a+a
20-1+6
20 1+6
20+1+6
a=2;b=016;a+a+a+a+a+a+b
a=2;b=01;c=6;a+a+b+c+c+c+c
201;a=6;a+a+a+a+a
2;a=01;b=6;a+b+b+b+b+b
2 016
a=2;b=01;c=6;a+b+c+c+c+c+c
a=2;b=016;a+b+b
a=2;b=01;c=6;a+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+a+b+c+c+c+c+c+c+c+c+c+c+c+c
201;a=6;a+a+a+a+a+a+a+a+a+a+a+a+a
2;a=01;b=6;a+b+b+b+b+b+b+b+b+b+b+b+b+b
a=20;16;a+a+a+a
a=2;b=01;c=6;a+b+c+c+c+c+c+c+c+c+c+c+c+c+c
a=2;b=016;a+b+b+b+b+b
a=2;b=01;c=6;a+a+b+c+c+c+c+c+c+c+c+c+c+c+c+c
a=20;b=16;a+b+b+b+b
2;a=01;b=6;a+b+b+b+b+b+b+b+b+b+b+b+b+b+b
a=2;b=016;a+a+a+b+b+b+b+b
a=2;b=01;c=6;a+b+c+c+c+c+c+c+c+c+c+c+c+c+c+c
a=20;b=16;a+a+b+b+b
a=2;b=01;c=6;a+a+b+c+c+c+c+c+c+c+c+c+c+c+c+c+c
201;a=6;a+a+a+a+a+a+a+a+a+a+a+a+a+a+a
2;a=01;b=6;a+b+b+b+b+b+b+b+b+b+b+b+b+b+b+b
a=20;b=16;a+a+a+b+b
a=2;b=01;c=6;a+b+c+c+c+c+c+c+c+c+c+c+c+c+c+c+c
a=2;b=016;a+a+a+a+a+a+a+b+b+b+b+b
a=2;b=01;c=6;a+a+b+c+c+c+c+c+c+c+c+c+c+c+c+c+c+c
2 01 6!!
2;a=01;b=6;a+b+b+b+b+b+b+b+b+b+b+b+b+b+b+b+b
a=2;b=016;a+b+b+b+b+b+b
a=2;b=01;c=6;a+b+c+c+c+c+c+c+c+c+c+c+c+c+c+c+c+c
a=20;16;a+a+a+a+a
\$\endgroup\$
  • \$\begingroup\$ Hrm, unless I misunderstood the question, shouldn't you be able to save a lot of bytes by assigning c to 16 when the number is even and large? Like for 96, etc. Not sure how your equation solver works, but using a=20 should also be helpful for several of these? \$\endgroup\$ – FryAmTheEggman Feb 18 '16 at 21:58
  • \$\begingroup\$ Yeah, then I dunno how long it would take to run it with 16 and 20 as well, but I expect that'll trim quite a bit for bigger numbers. \$\endgroup\$ – FryAmTheEggman Feb 18 '16 at 22:04
3
\$\begingroup\$

Dyalog APL (This is a joke, please don't submit), 25,957 bytes.

2016⊢≢⍬
2016⊢(⊢+≢)≢⍬
2016⊢(⊢+≢)(⊢+≢)≢⍬
...

Yeah, this is a joke entry, we need an APL solution, even if it's completely horrible. Works by incrementing ≢⍬ (0) n times. I don't want to give any secrets away from my actual submission.

Obviously could be golfed much more.

\$\endgroup\$
  • \$\begingroup\$ LOL. I got two upvotes. \$\endgroup\$ – Zacharý Feb 16 '17 at 21:34
  • \$\begingroup\$ Seriously, why are people upvoting this? \$\endgroup\$ – Zacharý Jun 22 '17 at 22:18
2
\$\begingroup\$

JavaScript, 5244 chars

Could probably be golfed a lot further. Test in the Chrome console. I kinda gave up at 10.

201&6
!!2016
2%016
20+~16
20-16
-2+0+1+6
2*0*1+6
2*0+1+6
2*01+6
2+01+6
-~-~-~-~-~-~20-16
-~-~-~-~-~-~-~20-16
-~-~-~-~-~-~-~-~20-16
-~-~-~-~-~-~-~-~-~20-16
20*1-6
!!2+016
2+016
!!20+16
2.0+16
2+!0+16
20+!16
20+!!16
-~20+!!16
-~-~20+!!16
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~20-16
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~20-16
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~20-16
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~20-16
2*016
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~20-16
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~20-16
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~20-16
(2+0)*16
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~20-16
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-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~-~-~-~-~-~-~-~-~-~20+16
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~20+16
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~20+16
20*-(1-6)
\$\endgroup\$
  • \$\begingroup\$ If 101 expressions was a bit much, you may want to have a go at this. There's already a JavaScript answer, but maybe you can do better - or differently... \$\endgroup\$ – Adám Mar 3 '16 at 12:12
1
\$\begingroup\$

Java 7, 1,083 bytes

For the byte-count I've only counted the expressions itself between the parenthesis. So I've excluded the System.out.printlns and class. Including those it would be 3,049 bytes.
PS: Not entirely sure if the int-cast for 72 is valid.. Although it does add 5 bytes anyway..

201&6
2-01%6
2%016
201%6
20-16
201%~6
2%01+6
2-01+6
2*01+6
2+01+6
~2+016
~2+016
2^016
20-1-6
2|016
20+1-6
2+016
2-~016
2+0+16
20-1%6
20|16
20+1%6
20*1|6
20|1|6
20+~1+6
20-1+6
20*1+6
20+1+6
2*016
20-~1-~6
-2*~016
20|~-16
(2+0)*16
20*~1^~6
-20*~1-6
20+~-16
20+16
20-~16
20-~-~16
-~2*~-016
20<<1%6
~-(-~2*016)
~2*-016
~20^-1<<6
~20*~1^6
~2*~016
20<<1|6
-20*~1-~6
~20*~1+6
~20*~1-~6
-20/~1*~-6
~2*~-~-~016
20|1<<~-6
-20*~-~1+~6
20*-~-~1-6
-20*~-~1-~-6
~-~2*-016
~20*~-~1-6
-20*~-~1^6
~(20/~1*6)
-20/~1*6
~2^(0-1)<<6
-2^(0-1)<<6
~20/~1*6
(2-01)<<6
(2+~0)|1<<6
2|01<<6
2-~0|1<<6
~-~2*~16
~20*~-~1+6
20/~1*~6
-~(20/~1*~6)
~-~(int)2.0*~-~16
-20<<-~1^~6
-20<<-~1^-6
~-~-~2*~016
~-20*(~1+6)
~-~20/~1*-~6
~-20<<-~1|6
~-(20*~(1-6))
20*(~1+6)
-~(20*~(1-6))
~-~-20|1<<6
~-20|1<<6
20|1<<6
-~20|1<<6
20<<-~1|6
20<<-~1|-~6
-~-~20*(~1+6)
~20*~-~-~1+~-6
~-~-20*-(1-6)
~20*~-~-~1-~6
~20*~-~-~1-~-~6
~2^~-~01<<~-6
-2^~-~01<<~-6
~-20*1*~-6
(2+01)<<~-6
-~(~2*~-~0*16)
~-~-(20*-(1-6))
~-(20*1*~-6)
20*-(1-6)

Ungolfed & test code:

Try it here.

class M{
  public static void main(String[]a){
    System.out.println(201&6);
    System.out.println(2-01%6);
    System.out.println(2%016);
    System.out.println(201%6);
    System.out.println(20-16);
    System.out.println(201%~6);
    System.out.println(2%01+6);
    System.out.println(2-01+6);
    System.out.println(2*01+6);
    System.out.println(2+01+6);
    System.out.println(~2+016);
    System.out.println(~2+016);
    System.out.println(2^016);
    System.out.println(20-1-6);
    System.out.println(2|016);
    System.out.println(20+1-6);
    System.out.println(2+016);
    System.out.println(2-~016);
    System.out.println(2+0+16);
    System.out.println(20-1%6);
    System.out.println(20|16);
    System.out.println(20+1%6);
    System.out.println(20*1|6);
    System.out.println(20|1|6);
    System.out.println(20+~1+6);
    System.out.println(20-1+6);
    System.out.println(20*1+6);
    System.out.println(20+1+6);
    System.out.println(2*016);
    System.out.println(20-~1-~6);
    System.out.println(-2*~016);
    System.out.println(20|~-16);
    System.out.println((2+0)*16);
    System.out.println(20*~1^~6);
    System.out.println(-20*~1-6);
    System.out.println(20+~-16);
    System.out.println(20+16);
    System.out.println(20-~16);
    System.out.println(20-~-~16);
    System.out.println(-~2*~-016);
    System.out.println(20<<1%6);
    System.out.println(~-(-~2*016));
    System.out.println(~2*-016);
    System.out.println(~20^-1<<6);
    System.out.println(~20*~1^6);
    System.out.println(~2*~016);
    System.out.println(20<<1|6);
    System.out.println(-20*~1-~6);
    System.out.println(~20*~1+6);
    System.out.println(~20*~1-~6);
    System.out.println(-20/~1*~-6);
    System.out.println(~2*~-~-~016);
    System.out.println(20|1<<~-6);
    System.out.println(-20*~-~1+~6);
    System.out.println(20*-~-~1-6);
    System.out.println(-20*~-~1-~-6);
    System.out.println(~-~2*-016);
    System.out.println(~20*~-~1-6);
    System.out.println(-20*~-~1^6);
    System.out.println(~(20/~1*6));
    System.out.println(-20/~1*6);
    System.out.println(~2^(0-1)<<6);
    System.out.println(-2^(0-1)<<6);
    System.out.println(~20/~1*6);
    System.out.println((2-01)<<6);
    System.out.println((2+~0)|1<<6);
    System.out.println(2|01<<6);
    System.out.println(2-~0|1<<6);
    System.out.println(~-~2*~16);
    System.out.println(~20*~-~1+6);
    System.out.println(20/~1*~6);
    System.out.println(-~(20/~1*~6));
    System.out.println(~-~(int)2.0*~-~16);
    System.out.println(-20<<-~1^~6);
    System.out.println(-20<<-~1^-6);
    System.out.println(~-~-~2*~016);
    System.out.println(~-20*(~1+6));
    System.out.println(~-~20/~1*-~6);
    System.out.println(~-20<<-~1|6);
    System.out.println(~-(20*~(1-6)));
    System.out.println(20*(~1+6));
    System.out.println(-~(20*~(1-6)));
    System.out.println(~-~-20|1<<6);
    System.out.println(~-20|1<<6);
    System.out.println(20|1<<6);
    System.out.println(-~20|1<<6);
    System.out.println(20<<-~1|6);
    System.out.println(20<<-~1|-~6);
    System.out.println(-~-~20*(~1+6));
    System.out.println(~20*~-~-~1+~-6);
    System.out.println(~-~-20*-(1-6));
    System.out.println(~20*~-~-~1-~6);
    System.out.println(~20*~-~-~1-~-~6);
    System.out.println(~2^~-~01<<~-6);
    System.out.println(-2^~-~01<<~-6);
    System.out.println(~-20*1*~-6);
    System.out.println((2+01)<<~-6);
    System.out.println(-~(~2*~-~0*16));
    System.out.println(~-~-(20*-(1-6)));
    System.out.println(~-(20*1*~-6));
    System.out.println(20*-(1-6));
  }
}
\$\endgroup\$

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.