25 lines
466 B
Plaintext
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);
|
|
}
|
|
}
|