Last active
February 2, 2022 16:27
-
-
Save KaiAragaki/bb204efc5d00fcae9c84ffbcabaaa08f to your computer and use it in GitHub Desktop.
Flip numbers on a finite interval with known bounds
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
# 'Flip' numbers on a number interval | |
# my_nums: 1 2 5 10 | |
# 1 | |
# interval: 1 ---- 2 ---- 3 ---- 4 ---- 5 ---- 6 ---- 7 ---- 8 ---- 9 ---- 10 | |
# Flipped: | |
# newnums: 1 6 9 10 | |
# 10 | |
# interval: 1 ---- 2 ---- 3 ---- 4 ---- 5 ---- 6 ---- 7 ---- 8 ---- 9 ---- 10 | |
my_nums <- c(1, 1, 2, 5, 10) | |
start_num <- 1 | |
end_num <- 10 | |
-my_nums + start_num + end_num |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment