feature/algoritmo #1

Merged
PatrickReisSantos merged 10 commits from feature/algoritmo into master 2022-11-02 16:06:18 +00:00
10 changed files with 82 additions and 22 deletions

View File

@ -1,4 +1,4 @@
export function greet(name) {
// implementar logica aqui
return "";
return `Hello ${name}`;
}

View File

@ -1,3 +1,4 @@
export function triangleArea(base, height) {
export function triangleArea(base, height) {
return (base * height) / 2;
// your code here
}
}

View File

@ -1,4 +1,6 @@
export function maxValue(values) {
if (values.length == 0) return 0;
return Math.max(...values);
// implementar logica aqui
}
}

View File

@ -1,4 +1,16 @@
export function fibonacci(value) {
let soma = 0;
let anterior = 0;
let proximo = 1;
if (value == 1) {
return (soma = 1);
}
for (let i = 2; i <= value; i++) {
soma = anterior + proximo;
anterior = proximo;
proximo = soma;
}
return soma;
// implementar logica aqui
}
}

View File

@ -1,4 +1,8 @@
export function isPrime(value) {
for (let divisor = 2; divisor < value; divisor++)
if (value % divisor === 0) {
return false;
}
return true;
// implementar logica aqui
}
}

View File

@ -1,4 +1,8 @@
export function sum(values) {
let soma = 0;
for (let i = 0; i < values.length; i++) {
soma += values[i];
}
return soma;
// implementar logica aqui
}
}

View File

@ -1,4 +1,10 @@
export function sumEven(value) {
// implementar logica aqui
}
let soma = 0;
for (let i = 0; i <= value.length; i++) {
if (value[i] % 2 === 0) {
soma += value[i];
}
}
return soma;
// implementar logica aqui if (variavel % 2 !== 0)
}

View File

@ -1,4 +1,6 @@
export function isAnagram(word1, word2) {
let str1 = word1.toLowerCase().split("").sort().join("");
let str2 = word2.toLowerCase().split("").sort().join("");
return str1 === str2;
// implementar logica aqui
}
}

View File

@ -1,4 +1,20 @@
export function mostUsedChar(text) {
// implementar logica aqui
return ""
}
let freqCounter = [];
let textStr = text.toLowerCase();
for (let char of textStr) {
freqCounter[char] = freqCounter[char] + 1 || 1;
}
let maxCount = 0;
let maxChar = null;
for (let key in freqCounter) {
if (freqCounter[key] > maxCount) {
maxCount = freqCounter[key];
maxChar = key;
}
}
// implementar logica aqui
return maxChar;
}

View File

@ -1,4 +1,17 @@
export function longestWords(words) {
// implementar logica aqui
}
let longestWord = "";
let longestWordsArray = [];
for (let i = 0; i < words.length; i++) {
if (words[i].length >= longestWord.length) {
longestWord = words[i];
}
}
for (let i = 0; i < words.length; i++) {
if (words[i].length == longestWord.length) {
longestWordsArray.push(words[i]);
}
}
return longestWordsArray;
// implementar logica aqui
}