Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f960d0b

Browse files
Solve 2021 day 1 part 1 in antimony
1 parent 61dd98d commit f960d0b

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

‎2021/Day1/Antimony/.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
main.js

‎2021/Day1/Antimony/main.sb‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
2+
fn main() {
3+
let data = "199\n200\n208\n210\n200\n207\n240\n269\n260\n263"
4+
let nums = data.split("\n")
5+
6+
console.log("Part 1:", part1(nums))
7+
}
8+
9+
fn part1(nums: int[]): int {
10+
let count = 0
11+
let last = nums[0]
12+
13+
for val in nums {
14+
if val > last {
15+
count += 1
16+
}
17+
last = val
18+
}
19+
20+
return count
21+
}

‎README.md‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,12 @@ iex(1)> c("main.ex")
2323
iex(2)> DayX.load_file |> DayX.first
2424
YOUR ANSWER
2525
iex(3)>
26-
```
26+
```
27+
28+
### [Antimony](https://github.com/antimony-lang/antimony)
29+
30+
Node.js needs to be installed as a runtime.
31+
32+
```sh
33+
sb run main.sb
34+
```

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /