alteryx Community

# 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.

## Challenge #406: What Is Your Lucky Number for the New Year?

12 - Quasar

My new lucky number is number six!

Spoiler
Alteryx

Me too @Chris-Nienart ! 🤣🤣🤣

16 - Nebula
Spoiler
9 - Comet
Spoiler
Solution Attached
8 - Asteroid

my lucky number is 7️⃣

Spoiler
9 - Comet
Spoiler
16 - Nebula
Spoiler
16 - Nebula
Spoiler
macro

8 - Asteroid

Lucky number is 5!

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.

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

Batch Macro

Iterative Macro

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