Today is a Saturday, which means nothing when it comes to DBC. Ok, that’s not strictly true – I could have very easily studied from home today, and I did get a much needed lie-in, but weekend studying is definitely necessary if you want to make the most of DBC and I figured I’d get much more done at the camp.
We had a self-assessment to do today, which everyone found very easy – it was essentially a copy of one of the phase 0 challenges with a bit of linear search and optional sorting+binary search thrown in. After that I decided to redo one of the challenges from earlier in the week after learning a bit more about regular expressions.
1 2 3 4 5
def pig_latin_word(input) return input if input.downcase =~ /^[aeiou]/ start_position = input.index(/[aeiou]/) input[start_position..(input.length)] + input[0..start_position-1] + 'ay' end
1 2 3
def pig_latin_word(input) input.gsub(/^([^aeiouAEIOU]+)(.*)/, "\\2\\1ay") end
The rest of my day was spent refactoring my Sudoku solver: yesterday I was able to get it solving any easy board (i.e. a board where there is always at least one cell with only one possible number). Today I was able to implement and optimize a recursive backtracking algorithm that so far has been able to solve any solvable board of any difficulty in under 30 seconds. I want to revisit it because I know I can make it faster, but I think tomorrow I’m going to scan through POODR since next week we’ll be deep-diving into OOP in ruby.