From 45d0b1727bcb898b8dc027cb6736da37140e07cb Mon Sep 17 00:00:00 2001 From: Patrick Date: Sun, 30 Oct 2022 10:13:26 -0300 Subject: [PATCH 01/10] feat: algoritmo 1 --- 01-greeting/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/01-greeting/index.js b/01-greeting/index.js index 8f551af..c1211f1 100644 --- a/01-greeting/index.js +++ b/01-greeting/index.js @@ -1,4 +1,4 @@ export function greet(name) { // implementar logica aqui - return ""; + return "Hello " + name; } From 7de8a8fc7fdc198980924c0d29687dba370e8fb9 Mon Sep 17 00:00:00 2001 From: Patrick Date: Sun, 30 Oct 2022 10:27:00 -0300 Subject: [PATCH 02/10] feat: algoritmo 2 --- 02-triangleArea/index.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/02-triangleArea/index.js b/02-triangleArea/index.js index 7628fcd..5895b7e 100644 --- a/02-triangleArea/index.js +++ b/02-triangleArea/index.js @@ -1,3 +1,4 @@ -export function triangleArea(base, height) { +export function triangleArea(base, height) { + return (base * height) / 2; // your code here -} \ No newline at end of file +} From 456a54299d6f68f691b99959118b7e636713fb9f Mon Sep 17 00:00:00 2001 From: Patrick Date: Sun, 30 Oct 2022 11:01:51 -0300 Subject: [PATCH 03/10] feat algoritmo 3 --- 03-maxValue/index.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/03-maxValue/index.js b/03-maxValue/index.js index e433b31..ef50539 100644 --- a/03-maxValue/index.js +++ b/03-maxValue/index.js @@ -1,4 +1,6 @@ export function maxValue(values) { + if (values.length == 0) return 0; + return Math.max(...values); + // implementar logica aqui - -} \ No newline at end of file +} From ec60fd02489e0e313a2299de8ffd4cdf617e34bc Mon Sep 17 00:00:00 2001 From: Patrick Date: Sun, 30 Oct 2022 11:33:25 -0300 Subject: [PATCH 04/10] feat: algoritmo 4 --- 04-fibonacci/index.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/04-fibonacci/index.js b/04-fibonacci/index.js index 37c64cc..869133e 100644 --- a/04-fibonacci/index.js +++ b/04-fibonacci/index.js @@ -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 - -} \ No newline at end of file +} From b285c40b5327094ae8ed9ca8426a7a08d4041f4f Mon Sep 17 00:00:00 2001 From: Patrick Date: Sun, 30 Oct 2022 15:23:32 -0300 Subject: [PATCH 05/10] feat: algoritmo 5 --- 05-isPrime/index.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/05-isPrime/index.js b/05-isPrime/index.js index ec9c4ac..6e51a1b 100644 --- a/05-isPrime/index.js +++ b/05-isPrime/index.js @@ -1,4 +1,11 @@ export function isPrime(value) { - // implementar logica aqui - -} \ No newline at end of file + for (let divisor = 2; divisor < value; divisor++) + if (value % divisor === 0) { + return false; + } + return true; + /* for (var divisor = 2; divisor <= value; divisor++) + if (value % divisor == 0) return true; + else false; */ + // implementar logica aqui 2 1 / 2 +} From 505f3a5dd48d6a78482d5aff186dd194895a5be9 Mon Sep 17 00:00:00 2001 From: Patrick Date: Sun, 30 Oct 2022 15:32:33 -0300 Subject: [PATCH 06/10] fix: template string algoritmo 1 --- 01-greeting/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/01-greeting/index.js b/01-greeting/index.js index c1211f1..5c0279c 100644 --- a/01-greeting/index.js +++ b/01-greeting/index.js @@ -1,4 +1,4 @@ export function greet(name) { // implementar logica aqui - return "Hello " + name; + return `Hello ${name}`; } From 26f091d1f3ea1176cef2bc80c9bbe6858cf07327 Mon Sep 17 00:00:00 2001 From: Patrick Date: Sun, 30 Oct 2022 15:36:54 -0300 Subject: [PATCH 07/10] fix: remove meus comentarios algoritmo 5 --- 05-isPrime/index.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/05-isPrime/index.js b/05-isPrime/index.js index 6e51a1b..8c7c33d 100644 --- a/05-isPrime/index.js +++ b/05-isPrime/index.js @@ -4,8 +4,5 @@ export function isPrime(value) { return false; } return true; - /* for (var divisor = 2; divisor <= value; divisor++) - if (value % divisor == 0) return true; - else false; */ - // implementar logica aqui 2 1 / 2 + // implementar logica aqui } From 176d485260236a9ff882f0d76548004e36cdf927 Mon Sep 17 00:00:00 2001 From: Patrick Date: Sun, 30 Oct 2022 20:53:26 -0300 Subject: [PATCH 08/10] feat: algoritmo 6 e 7 --- 06-sum/index.js | 8 ++++++-- 07-sumEven/index.js | 12 +++++++++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/06-sum/index.js b/06-sum/index.js index ebc2ee1..8914608 100644 --- a/06-sum/index.js +++ b/06-sum/index.js @@ -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 - -} \ No newline at end of file +} diff --git a/07-sumEven/index.js b/07-sumEven/index.js index bb1e095..998bbc0 100644 --- a/07-sumEven/index.js +++ b/07-sumEven/index.js @@ -1,4 +1,10 @@ export function sumEven(value) { - // implementar logica aqui - -} \ No newline at end of file + 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) +} From f981cf4b49034ac8003493f843052a7be33ea653 Mon Sep 17 00:00:00 2001 From: Patrick Date: Wed, 2 Nov 2022 01:34:44 -0300 Subject: [PATCH 09/10] feat: algoritmo 8 --- 08-isAnagram/index.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/08-isAnagram/index.js b/08-isAnagram/index.js index 918308a..c8f035d 100644 --- a/08-isAnagram/index.js +++ b/08-isAnagram/index.js @@ -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 - -} \ No newline at end of file +} From aa43fe4a02b95a85dcd5194b405d7b787f010b6e Mon Sep 17 00:00:00 2001 From: Patrick Date: Wed, 2 Nov 2022 12:58:37 -0300 Subject: [PATCH 10/10] feat: algoritmo 9 e 10 --- 09-mostRepeatedChar/index.js | 22 +++++++++++++++++++--- 10-longestWords/index.js | 19 ++++++++++++++++--- 2 files changed, 35 insertions(+), 6 deletions(-) diff --git a/09-mostRepeatedChar/index.js b/09-mostRepeatedChar/index.js index b113ed8..d165916 100644 --- a/09-mostRepeatedChar/index.js +++ b/09-mostRepeatedChar/index.js @@ -1,4 +1,20 @@ export function mostUsedChar(text) { - // implementar logica aqui - return "" -} \ No newline at end of file + 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; +} diff --git a/10-longestWords/index.js b/10-longestWords/index.js index a98d2d8..bf7fc1f 100644 --- a/10-longestWords/index.js +++ b/10-longestWords/index.js @@ -1,4 +1,17 @@ export function longestWords(words) { - // implementar logica aqui - -} \ No newline at end of file + 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 +}