The 2016 Year Game

Our 2016 Year Game was launched in January 2016 and ran until the end of the year. The idea was simple – to find APL expressions involving exactly the digits 2 0 1 6 in that order to equal the numbers 0 to 100 using the fewest characters possible. The minimum number of characters for an expression is 5 (the four digits 2 0 1 6 and a single primitive function/operator) so the smallest number of characters that a possible solution can have is 505.

A lovely elegant solution was pointed out by Lars Stampe Villadsen:

      ⎕IO←0
      {⍪⍳+/⍵*⌽⍵}2 0 1 6

and Bernard Legrand submitted two one-line solutions:

      (⍴⍬),⍳¯20+!1-⍨6

and

      (⍴⍬),⍳⍴'Be happy: this solution to Game 2016 will be the most stupid one, but it needs only five APL symbols'

These three each return all the numbers from 0 to 100. Not valid submissions for this particular game, but I did find them rather pleasing. Anthony Cipriano was inspired to go one step further and submitted an expression that creates the first 8 Fibonacci numbers:

      (⊢,(+/{(¯2∘↑)⍵}))/(⊂0 1),⍨⍳6

The wonderfully varied ways in which APL can be used (and in which APL users think!) was illustrated beautifully by some of the solutions. Although some numbers were attained in the same way by everyone (36, for example, was always 20+16), others lent themselves to multiple solutions. No-one managed to calculate 100 in fewer than 7 characters, but the 7-character answers included 20∧⌹.16, 20ׯ1+6, -20×1-6, 20×-1-6, ¯20×1-6 and various others on the same theme. Unity experienced similar creativity, with 1 being reached in the minimum possible number of characters (5) using ×2016, 201≢6, 20>16, 20≠16, 2<016, etc.

It was clear early on that submissions fell into two distinct groups – those who wrote a program to find the expressions and those who derived their expressions manually. I found the creativity evident in the manually-derived solutions very satisfying; the results may not have been as terse as those resulting from programs, but the individuality of the creators shows people inspired by their subject matter. Who can fail to appreciate the thought process behind arriving at 96 using (×/+\+\(!2 0 1))+6 rather than the more prosaic ⌈⍟!20+16 or ⎕IO-⍨+⍨20+16 rather than 20+⌈○16 for 71?

Having said that, the goal was conciseness and individual character counts are now tabulated on the 2016 Year Game page; an amalgamation of the lowest-character expressions that anyone achieved can also be downloaded from this page. Congratulations to Jonas Stensiö and Veli-Matti Jantunen, who both achieved the same character count as the amalgamated minimum (693).

(most names omitted to protect the not-so-innocent)

What’s Your Favourite Beautiful Squiggle?

Roger’s post speculating on Ken Iverson’s favourite APL expression reminded me that one of the delegates at Dyalog ’14 conducted a quick survey to find the most popular primitive (thanks to Alex Weiner for taking the initiative here!). His findings are reproduced below:

9 votes:
8 votes:
6 votes:
4 votes: ⍠ ⍟ * ⎕
3 votes: ⌽ ¨ ⍎
2 votes: ⍺ ∇ ≢ ← ⊃ ⊢ ⍬
1 vote: ⍉ , ∊ ⍋ ∘ ∧ ⍲ ⊥ ⌈

Unfortunately there were no reasons given…is it because it’s a shape that’s pleasing to the eye, a really nifty piece of functionality or something more esoteric?

As for me, it’s easy – my favourite is the Log glyph (). Not for a technical reason, although it performs a very useful function, nor due to its rather pleasing visual symmetry, but rather because of the way I was introduced to it. An APL virgin when I joined Dyalog 20 months ago, my first exercise was to familiarise myself with APL’s “beautiful squiggles”. When it came to the Log glyph I asked one of my colleagues a question and they dictated a line of APL to me to experiment with. As soon as they referred to by its informal name of “splat” that was it, I was entranced. Any language that is so powerful, so concise and yet can make adults have passionate discussions involving the word “splat” has got me for life.