Looking for Starter Kits? Head to the Community Gallery! Now formatted as YXIs for easy installation.
alteryx Community

# Weekly Challenge

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.

SOLVED

## Challenge #163: Caesar Cipher (on the way to Kryptos)

8 - Asteroid

Here is my solution...

Spoiler
13 - Pulsar

My solution! Similar in approach on part 1 as most, but I took a different approach on part 2. Loving these challenges!

Spoiler
For Part 1, I used a chartoint to convert it identified when to use addition or subtraction and then converted it back to a character.

For Part 2, I used a switch to convert any letter using the cipher style in the Wiki page so A->0, B->1,until Z->25. I then did the modular formula describe in the wiki page and then converted back to a character using the same type of switch function.
15 - Aurora

Such a fun challenge!!

Spoiler
Like many before me (looking at you, @NicoleJohnson and @patrick_digan), I went with a CharToInt and CharFromInt for the letter shifting.

Took an approach that works with both Part 1 and Part 2.

First step after tokenizing was to create a field to deal with capital or lowercase letters. For the letter shift, I found it easier to use all capital letters (conversely could work with all lowercase), so created a field to flag capital letters

Then, the conversion itself. First step is to check if it's a non-alpha character. In that case, just copy the original character. Using CharToInt on the capitalized alpha character will result in an integer from 65 (A) to 90 (Z). If subtracting the Base value (for part 1 it's 13, and for part 2, it's 1-26) from that integer is lower than 65, then take the integer value, add 26 to bump up to the end of the alphabet, and subtract the Base value; the new letter is the CharFromInt of that value. Otherwise, the new letter is the CharFromInt of the original integer value of the letter minus the base.

Last step converts lowercase letters back into lowercase

Then a summarize tool to concatenate the NewLtr field back to the original string.

Screenshot of the process:

Will "App-ify" this as well, and update my post when done.

Moderator
Spoiler
Always fun building out an iterative macro!

Also, not sure when I've used the CharToInt() function before but good to know it's there!

Great challenge. Cheers @TerryT .

15 - Aurora

Addendum to my post. Turns out it was really easy to turn into an App. Just took a little creativity on modifying the Base in my formula tool

Spoiler

Encryption/Decryption choice and the number shift field both feed into the Action tool. This modifies the Base field with a formula. So instead of assigning the value of 13, as in the original challenge, if the user chooses to encrypt, the value used as the Base will be positive (and letters will shift to higher in the alphabet), otherwise it will be negative (and letters will shift to lower in the alphabet)

Here's the interface. Give it a whirl!
7 - Meteor

Here is my answer to part I.

14 - Magnetar

Fun challenge! Had trouble with the first step (I think i'm not a literacy person, had just troubles with the alphabet :p )

7 - Meteor

I think I have a very similar solution to many of the others here.

Spoiler
11 - Bolide

Here I just thought that the question was »Why did the fish get expelled from School« 😂

Anyway it was a super fun challenge, all though the second part had me going for some time, I am looking forward to see a cleaver solution that solves both, because I more less brute forced the answer for part II

Spoiler
So the Part I had me going in some different directions, I briefly looked at making my own function, bur stil the complexity of handling strings made me relize that I would have to made a DLL for that to work, so in the end, everything was done in the formula tool

But I had to peek at an ASCII chart in order for me to the the calculations right
Solution IIn the end my calculations did work, and i could decode and code the mesage, and the same result.

Part II was a bit more tricky. and I could not figure out how to re-use my ROT-13 en/de-coder, so I enden up brute forcing the result, by generating all the combinations in order to find the right one,
Solution IIHow ever it was mentioned, that Caesar signed all his messages, so I'll assume another way to have solved this was to find out how off the signature (the end of the message) was from caesar, but I am not a fan of assumptions.

If my calculations is correct, then with this weekly challenge done I have just joined exclusive club of currently 46 members that have passed the Challenge Bergschrund Crevasse 👐

Still Climbing
/Verakso

18 - Pollux

Hi @Verakso

Congrats on making it to the Bergschrund Crevasse.  Keep it up. We look forward to seeing you at the Yellow Band.

Spoiler
As far as the "Brute Force" approach to finding Caesar's reply, that's the way that everybody did it.  The only other viable option that I can think is to use some sort of NLP to parse the entire reply text, but that's made much more difficult by the fact that there there are no spaces in the words.

BTW: I learned the joke as "Why did the lobster blush"

Dan