% Advent of Code 2015 Day 1
% https://adventofcode.com/2015/day/1

p = fileread('aoc201501_input.txt');

floor = 0;
n = length(p);
for i=1:n
    if p(i)=='('
        floor = floor + 1;
    elseif p(i)==')'
        floor = floor - 1;
    end
    if (floor == -1)
        fprintf('Part 2: Position %d puts Santa in the basement\n', i);
    end
end

fprintf('Part 1: Santa ends up at floor %d\n', floor);



