mirror of
https://github.com/bertptrs/adventofcode.git
synced 2025-12-25 21:00:31 +01:00
Add implementation for part 2.
This commit is contained in:
@@ -27,6 +27,7 @@ The current plan, in no particular order:
|
|||||||
- [x] PHP - [Day 19](./day-19/solution.php)
|
- [x] PHP - [Day 19](./day-19/solution.php)
|
||||||
- [ ] Prolog
|
- [ ] Prolog
|
||||||
- [ ] Python
|
- [ ] Python
|
||||||
|
- [x] R - [Day 20](./day-20/solution.r)
|
||||||
- [x] Ruby - [Day 08](./day-08/solution.rb)
|
- [x] Ruby - [Day 08](./day-08/solution.rb)
|
||||||
- [x] Rust - [Day 14](./day-14/solution.rs)
|
- [x] Rust - [Day 14](./day-14/solution.rs)
|
||||||
- [x] Scala - [Day 11](./day-11/solution.scala)
|
- [x] Scala - [Day 11](./day-11/solution.scala)
|
||||||
|
|||||||
@@ -14,4 +14,16 @@ speeds <- rowSums(abs(input[,4:6]))
|
|||||||
perm <- order(accs, speeds)
|
perm <- order(accs, speeds)
|
||||||
print(perm[1] - 1)
|
print(perm[1] - 1)
|
||||||
|
|
||||||
|
for (i in 1:100) {
|
||||||
|
# Update positions, speeds
|
||||||
|
for (coord in 1:3) {
|
||||||
|
input[,coord+3] <- input[,coord+3] + input[,coord+6]
|
||||||
|
input[,coord] <- input[,coord] + input[,coord+3]
|
||||||
|
}
|
||||||
|
|
||||||
|
dups = !(duplicated(input[,1:3]) | duplicated(input[,1:3], fromLast=TRUE))
|
||||||
|
|
||||||
|
input = input[dups,]
|
||||||
|
}
|
||||||
|
|
||||||
|
print(nrow(input))
|
||||||
|
|||||||
Reference in New Issue
Block a user