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 |
Tasks involving random numbers and/or output.
4
votes
Roll Dungeons and Dragons dice
Ruby, 116
Alternative Ruby version. I was trying to find a way to do it without the regular expressions, but the validation you have to do is a lot harder without them.
gets=~/^(\d+)?d(\d+)(\+\d+ …
1
vote
D&D Skill Challenges
Ruby 2.2, 75 bytes
f=->(v,s,f){p(r=rand(20)+1)<2?f=0:r>19?s=0:r<v ?f-=1:s-=1while s*f>0
p s<1}
Basic iterative solution. Example run:
f[12, 5, 3]
Might output:
11
17
8
14
7
false
You can s …
8
votes
Generate a pronounceable word
Ruby: 56 characters
([v=%w(a e i o u y),[*?a..?z]-v]*5).map{|a|$><<a.sample}
Example outputs:
itopytojog
umapujojim
ipagodusas
yfoqinifyw
ebylipodiz
2
votes
Generate ASCII wilderness map
Ruby 1.9 (127 116 112 107)
m=?.*o=W=200
29.times{|i|o+=i%9-i/28>0?[-1,1,20].sample: rand(W);m[o%W]='T~^'[i/9]||?o}
puts m.scan /.{20}/
The output is a bit plain, but I think it mostly meets the spe …
2
votes
Golfing A Weasel Program
Ruby - 225 202 203 198 chars
Ruby seems under-represented in this challenge so far so I thought I would give it a try! Improvements welcome.
g=-1
s=[]
puts"#{g+=1}: #{$.,s=(0..99).map{n=(r=0..27).m …
1
vote
Kids shuffling cards
Ruby, 111 101 characters
s=[*0..9,*?a..?j,*?q..?z,*?A..?J,*?Q..?Z,?\r]*''
loop{$><<s;s[1+rand(48),0]=s.slice!$.^=-2;sleep 0.3}
Loops infinitely.