This file contains hidden or 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
// https://www.codewars.com/kata/56606694ec01347ce800001b/train/javascript | |
function isTriangle(a,b,c) | |
{ | |
return a + b > c && a + c > b && c + b > a; | |
} | |
console.log(isTriangle(1,2,2), true); | |
console.log(isTriangle(7,2,2), false); |
This file contains hidden or 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
// https://www.codewars.com/kata/577a98a6ae28071780000989/train/javascript | |
var min = function(list){ | |
return list.reduce(function (p, v) { | |
return ( p < v ? p : v ); | |
}); | |
} | |
var max = function(list){ |
This file contains hidden or 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
// https://www.codewars.com/kata/57a083a57cb1f31db7000028/train/javascript | |
function powersOfTwo(n){ | |
var outcome =[]; | |
for (let i = 0; i <= n; i++) { | |
outcome.push(Math.pow(2, i)); | |
} | |
return outcome | |
} |
This file contains hidden or 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
/** | |
* Check if the Character is letter or not | |
* @param {String} str - character to check | |
* @return {object} An array with the character or null if isn't a letter | |
*/ | |
function isLetter (str) { | |
return str.length === 1 && str.match(/[a-zA-Z]/i) | |
} | |
/** |
This file contains hidden or 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
// https://www.codewars.com/kata/52d1bd3694d26f8d6e0000d3/train/javascript | |
function VigenèreCipher(key, abc) { | |
this.encode = function (message) { | |
let upperCase = message == message.toUpperCase(); | |
message = message.toLowerCase(); | |
let result = '' |
This file contains hidden or 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
// https://www.codewars.com/kata/52597aa56021e91c93000cb0/train/javascript | |
function moveZeros(array) { | |
return array.filter(function(value){ | |
return JSON.stringify(value) != "0" ; // filter no zero | |
}).concat(array.filter(function(value){ | |
return JSON.stringify(value) == "0"; // filter zero | |
})); | |
} |
This file contains hidden or 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
// https://www.codewars.com/kata/54acc128329e634e9a000362/train/javascript | |
function traverseTCPStates(eventList){ | |
var state = "CLOSED"; | |
var states = { | |
CLOSED : { APP_PASSIVE_OPEN : "LISTEN", APP_ACTIVE_OPEN : "SYN_SENT" }, | |
LISTEN: { RCV_SYN : "SYN_RCVD", APP_SEND : "SYN_SENT", APP_CLOSE : "CLOSED" }, | |
SYN_RCVD: { APP_CLOSE : "FIN_WAIT_1", RCV_ACK : "ESTABLISHED" }, |
This file contains hidden or 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
// https://www.codewars.com/kata/51c8e37cee245da6b40000bd/train/javascript | |
function solution(input, markers) { | |
let outcome = []; | |
let inputs = input.split("\n"); | |
for (let k = 0; k < inputs.length; k++) { | |
for (const m of markers) { | |
if(inputs[k].indexOf(m)>-1){ | |
inputs[k] = inputs[k].substring(0, inputs[k].indexOf(m)); | |
} |
This file contains hidden or 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
// https://www.codewars.com/kata/52774a314c2333f0a7000688/train/javascript | |
function validParentheses(parens) { | |
var count =0; | |
for (var i = 0; i < parens.length; i++) { | |
if(parens.charAt(i) =="(") count++; | |
if(parens.charAt(i) ==")") count--; | |
if(count ==-1 ) return false; | |
} | |
if(count == 0 ) return true; |
This file contains hidden or 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
// https://www.codewars.com/kata/51b66044bce5799a7f000003/train/javascript | |
const values = {M: 1000,CM: 900, D: 500,CD: 400,C: 100,XC: 90, L: 50, XL: 40,X: 10,IX: 9,V: 5,IV: 4,I: 1 } | |
const orders = ['M','CM','D','CD','C','XC','L','XL','X','IX','V','IV','I']; | |
function RomanNumerals(){}; | |
RomanNumerals.toRoman = function(num) { | |
let roman = '' | |
for (const symbol of orders) { | |
while (num >= values[symbol]) { |