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);
}
Enroe 2018-02-04Tweak colorscheme moreJune McEnroe 2018-02-04Color MatchParen DarkYellowJune McEnroe White is not obvious enough. 2018-02-04Add palette sampling to gfxxJune McEnroe 2018-02-04Add 4-bit RGB to gfxxJune McEnroe Replace default palette with alternating black and white. 2018-02-04Add Quit menu item to gfcocoaJune McEnroe 2018-02-04Switch back to sane Objective-C styleJune McEnroe 2018-02-04Quit gfcocoa when window closesJune McEnroe 2018-02-03Apparently this is how people write Objective-CJune McEnroe