48 ms·
From a quick glance it looks to only check conflicts at the box level, not row and column. This is the first CoffeeScript I've seen, it's nice and concise.
by power 14y ago
From a quick glance it looks to only check conflicts at the box level, not row and column. This is the first CoffeeScript I've seen, it's nice and concise.
- pathikrit 14y ago`g in [s[x][i], s[i][y], box i]` - the first 2 arguments check in row and column level and third in box level
- power 14y agoThanks for clarifying. If you've the time, could you tell me how I should read: non_conflicting = (g) -> ![0...9].some (i) -> g in [s[x][i], s[i][y], box i]
- pathikrit 14y ago[0...9].some (i) -> g in [s[x][i], s[i][y], box i] returns true iff it finds some i in [0,9) such that given a guess g, g equals either s[x][i] or s[i][y] or box i or in other words it finds a conflict in either a row or column or box for g assuming it g is at s[x][y] The ! at the start negates it - so the whole method non_conflicting returns true iff g does not conflict with any i. If Arrays in JavaScript had an "all" reducer it could be written like this: non_conflicting = (g) -> [0...9].all (i) -> g not in [s[x][i], s[i][y], box i]