-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcovid_vowels.js
58 lines (52 loc) · 1.36 KB
/
covid_vowels.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
function runProgram(input){
input = input.trim()
var count = 0
for(var i = 0; i < input.length; i++)
{
var sub_string = ""
for(var j = i; j < input.length; j++)
{
sub_string += input[j]
if(sub_string.length >= 4)
{
var obj = {
a : 0,
i : 0,
o : 0,
u : 0
}
for(var k = 0; k < sub_string.length; k++)
{
if(obj[sub_string[k]] == undefined)
{
continue
}
else
{
obj[sub_string[k]] += 1
}
}
if(obj.a > 0 && obj.i > 0 && obj.o > 0 && obj.u > 0)
{
count++
}
}
}
}
console.log(count)
}
process.stdin.resume();
process.stdin.setEncoding("ascii");
let read = "";
process.stdin.on("data", function (input) {
read += input;
});
process.stdin.on("end", function () {
read = read.replace(/\n$/,"")
runProgram(read);
});
process.on("SIGINT", function () {
read = read.replace(/\n$/,"")
runProgram(read);
process.exit(0);
});