Skip to content

Commit 9b254a6

Browse files
committed
Runtime: 86 ms (Top 60.46%) | Memory: 49.50 MB (Top 76.74%)
1 parent 3fa7a87 commit 9b254a6

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Runtime: 86 ms (Top 60.46%) | Memory: 49.50 MB (Top 76.74%)
2+
3+
/**
4+
* The rand7() API is already defined for you.
5+
* var rand7 = function() {}
6+
* @return {number} a random integer in the range 1 to 7
7+
*/
8+
var rand10 = function() {
9+
while (true) {
10+
const num1 = rand7() - 1;
11+
const num2 = rand7();
12+
13+
const combinedNum = num1 * 7 + num2;
14+
15+
if (combinedNum <= 40) {
16+
return (combinedNum % 10) + 1;
17+
}
18+
}
19+
};

0 commit comments

Comments
 (0)