C3
This commit is contained in:
parent
e0fcee5a17
commit
70348ba551
4
c3/.gitignore
vendored
Normal file
4
c3/.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
bin/*
|
||||||
|
!bin/run
|
||||||
|
|
||||||
|
**/problem
|
24
c3/2015/1/problem.c3
Normal file
24
c3/2015/1/problem.c3
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
1
c3/README.md
Normal file
1
c3/README.md
Normal file
@ -0,0 +1 @@
|
|||||||
|
To run this, download the c3 tar and unzip it directly into the bin directory
|
7
c3/bin/run
Executable file
7
c3/bin/run
Executable file
@ -0,0 +1,7 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
year=$1
|
||||||
|
day=$2
|
||||||
|
|
||||||
|
../c3/bin/c3c compile -o $year/$day/problem $year/$day/problem.c3 && \
|
||||||
|
time (cat ../data/$year/$day/input.txt | ./$year/$day/problem)
|
Loading…
Reference in New Issue
Block a user