A story for the collatz conjecture exercise

This appears to be one of the popular exercises. The current description can be found here. Over the past few days, I’ve been thinking it might be interesting to rephrase the plain instructions as a story — one designed to capture the reader’s attention by emphasizing the open-ended mystery of the conjecture. Here’s the result:

Introduction

One evening, you stumbled upon an old notebook filled with cryptic scribbles, as though someone had been obsessively chasing an idea. On one page, a single question stood out: Can every number find its way to 1? It was tied to something called the Collatz Conjecture, a puzzle that has baffled thinkers for decades.

The rules were deceptively simple. Pick any positive integer:

  • If it’s even, divide it by 2.
  • If it’s odd, multiply it by 3 and add 1.

Then, repeat these steps with the result, continuing indefinitely.

Curious, you picked number 12 to test and began the journey:

12 ➜ 6 ➜ 3 ➜ 10 ➜ 5 ➜ 16 ➜ 8 ➜ 4 ➜ 2 ➜ 1

Counting from the second number (6), it took 9 steps to reach 1, and each time the rules repeated, the number kept changing. At first, the sequence seemed unpredictable — jumping up, down, and all over. Yet, the conjecture claims that no matter the starting number, we’ll always end at 1.

It was fascinating, but also puzzling. Why does this always seem to work? Could there be a number where the process breaks down, looping forever or escaping into infinity? The notebook suggested solving this could reveal something profound — and with it, fame, fortune, and a place in history awaited whoever could unlock its secrets.

Instructions

Given a positive integer, return the number of steps it takes to reach 1 according to the rules of the Collatz Conjecture.

4 Likes

I really like this!

1 Like

It’s a nice starting point, but I think it plays a bit loosely with the actual task, as in it’s not super clear what you’re supposed to do from the story.

1 Like

:thinking:

True. But this is an older exercise that doesn’t separate the story from the instructions. Perhaps we should make an instructions.md file for the specifics? Like this one for Two-Fer, or this one for Saddle-Points?

1 Like

Sure, if @tasx is up for the task, I don’t see anything wrong with that.

What I meant was that I’d like to see the story hint/refer to the task a little bit more concretely.

Unfortunately I don’t think I have time for revisions now, so I’ll probably pay more attention late.

I’m aware of this issue and am already working on fixing it.

Edited my original post with an updated version.

1 Like

Look great! Could also add a funny warning to advice people not to try and prove this in case it drives them to madness :laughing:

2 Likes

<joke> Oh, why discourage anyone? It only took 538 years to prove Fermat’s Last Therom! This one could be easy-peasy.</joke> :wink:

3 Likes

The most dangerous equation? Yeah, there are people dying to try to solve this.

1 Like

That’s great, exactly what we want. The current reward for anyone proving the conjecture is approximately 1 million dollars.

2 Likes

That is something that should be mentioned in the exercise text. Marvellous.

2 Likes

Great idea. Here’s one way we can go about it:


One evening, you stumbled upon an old notebook filled with cryptic scribbles, as though someone had been obsessively chasing an idea. On one page, a single question stood out: Can every number find its way to 1?

It was tied to something called the Collatz Conjecture, a puzzle that has baffled thinkers for decades. The notebook hinted at something extraordinary. Solving this puzzle wouldn’t just answer a question about numbers; it could bring fame, fortune, and breakthroughs in science, securing your place in history.

You could link to Collatz conjecture Prize 120 million JPY | MathPrize and be more explicit that there’s a large cash reward ( 120,000,000 JPY) for solving it! (About $780,000 USD)

2 Likes

TIL that Collatz is not a Millennium Prize Problem. I thought it was!

Indeed, it’s not. The first reference from Bethany’s link discusses the history behind the selection of the Millennium Prize Problems.

About $780,000 USD in 2024

From the external link

(*) 120 million Japanese yen is about US$1,085,000 (1US$=JPY110.50 as of June 29, 2021).

Holy cow the yen has dropped off quite a bit :eyes:

also should mention if they can solve it then they can have exercism’s eternal insider status for FREE!

1 Like

Consider adding the approach of mushroom picking ! :mushroom: :ok_hand:

You are disturbing me. I am picking mushrooms ~ Grigori Perelman

1 Like

Edited my first post with the final draft. I tried to incorporate suggestions as best as I could.