aboutsummaryrefslogtreecommitdiff
path: root/2025/11/puzzle-1.awk
blob: aa752e10b072599f52e89e61e4422c58b83786ee (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/usr/bin/gawk -f

function npaths(src, dst,    n, i)
{
	if (src == dst)
		return 1;
	for (i in paths[src])
		n += npaths(paths[src][i], dst)
	return n
}

BEGIN { FS = ":? " }

{
	for (i = 2; i <= NF; i++)
		paths[$1][i - 1] = $i
}

END { print npaths("you", "out") }