Fork me on GitHub

Hi guys, may i ask for little code review? I wrote solution for one of the recent /r/dailyprogrammer tasks and it works like it should. But I just don’t like style of one function, I feel that it its not idiomatic and may be written in better way. Here is the code ( And my concern is about defusable? function which is recursive algorithm with backtracking for finding if given input can be solved according to rules. So I don’t like that there are so much nesting and three ifs in a row and I feel like there should be way to write it better.