summary refs log tree commit diff homepage
path: root/2020/day02.c
blob: 793396cb4d98d96c7a55c33dce7cf90477de46ad (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <stdio.h>
#include <stdlib.h>
int main(void) {
	int valid1 = 0, valid2 = 0;
	int l, u;
	char c, p[256];
	while (EOF != scanf("%d-%d %c: %s\n", &l, &u, &c, p)) {
		int n = 0;
		for (int i = 0; p[i]; ++i) {
			if (p[i] == c) n++;
		}
		if (n >= l && n <= u) valid1++;
		if ((p[l-1] == c) ^ (p[u-1] == c)) valid2++;
	}
	printf("%d\n", valid1);
	printf("%d\n", valid2);
}
itle='2019-10-24 01:17:43 -0400'>2019-10-24Ignore further CAP ENDJune McEnroe 2019-10-24Implement client CAP for server-timeJune McEnroe 2019-10-24Implement ringWriteJune McEnroe 2019-10-24Make clientFormat publicJune McEnroe 2019-10-24Make serverFormat publicJune McEnroe 2019-10-24Rename some thingsJune McEnroe 2019-10-23Add ISUPPORT draft to STANDARDSJune McEnroe 2019-10-23Track own originJune McEnroe 2019-10-23Track channels and sync ISUPPORTJune McEnroe 2019-10-23Track nick changesJune McEnroe 2019-10-23Rename Command to MessageJune McEnroe 2019-10-23Synchronize state after client registrationJune McEnroe 2019-10-23Send to server if client has no needsJune McEnroe 2019-10-23Implement some amount of client connectionJune McEnroe 2019-10-23Set clients non-blockingJune McEnroe 2019-10-23Clean up state.c and factor out parsingJune McEnroe 2019-10-23Respond to pingsJune McEnroe 2019-10-23Add verbose flagJune McEnroe 2019-10-23Set NOSIGPIPE on server connectionJune McEnroe 2019-10-23Set an initial loop capJune McEnroe 2019-10-23Fix rest parsingJune McEnroe 2019-10-23Add dynamic poll listJune McEnroe 2019-10-23Don't assume commands have targets and handle ERRORJune McEnroe 2019-10-23Clean up state somewhatJune McEnroe 2019-10-23Actually send the buffer...June McEnroe 2019-10-23Add stateJune McEnroe