Skip to content

Instantly share code, notes, and snippets.

@djhurio
Last active August 12, 2017 17:21
Show Gist options
  • Save djhurio/fab7e2e64b2a73e54591e230fb2f7630 to your computer and use it in GitHub Desktop.
Save djhurio/fab7e2e64b2a73e54591e230fb2f7630 to your computer and use it in GitHub Desktop.
Test cases for code golf challenge "Disappearing Elements" for R
# https://codegolf.stackexchange.com/questions/138570/disappearing-elements
f=function(S,X)Reduce(`[`,-X-1,S,,T)
f(el(strsplit("codegolf", "")), c(1, 4, 4, 0, 2))
f(el(strsplit("abc", "")), 0)
f(el(strsplit("abc", "")), vector("integer"))
f(el(strsplit("abc", "")), c(2, 0, 0))
f("", vector("integer"))
f(el(strsplit("codegolfing", "")), c(10, 9, 8, 3, 2, 1, 0))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment