This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Fun exercise with @marsbomber, his solution at https://gist.github.com/4291868 | |
List<BigDecimal> percentageBreakdown(List<Integer> input) { | |
return pb(input, 1.0000) | |
} | |
List<BigDecimal> pb(List<Integer> input, BigDecimal remaining) { | |
if (input.empty) return [] | |
def head = input.head() | |
if (head == 0) return [0] + pb(input.tail(), remaining) |