回答編集履歴
2
chousei
answer
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
```javascript
|
2
2
|
const a=[];
|
3
3
|
const num=3;
|
4
|
+
const max=1000;
|
4
|
-
for (let i = 1; i <=
|
5
|
+
for (let i = 1; i <= max; i++) {
|
5
6
|
const ran =Math.floor(Math.random() * 31);
|
6
7
|
a.push(ran);
|
7
8
|
if(a.length>num) a.shift();
|
1
調整
answer
CHANGED
@@ -1,12 +1,14 @@
|
|
1
1
|
```javascript
|
2
2
|
const a=[];
|
3
|
+
const num=3;
|
3
4
|
for (let i = 1; i <= 1000; i++) {
|
4
5
|
const ran =Math.floor(Math.random() * 31);
|
5
6
|
a.push(ran);
|
6
|
-
if(a.length>
|
7
|
+
if(a.length>num) a.shift();
|
7
|
-
if(a.length==
|
8
|
+
if(a.length==num && [...new Set(a)].length==1){
|
8
9
|
console.log(i);
|
9
10
|
break;
|
10
11
|
}
|
11
12
|
}
|
13
|
+
|
12
14
|
```
|