URL: https://fivethirtyeight.com/features/how-many-more-palindrome-dates-will-you-see/

Riddler Express:

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?

Approach:

### Create string of numbers 1 to 9 (for leading zeros)
leading.zero.nums <- c("01", "02" , "03" , '04', '05', '06', '07', '08', '09')

### create data frame of dates, reverse date strings, and palindrom indicator
### note: in order to account for leading zeros I made the dates strings. 
###       there is probably a better/cleaner approach
df <- crossing(month = c(leading.zero.nums, 10:12),
         day   = c(leading.zero.nums, 10:30),
         year  = 2020:2099 ) %>% 
mutate(combined = paste0(month, day, year),
       reversed = stringi::stri_reverse(combined),
       palindrome = combined == reversed)

sum(df$palindrome) - 1 # minus one since the question asks how many AFTER 02022020 
## [1] 8

Riddler Express Answer:

8 palindrome dates