context("test-day04")
test_that("parsing guard records and filling sleep values", {
x <- "
[1518-11-01 00:00] Guard #10 begins shift
[1518-11-01 00:05] falls asleep
[1518-11-01 00:25] wakes up
[1518-11-01 00:30] falls asleep
[1518-11-01 00:55] wakes up
[1518-11-01 23:58] Guard #99 begins shift
[1518-11-02 00:40] falls asleep
[1518-11-02 00:50] wakes up
[1518-11-03 00:05] Guard #10 begins shift
[1518-11-03 00:24] falls asleep
[1518-11-03 00:29] wakes up
[1518-11-04 00:02] Guard #99 begins shift
[1518-11-04 00:36] falls asleep
[1518-11-04 00:46] wakes up
[1518-11-05 00:03] Guard #99 begins shift
[1518-11-05 00:45] falls asleep
[1518-11-05 00:55] wakes up"
x <- read_text_lines(x)
df <- find_sleepiest_minute_of_sleepiest_guard(x)
expect_equal(df$minute * df$guard, 240)
df <- find_guard_with_sleepiest_minute(x)
expect_equal(df$minute * df$guard, 4455)
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.