package leetcode;

import java.util.Random;

/**
 * https://leetcode.com/problems/implement-rand10-using-rand7/
 */
public class Problem470 {
    private final Random random = new Random(System.currentTimeMillis());

    public int rand7() {
        int min = 1;
        int max = 7;
        return random.nextInt(max - min + 1) + min;
    }

    public int rand10() {
        // TODO
        return 0;
    }

    public static void main(String[] args) {
        Problem470 prob = new Problem470();
    }
}

@@ -374,128 +374,268 @@
     
-// TODO%0A        return 0
+int row = rand7();%0A        int col = rand7()
 ;%0A    
-%7D%0A%0A
     
-public static void main(String%5B%5D args) %7B%0A        Problem470 prob = new Problem470()
+int index = col + ((row - 1) * 7);%0A        while (index %3E 40) %7B%0A            row = rand7();%0A            col = rand7();%0A            index = col + ((row - 1) * 7);%0A        %7D%0A        return 1 + (index - 1) %25 10
 ;%0A  

Solve problem 470