From James Anderson comes a palindromic puzzle of calendars:
This past Sunday was Groundhog Day. Also, there was a football game. But to top it all off, the date, 02/02/2020, was palindromic, meaning it reads the same forwards and backwards (if you ignore the slashes).
If we write out dates in the American format of MM/DD/YYYY (i.e., the two digits of the month, followed by the two digits of the day, followed by the four digits of the year), how many more palindromic dates will there be this century?
all_century_days <- seq.Date(as.Date("2020/02/07"), as.Date("2099/12/31"), by = "days") %>% format("%m-%d-%Y")
is_palindrome <- function(x){
x == str_split(x, "", simplify = T) %>% rev() %>% paste0(collapse = "")
}
palindromes <- all_century_days %>% str_remove_all("-") %>% map_lgl(is_palindrome)
all_century_days[palindromes]## [1] "12-02-2021" "03-02-2030" "04-02-2040" "05-02-2050" "06-02-2060"
## [6] "07-02-2070" "08-02-2080" "09-02-2090"
A work by Jacob Hernández Mejía
jacobhdezm@outlook.com