Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,13 @@
romanToArabic <- function(roman) {
romanLookup <- c(I=1L, V=5L, X=10L, L=50L, C=100L, D=500L, M=1000L)
rSplit <- strsplit(toupper(roman), character(0)) # Split input vector into characters
toArabic <- function(item) {
digits <- romanLookup[item]
if (length(digits) > 1L) {
smaller <- (digits[-length(digits)] < digits[-1L])
digits[smaller] <- - digits[smaller]
}
sum(digits)
}
vapply(rSplit, toArabic, integer(1))
}

View file

@ -0,0 +1 @@
romanToArabic(c("MCMXII", "LXXXVI"))

View file

@ -0,0 +1 @@
as.integer(as.roman(c("MCMXII", "LXXXVI"))