use os; use io; use fmt; use strings; use strconv; export fn main() void = { const handle = os::open("input.txt")!; defer io::close(handle)!; let buf = io::drain(handle) as []u8; defer free(buf); let input = strings::fromutf8_unsafe(buf[..]); let lines = strings::split(input, "\n")!; let dial: i16 = 50; let zeroes_seen: u16 = 0; for (let line .. lines[..]) { if (strings::hasprefix(line, "L")) { dial -= strconv::stoi16(strings::ltrim(line, 'L'))!; } else if (strings::hasprefix(line, "R")) { dial += strconv::stoi16(strings::ltrim(line, 'R'))!; } else { continue; }; for (dial < 0 || dial > 99) { if (dial < 0) { dial += 100; } else if (dial > 99) { dial -= 100; }; }; if (dial == 0) { zeroes_seen += 1; }; }; fmt::printfln("Password: {}", zeroes_seen)!; };