Advent of Code: Day 11
Corporate Policy

First puzzle

This puzzle will deal with the generation of a “password.” The password is a string of characters from “a” to “z.” To get a new password, you need to add 1 to the least significant character of the old password. This addition will increase the letter “value” based on its alphabet position. For example:

For a password to be valid, the following properties needs to be true:

Some examples to test our code from the puzzle definition:

The input of the puzzle is the current password. First, it is useful to define an “inc” function to be able to find the next possible password by adding 1 to the characters. Then, the solution should be found by incrementing the password until a string presenting the above properties is found:

Second puzzle

The second puzzle solution is to find the next valid password. It is just evaluating the same calculation taking the first puzzle solution as input:

You can find this code along with my input and puzzle answers at here.

Written by Darien Martinez Torres on 11 March 2016