package domain const val PUZZLE_SIZE = 6 class Game( val categories: List, val grid: Grid, val horizontalRules: List, val verticalRules: List ) { fun areCategoriesValid(): Boolean = categories.mapIndexed { index, category -> category.any { item -> categories.filterIndexed { i, _ -> i > index }.any { it.contains(item) } } }.none { it } fun areRulesViolated(): Boolean = horizontalRules .map { it.isRuleViolated(grid) } .reduce { a, b -> a || b } || verticalRules .map { it.isRuleViolated(grid) } .reduce { a, b -> a || b } }