Add implementation for part 2.

This commit is contained in:
2017-12-20 14:18:32 +01:00
parent bb8c0e0658
commit f8cfe6dfa9
2 changed files with 13 additions and 0 deletions

View File

@@ -14,4 +14,16 @@ speeds <- rowSums(abs(input[,4:6]))
perm <- order(accs, speeds)
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))