Skip to content

Instantly share code, notes, and snippets.

@npjc
Created June 23, 2015 21:40
Show Gist options
  • Save npjc/1673ccdc124fecb2649a to your computer and use it in GitHub Desktop.
Save npjc/1673ccdc124fecb2649a to your computer and use it in GitHub Desktop.
scotia_half play
# pace to secs...minute:seconds character string to seconds integer
pts <- function(ms = "4:45") {
tmp <- as.integer(unlist(strsplit(ms, ":", fixed = TRUE)))
tmp[1]*60 + tmp[2]
}
# seconds to total time in hour:minute:seconds
ttl_time <- function(s) {
hrs <- floor(s / 3600)
leftovers <- s %% 3600
mins <- floor(leftovers / 60)
secs <- leftovers %% 60
paste0(hrs, "h ", mins, "m ", secs, "s")
}
# splits ------------------------------------------------------------------
ttl_secs <- sum(
# kms: 1,2,3 (basically to turn around point)
pts("4:30"),
pts("4:30"),
pts("4:30"),
# kms: 4, 5, 6, 7 (up marine drive)
pts("4:45"),
pts("4:45"),
pts("4:45"),
pts("4:45"),
# kms: 8, 9 (end of marine & big downhill)
pts("4:15"),
pts("4:15"),
# kms: 10, 11, 12 (spanish banks)
pts("4:45"),
pts("4:45"),
pts("4:45"),
# kms: 13, 14 (jericho to point grey)
pts("4:40"),
pts("4:40"),
# kms: 15, 16, 17 (cornwall to near bridge)
pts("4:35"),
pts("4:35"),
pts("4:35"),
# kms: 18, 19, 20, 21 (burrard bridge to finish)
pts("4:30"),
pts("4:15"),
pts("4:00"),
pts("3:50")
)
ttl_time(ttl_secs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment