Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reframe collatz-conjecture exercise instructions as a story #2508

Merged
merged 6 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
Loading