Wolfram Blog
Christopher Carlson

The Winners of the 2018 One-Liner Competition

October 25, 2018 — Christopher Carlson, Senior User Interface Developer, User Interfaces

Images and machine learning were the dominant themes of submissions to the One-Liner Competition held at this year’s Wolfram Technology Conference. The competition challenges attendees to show us the most astounding things they can accomplish with 128 or fewer characters—less than one tweet—of Wolfram Language code. And astound us they did. Read on to see how.

Honorable Mention
David DeBrota: The Eyes Have It (127 characters)

David’s submission takes first place in the category of creepiness—and was timely, given the upcoming Halloween holiday. The judges were impressed by its visual impact:

c=Flatten@DeleteCases
&#10005

c=Flatten@DeleteCases[WebImageSearch["eye iris","Images",MaxItems->120],$Failed];ImageCollage[ConformImages[c[[1;;Length[c]]]]]

David had a character to spare with this submission, so he had no reason to shorten it. But he could have saved 20 characters by eliminating code that was left over from his exploration process. I’ll leave it as an exercise for the interested reader to figure out which characters those are.

Honorable Mention
Abby Brown: Flag Mosaic (128 characters)

Abby’s submission recreates an image by assembling low-resolution flag images. In order to squeak in at the 128-character limit, she cleverly uses UN flags. Over half of the code is grabbing the flag and dress images; the heart of the rendering work is a compact 60-character application of ImagePartition, Nearest and ImageAssemble:

f=ImageResize
&#10005

f=ImageResize[#,{4,4}]&/@CountryData["UN","Flag"];{i=Entity["Word", "dress"][image],ImageAssemble@Map[Nearest[f,#][[1]]&,ImagePartition[i,4],{2}]}

This One-Liner derives from an activity in Abby’s computational thinking group at Torrey Pines High School. You can download a notebook that describes the activity by clicking the Flag Macaw link on this page.

Dishonorable Honorable Mention
Pedro Fonseca: Average Precision of the ResNet-101 Trained on YFCC100m Geotagged Data (127 characters)

Take a second to consider what this One-Liner does: gets the list of 164,599 city entities in the Wolfram Language, searches the web for an image of each one, applies the ResNet neural network to each image to guess where it was taken and compares that location with the geotagging information in the image to see how precise the neural network’s prediction is. This may well be an honorable mention… but we’d have to wait 14 hours for the code to evaluate in order to find out:

Mean
&#10005

Mean[GeoDistance[NetModel["ResNet-101 Trained on YFCC100m Geotagged Data"]@WebImageSearch[#[[1]]][1,1],#]&/@EntityList["City"]]

Dishonorable Mention
David DeBrota: Find the Black Disk (128 characters)

I suspect David was fishing for a dishonorable mention with this submission that creates what one judge called “the cruelest game of Where’s Waldo ever invented.” Your task is to find the black disk among the randomly colored random polygons:

Graphics
&#10005

Graphics[{Table[{RandomColor[],Translate[RandomPolygon["Convex"],{i,j}+RandomReal[{-E,E},2]]},{i,99},{j,99}],Disk[{9E,9E},1/E]}]

Graphics output

What? You can’t find the disk?? Here’s the output again with the disk enlarged:

Graphics (disk enlarged)
&#10005

Graphics[{Table[{RandomColor[],Translate[RandomPolygon["Convex"],{i,j}+RandomReal[{-E,E},2]]},{i,99},{j,99}],Disk[{9E,9E},5/E]}]

Graphics (disk enlarged)

Note David’s extensive use of the one-letter E to save characters in numeric quantities.

Third Place
Abby Brown: Alphabet of Words (128 characters)

The uniqueness and creativity of this idea moved the judges to award third place to this One-Liner that makes a table of words that are pronounced like letters. It’s fun, and it opens the door to further explorations, such as finding words (like “season”) whose pronunciations begin with a letter name:

w = # -> WordData

w = # -> WordData[#, "PhoneticForm"] &; a = w /@ Alphabet[]; p =
 w /@ WordList[]; Grid@
 Table[{a[[n]], If[a[[n, 2]] === #[[2]], #, Nothing] & /@ p}, {n, 26}]

Like Abby’s Flag Mosaic submission, this One-Liner also derives from an activity in Abby’s computational thinking group at Torrey Pines High School. You can download a notebook that describes the activity by clicking the Alpha Words link on this page.

Second Place
Isaac Gelman: Computational Thinking: The Age Distribution 2018 Wolfram Technology Conference Dinner (69 characters)

This was one of the most timely and shortest One-Liners we’ve yet seen. It answers a question that arose just hours before the end of the competition.

Every Wolfram Technology Conference includes a conference dinner at which Stephen Wolfram hosts an “ask me anything” session. One of the questions at this year’s dinner was “What is the age and gender distribution of conference attendees?”

To answer the age part of that question, Isaac took photos of all of the tables at the dinner, used FacialFeatures to estimate the ages of the people in the photos and made a histogram of the result. We can’t vouch for the accuracy of the result, but it seems plausible:

FacialFeatures
&#10005

FacialFeatures["Age"]/@Values[Databin@"ytgvoXyH"]//Flatten//Histogram

Here are the first three photos in the Databin:

Take
&#10005

Take[Values[Databin@"ytgvoXyH"],3]

Congratulations, Isaac, on a brilliant demonstration of computational thinking with Wolfram technology.

First Place
Philip Maymin: Eliza in a Tweet (127 characters)

Our first-place winner encapsulated an homage to Joseph Weizenbaum’s natural language conversation program, ELIZA, in a single tweet. Philip’s Eliza often responds with off-the-wall phrases that make it seem either a few cards short of a full deck or deeply profound. But it was the judges’ first conversation with Eliza, which eerily references current world events, that clinched first place:

While
&#10005

While[StringQ[x=InputString@HELP],Echo@NestWhile[#<>y&,x<>"
",StringFreeQ[",.\"
",y=(e=NetModel)[e[][[-7]]][#,"RandomSample"]]&]]

Eliza

Weizenbaum was aghast that people suggested that ELIZA could substitute for human psychotherapists. The program could not and was never intended to heal patients with psychological illnesses. Philip’s Eliza, however, could well drive you crazy.


There were 14 submissions to this year’s competition, all of which you can see in this notebook. Thank you, participants, for showing us once again the power and economy of the Wolfram Language.

Leave a Comment

3 Comments


Barrie Stokes

Christopher

Thanks for this One-Liner report.

In my own code I strive for readability now and in the far future, when I’ve maybe forgotten what I was trying to do. Fully mnemonic variable names, avoidance of @@, /@, etc., and particularly the use of (s->function-of-s) with Map instead of (function-of-#)&.

I guess it’s unavoidable that, for the most part, One-Liners that do as much as these do within in the 128 character constraint often look like assembly code. Surely no other language could match Mathematica, though, in its compact expressiveness.

Decoding (!) some of these entries is a micro coding course, adding to the pleasure thay give by running them.

Congratulations to all the 2018 entrants and winners.

Barrie

Posted by Barrie Stokes    October 25, 2018 at 9:46 pm
Murray Eisenberg

Am I blind, or is this article on the one-liners missing a link to a notebook version (where one can readily try the code rather than have to type the whole thing in again from the posted image))

Posted by Murray Eisenberg    November 7, 2018 at 4:45 pm
    Wolfram Blog

    Hi Murray. At the end of the article, there is a link to the notebook that contains all 14 entries. It’s in the very last paragraph mentioning that there were 14 entries. Please let us know if you’re having trouble accessing it for some reason.

    Posted by Wolfram Blog    November 7, 2018 at 4:51 pm


Leave a comment

Loading...

Or continue as a guest (your comment will be held for moderation):