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 |
The challenge involves mathematics in some central way. Also consider using more specific tags, listed in the tag wiki info.
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?
1
vote
Find i^n, given n
Groovy: 27-5 = 22
f={n->[1,'i',-1,'-i'][n%4]}