In case you missed the announcement: Alteryx One is here, and so is the Spring Release! Learn more about these new and exciting releases here!
Free Trial

Weekly Challenges

Solve the challenge, share your solution and summit the ranks of our Community!

Also available in | Français | Português | Español | 日本語
IDEAS WANTED

Want to get involved? We're always looking for ideas and content for Weekly Challenges.

SUBMIT YOUR IDEA

Challenge #475: The Collatz Conjecture

AYXAcademy
Alteryx
Alteryx

Full Width - WC banner.svg

Hi Community members,

 

A solution to last week’s challenge can be found here

 

This challenge for the mathematicians at heart was submitted by Ippei Nakagawa (@gawa). Thank you, Ippei, for this challenge!

 

The Collatz conjecture, also known as the 3n + 1 problem, is a conjecture in mathematics named after Lothar Collatz, who introduced it in 1937. It is an unsolved problem in mathematics that is simple to state but difficult to prove. The problem is defined as follows:

  1. Start with any positive integer N.
  2. Apply the following rules:
    • If N is even, divide it by 2.
    • If N is odd, multiply it by 3 and add 1.
  3. Repeat the process with the resulting number as much as necessary to reach the number 1. The conjecture states that no matter what positive integer N you start with, you will always eventually reach the number 1.

 

Here is an example:

Start with N=6:

  • 6 is even, so 6/2=3
  • 3 is odd, so 3×3+1=10
  • 10 is even, so 10/2=5
  • 5 is odd, so 5×3+1=16
  • 16 is even, so 16/2=8
  • 8 is even, so 8/2=4
  • 4 is even, so 4/2=2
  • 2 is even, so 2/2=1

A total of 8 steps were required in this example.

 

For this challenge, you need to create an iterative macro that simulates the repeated steps until reaching 1 for each number. Once the macro is created, your tasks are to:

  • Generate the numbers from 1 to 10,000.
  • Use the iterative macro to apply the Collatz conjecture to each number.
  • Identify the maximum number of steps used to reach the number 1.

 

Need a refresher? Review the following lessons in Academy to gear up:

 

Good luck!

 

The Academy Team

 

Download Start File

 

Download Solution File

 

RWvanLeeuwen
11 - Bolide

Here's my take

Spoiler
iterative macro that starts with these three fields (manipulating the [Value]  and incrementing the [Step])iterative macro that starts with these three fields (manipulating the [Value] and incrementing the [Step])
Pilsner
11 - Bolide

I always enjoy the mathematical challenges!

Spoiler
475.png

Macro:

475 macro.png

lwolfie
11 - Bolide

Fun Monday Morning Challenge.

RolandSchubert
16 - Nebula
16 - Nebula
Spoiler
475.jpg
RWvanLeeuwen
11 - Bolide

Quick tip for this challenge: I'd suggest keeping the number of iterations below 500.

I just tried generating 1,000,000 records and allowed for 1,000,000 iterations, but the last 432 records were not quite ready to be tackled using this routine. The last row that exited the program took less than 500 steps

 

Spoiler
475 remark - below 500 steps is fine.png
AkimasaKajitani
17 - Castor
17 - Castor

My solution. 

 

I don't use the macro.

 

Spoiler
Clipboard26.png
mmontgomery
11 - Bolide
11 - Bolide

C475

Spoiler
Nice I-macro to start the week!c475_I_Macro.pngc475.png
TurboToad
11 - Bolide

Fun Challenge! I added in a record ID to track which number had the most steps.

 

Spoiler
image.pngimage.png
olga_strubbe
11 - Bolide

I loved this challenge, thank you so much!  It was fun to build an iterative macro for this mathematical conjecture, in fact. 

My workflow and macro are included. 

Spoiler
2025-05-05_11-58-11.png

2025-05-05_12-01-31.png