Created
December 19, 2017 16:30
-
-
Save saraswatmks/94852ef0fe5bccfb63774dd92b134622 to your computer and use it in GitHub Desktop.
compare the triplets in R
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Enter your code here. Read input from STDIN. Print output to STDOUT | |
con <- file('stdin','r') | |
input <- readLines(con) | |
n1 <- input[[1]] | |
n2 <- input[[2]] | |
n1 <- as.numeric(unlist(strsplit(n1, ' '))) | |
n2 <- as.numeric(unlist(strsplit(n2, ' '))) | |
alice = 0 | |
bob = 0 | |
for(i in seq(n1)) | |
{ | |
if(n1[i] > n2[i]) | |
{ | |
alice = alice + 1 | |
} else if(n1[i] < n2[i]) | |
{ | |
bob = bob + 1 | |
} else { | |
next | |
} | |
} | |
result <- c(alice, bob) | |
cat(result) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment