mirror of
https://github.com/bertptrs/adventofcode.git
synced 2025-12-25 21:00:31 +01:00
Solution to day 20 part 1.
This commit is contained in:
1000
2017/day-20/input.txt
Normal file
1000
2017/day-20/input.txt
Normal file
File diff suppressed because it is too large
Load Diff
17
2017/day-20/solution.r
Executable file
17
2017/day-20/solution.r
Executable file
@@ -0,0 +1,17 @@
|
|||||||
|
#!/usr/bin/env Rscript
|
||||||
|
data <- readLines("stdin")
|
||||||
|
cleaned <- gsub(" $", "", gsub("^[^0-9-]+", "", gsub("[^0-9-]+", " ", data)))
|
||||||
|
|
||||||
|
tc <- textConnection(cleaned)
|
||||||
|
|
||||||
|
input <- read.csv(tc, header=FALSE, sep=" ")
|
||||||
|
|
||||||
|
close(tc)
|
||||||
|
|
||||||
|
accs <- rowSums(abs(input[,7:9]))
|
||||||
|
speeds <- rowSums(abs(input[,4:6]))
|
||||||
|
|
||||||
|
perm <- order(accs, speeds)
|
||||||
|
print(perm[1] - 1)
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user