The Winners of the 2018 One-Liner Competition
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[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[#,{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[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[{Table[{RandomColor[],Translate[RandomPolygon["Convex"],{i,j}+RandomReal[{-E,E},2]]},{i,99},{j,99}],Disk[{9E,9E},1/E]}] |
What? You can’t find the disk?? Here’s the output again with the disk enlarged:
✕
Graphics[{Table[{RandomColor[],Translate[RandomPolygon["Convex"],{i,j}+RandomReal[{-E,E},2]]},{i,99},{j,99}],Disk[{9E,9E},5/E]}] |
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[#, "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["Age"]/@Values[Databin@"ytgvoXyH"]//Flatten//Histogram |
Here are the first three photos in the Databin:
✕
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[StringQ[x=InputString@HELP],Echo@NestWhile[#<>y&,x<>" ",StringFreeQ[",.\" ",y=(e=NetModel)[e[][[-7]]][#,"RandomSample"]]&]] |
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.
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
I thought it would be fun to run #14 myself, but it seems I would need to purchase some credits. How many would I need if I decide to go through with it?
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))
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.