Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions week15/Victor/SecondGreatLow.jsx
Original file line number Diff line number Diff line change
@@ -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()));
14 changes: 14 additions & 0 deletions week15/Victor/SecondGreatlow.md
Original file line number Diff line number Diff line change
@@ -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
Empty file added week15/Victor/comments.md
Empty file.
27 changes: 27 additions & 0 deletions week16/Victor/PrimeMover.jsx
Original file line number Diff line number Diff line change
@@ -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<i; j++){
if(i%j==0){
prime++;
}
}
if(prime==0){
primes++;
}
if(primes==num){
return i;
}
}
}

// keep this function call here
console.log(PrimeMover(readline()));
11 changes: 11 additions & 0 deletions week16/Victor/PrimeMover.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
Author: Victor
Date: 2023-01-17
---
Prime Mover
Have the function PrimeMover(num) return the numth prime number. The range will be from 1 to 10^4. For example: if num is 16 the output should be 53 as 53 is the 16th prime number.
Examples
Input: 9
Output: 23
Input: 100
Output: 541
Empty file added week16/Victor/comments.md
Empty file.
16 changes: 16 additions & 0 deletions week2/victor/first_factorial.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
Author: Victor
Date: 2022-09-25
---

First Factorial


Have the function FirstFactorial(num) take the num parameter being passed and return the factorial of it.

For example: if num = 4, then your program should return (4 * 3 * 2 * 1) = 24. For the test cases, the range will be between 1 and 18 and the input will always be an integer.
Examples
Input: 4
Output: 24
Input: 8
Output: 40320
10 changes: 10 additions & 0 deletions week4/victor/Word_count.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@


function WordCount(str) {
let words = str.split(' ');
return words.length;

}

// keep this function call here
WordCount(readline());
Empty file added week4/victor/Word_count.md
Empty file.
12 changes: 12 additions & 0 deletions week4/victor/comments.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
Author: Victor
Date: 2022-10-17
---

Word Count
Have the function WordCount(str) take the str string parameter being passed and return the number of words the string contains (e.g. "Never eat shredded wheat or cake" would return 6). Words will be separated by single spaces.
Examples
Input: "Hello World"
Output: 2
Input: "one 22 three"
Output: 3
Empty file added week5/victor/comments.md
Empty file.