Last active
March 5, 2018 18:39
-
-
Save goldensunliu/fb54f6a2972883a3a61e9b942517a7b5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getNumberOfGroupsAssignedForNumber(number, groups) { | |
return groups.reduce((accumulator, row) => | |
accumulator + (row.get(number) > 0 ? 1 : 0), 0); | |
} | |
class Game extends Compoent { | |
... | |
// get the min between its completion in rows, columns and squares. | |
getNumberValueCount(number) { | |
const rows = this.state.board.getIn(['choices', 'rows']); | |
const columns = this.state.board.getIn(['choices', 'columns']); | |
const squares = this.state.board.getIn(['choices', 'squares']); | |
return Math.min( | |
getNumberOfGroupsAssignedForNumber(number, squares), | |
Math.min( | |
getNumberOfGroupsAssignedForNumber(number, rows), | |
getNumberOfGroupsAssignedForNumber(number, columns), | |
), | |
); | |
} | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment