Wolfram Blog
Christopher Carlson

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

February 26, 2019 — Christopher Carlson, Senior User Interface Developer, User Interfaces

This post discusses new Wolfram Language features from the upcoming release of Version 12. Copyable input expressions and a downloadable notebook will be available when Version 12 is released.

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