[This article was first published on R – Xi'an's Og, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
this leads to the above solution in R (26 bits). The same length as the C solution [which I do not get]
f(n){n=~n==(n^=-~n)*~n/2;}
And with shorter versions in many esoteric languages I had never heard of, like the 8 bits Brachylog code
ḃD
or the 7 bits Jelly
B¬ŒḂ⁼SƊ
As a side remark, since this was not the purpose of the game, the R code is most inefficient in creating a set of size (x+1), with most terms being Inf.
To leave a comment for the author, please follow the link and comment on their blog: R – Xi'an's Og.
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.