The North Pole is a desolate desert of snow in the winter. Even the last polar bear I saw was heading away from here. The creature was looking for food or warmth, and this was neither the place nor the time for those comforts. I alone headed north on my sleigh when there was not much more "north" left. Unlike the few animals that I had passed on my way, I was traveling for a job interview. I was to become...

Santa’s Little Coder

Santa's Little Coder is an interactive coding exercise primarily for Lynx Analytics R&D applicants. Do not let that stop you, though, even if you have no intention of applying!

You can solve the exercises in JavaScript in the browser. Or you can solve them with whatever technology you prefer and then simply return the solution from the JavaScript function. In this case it would be nice of you to describe your solution in a comment above the return statement.

If you don't like the snow, check out our other hiring exercise, Galactic Recursion.

Imagine my surprise when I found sleigh-tracks in the snow! How could someone have beaten me to this desperate interview? But soon my anger was washed away by the realization: the tracks were mine. I had not noticed when I turned around. I was lost.

I had to find my way before a hungry polar bear found mine. All I had to go by were my temperature readings. I had kept meticulous records for an arctic biologist friend at home. Now the data would help me to find the way if only I could figure out where I made the lowest measurement.

Thankfully my pocket computer still worked, even when my fingers were about to freeze. I had one measurement of −44 °C. That is uncharacteristically cold even for this time of the year. I knew it had to be due to the proximity of my prospective employer.

I backtracked to the icy cliffs where I made the particular measurement and took a closer look. I saw the faint impression of a sign inside the wall of bluish ice.

Please use keypad on your right.

The code is ....

The workshop being understaffed as it was, I was not surprised that the frost had damaged the sign beyond recognition. Thankfully I was told of this keycode before starting on my journey, and I have an almost holographic memory. I remembered that the four digits were all different and in an increasing order. What else...? Oh right! The product of the first two was the same as the sum of the last two.

The first number did not work. I rubbed my fingers together to force a little life back into them. The second number was also rejected. Despair was closing in on me. The last sequence was finally accepted with a beep and a boop. I let out a great sigh and watched as the ice transmaterialized in front of me, and a circular portal opened on the vertical surface.

On the other side I was welcomed by a curious creature. A furry humanoid shape stood before me, its head covered in infinitely branching antlers and a glowing orb in place of its nose. "Came to see Santa about the job, correct? She will be with you in a moment."

"Oh? I thought Santa was a man," I said in surprise.

"Santa a human? Yeah, right," the vile creature laughed. "You think a human could survive drinking that much milk and eating that many cookies in one night? No, she is a Hyperborean. Her kind evolved in a universe with extremely dangerous predators. The only way to safety was to become more-dimensional than their enemies. An arms race developed, and now... Here we are. Check this out!"

The creature showed me a cube made out of ice cream sticks. It looked normal enough in the dim light of Santa's workshop, but I quickly realized there was something odd about it. While I had seen cubes constructed of 12 ice cream sticks, I had never before seen one made of 1,811,939,328 sticks. How could this be? What grand dimension had I entered through the swirling portal?

By the time I had finished my calculation, Santa herself arrived. She appeared to be a restless tinkerer. Many of her numerous limbs held a half-finished game or toy, and she kept working on them as she led me to a conference room. In particular the sounds from a music box she was winding up struck my ears. I wanted to impress her with a clever remark, like the interview tips I had read online recommended.

I realized what made the melody of the music box particular was that it was composed for an unusual scale. While all the music I had ever heard was composed with a scale that split the octave into 12 semitones, the same was not true of the melody I listened to as we entered a small room with two comfortable chairs. The scale used for this music still split the octave into equal intervals, but was better able to represent perfect fifths and major thirds. I assumed this was the smallest such scale, and tried to calculate its size.

"Is that a 41-tone equal tempered scale?" I asked casually as we seated ourselves. Santa did not respond, but I thought I glimpsed an appreciative smile behind her brilliant white beard.

The room also had a lit fireplace for which I was terribly grateful. The warmth of the fire seeped into my frosty limbs and reinvigorated my mind as well. The interview was off to a good start, I felt. I talked at length about my past experiences as a graph analyst for a large Kabbalah firm.

Then, as I knew the interview was close to its end, Santa set forth a technical question. "The diameter of a graph is the maximum of the shortest distances between its points," she begun. "The chimneys of the world form a multi-dimensional graph that is of central importance for our logistics operations. Since I have to descend through these dark passageways, the diameter is a noteworthy metric. Please write a program for calculating the diameter of a directed graph."

"Ho ho ho," Santa remarked. She was satisfied with my code. So satisfied, in fact, that I was offered a job on the spot.

The economic downturn had not spared the trade of numerological analysts. I had been living on nothing but raw fish for weeks at that point. Of course I would say yes! But, to preserve a modicum of dignity, I asked for a minute to think by myself. Honestly, I just wanted to text my mother with the good news. But as I turned on my phone, my attention was drawn to an email that had just arrived.

A temperate climate. A three-dimensional environment. Human coworkers.

If these sound attractive to you, drop by for a job interview at Lynx Analytics R&D in Hungary! Please leave your contact information, and we will get in touch with you soon.

Failed to submit this form. Please try again or email us! The error was:

Thank you!