News for hackers. Stuff that matters.
Re:Determining an Election in K by chrispsn on Monday March 30, 2020 @03:31AM (#22725936)
Another approach to the 'highest averages' method, using a k9 dict:

    v: 10400 3400 6200
    s: 15

    quotients: ,/v%\.5+!s
    labels:    s/!s*#v              / list of 15x 0, 1, 2. arbitrary; could instead be party names
    top:       s#>labels!quotients  / k dicts can have duplicate keys; can sort items by key(^) or val(<>)
    seats:     `freq@!top           / count appearances of dict's keys
The ability to transform a dict's values while keeping the labels (keys) unchanged - sort, arithmetic, etc - is really powerful.

This answer is longer when minified, but it's faster in 2020.03.27:

    \t:100000 +/s>(#v)^<>,/v%/.5+!s           ⇒ 1494
    \t:100000 `freq@!s#>(s/!s*#v)!,/v%\.5+!s  ⇒ 691
Re:Determining an Election in K by chrispsn on Wednesday April 01, 2020 @02:57AM (#22746372)
Correction: I think the above can be a bit faster and shorter if we skip the dict, and just index into the keys. Compare:

     \t:100000 `freq@!s#>(s/!s*#v)!,/v%\.5+!s
    941
     \t:100000 `freq(s/!s*#v)s#>,/v%\.5+!s
    901