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

function npaths(src, dst,    n, i)
{
	if (src == dst)
		return 1;
	n = 0
	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") }