2
1
Fork 0

Day 2: Slightly simplify C solutions

Not sure why I did it that way. Maybe because I was originally
going to use strtol or something?
This commit is contained in:
Mia Herkt 2021-12-02 17:21:50 +01:00
parent 03f4a91463
commit d6bf929fc8
Signed by: mia
GPG Key ID: 72E154B8622EC191
2 changed files with 4 additions and 14 deletions

View File

@ -1,18 +1,13 @@
#include <stdio.h>
#include <string.h>
#include <assert.h>
int main(void) {
FILE *fp = fopen("input.txt", "r");
char buf[16] = {0}, *np;
char buf[16] = {0};
unsigned n, h = 0, v = 0;
while (fgets(buf, 16, fp) != NULL) {
np = strchr(buf, ' ');
assert(np != NULL);
np++;
sscanf(np, "%u", &n);
sscanf(buf, "%*s %u", &n);
switch (buf[0]) {
case 'd':

View File

@ -1,18 +1,13 @@
#include <stdio.h>
#include <string.h>
#include <assert.h>
int main(void) {
FILE *fp = fopen("input.txt", "r");
char buf[16] = {0}, *np;
char buf[16] = {0};
unsigned n, aim = 0, h = 0, v = 0;
while (fgets(buf, 16, fp) != NULL) {
np = strchr(buf, ' ');
assert(np != NULL);
np++;
sscanf(np, "%u", &n);
sscanf(buf, "%*s %u", &n);
switch (buf[0]) {
case 'd':