Skip to content

Commit

Permalink
Reframe collatz-conjecture exercise instructions as a story (#2508)
Browse files Browse the repository at this point in the history
* split into introduction and instructions

* update metadata

* make instructions more clear

* incorporate forum suggestions

* fix lint errors

* Apply suggestions from code review

Co-authored-by: Isaac Good <IsaacG@users.noreply.github.com>

---------

Co-authored-by: Isaac Good <IsaacG@users.noreply.github.com>
  • Loading branch information
tasxatzial and IsaacG authored Dec 10, 2024
1 parent d11557d commit 2d26738
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 31 deletions.
29 changes: 0 additions & 29 deletions exercises/collatz-conjecture/description.md

This file was deleted.

3 changes: 3 additions & 0 deletions exercises/collatz-conjecture/instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Instructions

Given a positive integer, return the number of steps it takes to reach 1 according to the rules of the Collatz Conjecture.
28 changes: 28 additions & 0 deletions exercises/collatz-conjecture/introduction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# 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][collatz-prize], and a place in history awaits whoever could unlock its secrets.

[collatz-prize]: https://mathprize.net/posts/collatz-conjecture/
4 changes: 2 additions & 2 deletions exercises/collatz-conjecture/metadata.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
title = "Collatz Conjecture"
blurb = "Calculate the number of steps to reach 1 using the Collatz conjecture."
source = "An unsolved problem in mathematics named after mathematician Lothar Collatz"
source_url = "https://en.wikipedia.org/wiki/3x_%2B_1_problem"
source = "Wikipedia"
source_url = "https://en.wikipedia.org/wiki/Collatz_conjecture"

0 comments on commit 2d26738

Please sign in to comment.