Wolfram Blog
Christopher Carlson

The Winners of the 2020 One-Liner Competition

October 20, 2020 — Christopher Carlson, Senior User Interface Developer, User Interfaces

Although this year’s Wolfram Technology Conference was virtual, that didn’t stop us from running the ninth annual One-Liner Competition, where attendees vie to produce the most amazing results they can with 128 or fewer characters of Wolfram Language code. Here are the winners, including an audio game, a hands-free 3D viewer and code that makes up countries.

Honorable Mention

Catalin Popescu: Untitled (128 characters)

ImageAssemble
&#10005

ImageAssemble[Map[Nearest[Quiet@EntityValue["FoodType", "Image"], #][[1]] &, ImagePartition[CloudGet[URLShorten[$Failed]], 4], {2}], "Fill"]

Catalin’s entry grabs an image of face anatomy that shows the muscle structure and renders it using images of foods—a visual interpretation of “you are what you eat”:

The judges liked the idea and result, but were not able to get the submission code to produce a result without tweaking it. What you see above is a tweaked output, probably lower resolution than the original submission.

Zooming in on the subimage below the left ear shows the low-resolution images of carrots, fish and other foods that make up the composite image:

Catalin’s submission is a great demonstration of the diverse data resources available in the Wolfram Language and how they can be combined to produce novel results.

Third Place

Philip Maymin: Repeat After Me (123 characters)

ListLinePlot
&#10005

ListLinePlot[Echo@AudioDistance[EmitSound@#; #, AudioCapture[]] & /@ WebAudioSearch["quote", "Samples", #Duration < 5 &], Axes -> False]

Philip’s audio game gathers short audio samples of quotes, then plays each one for you in turn and waits for you record yourself trying to reproduce the quote as accurately as possible (click one of the audio recorder images below to play the corresponding quote):




After each recording, the code uses Echo to print a measure of how closely you’ve reproduced the audio clip (the lower the better), and after the last of 10 clips, it gives a graph of your performance:

The judges commended the smooth interface, the novel idea and that it’s just plain fun. That the quotes included several from Homer Simpson clinched the third-place award.

Web search, audio processing, textual feedback, plotting: that’s a lot of functionality for 123 characters of code.

Second Place

Michael Sollami: Peter-Panning (Hands-Free Parallax) (126 characters)

c = {0, 0};Graphics3D
&#10005

c = {0, 0};
Graphics3D[{Hue@.4, 3~MengerMesh~3}, ViewPoint ->
  Dynamic@
   Join[c += Total[ImageDisplacements@CurrentImage@2, 3]; {-3}, c/9!]]

This entry really wowed the judges. Michael’s submission turns your camera into a hands-free controller for viewing 3D scenes. With a 3D Menger sponge on the screen, moving your head to the right causes the sponge to rotate left so you see its right side, as you would if you had an actual 3D object in front of you. Moving in any direction lets you see that side of the sponge, giving a natural and intuitive viewing experience.

Here’s an animation of what I see on the screen and how it moves as I move my head:

Michael’s code monitors the camera image inside a Dynamic, using ImageDisplacements to detect your head’s motion. He slips in just under the 128-character limit by skillful use of prefix and infix operators and by cleverly using Factorial to express a 6-digit scaling factor with just two characters (9!).

The judges found Michael’s choice of the MengerMesh particularly appropriate to demonstrate the concept.

First Place

Daniel Martin: Untitled (128 characters)

a = CountryData; "Name"
&#10005

a = CountryData;
"Name"[#~StringJoin@*StringTake~UpTo@5 &] "Flag"[#[[1]]~
     ImageCompose~{#[[2]], .5} &] /.
 x_@y_ :> y[#~a~x & /@ a[]~RandomChoice~2]

Daniel’s first-place entry makes up country names and flags to go along with them. Each time you evaluate the code, you get a new invented country. One of the judges found it so compelling that we lost him for a while to repeatedly hitting Shift+Return.

Here’s a grid of sample outputs:

alt

The judges liked the original idea and had fun exploring the results.

Daniel’s code, which butts right up against the 128-character limit, is a lesson in how to save characters by taking advantage of the Wolfram Language’s rich syntactic variants.


As always, there were many more great submissions than could be awarded prizes. You can see them all in this notebook.

Get full access to the latest Wolfram Language functionality with a Mathematica or Wolfram|One trial.

Leave a Comment

No Comments




Leave a comment