Skip to main content
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
Results tagged with
Search options not deleted user 3077

Tasks involving random numbers and/or output.

2 votes

How to randomize letters in a word

Groovy, 75 r={w->w.size()<3?w:w[0]+w[1..-2].toList().sort{Math.random()}.join()+w[-1]} assert r('a') == 'a' assert r('it') == 'it' assert r('cap') == 'cap' for(x in 1..10) { def w = r('Honorifi …
Armand's user avatar
  • 519
0 votes

Rand5() to Rand7()

Groovy rand7={if(b==null)b=rand5();(b=(rand5()+b)%7+1)} example distribution over 35,000 iterations: [1:5030, 2:4909, 3:5017, 4:4942, 5:5118, 6:4956, 7:5028] Is it bad that it's stateful?
Armand's user avatar
  • 519