diff --git a/week15/Victor/SecondGreatLow.jsx b/week15/Victor/SecondGreatLow.jsx new file mode 100644 index 0000000..3c27e17 --- /dev/null +++ b/week15/Victor/SecondGreatLow.jsx @@ -0,0 +1,22 @@ +function SecondGreatLow(arr) { + + if (arr.length === 2) { + arr.sort(function(a,b) {return a - b}); + return arr[1] + " " + arr[0]; + } + + var values = arr.filter(function(num, pos) { + return arr.indexOf(num) == pos; + }); + + if (values.length > 2) { + values.sort(function(a, b){return a-b}); + return values[1] + " " + values[values.length - 2]; + } + else { + return values[1] + " " + values[0]; + } + + } + + console.log(SecondGreatLow(readline())); \ No newline at end of file diff --git a/week15/Victor/SecondGreatlow.md b/week15/Victor/SecondGreatlow.md new file mode 100644 index 0000000..e84a550 --- /dev/null +++ b/week15/Victor/SecondGreatlow.md @@ -0,0 +1,14 @@ +--- +Author: Victor +Date: 2022-09-25 +--- + +Second GreatLow + +Have the function SecondGreatLow(arr) take the array of numbers stored in arr and return the second lowest and second greatest numbers, respectively, separated by a space. For example: if arr contains [7, 7, 12, 98, 106] the output should be 12 98. The array will not be empty and will contain at least 2 numbers. It can get tricky if there's just two numbers! + +Examples +Input: [1, 42, 42, 180] +Output: 42 42 +Input: [4, 90] +Output: 90 4 diff --git a/week15/Victor/comments.md b/week15/Victor/comments.md new file mode 100644 index 0000000..e69de29 diff --git a/week16/Victor/PrimeMover.jsx b/week16/Victor/PrimeMover.jsx new file mode 100644 index 0000000..24f1dcd --- /dev/null +++ b/week16/Victor/PrimeMover.jsx @@ -0,0 +1,27 @@ + +function PrimeMover(num) { + if(num==1){ + return 2; + } + if(num==2){ + return 3; + } + var primes=1; + for(var i=3; i<100000; i++){ + var prime=0; + for(var j=2; j