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