ACT NOW: The Alteryx team will be retiring support for Community account recovery and Community email-change requests Early 2026. Make sure to check your account preferences in my.alteryx.com to make sure you have filled out your security questions. Learn more here
Start Free Trial

General Discussions

Discuss any topics that are not product-specific here.

Euleryx Project 22 – Names Scores

Pilsner
13 - Pulsar

Euleryx Problem 22 – Names Scores

Pilsner_1-1768518129330.png

 

 

My workflow:

 

 

Spoiler

Workflow:

Pilsner_2-1768518137737.png

 

Answer: 871198282

 

 

Last Week's Favourite Solution:

A tough call last week, as the solutions provided took a similar approach for identifying the factors. I would like to shout out both @Qiu  and @AncientPandaman for providing such efficient brute force solutions to last week's challenge! Please find their solutions on page one of last week's post or click here.

 


Mathematical Theory:

Relatively straightforward challenge this week; however, that doesn’t mean we can't do a little rearranging to save a tool or two.

 

The way the question is phrased suggests that we need to do the following 4 steps:
1) Find the value of all letters in a given word

2) Sum the values of the letters in the word

3) Multiply this sum by the word's position in the list.

4) Sum the values calculated in the step above.

 

Taking the words Dog and Cat as an example the steps would go as follows:

 

  • D = 4, O = 15, G = 7 and C = 3, A = 1, T = 20
  • (4+15+7) = 26 and (3+1+20) = 24
  • When sorted alphabetically, Cat comes before Dog, hence we multiply the Cat sum by 1, and the Dog sum by 2
    26 x 2 = 52 and 24 x 1 = 24
  • 52+24 = 76

Written as one formula, it reads:

 

2 x (4 + 15 + 7)  +  1 x (3 + 1 + 20)

 

When written like this, you may notice that we don’t have to do the steps, as per the original order. Instead, let's do the multiplication before any of the addition.

 

  • D = 4, O = 15, G = 7 and C = 3, A = 1, T = 20
  • 2 x (4+15+7) and 1 x (3+1+20) to get (8+30+14) and (3+1+20)
  • Add all the numbers together now:
    (8+30+14) + (3+1+20) = 76

By simply rearranging the formula, we have been able to remove an entire step from the process, meaning the workflow should run faster. Here's the updated process:

 

1) Find the values of all the letters in a given word

2) Multiply each letter by the word's position in the list.

3) Sum ALL the values together

 

Method:

1) First of all we need to split all the names into their own row, sort them, and then give them a rank (position number):

Pilsner_4-1768518813941.png

 


2) Now, separate out each letter from each word, using tokenise in the regex tool.

Pilsner_5-1768518819560.png

 



3) Calculate the value of each letter. This can be found by identifying its position in the alphabet. And multiplying said position by the overall name's rank (from when we sorted them alphabetically).

Pilsner_6-1768518823823.png

 


4) Sum all the letter values to arrive at the answer:

Pilsner_7-1768518827466.png

 



5) Submit your answer to the Project Euler Website!

GifGIF.gif



Summary:

Even on simple problems, we can often look for efficiencies, sometimes by simply swapping the order of steps around.

 

Want to find out more, follow this link to our introduction post - Euleryx: Let The Games Begin.

 

3 REPLIES 3
Qiu
21 - Polaris
21 - Polaris

@Pilsner 
Thank you for the shout out. 😁

Qiu
21 - Polaris
21 - Polaris

I think we are taking similar approach.

Spoiler
Euleryx Project 22A.png
Hub119
12 - Quasar
12 - Quasar

Nice trick with the CharToInt - 64 function there @Pilsner ...way more elegant than my long IF statement to convert letters to alphabet order numbers 🤣

Spoiler
PE-22.png

 

Labels
Top Solution Authors