Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.

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 #406: What Is Your Lucky Number for the New Year?

ed_hayter
12 - Quasar

My new lucky number is number six!

 

Spoiler
image.pngimage.png
AYXAcademy
Alteryx
Alteryx

Me too @Chris-Nienart ! 🤣🤣🤣

RolandSchubert
16 - Nebula
16 - Nebula
Spoiler
406.jpg
balajilolla2
9 - Comet
Spoiler
Solution Attached
Screenshot 2023-12-27 084709.jpg
Dev73
8 - Asteroid

my lucky number is 7️⃣

Spoiler
challange 406-3.pngchallange 406-2.pngchallange 406-1.png
nSpire
9 - Comet
Spoiler
406.png406-02.png
Kenda
16 - Nebula
16 - Nebula
Spoiler
image.png
Kenda
16 - Nebula
16 - Nebula
Spoiler
macro

image.png
ARussell34
8 - Asteroid

Lucky number is 5!

 

AR_ 406 macro.pngAR_challenge 406_sol.png

WeiLi
7 - Meteor

I wanted a real challenge, so i did not use the start file and built everything based on the original post descriptions.

 

The results are as follows:

 

 

Spoiler

Task 1: Validate the process that all four-digit integer numbers with at least two distinct digits will transform into 6174 when applying the rules of Kaprekar’s constant.

Result: See Week406 Output, all numbers verified. There are 8991 qualifying numbers.

 

Task 2: Find the highest and the lowest number of iterations you need to transform any four-digit number into 6174 using this rule set.

Result: Highest is 7, lowest is 1.

 

Task 3: Determine your lucky number.

Result: 2


My solution used 1 Workflow, 1 Batch Macro, 1 Iterative Macro and 2 Standard Macros.

 

What is not obvious from the original question is that when you calculate the difference in step 3, the result need to be converted to 4 digits. For example, 1000 - 0001 = 999. More accurately, it is 0999. Thus, when you perform the next iteration, the number is 9990 - 0999 = 8991.

It is necessary for the larger number to always be a 4 digit number. If it is less than 4 digits, 0's need to be added to the end for this to work.

 

Solution image:

 

Spoiler
Main Workflow
 
406a.PNG

Batch Macro

 
406b.PNG

Iterative Macro

406c.PNG

 In addition to these, I built 2 standard macros, as I did not rely on RegEx, so parsing macros were created instead.