From f4693463369260abc7f69ef653b387a8c2d1437f Mon Sep 17 00:00:00 2001 From: vishal Date: Thu, 25 Jul 2024 09:40:27 +0530 Subject: [PATCH] fix test cases --- .gitignore | 3 +- .../tempCodeRunnerFile.js | 46 ++++++++++--------- .../Intersting-Arrays/tests/outputs/3.txt | 2 +- .../Intersting-Arrays/tests/outputs/5.txt | 2 +- 4 files changed, 29 insertions(+), 24 deletions(-) diff --git a/.gitignore b/.gitignore index 59d4343..351983d 100644 --- a/.gitignore +++ b/.gitignore @@ -41,4 +41,5 @@ yarn-error.log* .DS_Store *.pem -/ops/judge-ops/kcj-kubeconfig.yaml \ No newline at end of file +/ops/judge-ops/kcj-kubeconfig.yaml +apps/boilerplate-generator/tempCodeRunnerFile.js diff --git a/apps/boilerplate-generator/tempCodeRunnerFile.js b/apps/boilerplate-generator/tempCodeRunnerFile.js index baef2a7..f19f920 100644 --- a/apps/boilerplate-generator/tempCodeRunnerFile.js +++ b/apps/boilerplate-generator/tempCodeRunnerFile.js @@ -1,22 +1,26 @@ -[ - { - "input": 0, - "output": 32 - }, - { - "input": -40, - "output": -40 - }, - { - "input": 100, - "output": 212 - }, - { - "input": 37, - "output": 98.6 - }, - { - "input": -17.78, - "output": 0 +function intersect(A) { + function gcd(a, b) { + while (b) { + [a, b] = [b, a % b]; + } + return a; } -] \ No newline at end of file + + let g = A[0]; + for (let i = 1; i < A.length; i++) { + g = gcd(g, A[i]); + if (g === 1) { + break; + } + } + + return g === 1 ? "Yes" : "No"; +} + + + const input = require('fs').readFileSync('/Users/vishal/Desktop/PROJECTS/algoearth/apps/problems/Intersting-Arrays/tests/inputs/5.txt', 'utf8').trim().split('\n').join(' ').split(' '); + const size_A = parseInt(input.shift()); +const A = input.splice(0, size_A).map(Number); + const result = intersect(A); + console.log(result); + \ No newline at end of file diff --git a/apps/problems/Intersting-Arrays/tests/outputs/3.txt b/apps/problems/Intersting-Arrays/tests/outputs/3.txt index dcd7a5d..289cc91 100644 --- a/apps/problems/Intersting-Arrays/tests/outputs/3.txt +++ b/apps/problems/Intersting-Arrays/tests/outputs/3.txt @@ -1 +1 @@ -Yes +No \ No newline at end of file diff --git a/apps/problems/Intersting-Arrays/tests/outputs/5.txt b/apps/problems/Intersting-Arrays/tests/outputs/5.txt index cf45697..3fdfb3d 100644 --- a/apps/problems/Intersting-Arrays/tests/outputs/5.txt +++ b/apps/problems/Intersting-Arrays/tests/outputs/5.txt @@ -1 +1 @@ -No +Yes \ No newline at end of file