Skip to content

Commit fdf3fab

Browse files
committed
Initial commit
0 parents  commit fdf3fab

File tree

3 files changed

+61
-0
lines changed

3 files changed

+61
-0
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
input.self

2020/day1/solve.self

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
'../../../objects/everything.self' _RunScript.
2+
3+
(|
4+
parent* = self.
5+
6+
"Should be a string with the numbers as space separated inputs."
7+
input = 'input.self' _RunScript.
8+
9+
part1 = (| values. integerValues |
10+
values: input splitOn: ' '.
11+
integerValues: list copyRemoveAll.
12+
values do: [| :node | integerValues append: node value toInteger ].
13+
14+
0 to: integerValues size prec Do: [| :i. a |
15+
a: integerValues at: i.
16+
i succ to: integerValues size Do: [| :j. b |
17+
'i: ' print. i _StringPrint. ' j: ' print. j _StringPrint. '' printLine.
18+
b: integerValues at: j.
19+
((a + b) = 2020) ifTrue: [
20+
^ a * b.
21+
].
22+
].
23+
].
24+
).
25+
26+
part2 = 'TODO part 2'.
27+
28+
main = (
29+
'Part 1: ' print. part1 _StringPrint. '' printLine.
30+
part2 printLine.
31+
).
32+
|) main.

README.md

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
Advent of Code Challenges in zigSelf
2+
---
3+
4+
These are used to test the language's capabilities and fix bugs.
5+
6+
## Requirements
7+
8+
You need zigSelf.
9+
10+
## How to Run
11+
12+
The files expect to be executed in a directory within the main zigSelf repo, so
13+
that they can reach the standard library.
14+
15+
```console
16+
# In the zigSelf repository root
17+
$ git clone https://github.com/sin-ack/zigself-advent-of-code aoc
18+
# Provide your puzzle input for the day. The solve.self file will tell you
19+
# how the input should be formatted.
20+
$ $EDITOR aoc/2020/day1/input.self
21+
# Solve the challenge
22+
$ zig build run -- aoc/2020/day1/solve.self
23+
```
24+
25+
## License
26+
27+
All the code in this repository is licensed under the 2-Clause BSD License. See
28+
[LICENSE](LICENSE) for more details.

0 commit comments

Comments
 (0)