|
| 1 | +import { combinations } from './killer-sudoku-helper'; |
| 2 | + |
| 3 | +describe('Trivial 1-digit cages', () => { |
| 4 | + test('1', () => { |
| 5 | + const inputCage = { |
| 6 | + sum: 1, |
| 7 | + size: 1, |
| 8 | + exclude: [], |
| 9 | + }; |
| 10 | + const expected = [[1]]; |
| 11 | + const actual = combinations(inputCage); |
| 12 | + expect(actual).toEqual(expected); |
| 13 | + }); |
| 14 | + |
| 15 | + xtest('2', () => { |
| 16 | + const inputCage = { |
| 17 | + sum: 2, |
| 18 | + size: 1, |
| 19 | + exclude: [], |
| 20 | + }; |
| 21 | + const expected = [[2]]; |
| 22 | + const actual = combinations(inputCage); |
| 23 | + expect(actual).toEqual(expected); |
| 24 | + }); |
| 25 | + |
| 26 | + xtest('3', () => { |
| 27 | + const inputCage = { |
| 28 | + sum: 3, |
| 29 | + size: 1, |
| 30 | + exclude: [], |
| 31 | + }; |
| 32 | + const expected = [[3]]; |
| 33 | + const actual = combinations(inputCage); |
| 34 | + expect(actual).toEqual(expected); |
| 35 | + }); |
| 36 | + |
| 37 | + xtest('4', () => { |
| 38 | + const inputCage = { |
| 39 | + sum: 4, |
| 40 | + size: 1, |
| 41 | + exclude: [], |
| 42 | + }; |
| 43 | + const expected = [[4]]; |
| 44 | + const actual = combinations(inputCage); |
| 45 | + expect(actual).toEqual(expected); |
| 46 | + }); |
| 47 | + |
| 48 | + xtest('5', () => { |
| 49 | + const inputCage = { |
| 50 | + sum: 5, |
| 51 | + size: 1, |
| 52 | + exclude: [], |
| 53 | + }; |
| 54 | + const expected = [[5]]; |
| 55 | + const actual = combinations(inputCage); |
| 56 | + expect(actual).toEqual(expected); |
| 57 | + }); |
| 58 | + |
| 59 | + xtest('6', () => { |
| 60 | + const inputCage = { |
| 61 | + sum: 6, |
| 62 | + size: 1, |
| 63 | + exclude: [], |
| 64 | + }; |
| 65 | + const expected = [[6]]; |
| 66 | + const actual = combinations(inputCage); |
| 67 | + expect(actual).toEqual(expected); |
| 68 | + }); |
| 69 | + |
| 70 | + xtest('7', () => { |
| 71 | + const inputCage = { |
| 72 | + sum: 7, |
| 73 | + size: 1, |
| 74 | + exclude: [], |
| 75 | + }; |
| 76 | + const expected = [[7]]; |
| 77 | + const actual = combinations(inputCage); |
| 78 | + expect(actual).toEqual(expected); |
| 79 | + }); |
| 80 | + |
| 81 | + xtest('8', () => { |
| 82 | + const inputCage = { |
| 83 | + sum: 8, |
| 84 | + size: 1, |
| 85 | + exclude: [], |
| 86 | + }; |
| 87 | + const expected = [[8]]; |
| 88 | + const actual = combinations(inputCage); |
| 89 | + expect(actual).toEqual(expected); |
| 90 | + }); |
| 91 | + |
| 92 | + xtest('9', () => { |
| 93 | + const inputCage = { |
| 94 | + sum: 9, |
| 95 | + size: 1, |
| 96 | + exclude: [], |
| 97 | + }; |
| 98 | + const expected = [[9]]; |
| 99 | + const actual = combinations(inputCage); |
| 100 | + expect(actual).toEqual(expected); |
| 101 | + }); |
| 102 | +}); |
| 103 | + |
| 104 | +describe('Other cages', () => { |
| 105 | + xtest('Cage with sum 45 contains all digits 1:9', () => { |
| 106 | + const inputCage = { |
| 107 | + sum: 45, |
| 108 | + size: 9, |
| 109 | + exclude: [], |
| 110 | + }; |
| 111 | + const expected = [[1, 2, 3, 4, 5, 6, 7, 8, 9]]; |
| 112 | + const actual = combinations(inputCage); |
| 113 | + expect(actual).toEqual(expected); |
| 114 | + }); |
| 115 | + |
| 116 | + xtest('Cage with only 1 possible combination', () => { |
| 117 | + const inputCage = { |
| 118 | + sum: 7, |
| 119 | + size: 3, |
| 120 | + exclude: [], |
| 121 | + }; |
| 122 | + const expected = [[1, 2, 4]]; |
| 123 | + const actual = combinations(inputCage); |
| 124 | + expect(actual).toEqual(expected); |
| 125 | + }); |
| 126 | + |
| 127 | + xtest('Cage with several combinations', () => { |
| 128 | + const inputCage = { |
| 129 | + sum: 10, |
| 130 | + size: 2, |
| 131 | + exclude: [], |
| 132 | + }; |
| 133 | + const expected = [ |
| 134 | + [1, 9], |
| 135 | + [2, 8], |
| 136 | + [3, 7], |
| 137 | + [4, 6], |
| 138 | + ]; |
| 139 | + const actual = combinations(inputCage); |
| 140 | + expect(actual).toEqual(expected); |
| 141 | + }); |
| 142 | + |
| 143 | + xtest('Cage with several combinations that is restricted', () => { |
| 144 | + const inputCage = { |
| 145 | + sum: 10, |
| 146 | + size: 2, |
| 147 | + exclude: [1, 4], |
| 148 | + }; |
| 149 | + const expected = [ |
| 150 | + [2, 8], |
| 151 | + [3, 7], |
| 152 | + ]; |
| 153 | + const actual = combinations(inputCage); |
| 154 | + expect(actual).toEqual(expected); |
| 155 | + }); |
| 156 | +}); |
0 commit comments