Challenge #406: What Is Your Lucky Number for the New Year?
- S'abonner au fil RSS
- Marquer le sujet comme nouveau
- Marquer le sujet comme lu
- Placer ce Sujet en tête de liste pour l'utilisateur actuel
- Marquer
- S'abonner
- Sourdine
- Page imprimable
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler au modérateur
Hi Maveryx,
A solution to last week’s challenge can be found here.
Roland van Leeuwen submitted this idea a while back, and now is the right time to share it! With 2024 approaching, let's determine our unique lucky numbers. Thanks, @RWvanLeeuwen, for your contributions to our Community!
In the quiet town of Serendipity Springs, there exists a magical tradition linked to Kaprekar's constant. Residents believe that the enchanted number 6174 holds the key to unlocking good fortune. This mystical connection is celebrated every New Year's Eve, adding an air of excitement and mystery to the festivities.
Following the rules of Kaprekar's constant, the townsfolk take their birth year, arrange the digits in both ascending and descending order, subtract the smaller number from the larger one, and continue the process until they reach the magical number 6174. The number of iterations used in this process is believed to represent their individual lucky number.
For instance, if someone has 1977 as the birth year, the following process is applied:
(Note: To apply Kaprekar’s constant, the number should contain at least two different digits, and leading zeros are allowed).
- Arrange the digits of 1977 in descending order: 9771.
- Arrange the digits of 1977 in ascending order: 1779.
- Subtract the smaller number from the bigger number: 9771 – 1779 = 7992 (first iteration).
- Use the output of Step 3 and apply Steps 1 and 2 another time (second iteration).
- Repeat until you get your result 6174.
- 9972-2799 = 7173 (second iteration)
- 7731-1377 = 6354
- 6543-3456 = 3087
- 8730-0378 = 8352
- 8532-2358 = 6174 (six iterations to get 6174 as a result)
If you were born in 1977, according to Serendipity Springs habitants, your lucky number is 6.
Long story, right? What is your challenge then?
Imagine using Alteryx Designer to validate Kaprekar’s constant and generate your lucky number!
Tasks:
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.
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.
Task 3: Determine your lucky number.
HINTS:
You can choose how you want to solve the challenge, but this is the route we would suggest:
- Create an iterative macro to 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.
- Create a batch macro that uses your iterative macro to find the highest and the lowest number of iterations you need to transform any four-digit number into 6174 using this rule set.
- Apply the batch macro to a workflow with your birth year to determine your lucky number. (We are using 1977 in our solution.)
Wishing you a Happy New Year from Alteryx Academy!
May the year ahead be filled with fantastic moments for everyone, and in 2024, get ready for new challenges, updates, and opportunities to strengthen your abilities!
Thank you for all your contributions to our Community in 2023!
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler au modérateur
My lucky number was "3"!
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler au modérateur
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler au modérateur
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler au modérateur
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler au modérateur
Maybe I am just being paranoid, but I somehow smell AOC from this weekly challenge. 🤣
Task 2: Highest and the lowest number of iterations are 7 and 1
Task 3: My luck number is 6 and I would not say which number it is from.
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler au modérateur
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler au modérateur
Lucky number is 3 for me. Now I need to find another half dozen algorithms to fill out the rest of my lottery ticket.
Workflow
Macro
No numeric comparisons needed!
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler au modérateur
Lucky Number 6. Feel bad for anyone born in a repeated digit year (e.g. 1111), who have no lucky number :`(
Only need 1 iterative macro (no batch macro):
Iterative Macro:
I hope y'all had a Merry Christmas and have a Happy New Year! Happy Solving!!!
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler au modérateur
Here is my solution with iterative macro within a batch macro:
Iterative Macro:
Batch Macro: