Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.