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
34 changes: 34 additions & 0 deletions week13/Victor/ArithGeo.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
function ArithGeoII(arr) {
var num1 = arr[0];
var num2 = arr[1];
var arithmetic = num2 - num1;
var geometric = num2 / num1;

var isArithmetic = true;
var isGeometric = true;

for (var i = 0; i < arr.length-1; i++) {
var first = arr[i];
var second = arr[i+1];

if (second / first !== geometric) {
isGeometric = false;
}

if ((second - first) !== arithmetic) {
isArithmetic = false;
}

}

if (isGeometric) {
return 'Geometric'
} else if (isArithmetic) {
return 'Arithmetic'
} else {
return -1
}
}

// keep this function call here
ArithGeoII(readline());
13 changes: 13 additions & 0 deletions week13/Victor/ArithGeo.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
Author: Victor
Date: 7-12-22
---


Arith Geo II
Have the function ArithGeoII(arr) take the array of numbers stored in arr and return the string "Arithmetic" if the sequence follows an arithmetic pattern or return "Geometric" if it follows a geometric pattern. If the sequence doesn't follow either pattern return -1. An arithmetic sequence is one where the difference between each of the numbers is consistent, where as in a geometric sequence, each term after the first is multiplied by some constant or common ratio. Arithmetic example: [2, 4, 6, 8] and Geometric example: [2, 6, 18, 54]. Negative numbers may be entered as parameters, 0 will not be entered, and no array will contain all the same elements.
Examples
Input: [5,10,15]
Output: Arithmetic
Input: [2,4,16,24]
Output: -1
Empty file added week13/Victor/comment.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.