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

# use like e.g.
# nissy scramble -n 20 | ./utils/solvetest_gen.sh eofb -o -N | \
#     tee tools/401_solvetest_opt0_EO_FB/scrambles.h

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