summary refs log tree commit diff homepage
path: root/2020/day05.c
blob: 8d87fcb3b5a8e255bfe709f30514ac29bf4a4e69 (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
#include <stdio.h>
#include <stdlib.h>
static int id(const char *s) {
	int row = 0, col = 0, size = 128;
	while (*s == 'F' || *s == 'B') {
		size /= 2;
		if (*s++ == 'B') row += size;
	}
	size = 8;
	while (*s) {
		size /= 2;
		if (*s++ == 'R') col += size;
	}
	return row * 8 + col;
}
int main(void) {
	char s[11];
	int max = 0;
	while (EOF != scanf("%s\n", s)) {
		if (id(s) > max) max = id(s);
	}
	printf("%d\n", max);
}