### Completing the time and levelling the letters

Completing the time We are given a time, such as 12:34, with one of the digits replaced by '?'. We are asked what digit when substituted for the '?' results in the maximum valid time. There are six cases to consider: The first digit is ? and the second is [0123] - the answer is 2 The first digit is ? and the second is [456789] - the answer is 1 The second digit is ? and the first is 1 - the answer is 9 The second digit is ? and the first is 2 - the answer is 3 The third digit is ? - the answer is 5 The fourth digit is ? - the answer is 9 This is a rather messy set of conditions. The easiest - and perhaps clearest - way of performing the task is just a set of if/elsif clauses using the above logic, and that's what I submitted. I used split to put the characters into in array to make my conditions easy to read - for example $chars[0] eq '?' - but it could equally be done using regular expressions - for example $string =~ m|^...\?| is true if the 4th characte