package leetcode;

/**
 * https://leetcode.com/problems/new-21-game/
 */
public class Problem837 {
    public double new21Game(int N, int K, int W) {
        // TODO
        return 0;
    }

    public static void main(String[] args) {
        Problem837 prob = new Problem837();
        System.out.println(prob.new21Game(10, 1, 10)); // 1.00000
        System.out.println(prob.new21Game(6, 1, 10)); // 0.60000
        System.out.println(prob.new21Game(21, 17, 10)); // 0.73278
        System.out.println(prob.new21Game(2, 2, 4)); // 0.3125
        System.out.println(prob.new21Game(10, 2, 10)); // 0.99
    }
}

@@ -155,32 +155,414 @@
     
-// TODO%0A        return 0
+return new21Game(N, K, W, 0);%0A    %7D%0A%0A    private static double new21Game(int n, int k, int w, int val) %7B%0A        if (val %3E= k) %7B%0A            if (val %3C= n) %7B%0A                return 1;%0A            %7D%0A            return 0;%0A        %7D%0A        double sum = 0;%0A        for (int i = 1; i %3C= w; i++) %7B%0A            double p = new21Game(n, k, w, val + i) * (1.0 / w);%0A            sum += p;%0A        %7D%0A        return sum
 ;%0A  

Update problem 837