|
@@ -7,26 +7,22 @@ let invalid = []
|
|
|
function find_occurences(str, char_to_count) {
|
|
|
return str.split(char_to_count).length - 1;
|
|
|
}
|
|
|
-async function main() {
|
|
|
|
|
|
- for (let index = 0; index < data.length; index++) {
|
|
|
- const element = data[index];
|
|
|
- let info = element[0].split(' ')
|
|
|
- let info2 = info[0].split('-')
|
|
|
- let count = await find_occurences(element[1], info[1])
|
|
|
- if (count >= info2[0]) {
|
|
|
- if (count <= info2[1]) {
|
|
|
- // console.log('valid')
|
|
|
- } else {
|
|
|
- invalid.push(element)
|
|
|
- }
|
|
|
+data.forEach(element => {
|
|
|
+ let info = element[0].split(' ')
|
|
|
+ let info2 = info[0].split('-')
|
|
|
+ let count = find_occurences(element[1], info[1])
|
|
|
+ if (count >= info2[0]) {
|
|
|
+ if (count <= info2[1]) {
|
|
|
+ console.log(element)
|
|
|
} else {
|
|
|
invalid.push(element)
|
|
|
}
|
|
|
- // console.log('valid')
|
|
|
+ } else {
|
|
|
+ invalid.push(element)
|
|
|
}
|
|
|
- let answer = data.length - invalid.length
|
|
|
- console.log(answer)
|
|
|
-}
|
|
|
+ console.log(element)
|
|
|
+});
|
|
|
|
|
|
-main()
|
|
|
+let answer = data.length - invalid.length
|
|
|
+console.log('Valid ' + answer)
|