Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
|
|
@ -0,0 +1,12 @@
|
|||
(import [collections [Counter]])
|
||||
(import [random [randint]])
|
||||
|
||||
(defn uniform? [f repeats delta]
|
||||
; Call 'f' 'repeats' times, then check if the proportion of each
|
||||
; value seen is within 'delta' of the reciprocal of the count
|
||||
; of distinct values.
|
||||
(setv bins (Counter (list-comp (f) [i (range repeats)])))
|
||||
(setv target (/ 1 (len bins)))
|
||||
(all (list-comp
|
||||
(<= (- target delta) (/ n repeats) (+ target delta))
|
||||
[n (.values bins)])))
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
(for [f [
|
||||
(fn [] (randint 1 10))
|
||||
(fn [] (if (randint 0 1) (randint 1 9) (randint 1 10)))]]
|
||||
(print (uniform? f 5000 .02)))
|
||||
Loading…
Add table
Add a link
Reference in a new issue