37 lines
1.1 KiB
Dart
37 lines
1.1 KiB
Dart
// Freeze new 7x7 boards. Existing v1 completions are preserved separately.
|
|
import 'dart:io';
|
|
|
|
import 'package:lumen/domain/puzzle.dart';
|
|
|
|
void main() {
|
|
final lines = <String>[
|
|
'// Generated by tool/author_postcard_puzzles.dart. Stable v2 identities.',
|
|
'const postcardPatterns = <(String, List<int>)>[',
|
|
];
|
|
final seen = <String>{};
|
|
for (var i = 0; i < 42; i++) {
|
|
final random = JavaRandom(BigInt.from(490018 + 7919 * i));
|
|
final p = Puzzle(7, List.generate(49, (_) => random.next(1)));
|
|
if (!seen.add(p.solution.join())) throw StateError('Duplicate board');
|
|
for (var j = 0; j < 49; j++) {
|
|
p.given[j] = true;
|
|
}
|
|
final order = List.generate(49, (j) => j);
|
|
random.shuffle(order);
|
|
for (final j in order) {
|
|
p.given[j] = false;
|
|
if (p.countSolutions() != 1 ||
|
|
!LogicSolver(49, p.constraints).analyze(p.initial).solved) {
|
|
p.given[j] = true;
|
|
}
|
|
}
|
|
lines.add(
|
|
" ('${p.solution.join()}', ${[for (var j = 0; j < 49; j++)
|
|
if (p.given[j]) j]}),",
|
|
);
|
|
}
|
|
lines.add('];');
|
|
File('lib/domain/postcard_patterns.dart')
|
|
.writeAsStringSync('${lines.join('\n')}\n');
|
|
}
|