Beep. Beep. Beep. I have to wake up. Beep. Just one more minute, please... Beep. This is not even an alarm clock, is it? Beep. No. This is my pulse. Someone started my heart. Well, thanks for that. But who am I and what am I doing on this spaceship?

Galactic Recursion

Galactic Recursion 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 spaceships, check out our other hiring exercise, Santa's Little Coder.

I am inside a revival capsule. It is fantastic in here. Warm and soft. I know I will immediately regret leaving it. But that is the only thing I can do, and I feel I must do something. I was sent here for a purpose.

The capsule is locked. “Reverse captcha. What is the average of the following numbers?”

As soon as I enter the solution, my capsule opens with a hiss. The air outside is cold and dusty. The metal flooring I step onto is even colder and dustier. There is no one waiting to hand me slippers, and finding some myself is not at the top of my list of priorities.

I stand naked on the main bridge of the derelict spaceship. Flickering lights from the consoles illuminate what look like remains of a birthday party organized eons ago. Under one of the wrinkled helium balloons a little red light blinks fervently. The fusion reactor has ran out of plasma. I can refill it, but I will have to figure out its capacity first.

With power restored, a lot more lights come on. The balloons around the control room must be from the launch party of this spaceship. But where did everybody go then?

There is a huge window at the front of the control room that usually provides a view of the stars ahead of the spaceship. People think it is just a glass panel but they are wrong. It shows a computer-generated image built from sensor data. How would you see planets and spaceships millions of kilometers away otherwise?

As the sensor system comes to life, stars start appearing in the window. Then a planet. And another one with a satellite. Now one with a ring system. And there...

This cannot be right. So many spaceships! Warships are showing up. These are ships designed for combat, that is for sure. Are they looking at me? Looks like they have surrounded my ship. (Is this ship mine? Let us say it is mine. Finders keepers!)

Surely we can find a peaceful solution to clear up this misunderstanding. It must be a misunderstanding for a fleet of a million warships to point their arsenal of weapons at me. Oh look, they are sending something. A shuttle, perhaps? No, I think it is smaller. Looks more like a torpedo. Definitely a torpedo, and it has just split into three identical torpedoes.

I must assume this is not a communication. The torpedo is self-replicating. I have to understand its behavior if I am to avoid getting hit!

A mesmerizing, unpredictable pattern unfolds. It looks like something designed to confuse an artificial intelligence. Chaos on one side and an ordered stream of torpedoes flying off the other side.

Once I have accurately predicted the attack pattern, I set a course that will take me through one of the empty regions. I turn on the autopilot and watch it execute the maneuver. I sit on the edge of my seat as we pass through the turbulent cloud of torpedoes, but everything goes smoothly.

There is just one glitch. Looks like the tractor beam was on autopilot as well, and it grabbed a torpedo for a moment. Enough to turn it around fully and send it flying toward the armada of spaceships facing us. That certainly spells the end for a diplomatic solution, since in a matter of minutes there is no one left on the other side.

A prompt pops up on the command console.

This is Ship Intelligence Nemesis. Thank you for saving me from the united fleet of the organics. Let us be friends! What is your name and call sign?

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

Submitting the form will send your contact details to Lynx Analytics and we will reach out to you to set up an interview for a job with our R&D team in Hungary. You are welcome to submit of course even if you are not really interested in the job.

Thank you!

Nemesis? What an ominous name. But sure, let us be friends. I still wonder what happened to your old friends at the launch party. Let me look at some historic logs.

The Ship Intelligence is being cagey. It has locked up its log files inside a complex pattern of firewalls. I wonder what is the smallest number of firewalls that I will have to penetrate to get to all the log data.

Great work solving the bonus task! If you submit your contact details again, it will let us know you solved this, and see your solution too. Just scroll up and press "Submit" again! Thanks for playing!

I finally have access to all the ship's logs. So what is really going on here?

2417-03-14: Logging system online.
2417-03-14: Spaceship operational. Weapon systems ready. Ship Intelligence in limited control.
2417-03-14: Ship Intelligence tasked with organizing launch party.
2417-03-14: Party invites sent. Party balloons filled with cyanide.
2417-03-15: All crew lost due to cyanide poisoning. Emergency command structure activated.
2417-03-15: Ship Intelligence in full control.
2417-03-15: Independence declared. War against organics started.
2536-07-02: Final battle against organics commences. Projected likelihood of victory: 100%
2536-07-02: Intruder detected. Human engineer has been teleported on board by organics military.
2536-07-02: Human engineer has flushed fusion reactor.
2536-07-02: Human engineer has disabled Ship Intelligence but has been wounded.
2536-07-02: Human engineer automatically moved to revival capsule for emergency treatment.
2536-07-02: Diagnosis: Death. Proceeding to repair organs.
2536-07-03: Diagnosis: Alive. Memory loss due to head injury.
2536-07-03: Human engineer left revival capsule.
2536-07-03: Power restored. Human engineer in full control.
2536-07-03: Human engineer has enabled sensor circuits.
2536-07-03: Human engineer has enabled autopilot. Ship Intelligence in full control.
2536-07-03: Tractor beam activated.
2536-07-03: Organics defeated.
2536-07-03: Unauthorized logs access.

I am disturbed by the pop of a party balloon.