aboutsummaryrefslogtreecommitdiff
path: root/utils/solvetest_gen.sh
blob: 11dcd07e38fce016a0e94e780f97d0a5642c5a93 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/sh

args="$@"

getsolutions() {
	nissy solve -p $args "$1" |
	while read -r solution; do
		printf '\t\t"%s\\n"\n' "$solution"
	done
}

printf "struct {\n\tchar *scramble;\n\tchar *solutions;\n} s[] = {\n"

i=0
while read -r scramble; do
	solutions="$(getsolutions "$scramble")"
	printf '[%s] = {\n\t.scramble = "%s",\n' "$i" "$scramble"
	printf '\t.solutions =\n%s\n' "$solutions"
	printf '},\n'
	i=$((i+1))
done

printf '{\n\t.scramble = "", /* End-of-list signal */\n}\n};\n'

Generated with cgit - Back to sebastiano.tronto.net