Skip to content

Instantly share code, notes, and snippets.

@KaiAragaki
Last active February 2, 2022 16:27
Show Gist options
  • Save KaiAragaki/bb204efc5d00fcae9c84ffbcabaaa08f to your computer and use it in GitHub Desktop.
Save KaiAragaki/bb204efc5d00fcae9c84ffbcabaaa08f to your computer and use it in GitHub Desktop.
Flip numbers on a finite interval with known bounds
# '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