Search Results
Search type | Search syntax |
---|---|
Tags | [tag] |
Exact | "words here" |
Author |
user:1234 user:me (yours) |
Score |
score:3 (3+) score:0 (none) |
Answers |
answers:3 (3+) answers:0 (none) isaccepted:yes hasaccepted:no inquestion:1234 |
Views | views:250 |
Code | code:"if (foo != bar)" |
Sections |
title:apples body:"apples oranges" |
URL | url:"*.example.com" |
Saves | in:saves |
Status |
closed:yes duplicate:no migrated:no wiki:no |
Types |
is:question is:answer |
Exclude |
-[tag] -apples |
For more details on advanced search visit our help page |
Code-golf is a competition to solve a particular problem in the fewest bytes of source code.
1
vote
Turn a sentence into a dictionary
R, 60 bytes
sort(setdiff(strsplit(tolower(readline()),"[^a-z]")[[1]],"")
Used setdiff to remove possible empty strings, but it deduplicates as well.
4
votes
Code ladder, Cops
R, 21 bytes, 10 numbers Cracked
__i___________i______
Works for 10 numbers. _ is hidden character.
Original solution:
2
votes
Code ladder, Cops
R, 22 bytes, 10 numbers, Cracked
_et_______)____is_____
_ is a hidden character.
See the redux version.
0
votes
Code ladder, Cops
R, 22 bytes, 10 numbers SAFE
_et___e_(_)____is_1___
_ is hidden character
Solution:
1
vote
Will it halt? (Robbers)
R Jarko Dubbeldam
f=function(x)while(1)if(length(x))grep(x,'')
Fails with a function argument, e.g.,
f(mean)
# Error in as.character(pattern) :
cannot coerce type 'closure' to vector of type 'cha …
1
vote
Will it halt? (Cops)
R, 63 bytes (cracked)
f=function(x){set.seed(4);try(eval(x));x=rpois(1,1);while(x){}}
2
votes
Will it halt? (Robbers)
R, Jarko Dubbeldam
"unlist"
Though it's just one more function that could be added to the exceptions - I doubt it's the intended solution.
Two more cracks: 'is.vector' and 'return'. These both wo …
4
votes
Draw the Swiss Flag
R, 112 bytes
par(bg=2,mar=0*1:4)
plot(0:32,0:32,'n',xaxs="i",yaxs="i")
rect(c(6,13),c(13,6),c(26,19),c(19,26),c="white",b=NA)
Though, to guarantee the aspect ratio, we need 5 more bytes for a total …
4
votes
We had a question once which only failed on Sundays
R, 31 bytes 30 bytes
if(format(Sys.Date(),'%u')>6)a
Try it online!
No output on non-Sundays, Error: object 'a' not found on Sundays.
format(Sys.Date(),'%u') was the shortest way I could find to …