aoc_omni/c3/2015/1/problem.c3
2024-11-19 20:32:23 -05:00

25 lines
466 B
Plaintext

import std::io;
fn void main()
{
String! line = io::readline();
if (try line) {
int floor = 0;
foreach (paren : line) {
if (paren == '(') floor++;
if (paren == ')') floor--;
}
io::printfn("Part 1: %d", floor);
floor = 0;
int index = 0;
foreach (paren : line) {
if (paren == '(') floor++;
if (paren == ')') floor--;
index++;
if (floor < 0) break;
}
io::printfn("Part 2: %d", index);
}
}