Wolfram Computation Meets Knowledge

Computing in 128 Characters: Winners of the 2018 Wolfram Employees One-Liner Competition

Every year at the Wolfram Technology Conference, attendees take part in the One-Liner Competition, a contest to see who can do the most astounding things with 128 characters of Wolfram Language code. Wolfram employees are not allowed to compete out of fairness to our conference visitors, but nevertheless every year I get submissions and requests to submit from my colleagues that I have to reject. To provide an outlet for their eagerness to show how cool the software is that they develop, this year we organized the first internal One-Liner Competition.

Abstract Art

We awarded first-, second- and third-place prizes as well as six honorable mentions and one dishonorable mention. And the winners are…

Honorable Mention

Danny Finn, Consultant

ImageGuessr (Wolfram Pictionary) (128 characters)

Danny’s submission is a complete game in 128 characters. Some of the judges found it so compelling that they went on playing after the judging session ended.

The code picks a random word and assembles a collage of images found on the web by searching for that word. Then it puts up a dialog with the collage and an input field for the player to guess what the word is. When the player enters a word, it correlates the semantic features of the guess with the semantic features of the word. The higher the correlation, the closer the guess in meaning to the original word. That’s a lot of functionality in one tweet of code!

{w=RandomWord
&#10005

{w=RandomWord[],g=ToString@Input@ImageCollage@WebImageSearch[w,"Images"],Dot@@@FeatureExtract[{{w,g}},"WordVectors"][[;;,;;,1]]}

erase

{"expunge", "erase", {8.53923}}

Honorable Mention

Danny Finn, Consultant

Notebook Pox (123 characters)

Danny earned a second honorable mention for code that gives your notebook a case of the pox. He probably would have earned a dishonorable mention had he not also provided the cure (see the second input in this section).

Danny could have saved seven characters by eliminating the unnecessary System` that precedes BackgroundAppearance, probably a leftover from some sort of experimentation.

SetOptions
&#10005

SetOptions[EvaluationNotebook[],System`BackgroundAppearance->Rasterize@Graphics[{Red,Disk[#,0.01]&/@RandomReal[1,{99,2}]}]]

Notebook Pox

SetOptions
&#10005

SetOptions[EvaluationNotebook[],System`BackgroundAppearance->None]

Honorable Mention

Sarah Stanley, Principal Consultant

Rainforest Winter (126 characters)

Sarah’s submission combines image search and an image-transforming neural network in a novel way to show what the rainforest would look like if it snowed. The ListAnimate output shows a selection of winterized rainforest images.

ResourceObject
&#10005

ResourceObject[a="CycleGAN Summer-to-Winter Translation"];ListAnimate[ NetModel[a][#]&/@WebImageSearch["rainforest","Images"]]

Honorable Mention

Sarah Stanley, Principal Consultant

Changing Tigers’ Stripes (128 characters)

Like Danny, Sarah also earned a second honorable mention, for an image search and neural network combination that removes tigers’ stripes. The ResourceObject that the code retrieves is the CycleGAN Zebra-to-Horse Translation Trained on ImageNet Competition Data neural network, a name that would have chewed up 72 of her 128 characters had her code not instead used the more compact numeric identifier. While the original network was trained to convert zebras to horses, Sarah applied it to a new domain, white tigers, to interesting effect.

ResourceObject
&#10005

ResourceObject[a="4b148040-10cd-43e2-8152-1a31c675cec3"];{#,  NetModel[a]@#}&/@WebImageSearch["white tiger","Images"]//TableForm

Changing Tigers’ Stripes

Honorable Mention

Brian Wood, Lead Technical Marketing Writer

A Little Fun with Motion (117 characters)

Brian’s submission does video effects on the fly with a compact piece of image-processing code that creates color trails as an object moves. When an object is stationary, the superimposed color trails sum to faithfully recreate the original image.

Manipulate
&#10005

Manipulate[With[{c:=CurrentImage[],p:=Pause[t]},ImageAdd[(p;ImageMultiply[c,#])&/@{Red,Green,Blue}]],{t,.05,.15,.01}]

A Little Fun with Motion

Honorable Mention

Daniel Carvalho, International Business Development Executive

Wave (93 characters)

After knotting their brains trying to understand some of the more complex submissions, the judges found Daniel’s meditative, gently rolling wave a soothing balm.

Animate
&#10005

Animate[Plot3D[Sin[f+x]Cos[f+y],{x,0,2Pi},{y,0,2Pi},ColorFunction->"DeepSeaColors"],{f,0,Pi}]

Wave

Dishonorable Mention

Jon McLoone, Director, Technical Communication and Strategy

Surprisingly Short Minesweeper Code (47 characters?)

Jon’s Minesweeper submission was a first: an entry that hacked the submission notebook to subvert its character-counting code. It serves as a brilliant example of why you get that annoying Enable Dynamics button when you open a Wolfram Notebook that contains dynamic code:

Enable Dynamics

When you open Jon’s submission, you see 2,000-some characters of code for a functional Minesweeper game that begins like this:

DynamicModule[{
&#10005

DynamicModule[{$GameTime = 0, $Time, data = {{}}, display = {}, 
  neighbours, $GameState = "Start", $GameData, h = 9, w = 9, n = 10, 
  bombchar =

In spite of the huge submission, the character counter at the top shows that his submission is just 47 characters long:

Submission

A note that accompanied Jon’s submission reads, “Surprisingly short Minesweeper code. It may look longer but scores only 47 characters. Go on check! And, I promise, I haven’t changed the submission template, you can copy the code into a fresh OneLiner template and see.”

So how did he do it? He indeed hadn’t changed the source code embedded in the submission notebook, but he did redefine some of the functions that that code defines. You can see how when you use Cell > Show Expression on the cell that contains his code.

The first "0" in the code is wrapped with a DynamicWrapperBox that gives the submission notebook’s character-counting functions new definitions. Instead of counting the characters in the submission, the new definitions count the characters in the string “Surely deserving of a dishounourable [sic] mention!!!” (47 characters):

RowBox
&#10005

RowBox[{"$GameTime","=",InterpretationBox[DynamicWrapperBox["0",Quiet[Clear[$CellContext`BoxesToTweetString,$CellContext`UntweetableBoxTypes];$CellContext`UntweetableBoxTypes[BlankNullSequence[]]={};$CellContext`BoxesToTweetString[BlankNullSequence[]]:="Surely deserving of a dishounourable mention!!!";
Protect[$CellContext`UntweetableBoxTypes,$CellContext`BoxesToTweetString]] ],0]}]

The first time Jon’s submission is scrolled onscreen, the DynamicWrapperBox code activates and hacks the submission notebook. Indeed deserving of a dishonorable mention, Jon!

Third Place

Jofre Espigule-Pons, Consultant

Endangered Species (122 characters)

The best submissions combine Wolfram Language components in ways that produce beautiful, useful and surprising results. Jofre’s submission meets all three criteria. It finds the intersection of the class of mammals with the class of endangered species (i.e. the class of endangered mammals), gets an image of each one and assembles the images into a collage—a graphic reminder of the biological wealth we are in danger of losing.

ImageCollage
&#10005

ImageCollage[#["Image"]&/@(EntityClass[s="Species","Mammal"<>s][e="Entities"]⋂endangered species species specifications[e]),Method->"Columns"]

Second Place

Lou D’Andria, Senior User Interface Developer

Wolfram Celebrities (123 characters)

We had a lot of fun with Lou’s submission that scrapes employee images from our company directory and uses Classify to find the notable person that they most resemble.

Labeled
&#10005

Labeled[#,Classify["NotablePerson",#]]&/@Import["https://abcd.wolfram.com/efghi/jilmnopqr/stuvwx/images",{"HTML","Images"}]

A surprisingly large number of people in the company were identified as “Stephen Wolfram” (including Stephen himself). Hmm…

Stephen Wolfram lookalikes

First Place

Jon McLoone, Director, Technical Communication and Strategy

Evolving Abstract Art (68 characters)

The same colleague who earned this competition’s dishonorable mention also took first place. The elegance and concision of Jon McLoone’s 68-character submission won over the judges with its high ratio of graphical impact to code length. It’s both animated and graphically engaging, and keeps you watching to see how the image will evolve:

i=RandomImage
&#10005

i=RandomImage[1,300,ColorSpace->"RGB"];
Dynamic[i=ImageRestyle[i,i]]

Abstract Art

Jon took advantage of the complexity-compounding effect of repetition to create code that delivers far more than its small character count promises. Congratulations, Jon!


There were many more great entries—34 total—that you can see by downloading this notebook. To all who participated: thanks for showing us once again the power of the Wolfram Language.

Get a Mathematica service plan to be the first to receive an upgrade for the upcoming release of Version 12 of the Wolfram Language.

Buy now!

Comments

Join the discussion

!Please enter your comment (at least 5 characters).

!Please enter your name.

!Please enter a valid email address.

11 comments

  1. The winner’s code seems to require a version newer than 11.3 which crashes on that code.

    Reply
  2. Great post.Will there be a notebook? I tried Jon’s winning entry and got just an $Aborted. How do I fix this?

    Reply
    • Hi Tom:

      I commend you on noticing that they both used the RandomImage function. However, with Jon’s code being so concise (just 68 characters) vs the 120+ in the code from 2016, it’s hard to not acknowledge that level of precision! Great eye though for noticing the similarities!

      Reply
  3. The use of RandomImage is not what matters, but rather the idea of using a Dynamic image that updates itself with a neural network – that was the borrowed idea.

    Reply
    • Yes, there are certainly similarities. But I’m not so sure I would say the idea was borrowed. They’re both very interesting.

      Reply
      • Well that’s embarrassing! It certainly wasn’t in my mind when I wrote my entry and I have no recollection of that past entry, though I would have looked at the blog at the time – I wasn’t at the technology conference that year.

        In my defense, if you look at what they are trying to achieve, that is quite different, even if that code structure is rather similar. Dynamic[i=fn[i]] is a pretty standard trick to make a refreshing notebook element, that neither of us can take much credit for. But Michael Sollami is using the network as his fn to inject randomness by using NetInitialize to create, effectively, a random image filter each time. It is really a structured random walk through image space. What I was trying to do was to use a fixed network to iterate towards a fixed point of i==fn[i] in a similar way to my blog from 2010: https://blog.wolfram.com/2010/09/07/self-description/
        I had in mind “can we extract the essential pattern from the randomness by refining the image to its key features”. If you set the image size to 256, it does do that, but it turned out to be much more boring to watch than the constant zooming effect you get from using a 300px image. so I submitted that instead.

        Reply