This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function angryProfessor(k, a) { | |
// Write your code here | |
let alumnsLate = 0; | |
//Lets travel the loop | |
//we've gotta travel the loop searching | |
//if the element (time) is higher than 0 | |
//than would mean that the alumn was late | |
for(let i = 0; i<a.length; i++){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function sockMerchant(n, ar) { | |
let socksPairs = 0 ; | |
let counter = 0; | |
let diferentNumbers = []; | |
//travel the array | |
for(let i = 0; i<ar.length; i++){ | |
//esta omitiendo | |
if(!diferentNumbers.includes(ar[i])){ | |
//agregarlo al arreglo de diferentes numeros | |
diferentNumbers.push(ar[i]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function divisibleSumPairs(n, k, ar) { | |
let sum = 0; | |
let pairs = 0; | |
//two loops | |
for(let i = 0; i<ar.length; i++){ | |
//second loop | |
for(let j = i+1; j<ar.length; j++){ | |
if((ar[i]+ar[j])%k==0){ | |
pairs++; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function breakingRecords(scores) { | |
// Write your code here | |
let records = [0,0] | |
let best = scores[0]; | |
let worst = scores[0]; | |
let bestCounter = 0; | |
let worstCounter = 0; | |
//travel the array | |
scores.forEach(score=>{ | |
//for each score, we have to compare |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function bonAppetit(bill, k, b) { | |
// Write your code here | |
//bill is an array that contains all the items consumed | |
//k is the item anna didn't eat | |
//b is the amount of money Anna gave to Brian | |
let total = 0; | |
//splice the array | |
let newBill =bill.filter(element=> { | |
if(element!=bill[k]){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getMoneySpent(keyboards, drives, b) { | |
/* | |
* Write your code here. | |
*/ | |
//Given an keyboards array an a drives array | |
//We've gotta find how many possibles | |
//'Combinations' are given a budget | |
//Example: | |
//keyboards = [40,25,30,60] | |
//drives = [10,12,14,7,18] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function birthday(s, d, m) { | |
// Write your code here | |
//we have to travel the array searching for the requirements | |
//EXAMPLE: | |
//s= [2,2,2,1,3,1] | |
//m = 2 | |
//p = 4 | |
//First: we travel the array searching i to i+m | |
let founds = 0; | |
let splicedArray; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function catAndMouse(x, y, z) { | |
let winner; | |
if(Math.abs(z-x) == Math.abs(z-y)){ | |
//The Mouse scapes | |
winner = 'Mouse C' | |
} | |
else{ | |
//Define a wineer (CAT A OR CAT B) | |
if(Math.abs(z-x)< Math.abs(z-y)) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function pageCount(n, p) { | |
// Write your code here | |
//Identificar desde que lado empezaremos | |
let foundPage = false; | |
let currentPages = 0; | |
let counts = 0; | |
let tipoDeNumero = 0; | |
if(n%2!=0){ | |
//Numero par = 0 | |
//Numero impar = 1 |
NewerOlder