#include <stdio.h>
#include "aocdailies.h"

void aoc201501(char *data, size_t len) {
    (void)len; // unused argument
    int floor = 0, basementsteps = -1;
    char *ddata = data;                            // save start
    while (*data) {
        if (*data == '(') floor++;
        else if (*data == ')') floor--;
        data++;
        // if entered the basement, part 2 done
        if (floor == -1) {
            basementsteps = data - ddata;          // steps taken
            break;
        }
    }
    // continue with no regard to basement
    while (*data) {
        if (*data == '(') floor++;
        else if (*data == ')') floor--;
        data++;
    }
    printf("Santa is taken to floor {%d}.\n", floor);
    printf("Santa first goes to the basement at step {%d}.\n", basementsteps);
}
