Comment detail

議席数をドント方式で (Nested Flatten)

wikipediaの数式を元に作成しました。 変数v、sもそのままです。

http://ja.wikipedia.org/wiki/%E3%83%89%E3%83%B3%E3%83%88%E5%BC%8F

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
println dont([ 123, 4, 56, 78 ], 100)

def dont( vlist, countOfSheet ){
    def groups = vlist.collect{ [ v:it, s:0 ] }

    countOfSheet.times{
        def map = groups.max{ it.v/(it.s + 1) }
        map.s++
    }
    
    groups.collect{ it.s }
}

Index

Feed

Other

Link

Pathtraq

loading...