The fourth day has been added

This commit is contained in:
Alexander Munch-Hansen 2017-12-06 02:33:21 +01:00
parent 170d7b5647
commit ddfd12346e

View File

@ -26,3 +26,10 @@ For the second part, the spiral had changed slightly. Now every number was the s
![](https://dcav.pw/amoeFOuI) ![](https://dcav.pw/amoeFOuI)
I was not able to find a particular pattern in this, so I ended up building the spiral, using the fact that Ruby allows for hashes to have a default value, so I could set that to 0 and then iniate (0,0) => 1 and from there count the the numbers around it. The implementation is somewhat ugly. I was not able to find a particular pattern in this, so I ended up building the spiral, using the fact that Ruby allows for hashes to have a default value, so I could set that to 0 and then iniate (0,0) => 1 and from there count the the numbers around it. The implementation is somewhat ugly.
## The 4th of December
Given a list of words, one had to figure out if the given list is a valid `passphrase`. A passphrase consists of a series of words (lowercase letters) separated by spaces and there can be no duplicate words in the passphrase.
This first part was simply solved by converting each list to a set by calling `uniq` on it and then checking if the length is the same as for the original list. If not, there must have been some duplicates.
For the second part, if any word was a permutation of another word, this list was now not a valid passphrase. Because of this, it could be solved by looping through all words, taking the permutation and then checking if either of the permutation was already known and if so, the list was decided to be not a valid passphrase.