summary refs log tree commit diff homepage
path: root/2022/day06.awk
blob: b6827805fd4ed2e5432b82729b7d6fbdf9caae0a (plain) (blame)
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
28
function repeats(s, i) {
	for (i = 1; i <= length(s); i++) {
		for (j = i+1; j <= length(s); j++) {
			if (substr(s, i, 1) == substr(s, j, 1)) return 1;
		}
	}
	return 0;
}
{
	for (i = 1; i <= length; i++) {
		c1 = c2;
		c2 = c3;
		c3 = c4;
		c4 = substr($1, i, 1);
		if (c1 == c2 || c1 == c3 || c1 == c4) continue;
		if (c2 == c3 || c2 == c4) continue;
		if (c3 == c4) continue;
		if (i < 4) continue;
		print i;
		break;
	}
	for (i = 1; i+14 <= length; i++) {
		s = substr($1, i, 14);
		if (repeats(s)) continue;
		print 13+i;
		break;
	}
}
inalrc?id=3075bef323a3260d78050a9235b478676b76ae5a&follow=1'>Update terminal colors with proper base16 paletteJune McEnroe 2013-04-27Update location of Xfce4-Terminal configurationJune McEnroe 2013-04-24Update system configurationsJune McEnroe 2013-04-23Fix terminal colorsJune McEnroe 2013-04-14Start xcompmgrJune McEnroe 2013-04-06Drop pacman-color, regular pacman now has colorJune McEnroe 2013-04-06Restore wallpaper automaticallyJune McEnroe 2013-03-22Simplify autostartJune McEnroe 2013-02-24Default to Ruby 2.0June McEnroe 2013-01-26Make pretty riplrcJune McEnroe 2013-01-26Default to awesome sessionJune McEnroe 2013-01-26Add git promptJune McEnroe 2013-01-26Actually port awesome config to 3.5June McEnroe 2013-01-26Make pretty zshrcJune McEnroe 2013-01-26Port awesome config to 3.5June McEnroe 2013-01-26Replace RVM with chrubyJune McEnroe