From 4115453b8a58ae4b517ed1647e3fe78431218a13 Mon Sep 17 00:00:00 2001 From: Hardanish Singh <61027578+Hardanish-Singh@users.noreply.github.com> Date: Thu, 11 Dec 2025 10:40:39 -0500 Subject: [PATCH 01/74] AB Check --- string manipulation/ab_check.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/string manipulation/ab_check.js b/string manipulation/ab_check.js index 2282052..ed16d49 100644 --- a/string manipulation/ab_check.js +++ b/string manipulation/ab_check.js @@ -21,16 +21,15 @@ function ABCheck(string) { let ab_counter = 0; let temp = new String(""); - for(let i=0; i 0 && string[i] !== temp && ab_counter === 3) return true; + for (let i = 0; i < string.length; i++) { + if (string[i] === "a" || string[i] === "b") { + if (temp.length > 0 && string[i] !== temp && ab_counter === 3) return true; ab_counter = 0; temp = string[i]; - } - else ab_counter++; + } else ab_counter++; } return false; } // KEEP THIS FUNCTION CALL HERE. -console.log(ABCheck(readline())); \ No newline at end of file +console.log(ABCheck(readline())); From 95d7d2d171fea064e5a24dab94cbdf3a539600d2 Mon Sep 17 00:00:00 2001 From: Hardanish Singh <61027578+Hardanish-Singh@users.noreply.github.com> Date: Thu, 11 Dec 2025 10:41:47 -0500 Subject: [PATCH 02/74] Alphabet Searching --- string manipulation/alphabet_searching.js | 25 +++++++++++------------ 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/string manipulation/alphabet_searching.js b/string manipulation/alphabet_searching.js index 8d527c4..93d8d39 100644 --- a/string manipulation/alphabet_searching.js +++ b/string manipulation/alphabet_searching.js @@ -19,21 +19,20 @@ * Output 2: false * ***************************************************************/ -function AlphabetSearching( string ) { - //SORT THE STRING & REMOVE DUPLICATES FROM THE STRING - let sortedStringArray = Array.from( new Set( string.split("").sort() ) ); - //COUNT THE ENGLISH ALPHABET CHARACTERS - let count = 0; - - //LOOP THROUGH STRING - for ( let i = 0; i < sortedStringArray.length; i++ ) { - if ( sortedStringArray[i].toLowerCase() >= "a" && sortedStringArray[i].toLowerCase() <= "z" ) { - count++; - } - } +function AlphabetSearching(string) { + //SORT THE STRING & REMOVE DUPLICATES FROM THE STRING + let sortedStringArray = Array.from(new Set(string.split("").sort())); + //COUNT THE ENGLISH ALPHABET CHARACTERS + let count = 0; - return ( count === 26 ) ? true : false; + //LOOP THROUGH STRING + for (let i = 0; i < sortedStringArray.length; i++) { + if (sortedStringArray[i].toLowerCase() >= "a" && sortedStringArray[i].toLowerCase() <= "z") { + count++; + } + } + return count === 26 ? true : false; } // KEEP THIS FUNCTION CALL HERE From d523b6e2f253024c6a587e59e723c9a612169088 Mon Sep 17 00:00:00 2001 From: Hardanish Singh <61027578+Hardanish-Singh@users.noreply.github.com> Date: Thu, 11 Dec 2025 10:42:10 -0500 Subject: [PATCH 03/74] Alphabet Soup --- string manipulation/alphabet_soup.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/string manipulation/alphabet_soup.js b/string manipulation/alphabet_soup.js index 772a908..8512362 100644 --- a/string manipulation/alphabet_soup.js +++ b/string manipulation/alphabet_soup.js @@ -21,7 +21,7 @@ ***************************************************************/ function AlphabetSoup(str) { - return str.split("").sort().join(""); + return str.split("").sort().join(""); } // KEEP THIS FUNCTION CALL HERE From 936fa27236641c928e5a6172c9c49c26bc3942a0 Mon Sep 17 00:00:00 2001 From: Hardanish Singh <61027578+Hardanish-Singh@users.noreply.github.com> Date: Thu, 11 Dec 2025 10:42:42 -0500 Subject: [PATCH 04/74] ASCII Convertion --- string manipulation/ascii_convertion.js | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/string manipulation/ascii_convertion.js b/string manipulation/ascii_convertion.js index 43602d4..4f63210 100644 --- a/string manipulation/ascii_convertion.js +++ b/string manipulation/ascii_convertion.js @@ -17,20 +17,19 @@ * Output 2: 979899 4242 * ***************************************************************/ -function ASCIIConversion( str ) { - let asciiValueString = new String(""); +function ASCIIConversion(str) { + let asciiValueString = new String(""); - for ( let i = 0; i < str.length; i++ ) { - if ( str[i] === " " ) { - asciiValueString += str[i]; - } - else { - asciiValueString += str.charCodeAt(i); - } + for (let i = 0; i < str.length; i++) { + if (str[i] === " ") { + asciiValueString += str[i]; + } else { + asciiValueString += str.charCodeAt(i); } + } - return asciiValueString; + return asciiValueString; } // KEEP THIS FUNCTION CALL HERE -console.log(ASCIIConversion(readline())); \ No newline at end of file +console.log(ASCIIConversion(readline())); From ef972add027a9e762047afad12c1e4d17a85816a Mon Sep 17 00:00:00 2001 From: Hardanish Singh <61027578+Hardanish-Singh@users.noreply.github.com> Date: Thu, 11 Dec 2025 10:43:43 -0500 Subject: [PATCH 05/74] Basic Roman Numerals --- string manipulation/basic_roman_numerals.js | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/string manipulation/basic_roman_numerals.js b/string manipulation/basic_roman_numerals.js index 08935ed..03feeef 100644 --- a/string manipulation/basic_roman_numerals.js +++ b/string manipulation/basic_roman_numerals.js @@ -24,16 +24,17 @@ ***************************************************************/ function BasicRomanNumerals(str) { - const NumeralsArray = { I: 1, V: 5, X: 10, L: 50, C: 100, D: 500, M: 1000 }; - let numeralString = str; - let currentIndex = numeralString[0]; - let numberTotal = NumeralsArray[currentIndex]; - for (let i = 1; i < numeralString.length; i++) { - if (NumeralsArray[currentIndex] >= NumeralsArray[numeralString[i]]) numberTotal += NumeralsArray[numeralString[i]]; - else numberTotal = numberTotal - NumeralsArray[numeralString[i - 1]] * 2 + NumeralsArray[numeralString[i]]; - currentIndex = numeralString[i]; - } - return numberTotal; + const NumeralsArray = { I: 1, V: 5, X: 10, L: 50, C: 100, D: 500, M: 1000 }; + let numeralString = str; + let currentIndex = numeralString[0]; + let numberTotal = NumeralsArray[currentIndex]; + for (let i = 1; i < numeralString.length; i++) { + if (NumeralsArray[currentIndex] >= NumeralsArray[numeralString[i]]) + numberTotal += NumeralsArray[numeralString[i]]; + else numberTotal = numberTotal - NumeralsArray[numeralString[i - 1]] * 2 + NumeralsArray[numeralString[i]]; + currentIndex = numeralString[i]; + } + return numberTotal; } // KEEP THIS FUNCTION CALL HERE console.log(BasicRomanNumerals(readline())); From b1e95416ef2f7b3a7ab5b4c175e08aeff6c0b59b Mon Sep 17 00:00:00 2001 From: Hardanish Singh <61027578+Hardanish-Singh@users.noreply.github.com> Date: Thu, 11 Dec 2025 10:44:55 -0500 Subject: [PATCH 06/74] Binary Reversal --- string manipulation/binary_reversal.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/string manipulation/binary_reversal.js b/string manipulation/binary_reversal.js index 05a445f..87efa12 100644 --- a/string manipulation/binary_reversal.js +++ b/string manipulation/binary_reversal.js @@ -27,11 +27,13 @@ function BinaryReversal(str) { let paddedBinaryRepresentation = (+str).toString(2); - while(paddedBinaryRepresentation.length % 8 !== 0) paddedBinaryRepresentation = String.fromCharCode(48) + paddedBinaryRepresentation; + while (paddedBinaryRepresentation.length % 8 !== 0) + paddedBinaryRepresentation = String.fromCharCode(48) + paddedBinaryRepresentation; let reversePaddedBinaryRepresentation = new String(""); - for(let i=paddedBinaryRepresentation.length-1; i>=0; i--) reversePaddedBinaryRepresentation += paddedBinaryRepresentation[i]; + for (let i = paddedBinaryRepresentation.length - 1; i >= 0; i--) + reversePaddedBinaryRepresentation += paddedBinaryRepresentation[i]; return parseInt(reversePaddedBinaryRepresentation, 2); } // KEEP THIS FUNCTION CALL HERE -console.log(BinaryReversal(readline())); \ No newline at end of file +console.log(BinaryReversal(readline())); From c48f03d5cd96122aa48ba6cb6105bc9ea009c580 Mon Sep 17 00:00:00 2001 From: Hardanish Singh <61027578+Hardanish-Singh@users.noreply.github.com> Date: Thu, 11 Dec 2025 10:45:13 -0500 Subject: [PATCH 07/74] Caesar Cipher --- string manipulation/caesar_cipher.js | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/string manipulation/caesar_cipher.js b/string manipulation/caesar_cipher.js index ccc8431..9afb3da 100644 --- a/string manipulation/caesar_cipher.js +++ b/string manipulation/caesar_cipher.js @@ -26,21 +26,19 @@ ***************************************************************/ function CaesarCipher(string, number) { - let caesarCiper = new String(""); - for(let i=0; i= 97 && value <= 122) caesarCiper += String.fromCharCode(string.charCodeAt(i)+number); - else if(value > 122) caesarCiper += String.fromCharCode(96+(value - 122)); - } - else if(string[i].match(/^[A-Z]+$/)) { - let value = Number(string.charCodeAt(i)+number); - if(value >= 65 && value <= 90) caesarCiper += String.fromCharCode(string.charCodeAt(i)+number); - else if(value > 90) caesarCiper += String.fromCharCode(64+(value - 90)); - } - else caesarCiper += string[i]; + let caesarCiper = new String(""); + for (let i = 0; i < string.length; i++) { + if (string[i].match(/^[a-z]+$/)) { + let value = Number(string.charCodeAt(i) + number); + if (value >= 97 && value <= 122) caesarCiper += String.fromCharCode(string.charCodeAt(i) + number); + else if (value > 122) caesarCiper += String.fromCharCode(96 + (value - 122)); + } else if (string[i].match(/^[A-Z]+$/)) { + let value = Number(string.charCodeAt(i) + number); + if (value >= 65 && value <= 90) caesarCiper += String.fromCharCode(string.charCodeAt(i) + number); + else if (value > 90) caesarCiper += String.fromCharCode(64 + (value - 90)); + } else caesarCiper += string[i]; } return caesarCiper; } // KEEP THIS FUNCTION CALL HERE -console.log(CaesarCipher(readline())); \ No newline at end of file +console.log(CaesarCipher(readline())); From c1fadb8153c472a414c059d29cfcb56342faa716 Mon Sep 17 00:00:00 2001 From: Hardanish Singh <61027578+Hardanish-Singh@users.noreply.github.com> Date: Thu, 11 Dec 2025 10:46:19 -0500 Subject: [PATCH 08/74] Calculator --- string manipulation/Calculator.js | 49 +++++++++++++------------------ 1 file changed, 21 insertions(+), 28 deletions(-) diff --git a/string manipulation/Calculator.js b/string manipulation/Calculator.js index 1de7597..804eb0e 100644 --- a/string manipulation/Calculator.js +++ b/string manipulation/Calculator.js @@ -2,7 +2,7 @@ * CODERBYTE CALCULATOR CHALLENGE * * * * Problem Statement * - * Have the function Calculator(str) take the str parameter * + * Have the function Calculator(str) take the str parameter * * being passed and evaluate the mathematical expression within * * in. For example, if str were "2+(3-1)*3" the output should * * be 8. Another example: if str were "(2-0)(6/2)" the output * @@ -26,46 +26,39 @@ * * ***************************************************************/ -function parse( str ) { - return Function(`'use strict'; return (${str})`)() +function parse(str) { + return Function(`'use strict'; return (${str})`)(); } -function Calculator(string) { +function Calculator(string) { let evaluateExpression = new String(""); let splittedString = string.split(""); let flag = false; - for( let i=0; i Date: Thu, 11 Dec 2025 14:12:43 -0500 Subject: [PATCH 09/74] Camel Case --- string manipulation/camelCase.js | 57 ++++++++++++++++---------------- 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/string manipulation/camelCase.js b/string manipulation/camelCase.js index 5c3e33d..e29c972 100644 --- a/string manipulation/camelCase.js +++ b/string manipulation/camelCase.js @@ -21,37 +21,38 @@ ***************************************************************/ function CamelCase(str) { - let string = str; - let camelCaseString = new String(""); - let camelCaseArray = new Array(); - for (let i = 0; i < string.length; i++) if (!(string[i].toLowerCase() >= "a" && string[i].toLowerCase() <= "z")) camelCaseArray.push(i); - if (camelCaseArray.length === 0) return string; - let position = 0; - let toggleFlag = 0; - for (let i = 0; i < camelCaseArray.length; i++) { + let string = str; + let camelCaseString = new String(""); + let camelCaseArray = new Array(); + for (let i = 0; i < string.length; i++) + if (!(string[i].toLowerCase() >= "a" && string[i].toLowerCase() <= "z")) camelCaseArray.push(i); + if (camelCaseArray.length === 0) return string; + let position = 0; + let toggleFlag = 0; + for (let i = 0; i < camelCaseArray.length; i++) { + toggleFlag = 0; + for (let j = position; j < string.length; j++) { + if (j == camelCaseArray[i]) { + position++; + break; + } + if (i == 0) camelCaseString += string[j].toLowerCase(); + else { + if (toggleFlag == 0) camelCaseString += string[j].toUpperCase(); + else camelCaseString += string[j].toLowerCase(); + } + position++; + toggleFlag++; + } + } toggleFlag = 0; - for (let j = position; j < string.length; j++) { - if (j == camelCaseArray[i]) { + for (let k = position; k < string.length; k++) { + if (toggleFlag == 0) camelCaseString += string[k].toUpperCase(); + else camelCaseString += string[k].toLowerCase(); position++; - break; - } - if (i == 0) camelCaseString += string[j].toLowerCase(); - else { - if (toggleFlag == 0) camelCaseString += string[j].toUpperCase(); - else camelCaseString += string[j].toLowerCase(); - } - position++; - toggleFlag++; + toggleFlag++; } - } - toggleFlag = 0; - for (let k = position; k < string.length; k++) { - if (toggleFlag == 0) camelCaseString += string[k].toUpperCase(); - else camelCaseString += string[k].toLowerCase(); - position++; - toggleFlag++; - } - return camelCaseString; + return camelCaseString; } // KEEP THIS FUNCTION CALL HERE From d4dec9795103b9fa8d947b900fb2074b922f7242 Mon Sep 17 00:00:00 2001 From: Hardanish Singh <61027578+Hardanish-Singh@users.noreply.github.com> Date: Fri, 12 Dec 2025 09:11:43 -0500 Subject: [PATCH 10/74] Codeland Username Validation --- .../codeland_username_validation.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/string manipulation/codeland_username_validation.js b/string manipulation/codeland_username_validation.js index d374724..e27373c 100644 --- a/string manipulation/codeland_username_validation.js +++ b/string manipulation/codeland_username_validation.js @@ -21,13 +21,14 @@ * * ***************************************************************/ -function CodelandUsernameValidation(string) { - if(string.length<4 || string.length>25) return false; - if(!string[0].match(/[a-zA-Z]/g)) return false; - if(string[string.length-1] === '_') return false; - for(let i=0; i 25) return false; + if (!string[0].match(/[a-zA-Z]/g)) return false; + if (string[string.length - 1] === "_") return false; + for (let i = 0; i < string.length; i++) + if (!(string[i].match(/[a-zA-Z]/g) || string[i].match(/[1-9]/g) | (string[i] === "_"))) return false; + return true; } -// KEEP THIS FUNCTION CALL HERE -console.log(CodelandUsernameValidation(readline())); \ No newline at end of file +// KEEP THIS FUNCTION CALL HERE +console.log(CodelandUsernameValidation(readline())); From 1a474ea4055091c8c3d3f2eda60ee151fc8d6382 Mon Sep 17 00:00:00 2001 From: Hardanish Singh <61027578+Hardanish-Singh@users.noreply.github.com> Date: Fri, 12 Dec 2025 15:11:10 -0500 Subject: [PATCH 11/74] Command Line --- string manipulation/command_line.js | 47 ++++++++++++++--------------- 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/string manipulation/command_line.js b/string manipulation/command_line.js index 306be5e..c3a8085 100644 --- a/string manipulation/command_line.js +++ b/string manipulation/command_line.js @@ -31,33 +31,32 @@ * * ***************************************************************/ -function CommandLine( string ) { - let splitStirngAtEqualSign = string.split("="); - let argumentsArray = new Array(); - let argumentsString = new String(""); +function CommandLine(string) { + let splitStirngAtEqualSign = string.split("="); + let argumentsArray = new Array(); + let argumentsString = new String(""); - for( let i=0; i Date: Fri, 12 Dec 2025 15:11:48 -0500 Subject: [PATCH 12/74] Consonant Count --- string manipulation/consonant_count.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/string manipulation/consonant_count.js b/string manipulation/consonant_count.js index 9065be3..e671387 100644 --- a/string manipulation/consonant_count.js +++ b/string manipulation/consonant_count.js @@ -14,16 +14,16 @@ * Output 2: 6 * * * ***************************************************************/ - -function ConsonantCount( str ) { - let count = 0; - let vowelRegex = /^[aeiouAEIOU]$/; - for( let i=0; i= 'a' && str[i].toLowerCase() <= 'z' ) { - count++; - } - } - return count; + +function ConsonantCount(str) { + let count = 0; + let vowelRegex = /^[aeiouAEIOU]$/; + for (let i = 0; i < str.length; i++) { + if (!str[i].match(vowelRegex) && str[i].toLowerCase() >= "a" && str[i].toLowerCase() <= "z") { + count++; + } + } + return count; } // keep this function call here From fde2ddd8d50edaa0bfeab967ba84a6f553cf9166 Mon Sep 17 00:00:00 2001 From: Hardanish Singh <61027578+Hardanish-Singh@users.noreply.github.com> Date: Fri, 12 Dec 2025 15:12:20 -0500 Subject: [PATCH 13/74] Correct Path --- string manipulation/correct_path.js | 132 ++++++++++++++-------------- 1 file changed, 66 insertions(+), 66 deletions(-) diff --git a/string manipulation/correct_path.js b/string manipulation/correct_path.js index 14db30c..bb3d882 100644 --- a/string manipulation/correct_path.js +++ b/string manipulation/correct_path.js @@ -37,98 +37,98 @@ let quotientMarkCount = 0; //LOOP THROUGH STRING & COUNT QUOTIENT MARKS for (let i = 0; i < string.length; i++) { - if (string[i] === "?") { - quotientMarkCount++; - } + if (string[i] === "?") { + quotientMarkCount++; + } } //IF QUOTIENTMARKCOUNT IS 1, THEN INIALIZE TO POSSIBLEMOVESARRAY if (quotientMarkCount === 1) { - combinationArray = possibleMovesArray; + combinationArray = possibleMovesArray; } //DYNAMIC FUNCTION WHICH MAKES MOVES ARRAY COMBINATION & RETURN ARRAY RECURSIVELY function makeMovesCombination(movesCount, movesArray) { - let combinationArrayCopy = []; + let combinationArrayCopy = []; - for (let i = 0; i < possibleMovesArray.length; i++) { - for (let j = 0; j < movesArray.length; j++) { - combinationArrayCopy.push(possibleMovesArray[i] + "" + movesArray[j]); + for (let i = 0; i < possibleMovesArray.length; i++) { + for (let j = 0; j < movesArray.length; j++) { + combinationArrayCopy.push(possibleMovesArray[i] + "" + movesArray[j]); + } } - } - return combinationArrayCopy; + return combinationArrayCopy; } //LOOP THROUGH QUOTIENTMARK & CONSTRUCT MOVES ARRAY RECURSIVELY for (let i = 2; i <= quotientMarkCount; i++) { - if (combinationArray.length === 0) { - combinationArray = makeMovesCombination(i, possibleMovesArray); - } else { - combinationArray = makeMovesCombination(i, combinationArray); - } + if (combinationArray.length === 0) { + combinationArray = makeMovesCombination(i, possibleMovesArray); + } else { + combinationArray = makeMovesCombination(i, combinationArray); + } } //LOOP THROUGH COMBINATION ARRAY & CONSTRUCT MOVES STRING & TRY EACH COMBINATION for (let i = 0; i < combinationArray.length; i++) { - let temp = 0; - let combinationString = new String(""); - - for (let j = 0; j < string.length; j++) { - if (string[j] === "?") { - combinationString += combinationArray[i][temp]; - temp++; - } else { - combinationString += string[j]; + let temp = 0; + let combinationString = new String(""); + + for (let j = 0; j < string.length; j++) { + if (string[j] === "?") { + combinationString += combinationArray[i][temp]; + temp++; + } else { + combinationString += string[j]; + } } - } - let isPathGood = makeArrayMovement(combinationString); - if (isPathGood === true) { - console.log(combinationString); - break; - } + let isPathGood = makeArrayMovement(combinationString); + if (isPathGood === true) { + console.log(combinationString); + break; + } } //CHECK STRING COMBINATION function makeArrayMovement(combinationString) { - let array = [ - [0, 0, 0, 0, 0], - [0, 0, 0, 0, 0], - [0, 0, 0, 0, 0], - [0, 0, 0, 0, 0], - [0, 0, 0, 0, 0], - ]; - let row = 0; - let column = 0; - - for (let i = 0; i < combinationString.length; i++) { - if (combinationString[i] === "r") { - column++; - } else if (combinationString[i] === "d") { - row++; - } else if (combinationString[i] === "l") { - column--; - } else if (combinationString[i] === "u") { - row--; + let array = [ + [0, 0, 0, 0, 0], + [0, 0, 0, 0, 0], + [0, 0, 0, 0, 0], + [0, 0, 0, 0, 0], + [0, 0, 0, 0, 0], + ]; + let row = 0; + let column = 0; + + for (let i = 0; i < combinationString.length; i++) { + if (combinationString[i] === "r") { + column++; + } else if (combinationString[i] === "d") { + row++; + } else if (combinationString[i] === "l") { + column--; + } else if (combinationString[i] === "u") { + row--; + } + + //IF PATH GOES OUT OF GRID + if (row < 0 || column < 0 || row > 4 || column > 4) { + break; + } + + //IF THE PATH IS ALREADY TRAVERSED, THEN RETURN FALSE + if (array[row][column] === 1) { + return false; + } + + array[row][column] = 1; } - //IF PATH GOES OUT OF GRID - if (row < 0 || column < 0 || row > 4 || column > 4) { - break; - } - - //IF THE PATH IS ALREADY TRAVERSED, THEN RETURN FALSE - if (array[row][column] === 1) { - return false; + if (row === 4 && column === 4) { + return true; + } else { + return false; } - - array[row][column] = 1; - } - - if (row === 4 && column === 4) { - return true; - } else { - return false; - } } From 73cf45d13085833cfefb2583de0a5acc5f8d667e Mon Sep 17 00:00:00 2001 From: Hardanish Singh <61027578+Hardanish-Singh@users.noreply.github.com> Date: Fri, 12 Dec 2025 15:13:12 -0500 Subject: [PATCH 14/74] Counting Minutes One --- string manipulation/counting_minutes_one.js | 85 ++++++++++----------- 1 file changed, 42 insertions(+), 43 deletions(-) diff --git a/string manipulation/counting_minutes_one.js b/string manipulation/counting_minutes_one.js index b549ec9..fc00de7 100644 --- a/string manipulation/counting_minutes_one.js +++ b/string manipulation/counting_minutes_one.js @@ -7,7 +7,7 @@ * (each properly formatted with a colon and am or pm) * * separated by a hyphen and return the total number of minutes * * between the two times. The time will be in a 12 hour clock * - * format. * + * format. * * For example: if str is 9:00am-10:00am then the * * output should be 60. If str is 1:00pm-11:00am the output * * should be 1320. * @@ -26,50 +26,49 @@ ***************************************************************/ function CountingMinutesI(dateString) { - let splitDateStringAtHiphen = dateString.split("-"); - let hours1; - let minutes1 = ""; - let ampm1 = ""; - let hours2; - let minutes2 = ""; - let ampm2 = ""; - for (let i = 0; i < splitDateStringAtHiphen.length; i++) { - let splitDateStringAtColon = splitDateStringAtHiphen[i].split(":"); - for (let j = 0; j < splitDateStringAtColon.length; j++) { - if (j == 0 && i == 0) hours1 = Number(splitDateStringAtColon[j]); - else if (j == 0 && i == 1) hours2 = Number(splitDateStringAtColon[j]); - else if (j == 1 && i == 0) { - for (let k = 0; k < splitDateStringAtColon[j].length; k++) { - if (k < 2) minutes1 += splitDateStringAtColon[j][k]; - else ampm1 += splitDateStringAtColon[j][k]; + let splitDateStringAtHiphen = dateString.split("-"); + let hours1; + let minutes1 = ""; + let ampm1 = ""; + let hours2; + let minutes2 = ""; + let ampm2 = ""; + for (let i = 0; i < splitDateStringAtHiphen.length; i++) { + let splitDateStringAtColon = splitDateStringAtHiphen[i].split(":"); + for (let j = 0; j < splitDateStringAtColon.length; j++) { + if (j == 0 && i == 0) hours1 = Number(splitDateStringAtColon[j]); + else if (j == 0 && i == 1) hours2 = Number(splitDateStringAtColon[j]); + else if (j == 1 && i == 0) { + for (let k = 0; k < splitDateStringAtColon[j].length; k++) { + if (k < 2) minutes1 += splitDateStringAtColon[j][k]; + else ampm1 += splitDateStringAtColon[j][k]; + } + } else if (j == 1 && i == 1) { + for (let k = 0; k < splitDateStringAtColon[j].length; k++) { + if (k < 2) minutes2 += splitDateStringAtColon[j][k]; + else ampm2 += splitDateStringAtColon[j][k]; + } + } } - } - else if (j == 1 && i == 1) { - for (let k = 0; k < splitDateStringAtColon[j].length; k++) { - if (k < 2) minutes2 += splitDateStringAtColon[j][k]; - else ampm2 += splitDateStringAtColon[j][k]; - } - } } - } - minutes1 = Number(minutes1); - minutes2 = Number(minutes2); - if (ampm1 === "pm" && hours1 <= 11) hours1 += 12; - if (ampm2 === "pm" && hours2 <= 11) hours2 += 12; - if (ampm1 === "am" && hours1 == 12) hours1 = 0; - if (ampm2 === "am" && hours2 == 12) hours2 = 0; - let minutesOneConverted = hours1 * 60 + minutes1; - let minutesTwoConverted = hours2 * 60 + minutes2; - if (minutesOneConverted > minutesTwoConverted) { - hours2 += 24; - let timeOne = hours2 * 60 + minutes2; - let timeTwo = hours1 * 60 + minutes1; - return timeOne - timeTwo; - } else { - let timeOne = hours2 * 60 + minutes2; - let timeTwo = hours1 * 60 + minutes1; - return timeOne - timeTwo; - } + minutes1 = Number(minutes1); + minutes2 = Number(minutes2); + if (ampm1 === "pm" && hours1 <= 11) hours1 += 12; + if (ampm2 === "pm" && hours2 <= 11) hours2 += 12; + if (ampm1 === "am" && hours1 == 12) hours1 = 0; + if (ampm2 === "am" && hours2 == 12) hours2 = 0; + let minutesOneConverted = hours1 * 60 + minutes1; + let minutesTwoConverted = hours2 * 60 + minutes2; + if (minutesOneConverted > minutesTwoConverted) { + hours2 += 24; + let timeOne = hours2 * 60 + minutes2; + let timeTwo = hours1 * 60 + minutes1; + return timeOne - timeTwo; + } else { + let timeOne = hours2 * 60 + minutes2; + let timeTwo = hours1 * 60 + minutes1; + return timeOne - timeTwo; + } } // KEEP THIS FUNCTION CALL HERE From 6083aa6180a6fbe25f2c70d4c93624a8166d45cf Mon Sep 17 00:00:00 2001 From: Hardanish Singh <61027578+Hardanish-Singh@users.noreply.github.com> Date: Fri, 12 Dec 2025 15:13:27 -0500 Subject: [PATCH 15/74] Counting Minutes --- string manipulation/counting_minutes.js | 56 ++++++++++++------------- 1 file changed, 27 insertions(+), 29 deletions(-) diff --git a/string manipulation/counting_minutes.js b/string manipulation/counting_minutes.js index ed9e081..95d4384 100644 --- a/string manipulation/counting_minutes.js +++ b/string manipulation/counting_minutes.js @@ -7,7 +7,7 @@ * (each properly formatted with a colon and am or pm) * * separated by a hyphen and return the total number of minutes * * between the two times. The time will be in a 12 hour clock * - * format. * + * format. * * For example: if str is 9:00am-10:00am then the * * output should be 60. If str is 1:00pm-11:00am the output * * should be 1320. * @@ -34,23 +34,22 @@ function CountingMinutes(dateString) { let minutes2 = ""; let ampm2 = ""; for (let i = 0; i < splitDateStringAtHiphen.length; i++) { - let splitDateStringAtColon = splitDateStringAtHiphen[i].split(":"); - for (let j = 0; j < splitDateStringAtColon.length; j++) { - if (j == 0 && i == 0) hours1 = Number(splitDateStringAtColon[j]); - else if (j == 0 && i == 1) hours2 = Number(splitDateStringAtColon[j]); - else if (j == 1 && i == 0) { - for (let k = 0; k < splitDateStringAtColon[j].length; k++) { - if (k < 2) minutes1 += splitDateStringAtColon[j][k]; - else ampm1 += splitDateStringAtColon[j][k]; - } - } - else if (j == 1 && i == 1) { - for (let k = 0; k < splitDateStringAtColon[j].length; k++) { - if (k < 2) minutes2 += splitDateStringAtColon[j][k]; - else ampm2 += splitDateStringAtColon[j][k]; - } + let splitDateStringAtColon = splitDateStringAtHiphen[i].split(":"); + for (let j = 0; j < splitDateStringAtColon.length; j++) { + if (j == 0 && i == 0) hours1 = Number(splitDateStringAtColon[j]); + else if (j == 0 && i == 1) hours2 = Number(splitDateStringAtColon[j]); + else if (j == 1 && i == 0) { + for (let k = 0; k < splitDateStringAtColon[j].length; k++) { + if (k < 2) minutes1 += splitDateStringAtColon[j][k]; + else ampm1 += splitDateStringAtColon[j][k]; + } + } else if (j == 1 && i == 1) { + for (let k = 0; k < splitDateStringAtColon[j].length; k++) { + if (k < 2) minutes2 += splitDateStringAtColon[j][k]; + else ampm2 += splitDateStringAtColon[j][k]; + } + } } - } } minutes1 = Number(minutes1); minutes2 = Number(minutes2); @@ -61,17 +60,16 @@ function CountingMinutes(dateString) { let minutesOneConverted = hours1 * 60 + minutes1; let minutesTwoConverted = hours2 * 60 + minutes2; if (minutesOneConverted > minutesTwoConverted) { - hours2 += 24; - let timeOne = hours2 * 60 + minutes2; - let timeTwo = hours1 * 60 + minutes1; - return timeOne - timeTwo; + hours2 += 24; + let timeOne = hours2 * 60 + minutes2; + let timeTwo = hours1 * 60 + minutes1; + return timeOne - timeTwo; } else { - let timeOne = hours2 * 60 + minutes2; - let timeTwo = hours1 * 60 + minutes1; - return timeOne - timeTwo; + let timeOne = hours2 * 60 + minutes2; + let timeTwo = hours1 * 60 + minutes1; + return timeOne - timeTwo; } - } - - // KEEP THIS FUNCTION CALL HERE - console.log(CountingMinutes(readline())); - \ No newline at end of file +} + +// KEEP THIS FUNCTION CALL HERE +console.log(CountingMinutes(readline())); From 92f7f1f7545bcc413ddeb318e24b4f0584bdd1e1 Mon Sep 17 00:00:00 2001 From: Hardanish Singh <61027578+Hardanish-Singh@users.noreply.github.com> Date: Fri, 12 Dec 2025 15:14:36 -0500 Subject: [PATCH 16/74] Dash Insert Two --- string manipulation/dash_insert_two.js | 27 ++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/string manipulation/dash_insert_two.js b/string manipulation/dash_insert_two.js index 1f36317..348fc13 100644 --- a/string manipulation/dash_insert_two.js +++ b/string manipulation/dash_insert_two.js @@ -25,16 +25,27 @@ function DashInsertII(number) { let string = String(number); let dashInsertTwo = new String(""); - for(let i=0; i0 && Number(string[i+1])>0) dashInsertTwo += string[i] + "-"; - else if(Number(string[i])%2===0 && Number(string[i+1])%2===0 && Number(string[i])>0 && Number(string[i+1])>0) dashInsertTwo += string[i] + "*"; + for (let i = 0; i < string.length; i++) { + if (i !== string.length - 1) { + if ( + Number(string[i]) % 2 !== 0 && + Number(string[i + 1]) % 2 !== 0 && + Number(string[i]) > 0 && + Number(string[i + 1]) > 0 + ) + dashInsertTwo += string[i] + "-"; + else if ( + Number(string[i]) % 2 === 0 && + Number(string[i + 1]) % 2 === 0 && + Number(string[i]) > 0 && + Number(string[i + 1]) > 0 + ) + dashInsertTwo += string[i] + "*"; else dashInsertTwo += string[i]; - } - else if(i===string.length-1) dashInsertTwo += string[i]; + } else if (i === string.length - 1) dashInsertTwo += string[i]; } return dashInsertTwo; } - + // KEEP THIS FUNCTION CALL HERE -console.log(DashInsertII(readline())); \ No newline at end of file +console.log(DashInsertII(readline())); From 44bba0808d21c53d1e21b795119cc6bebd2eccd8 Mon Sep 17 00:00:00 2001 From: Hardanish Singh <61027578+Hardanish-Singh@users.noreply.github.com> Date: Sat, 13 Dec 2025 14:32:43 -0500 Subject: [PATCH 17/74] Dash Insert --- string manipulation/dash_insert.js | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/string manipulation/dash_insert.js b/string manipulation/dash_insert.js index ecd83cd..b6e8ef8 100644 --- a/string manipulation/dash_insert.js +++ b/string manipulation/dash_insert.js @@ -15,24 +15,19 @@ * Output 2: 567-30 * ***************************************************************/ -function DashInsert( str ) { - //VARIABLE DECLARATION - let fs = ""; - //LOOP THROUGH STRING - for ( let i = 0; i < str.length; i++ ) { - if ( - i != str.length - 1 && - Number(str[i]) % 2 != 0 && - Number(str[i + 1]) % 2 != 0 - ) { - fs += str[i] + "-"; - } - else { - fs += str[i]; - } +function DashInsert(str) { + //VARIABLE DECLARATION + let fs = ""; + //LOOP THROUGH STRING + for (let i = 0; i < str.length; i++) { + if (i != str.length - 1 && Number(str[i]) % 2 != 0 && Number(str[i + 1]) % 2 != 0) { + fs += str[i] + "-"; + } else { + fs += str[i]; } - return fs; + } + return fs; } // KEEP THIS FUNCTION CALL HERE -console.log( DashInsert( readline() ) ); +console.log(DashInsert(readline())); From 73d99bd4c6c74116f088f275bec0f8a58ce68479 Mon Sep 17 00:00:00 2001 From: Hardanish Singh <61027578+Hardanish-Singh@users.noreply.github.com> Date: Sat, 13 Dec 2025 14:33:18 -0500 Subject: [PATCH 18/74] Different Cases --- string manipulation/different_cases.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/string manipulation/different_cases.js b/string manipulation/different_cases.js index 0c3ef98..4a242eb 100644 --- a/string manipulation/different_cases.js +++ b/string manipulation/different_cases.js @@ -26,11 +26,13 @@ function DifferentCases(string) { let punctuationRegex = /\w+|\s+|[^\s\w]+/g; - let array = string.match(punctuationRegex); + let array = string.match(punctuationRegex); let differentCases = new String(""); - for(let i=0; i Date: Sat, 13 Dec 2025 14:33:39 -0500 Subject: [PATCH 19/74] Distinct Characters --- string manipulation/distinct_characters.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/string manipulation/distinct_characters.js b/string manipulation/distinct_characters.js index c0016dc..3f6caf0 100644 --- a/string manipulation/distinct_characters.js +++ b/string manipulation/distinct_characters.js @@ -19,6 +19,6 @@ * Output 2: false * ***************************************************************/ -function DistinctCharacters( str ) { - return Array.from( new Set( str.split("") ) ).length >= 10 ? true : false; -} \ No newline at end of file +function DistinctCharacters(str) { + return Array.from(new Set(str.split(""))).length >= 10 ? true : false; +} From f9c5ed77210a0d0e38b4447d7e10f362b0de6a72 Mon Sep 17 00:00:00 2001 From: Hardanish Singh <61027578+Hardanish-Singh@users.noreply.github.com> Date: Sat, 13 Dec 2025 14:34:02 -0500 Subject: [PATCH 20/74] Ex Oh --- string manipulation/ex_oh.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/string manipulation/ex_oh.js b/string manipulation/ex_oh.js index 16dd4f0..f10dd75 100644 --- a/string manipulation/ex_oh.js +++ b/string manipulation/ex_oh.js @@ -23,17 +23,17 @@ ***************************************************************/ function ExOh(string) { - //VARIABLE DECLARATION - let x_count = 0; - let o_count = 0; - //LOOP THROUGH STRING - for (let i = 0; i < string.length; i++) { - if (string[i].toLowerCase() === "x") x_count++; - else if (string[i].toLowerCase() === "o") o_count++; - } - //CONDITIONAL CHECKING - if (x_count === o_count) return "true"; - else return "false"; + //VARIABLE DECLARATION + let x_count = 0; + let o_count = 0; + //LOOP THROUGH STRING + for (let i = 0; i < string.length; i++) { + if (string[i].toLowerCase() === "x") x_count++; + else if (string[i].toLowerCase() === "o") o_count++; + } + //CONDITIONAL CHECKING + if (x_count === o_count) return "true"; + else return "false"; } // KEEP THIS FUNCTION CALL HERE From afc506756beefd6aa486f5057d932aee1592693c Mon Sep 17 00:00:00 2001 From: Hardanish Singh <61027578+Hardanish-Singh@users.noreply.github.com> Date: Sat, 13 Dec 2025 14:34:16 -0500 Subject: [PATCH 21/74] First Reverse --- string manipulation/first_reverse.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/string manipulation/first_reverse.js b/string manipulation/first_reverse.js index c75959b..d717716 100644 --- a/string manipulation/first_reverse.js +++ b/string manipulation/first_reverse.js @@ -18,7 +18,7 @@ * Output 2: edoC evoL I * * * * Solution Efficiency * - * This user scored higher than 29.4% of users who solved this * + * This user scored higher than 29.4% of users who solved this * * challenge. * * * ***************************************************************/ @@ -26,6 +26,6 @@ function FirstReverse(string) { return string.split("").reverse().join(""); } - + // KEEP THIS FUNCTION CALL HERE -console.log(FirstReverse(readline())); \ No newline at end of file +console.log(FirstReverse(readline())); From e4ff36a9c826a52a06844e61db077658da4f5f1f Mon Sep 17 00:00:00 2001 From: Hardanish Singh <61027578+Hardanish-Singh@users.noreply.github.com> Date: Sat, 13 Dec 2025 14:34:36 -0500 Subject: [PATCH 22/74] FizzBuzz --- string manipulation/fizzbuzz.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/string manipulation/fizzbuzz.js b/string manipulation/fizzbuzz.js index 5e8d3fa..fc797eb 100644 --- a/string manipulation/fizzbuzz.js +++ b/string manipulation/fizzbuzz.js @@ -25,21 +25,21 @@ * Output 2: "1 2 Fizz 4 Buzz Fizz 7 8" * * * * Solution Efficiency * - * This user scored higher than 62.1% of users who solved this * + * This user scored higher than 62.1% of users who solved this * * challenge. * * * ***************************************************************/ -function FizzBuzz(num) { +function FizzBuzz(num) { let string = new String(""); - for(let i=1; i<=num; i++){ - if(i%3===0 && i%5===0) string += "FizzBuzz "; - else if(i%3===0) string += "Fizz "; - else if(i%5===0) string += "Buzz "; + for (let i = 1; i <= num; i++) { + if (i % 3 === 0 && i % 5 === 0) string += "FizzBuzz "; + else if (i % 3 === 0) string += "Fizz "; + else if (i % 5 === 0) string += "Buzz "; else string += i + " "; } return string.trim(); } - + // KEEP THIS FUNCTION CALL HERE -console.log(FizzBuzz(readline())); \ No newline at end of file +console.log(FizzBuzz(readline())); From dcf0ad473fd5ec56701b836b2576c8a7e8451d5b Mon Sep 17 00:00:00 2001 From: Hardanish Singh <61027578+Hardanish-Singh@users.noreply.github.com> Date: Sat, 13 Dec 2025 14:34:49 -0500 Subject: [PATCH 23/74] Formatted Division --- string manipulation/formatted_division.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/string manipulation/formatted_division.js b/string manipulation/formatted_division.js index 4d1bec4..59c92f1 100644 --- a/string manipulation/formatted_division.js +++ b/string manipulation/formatted_division.js @@ -5,7 +5,7 @@ * Have the function FormattedDivision(num1,num2) take both * * parameters being passed, divide num1 by num2, and return the * * result as a string with properly formatted commas and 4 * - * significant digits after the decimal place. * + * significant digits after the decimal place. * * * * For example: if num1 is 123456789 and num2 is 10000 * * the output should be "12,345.6789". * @@ -20,15 +20,15 @@ * Output 2: 1.0000 * * * * Solution Efficiency * - * This user scored higher than 53.8% of users who solved this * + * This user scored higher than 53.8% of users who solved this * * challenge. * * * ***************************************************************/ -function FormattedDivision(num1,num2) { - let array = ((num1/num2).toFixed(4)).split("."); +function FormattedDivision(num1, num2) { + let array = (num1 / num2).toFixed(4).split("."); return new String(new Intl.NumberFormat().format(array[0]) + "." + array[1]).toString(); } - + // KEEP THIS FUNCTION CALL HERE -console.log(FormattedDivision(readline())); \ No newline at end of file +console.log(FormattedDivision(readline())); From d31631c9661948a2b98e02b4edb0520fbcdc760b Mon Sep 17 00:00:00 2001 From: Hardanish Singh <61027578+Hardanish-Singh@users.noreply.github.com> Date: Sat, 13 Dec 2025 14:35:03 -0500 Subject: [PATCH 24/74] Formatted Numbers --- string manipulation/formatted_numbers.js | 29 ++++++++++++------------ 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/string manipulation/formatted_numbers.js b/string manipulation/formatted_numbers.js index e334875..b8e4b8f 100644 --- a/string manipulation/formatted_numbers.js +++ b/string manipulation/formatted_numbers.js @@ -21,20 +21,21 @@ * * ***************************************************************/ -function FormattedNumber(strArr) { - let noOfDecimals = strArr[0].split("."); - if(noOfDecimals.length > 2) return false; - let unformattedNumber = new String(""); - for(let i=0; i1?("."+noOfDecimals[1]) : ""); - let zeroPadding = 0; - for(let i=0; i 1) for(let i=0; i 2) return false; + let unformattedNumber = new String(""); + for (let i = 0; i < noOfDecimals[0].length; i++) if (strArr[0][i] !== ",") unformattedNumber += strArr[0][i]; + unformattedNumber = + new Intl.NumberFormat().format(unformattedNumber) + (noOfDecimals.length > 1 ? "." + noOfDecimals[1] : ""); + let zeroPadding = 0; + for (let i = 0; i < noOfDecimals[0].length; i++) { + if (noOfDecimals[0][i] === "0") zeroPadding++; + else break; + } + if (noOfDecimals[0].length > 1) for (let i = 0; i < zeroPadding; i++) unformattedNumber = "0" + unformattedNumber; + return strArr[0] === unformattedNumber ? true : false; } // KEEP THIS FUNCTION CALL HERE -console.log(FormattedNumber(readline())); \ No newline at end of file +console.log(FormattedNumber(readline())); From d6de03c288b2e40f24dd6e0e6f7a198513f231d0 Mon Sep 17 00:00:00 2001 From: Hardanish Singh <61027578+Hardanish-Singh@users.noreply.github.com> Date: Sat, 13 Dec 2025 14:35:28 -0500 Subject: [PATCH 25/74] HTML ELEMENTS --- string manipulation/html_elements.js | 31 ++++++++++++++++------------ 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/string manipulation/html_elements.js b/string manipulation/html_elements.js index 86d07b8..451d498 100644 --- a/string manipulation/html_elements.js +++ b/string manipulation/html_elements.js @@ -30,7 +30,7 @@ * Output 2: i * * * * Solution Efficiency * - * This user scored higher than 84.5% of users who solved this * + * This user scored higher than 84.5% of users who solved this * * challenge. * * * ****************************************************************/ @@ -42,17 +42,20 @@ function HTMLElements(string) { let closingTags = new Array(); let temp1 = new String(""); let temp2 = new String(""); - for(let i=0; i') temp1 += openingTags[i][j]; - for(let m=0; m") temp1 += openingTags[i][j]; + for (let m = 0; m < closingTags.length; m++) { temp2 = new String(""); - for(let n=0; n') temp2 += closingTags[m][n]; - if(temp1===temp2) { + for (let n = 0; n < closingTags[m].length; n++) + if (closingTags[m][n] !== "<" && closingTags[m][n] !== "/" && closingTags[m][n] !== ">") + temp2 += closingTags[m][n]; + if (temp1 === temp2) { openingTags.splice(i, 1); i--; closingTags.splice(m, 1); @@ -60,8 +63,10 @@ function HTMLElements(string) { } } } - return (openingTags.length === 0 ) ? true : openingTags[openingTags.length-1].slice(1).slice(0, openingTags[0].length-2); - } - - // KEEP THIS FUNCTION CALL HERE - console.log(HTMLElements(readline())); \ No newline at end of file + return openingTags.length === 0 + ? true + : openingTags[openingTags.length - 1].slice(1).slice(0, openingTags[0].length - 2); +} + +// KEEP THIS FUNCTION CALL HERE +console.log(HTMLElements(readline())); From 891b3be51c3af930902ad704a8d455f1207f8102 Mon Sep 17 00:00:00 2001 From: Hardanish Singh <61027578+Hardanish-Singh@users.noreply.github.com> Date: Sat, 13 Dec 2025 14:35:48 -0500 Subject: [PATCH 26/74] Letter Capitalize --- string manipulation/letter_capitalize.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/string manipulation/letter_capitalize.js b/string manipulation/letter_capitalize.js index 87c813e..4af8650 100644 --- a/string manipulation/letter_capitalize.js +++ b/string manipulation/letter_capitalize.js @@ -14,7 +14,7 @@ * Output 2: I Ran There * * * * Solution Efficiency * - * The user scored higher than 50.6% of users who solved this * + * The user scored higher than 50.6% of users who solved this * * challenge. * * * ***************************************************************/ @@ -22,9 +22,11 @@ function LetterCapitalize(string) { let splitStringAtSpace = string.split(" "); let letterCapitalizedString = new String(""); - for(let i=0; i Date: Sat, 13 Dec 2025 14:36:12 -0500 Subject: [PATCH 27/74] Letter Changes --- string manipulation/letter_changes.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/string manipulation/letter_changes.js b/string manipulation/letter_changes.js index e189b5d..8dde51f 100644 --- a/string manipulation/letter_changes.js +++ b/string manipulation/letter_changes.js @@ -26,15 +26,15 @@ function LetterChanges(string) { let lettersChangedString = new String(""); let lettersRegex = /^[A-Za-z]$/; let vowelRegex = /^[aeiouAEIOU]$/; - for(let i=0; i Date: Sat, 13 Dec 2025 14:36:34 -0500 Subject: [PATCH 28/74] Letter Counting I --- string manipulation/letter_count_one.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/string manipulation/letter_count_one.js b/string manipulation/letter_count_one.js index 48a9375..348185e 100644 --- a/string manipulation/letter_count_one.js +++ b/string manipulation/letter_count_one.js @@ -32,7 +32,7 @@ function LetterCountI(str) { for (let j = 0; j < array[i].length; j++) { let count = 0; for (let f = j; f < array[i].length; f++) if (array[i][j] == array[i][f]) count++; - if(count > 1) { + if (count > 1) { temp2d.push(array[i][j]); temp2d.push(count); } @@ -41,15 +41,15 @@ function LetterCountI(str) { } let maxElement = -1; let maxIndex = -1; - for(let i=0; i maxElement) { - maxElement = mainArray[i].length; - maxIndex = i; + for (let i = 0; i < mainArray.length; i++) { + if (mainArray[i].length === 0) continue; + if (mainArray[i].length > maxElement) { + maxElement = mainArray[i].length; + maxIndex = i; } } - return (maxIndex >= 0) ? array[maxIndex] : maxIndex; + return maxIndex >= 0 ? array[maxIndex] : maxIndex; } //KEEP THIS FUNCTION CALL HERE -console.log(LetterCountI(readline())); \ No newline at end of file +console.log(LetterCountI(readline())); From 659d22962fd0d0619b99c6b174a74cc07e450fc5 Mon Sep 17 00:00:00 2001 From: Hardanish Singh <61027578+Hardanish-Singh@users.noreply.github.com> Date: Sat, 13 Dec 2025 14:36:45 -0500 Subject: [PATCH 29/74] Longest Word --- string manipulation/longest_word.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/string manipulation/longest_word.js b/string manipulation/longest_word.js index d795a6f..a6be5f5 100644 --- a/string manipulation/longest_word.js +++ b/string manipulation/longest_word.js @@ -16,7 +16,7 @@ * Output 2: love * * * * Solution Efficiency * - * This user scored higher than 63.3% of users who solved this * + * This user scored higher than 63.3% of users who solved this * * challenge. * ***************************************************************/ @@ -24,9 +24,12 @@ function LongestWord(sentence) { let splitStringAtSpace = sentence.split(" "); let punctuationString = /[.,\/#!$%\^&\*;:{}=\-_`~()]/g; let maxLength = 0; - for(let i=0; i maxLength) maxLength = splitStringAtSpace[i].replace(punctuationString, "").length; - for(let i=0; i maxLength) + maxLength = splitStringAtSpace[i].replace(punctuationString, "").length; + for (let i = 0; i < splitStringAtSpace.length; i++) + if (maxLength === splitStringAtSpace[i].length) return splitStringAtSpace[i]; } // KEEP THIS FUNCTION CALL HERE -console.log(LongestWord(readline())); \ No newline at end of file +console.log(LongestWord(readline())); From c41d77a55894c94f80b8ba998fbcb1ddc1a6c7e4 Mon Sep 17 00:00:00 2001 From: Hardanish Singh <61027578+Hardanish-Singh@users.noreply.github.com> Date: Sat, 13 Dec 2025 14:37:11 -0500 Subject: [PATCH 30/74] Minimum Window SubString --- .../minimum_window_substring.js | 47 ++++++++++--------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/string manipulation/minimum_window_substring.js b/string manipulation/minimum_window_substring.js index 8b44a50..ee310c3 100644 --- a/string manipulation/minimum_window_substring.js +++ b/string manipulation/minimum_window_substring.js @@ -31,14 +31,13 @@ * * ***************************************************************/ - -function MinWindowSubstring (stringArray) { +function MinWindowSubstring(stringArray) { let string = stringArray[0]; let target = stringArray[1]; let targetDictionary = {}; let stringDictionary = {}; - for(let i=0; i rightPointer || rightPointer > string.length) break; - let flag = checkObjectKeysArray(Object.keys(targetDictionary), Object.keys(stringDictionary), targetDictionary, stringDictionary); - if(flag === true) { - if((rightPointer - leftPointer + 1) <= subStringLength){ + while (true) { + if (leftPointer > rightPointer || rightPointer > string.length) break; + let flag = checkObjectKeysArray( + Object.keys(targetDictionary), + Object.keys(stringDictionary), + targetDictionary, + stringDictionary + ); + if (flag === true) { + if (rightPointer - leftPointer + 1 <= subStringLength) { subStringLength = rightPointer - leftPointer + 1; lp = leftPointer; rp = rightPointer; } - if(string[leftPointer] in stringDictionary) stringDictionary[string[leftPointer]] -= 1; + if (string[leftPointer] in stringDictionary) stringDictionary[string[leftPointer]] -= 1; leftPointer++; - } - else { - if(string[rightPointer] in stringDictionary) stringDictionary[string[rightPointer]] += 1; + } else { + if (string[rightPointer] in stringDictionary) stringDictionary[string[rightPointer]] += 1; else stringDictionary[string[rightPointer]] = 1; - rightPointer++; + rightPointer++; } } return string.substring(lp, rp); -}; -function checkObjectKeysArray(array1, array2, targetDictionary, stringDictionary){ - if(array2.length===0 || array1.length > array2.length) return false; +} +function checkObjectKeysArray(array1, array2, targetDictionary, stringDictionary) { + if (array2.length === 0 || array1.length > array2.length) return false; let temp = false; - for(let i=0; i Date: Sat, 13 Dec 2025 14:37:23 -0500 Subject: [PATCH 31/74] Number Encoding --- string manipulation/number_encoding.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/string manipulation/number_encoding.js b/string manipulation/number_encoding.js index b70ca1a..e85de33 100644 --- a/string manipulation/number_encoding.js +++ b/string manipulation/number_encoding.js @@ -17,20 +17,20 @@ * Output 2: 10110-1 * * * * Solution Efficiency * - * This user scored higher than 30.7% of users who solved this * + * This user scored higher than 30.7% of users who solved this * * challenge. * * * ***************************************************************/ function NumberEncoding(string) { let numberEncoding = new String(""); - for(let i=0; i Date: Mon, 15 Dec 2025 09:51:18 -0500 Subject: [PATCH 32/74] Number Reverse --- string manipulation/number_reverse.js | 55 +++++++++++++-------------- 1 file changed, 27 insertions(+), 28 deletions(-) diff --git a/string manipulation/number_reverse.js b/string manipulation/number_reverse.js index 76d186b..3b9e291 100644 --- a/string manipulation/number_reverse.js +++ b/string manipulation/number_reverse.js @@ -15,39 +15,38 @@ * * ***************************************************************/ -function NumberReverse( str ) { - let numbers = []; - let temp = ''; +function NumberReverse(str) { + let numbers = []; + let temp = ""; - for( let i=0; i Date: Mon, 15 Dec 2025 09:51:29 -0500 Subject: [PATCH 33/74] Off Binary --- string manipulation/off_binary.js | 35 +++++++++++++++---------------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/string manipulation/off_binary.js b/string manipulation/off_binary.js index e9a9f7c..75f622b 100644 --- a/string manipulation/off_binary.js +++ b/string manipulation/off_binary.js @@ -2,13 +2,13 @@ * CODERBYTE OFF BINARY CHALLENGE * * * * Problem Statement * - * Have the function OffBinary(strArr) read the array of strings* + * Have the function OffBinary(strArr) read the array of strings* * stored in strArr, which will contain two elements, the first * - * will be a positive decimal number and the second element will* - * be a binary number. Your goal is to determine how many digits* + * will be a positive decimal number and the second element will* + * be a binary number. Your goal is to determine how many digits* * in the binary number need to be changed to represent the * * decimal number correctly (either 0 change to 1 or vice versa)* - * * + * * * For example: if strArr is ["56", "011000"] then your program * * should return 1 because only 1 digit needs to change in the * * binary number (the first zero needs to become a 1) to * @@ -23,21 +23,20 @@ * * ***************************************************************/ -function OffBinary(strArr) { +function OffBinary(strArr) { + let number = +strArr[0]; + let receivedBinary = strArr[1]; + let actualBinary = (number >>> 0).toString(2); + let count = 0; - let number = +strArr[0]; - let receivedBinary = strArr[1]; - let actualBinary = ( number >>> 0 ).toString(2); - let count = 0; - - for( let i=0; i Date: Mon, 15 Dec 2025 09:51:41 -0500 Subject: [PATCH 34/74] One Decremented --- string manipulation/one_decremented.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/string manipulation/one_decremented.js b/string manipulation/one_decremented.js index b1a9798..96db5ef 100644 --- a/string manipulation/one_decremented.js +++ b/string manipulation/one_decremented.js @@ -18,15 +18,15 @@ * * ***************************************************************/ -function OneDecremented( str ) { - let count = 0; - for( let i = 0; i < str.length-1; i++ ) { - if( Number( str[i] ) - Number( str[i+1] ) === 1 ) { - count++; - } +function OneDecremented(str) { + let count = 0; + for (let i = 0; i < str.length - 1; i++) { + if (Number(str[i]) - Number(str[i + 1]) === 1) { + count++; } - return count; + } + return count; } // KEEP THIS FUNCTION CALL HERE -console.log( OneDecremented( readline() ) ); \ No newline at end of file +console.log(OneDecremented(readline())); From 9de86c7e1965fdec3f5a5a8c681668a3075b8c87 Mon Sep 17 00:00:00 2001 From: Hardanish Singh <61027578+Hardanish-Singh@users.noreply.github.com> Date: Mon, 15 Dec 2025 09:51:51 -0500 Subject: [PATCH 35/74] Palindrome Two --- string manipulation/palindrome_two.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/string manipulation/palindrome_two.js b/string manipulation/palindrome_two.js index 41e3dab..ef9edf6 100644 --- a/string manipulation/palindrome_two.js +++ b/string manipulation/palindrome_two.js @@ -2,7 +2,7 @@ * CODERBYTE PALINDROME TWO CHALLENGE * * * * Problem Statement * - * Have the function PalindromeTwo(str) take the str parameter * + * Have the function PalindromeTwo(str) take the str parameter * * being passed and return the string true if the parameter is * * a palindrome, (the string is the same forward as it is * * backward) otherwise return the string false. The parameter * @@ -29,11 +29,13 @@ function PalindromeTwo(string) { let array = string.match(punctuationRegex); let originalStringWithoutPunctuation = new String(""); let reversedString = new String(""); - for(let i=0; i=0; i--) reversedString += originalStringWithoutPunctuation[i]; - if(originalStringWithoutPunctuation.toLowerCase() === reversedString.toLowerCase()) return true; - else return false; + for (let i = 0; i < array.length; i++) + if (array[i].match(/^[a-zA-Z]+$/)) originalStringWithoutPunctuation += array[i]; + for (let i = originalStringWithoutPunctuation.length - 1; i >= 0; i--) + reversedString += originalStringWithoutPunctuation[i]; + if (originalStringWithoutPunctuation.toLowerCase() === reversedString.toLowerCase()) return true; + else return false; } - + // KEEP THIS FUNCTION CALL HERE -console.log(PalindromeTwo(readline())); \ No newline at end of file +console.log(PalindromeTwo(readline())); From 956926491766a86d8d8b5d043548f944ea233de9 Mon Sep 17 00:00:00 2001 From: Hardanish Singh <61027578+Hardanish-Singh@users.noreply.github.com> Date: Mon, 15 Dec 2025 09:52:10 -0500 Subject: [PATCH 36/74] Palindrome --- string manipulation/palindrome.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/string manipulation/palindrome.js b/string manipulation/palindrome.js index 4df5927..359c9da 100644 --- a/string manipulation/palindrome.js +++ b/string manipulation/palindrome.js @@ -23,11 +23,11 @@ ***************************************************************/ function Palindrome(str) { - let originalString = str.replace(/\s/g, ""); - let reversedString = ""; - for (let i = originalString.length - 1; i >= 0; i--) reversedString += originalString[i]; - if (originalString === reversedString) return true; - else return false; + let originalString = str.replace(/\s/g, ""); + let reversedString = ""; + for (let i = originalString.length - 1; i >= 0; i--) reversedString += originalString[i]; + if (originalString === reversedString) return true; + else return false; } // KEEP THIS FUNCTION CALL HERE From 5abedb091611225c21ad09a62d49078948d13413 Mon Sep 17 00:00:00 2001 From: Hardanish Singh <61027578+Hardanish-Singh@users.noreply.github.com> Date: Mon, 15 Dec 2025 09:52:24 -0500 Subject: [PATCH 37/74] Add files via upload --- string manipulation/question_marks.js | 33 +++++++++++++-------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/string manipulation/question_marks.js b/string manipulation/question_marks.js index f87fc3d..54b569e 100644 --- a/string manipulation/question_marks.js +++ b/string manipulation/question_marks.js @@ -37,23 +37,22 @@ ***************************************************************/ function QuestionsMarks(string) { - let questionMarkCount = 0; - let temp = 0; - let flag = false; - for(let i=0; i Date: Mon, 15 Dec 2025 09:52:35 -0500 Subject: [PATCH 38/74] Run Length --- string manipulation/run_length.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/string manipulation/run_length.js b/string manipulation/run_length.js index 7b52faf..c18a220 100644 --- a/string manipulation/run_length.js +++ b/string manipulation/run_length.js @@ -20,23 +20,22 @@ * Output 2: 3w3b1w * * * * Solution Efficiency * - * This user scored higher than 42.4% of users who solved this * + * This user scored higher than 42.4% of users who solved this * * challenge. * ***************************************************************/ -function RunLength(string) { +function RunLength(string) { let array = string.split(""); - let counter = 0 ; + let counter = 0; let runLength = new String(""); - for(let i=0; i<=array.length; i++){ - if(array[i] !== array[i+1]) { + for (let i = 0; i <= array.length; i++) { + if (array[i] !== array[i + 1]) { runLength += counter + 1 + array[i]; counter = 0; - } - else counter++; + } else counter++; } return runLength; } // KEEP THIS FUNCTION CALL HERE -console.log(RunLength(readline())); \ No newline at end of file +console.log(RunLength(readline())); From d3c411788835118d9e9e895a5720224ca2fc2a58 Mon Sep 17 00:00:00 2001 From: Hardanish Singh <61027578+Hardanish-Singh@users.noreply.github.com> Date: Mon, 15 Dec 2025 09:52:47 -0500 Subject: [PATCH 39/74] Simple Password --- string manipulation/simple_password.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/string manipulation/simple_password.js b/string manipulation/simple_password.js index 455aa24..2f5db87 100644 --- a/string manipulation/simple_password.js +++ b/string manipulation/simple_password.js @@ -9,7 +9,7 @@ * 2. It must contain at least one number. * * 3. It must contain a punctuation mark. * * 4. It cannot have the word "password" in the string. * - * 5. It must be longer than 7 characters and * + * 5. It must be longer than 7 characters and * * shorter than 31 characters. * * If all the above constraints are met within the string, the * * your program should return the string true, otherwise your * @@ -26,15 +26,15 @@ * * ***************************************************************/ -function SimplePassword(str) { - finalString = str.replace(/[^\w\s]|_/g, "").replace(/\s+/g, " "); - if(str.length === finalString.length) return false; - if(str.match(/[a-zA-Z]/g).length === 0 || str.match(/[0-9]/g).length === 0) return false; - str = str.toLowerCase(); - if(str.includes("password")) return false; - if(str.length <= 7 || str.length >= 31) return false; - return true; +function SimplePassword(str) { + finalString = str.replace(/[^\w\s]|_/g, "").replace(/\s+/g, " "); + if (str.length === finalString.length) return false; + if (str.match(/[a-zA-Z]/g).length === 0 || str.match(/[0-9]/g).length === 0) return false; + str = str.toLowerCase(); + if (str.includes("password")) return false; + if (str.length <= 7 || str.length >= 31) return false; + return true; } - + // KEEP THIS FUNCTION CALL HERE -console.log(SimplePassword(readline())); \ No newline at end of file +console.log(SimplePassword(readline())); From 29f69eb6bf83dd6e5eebbc91c1eae38e5cb73bc1 Mon Sep 17 00:00:00 2001 From: Hardanish Singh <61027578+Hardanish-Singh@users.noreply.github.com> Date: Mon, 15 Dec 2025 09:53:12 -0500 Subject: [PATCH 40/74] Simple Symbols --- string manipulation/simple_symbols.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/string manipulation/simple_symbols.js b/string manipulation/simple_symbols.js index 43370a1..0e49c67 100644 --- a/string manipulation/simple_symbols.js +++ b/string manipulation/simple_symbols.js @@ -24,9 +24,11 @@ ***************************************************************/ function SimpleSymbols(string) { - for(let i=0; i= 'a' && string[i].toLowerCase() <= 'z') if(!(string[i-1] === '+' && string[i+1] === '+')) return false; + for (let i = 0; i < string.length; i++) + if (string[i].toLowerCase() >= "a" && string[i].toLowerCase() <= "z") + if (!(string[i - 1] === "+" && string[i + 1] === "+")) return false; return true; } //KEEP THIS FUNCTION CALL HERE -console.log(SimpleSymbols(readline())); \ No newline at end of file +console.log(SimpleSymbols(readline())); From c971f6a27cf662abd471c8f67aac0f9b37750504 Mon Sep 17 00:00:00 2001 From: Hardanish Singh <61027578+Hardanish-Singh@users.noreply.github.com> Date: Mon, 15 Dec 2025 09:53:25 -0500 Subject: [PATCH 41/74] Star Rating --- string manipulation/star_rating.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/string manipulation/star_rating.js b/string manipulation/star_rating.js index 5b37980..3e6d860 100644 --- a/string manipulation/star_rating.js +++ b/string manipulation/star_rating.js @@ -27,15 +27,15 @@ ***************************************************************/ function StarRating(string) { - let answer = new String(""); - for(let i=0; i= 0.75) answer += "full "; - else if((Number(string)%1) >= 0.25 && (Number(string)%1) < 0.75) answer += "half "; - else answer += "empty "; - for(let i=0; i= 0.75) answer += "full "; + else if (Number(string) % 1 >= 0.25 && Number(string) % 1 < 0.75) answer += "half "; + else answer += "empty "; + for (let i = 0; i < parseInt(5 - parseInt(Number(string))) - 1; i++) answer += "empty "; + return answer.trim(); } - + // KEEP THIS FUNCTION CALL HERE -console.log(StarRating(readline())); \ No newline at end of file +console.log(StarRating(readline())); From 8706ecb19f05eb77f8b0e0533a463e279173f5ce Mon Sep 17 00:00:00 2001 From: Hardanish Singh <61027578+Hardanish-Singh@users.noreply.github.com> Date: Mon, 15 Dec 2025 10:36:46 -0500 Subject: [PATCH 42/74] String Calculate --- string manipulation/string_calculate.js | 33 ++++++++++++++----------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/string manipulation/string_calculate.js b/string manipulation/string_calculate.js index b409b73..b517317 100644 --- a/string manipulation/string_calculate.js +++ b/string manipulation/string_calculate.js @@ -27,30 +27,35 @@ * * ***************************************************************/ -function parse( str ) { - return Function(`'use strict'; return (${str})`)() +function parse(str) { + return Function(`'use strict'; return (${str})`)(); } function StringCalculate(string) { let evaluateExpression = new String(""); let splittedString = string.split(""); let flag = false; - for(let i=0; i Date: Mon, 15 Dec 2025 10:36:57 -0500 Subject: [PATCH 43/74] String Changes --- string manipulation/string_changes.js | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/string manipulation/string_changes.js b/string manipulation/string_changes.js index f5eaa39..10a2465 100644 --- a/string manipulation/string_changes.js +++ b/string manipulation/string_changes.js @@ -11,7 +11,7 @@ * string (then remove the N). All other characters in the * * string will be lowercase letters. * * For example: "abcNdgM" should return "abcgg". * - * The final string will never be empty. * + * The final string will never be empty. * * * * Examples * * Input 1: "MrtyNNgMM" * @@ -28,26 +28,24 @@ function StringChanges(string) { let splitCharacters = string.split(""); - for(let i=0; i Date: Mon, 15 Dec 2025 10:38:08 -0500 Subject: [PATCH 44/74] String Expression --- string manipulation/string_expression.js | 64 ++++++++++++------------ 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/string manipulation/string_expression.js b/string manipulation/string_expression.js index b3bbd4b..8586ec6 100644 --- a/string manipulation/string_expression.js +++ b/string manipulation/string_expression.js @@ -22,43 +22,43 @@ * * ***************************************************************/ -function parse( str ) { - return Function(`'use strict'; return (${str})`)() +function parse(str) { + return Function(`'use strict'; return (${str})`)(); } function StringExpression(string) { let numberToWords = { - 'zero': 0, - 'one': 1, - 'two': 2, - 'three': 3, - 'four': 4, - 'five': 5, - 'six': 6, - 'seven': 7, - 'eight': 8, - 'nine': 9, - 'minus': '-', - 'plus' : '+' + zero: 0, + one: 1, + two: 2, + three: 3, + four: 4, + five: 5, + six: 6, + seven: 7, + eight: 8, + nine: 9, + minus: "-", + plus: "+", }; let wordsToNumber = { - 0: 'zero', - 1: 'one', - 2: 'two', - 3: 'three', - 4: 'four', - 5: 'five', - 6: 'six', - 7: 'seven', - 8: 'eight', - 9: 'nine' + 0: "zero", + 1: "one", + 2: "two", + 3: "three", + 4: "four", + 5: "five", + 6: "six", + 7: "seven", + 8: "eight", + 9: "nine", }; let count = 0; let position = 0; let expression = new String(""); - for(let i=0; i<=string.length; i++){ - if(count == 3 || count == 4 || count == 5) { - if(numberToWords[string.slice(position, i)] || numberToWords[string.slice(position, i)] == 0) { + for (let i = 0; i <= string.length; i++) { + if (count == 3 || count == 4 || count == 5) { + if (numberToWords[string.slice(position, i)] || numberToWords[string.slice(position, i)] == 0) { expression += numberToWords[string.slice(position, i)]; count = 0; position = i; @@ -68,12 +68,12 @@ function StringExpression(string) { } let value = String(parse(expression)); let result = new String(""); - for(let i=0; i Date: Tue, 16 Dec 2025 08:55:55 -0500 Subject: [PATCH 45/74] String Reduction --- string manipulation/string_reduction.js | 32 ++++++++++++------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/string manipulation/string_reduction.js b/string manipulation/string_reduction.js index 3adebf8..d880fde 100644 --- a/string manipulation/string_reduction.js +++ b/string manipulation/string_reduction.js @@ -34,30 +34,28 @@ * * ***************************************************************/ -function StringReduction(string) { +function StringReduction(string) { let stringReduction = new String(""); let stringReplacements = { - "ab": "c", - "ac": "b", - "bc": "a", - "ca": "b", - "cb": "a" + ab: "c", + ac: "b", + bc: "a", + ca: "b", + cb: "a", }; let flag = false; - for(let i=0; i Date: Tue, 16 Dec 2025 09:38:36 -0500 Subject: [PATCH 46/74] String Scramble --- string manipulation/string_scramble.js | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/string manipulation/string_scramble.js b/string manipulation/string_scramble.js index 0e47bde..9ce538e 100644 --- a/string manipulation/string_scramble.js +++ b/string manipulation/string_scramble.js @@ -2,7 +2,7 @@ * CODERBYTE STRING SCRAMBLE CHALLENGE * * * * Problem Statement * - * Have the function StringScramble(str1,str2) take both * + * Have the function StringScramble(str1,str2) take both * * parameters being passed and return the string true if a * * portion of str1 characters can be rearranged to match str2, * * otherwise return the string false. * @@ -24,24 +24,24 @@ ***************************************************************/ //SOLUTION 1 -function StringScramble(string1, string2) { +function StringScramble(string1, string2) { let array1 = string1.split(""); let array2 = string2.split(""); - for(let i=0; i Date: Tue, 16 Dec 2025 09:56:24 -0500 Subject: [PATCH 47/74] String ZigZag --- string manipulation/string_zigzag.js | 57 ++++++++++++++-------------- 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/string manipulation/string_zigzag.js b/string manipulation/string_zigzag.js index af6f046..ff7e315 100644 --- a/string manipulation/string_zigzag.js +++ b/string manipulation/string_zigzag.js @@ -24,34 +24,35 @@ ***************************************************************/ function StringZigzag(strArr) { - if(Number(strArr[1]) === 1) return strArr[0]; - let zigZagArray; - if(Number(strArr[1]) >= strArr[0].length) zigZagArray = new Array(Number(strArr[0].length)); - else zigZagArray = new Array(Number(strArr[1])); - for(let i=0; i=1 && count=Number(strArr[1]) && count<=(Number(strArr[1])+(Number(strArr[1])-1))) { - if(count == (Number(strArr[1])+(Number(strArr[1])-1))) { - row = 1; - count = row + 1; - } - else { - count++; - row--; - } - } + if (Number(strArr[1]) === 1) return strArr[0]; + let zigZagArray; + if (Number(strArr[1]) >= strArr[0].length) zigZagArray = new Array(Number(strArr[0].length)); + else zigZagArray = new Array(Number(strArr[1])); + for (let i = 0; i < zigZagArray.length; i++) zigZagArray[i] = new Array(Number(strArr[0].length)); + let row = 0, + column = 0, + count = 1; + for (let i = 0; i < strArr[0].length; i++) { + zigZagArray[row][column] = strArr[0][i]; + column++; + if (count >= 1 && count < Number(strArr[1])) { + count++; + row++; + } else if (count >= Number(strArr[1]) && count <= Number(strArr[1]) + (Number(strArr[1]) - 1)) { + if (count == Number(strArr[1]) + (Number(strArr[1]) - 1)) { + row = 1; + count = row + 1; + } else { + count++; + row--; + } } - let zigZagString = new String(""); - for(let i=0; i Date: Tue, 16 Dec 2025 10:57:34 -0500 Subject: [PATCH 48/74] Swipe Case Two --- string manipulation/swipe_case_two.js | 33 ++++++++++++++------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/string manipulation/swipe_case_two.js b/string manipulation/swipe_case_two.js index ae6695c..a187d02 100644 --- a/string manipulation/swipe_case_two.js +++ b/string manipulation/swipe_case_two.js @@ -28,26 +28,27 @@ function SwapII(str) { let swipeCaseTwo = new String(""); let start = 0; let end = 0; - for(let i=0; i Date: Tue, 16 Dec 2025 10:57:46 -0500 Subject: [PATCH 49/74] Time Convert --- string manipulation/time_convert.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/string manipulation/time_convert.js b/string manipulation/time_convert.js index 49dd333..3c51769 100644 --- a/string manipulation/time_convert.js +++ b/string manipulation/time_convert.js @@ -16,14 +16,14 @@ * Output 2: 0:45 * * * * Solution Efficiency * - * The user scored higher than 29.1% of users who solved this * + * The user scored higher than 29.1% of users who solved this * * challenge. * ***************************************************************/ function TimeConvert(num) { - let hours = Math.floor(num / 60); - let minutes = num % 60; - return hours + ":" + minutes; + let hours = Math.floor(num / 60); + let minutes = num % 60; + return hours + ":" + minutes; } // KEEP THIS FUNCTION CALL HERE From 38d22d5bcf6292586eb65b14ad47ded6d74fd0ea Mon Sep 17 00:00:00 2001 From: Hardanish Singh <61027578+Hardanish-Singh@users.noreply.github.com> Date: Tue, 16 Dec 2025 10:58:01 -0500 Subject: [PATCH 50/74] Vowel Count --- string manipulation/vowel_count.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/string manipulation/vowel_count.js b/string manipulation/vowel_count.js index f2f175f..75fc7d6 100644 --- a/string manipulation/vowel_count.js +++ b/string manipulation/vowel_count.js @@ -26,7 +26,6 @@ function VowelCount(str) { for (let i = 0; i < str.length; i++) if (str[i].match(vowelRegex)) vowelCount++; return vowelCount; } - + // KEEP THIS FUNCTION CALL HERE console.log(VowelCount(readline())); - \ No newline at end of file From a006dd44727c04b70be3ee2e841afa4531be16ed Mon Sep 17 00:00:00 2001 From: Hardanish Singh <61027578+Hardanish-Singh@users.noreply.github.com> Date: Tue, 16 Dec 2025 10:58:22 -0500 Subject: [PATCH 51/74] Word Count --- string manipulation/word_count.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/string manipulation/word_count.js b/string manipulation/word_count.js index 722b38f..873e2bc 100644 --- a/string manipulation/word_count.js +++ b/string manipulation/word_count.js @@ -16,8 +16,8 @@ ***************************************************************/ function WordCount(str) { - let string = str.trim().split(" "); - return string.length; + let string = str.trim().split(" "); + return string.length; } // KEEP THIS FUNCTION CALL HERE From c81849f4aebccd25e75ec012bcf27fa121548933 Mon Sep 17 00:00:00 2001 From: Hardanish Singh <61027578+Hardanish-Singh@users.noreply.github.com> Date: Tue, 16 Dec 2025 11:07:25 -0500 Subject: [PATCH 52/74] SQL Basic Sum --- SQL/sql_basic_sum.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/SQL/sql_basic_sum.sql b/SQL/sql_basic_sum.sql index af4effb..014bf85 100644 --- a/SQL/sql_basic_sum.sql +++ b/SQL/sql_basic_sum.sql @@ -5,7 +5,7 @@ * MySQL version: 5.5.56-log * * * * In this MySQL challenge, * -* your query should return LastName & the sum of Age from your table for all users with a LastName = Smith* +* your query should return LastName & the sum of Age from your table for all users with a LastName = Smith* * The column title of the summed ages should be SumAge. Your output should look like the following table. * * * * +----------+---------+ * @@ -15,6 +15,7 @@ * +----------+---------+ * * * *****************************************************************************************************************/ + SELECT LastName, SUM(Age) AS SumAge From 3a5f0b3ed98405c241bebc9dd8a44341ee252b31 Mon Sep 17 00:00:00 2001 From: Hardanish Singh <61027578+Hardanish-Singh@users.noreply.github.com> Date: Tue, 16 Dec 2025 11:08:35 -0500 Subject: [PATCH 53/74] SQL User Logins --- SQL/sql_user_logins.sql | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/SQL/sql_user_logins.sql b/SQL/sql_user_logins.sql index 0cd1699..77c8b6d 100644 --- a/SQL/sql_user_logins.sql +++ b/SQL/sql_user_logins.sql @@ -38,8 +38,8 @@ * Problem Statement * * In this MySQL challenge, the table provided shows all new users signing up on a specific * * date in the format YYYY-MM-DD. Your query should output the change from one month to the * - * next. Because the first month has no preceding month, your output should skip that row. * - * Your output should look like the following table. * + * next. Because the first month has no preceding month, your output should skip that row. * + * Your output should look like the following table. * * * * * * +-----------------+---------------------+ * @@ -53,9 +53,7 @@ * * ********************************************************************************************/ -/* - SOLUTION ONE WITHOUT LAG FUNCTION -*/ +-- SOLUTION ONE WITHOUT LAG FUNCTION SELECT MONTHNAME(STR_TO_DATE(MONTH(DateJoined), '%m')) AS Month, date1 - previous AS MonthToMonthChange From 2cff6c2f854f80f5dfa7239a88c54b3c3bf38bdf Mon Sep 17 00:00:00 2001 From: Hardanish Singh <61027578+Hardanish-Singh@users.noreply.github.com> Date: Tue, 16 Dec 2025 11:08:44 -0500 Subject: [PATCH 54/74] SQL User Logins --- SQL/sql_user_logins.sql | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/SQL/sql_user_logins.sql b/SQL/sql_user_logins.sql index 77c8b6d..895d1a1 100644 --- a/SQL/sql_user_logins.sql +++ b/SQL/sql_user_logins.sql @@ -78,10 +78,7 @@ FROM ) AS SubQuery2 WHERE previous > 0 -/* - SOLUTION 2 WITH LAG FUNCTION, USED IN MYSQL VERSION 8.0+ -*/ - +-- SOLUTION 2 WITH LAG FUNCTION, USED IN MYSQL VERSION 8.0+ SELECT MONTHNAME(STR_TO_DATE(MONTH(DateJoined), '%m')) AS Month, date1 - date2 AS MonthToMonthChange From 999dfe044f5aa3fa353e8a361de71a582b5b400c Mon Sep 17 00:00:00 2001 From: Hardanish Singh <61027578+Hardanish-Singh@users.noreply.github.com> Date: Tue, 16 Dec 2025 11:09:06 -0500 Subject: [PATCH 55/74] SQL Vendor Join --- SQL/sql_vendor_join.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SQL/sql_vendor_join.sql b/SQL/sql_vendor_join.sql index a9376f8..b3ed8c9 100644 --- a/SQL/sql_vendor_join.sql +++ b/SQL/sql_vendor_join.sql @@ -14,7 +14,7 @@ * +---------+---------------------+-------+ * * | 27| Machinx | 1| * * | 5| WaterBus Enterprise | 1| * - * | 36| Johnson and Sons | 2| * + * | 36| Johnson and Sons | 2| * * | 35| Shipping & Co. | 3| * * | 6| Alloy LLC | 3| * * | 40| FireConsulting | 5| * From 152cd441c5057221632e25b71affd2a7b9c8d132 Mon Sep 17 00:00:00 2001 From: Hardanish Singh <61027578+Hardanish-Singh@users.noreply.github.com> Date: Tue, 16 Dec 2025 11:09:54 -0500 Subject: [PATCH 56/74] Bracket Matcher --- searching/Bracket_Matcher.js | 36 +++++++++++++++--------------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/searching/Bracket_Matcher.js b/searching/Bracket_Matcher.js index 54a5d27..cbe34d5 100644 --- a/searching/Bracket_Matcher.js +++ b/searching/Bracket_Matcher.js @@ -1,5 +1,5 @@ /**************************************************************** - * CODERBYTE BRACKET MATCHER CHALLENGE * + * CODERBYTE BRACKET MATCHER CHALLENGE * * * * Problem Statement * * Have the function BracketMatcher(str) take the str parameter * @@ -9,7 +9,7 @@ * should be 1, but if str is "((hello (world))" the the output * * should be 0 because the brackets do not correctly match up. * * Only "(" and ")" will be used as brackets. If str contains * - * no brackets return 1. * + * no brackets return 1. * * * * Examples * * Input 1: "(coder)(byte))" * @@ -20,26 +20,20 @@ * * ***************************************************************/ -function BracketMatcher( str ) -{ - let count = 0; - for( let i=0; i Date: Tue, 16 Dec 2025 11:10:14 -0500 Subject: [PATCH 57/74] Even Pairs --- searching/EvenPairs.js | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/searching/EvenPairs.js b/searching/EvenPairs.js index 65ebf4e..09b2e48 100644 --- a/searching/EvenPairs.js +++ b/searching/EvenPairs.js @@ -20,23 +20,23 @@ * * ***************************************************************/ -function EvenPairs( str ) { - // SOLUTION 1 - for( let i=0; i Date: Tue, 16 Dec 2025 11:12:05 -0500 Subject: [PATCH 58/74] Even Pairs --- searching/EvenPairs.js | 72 ++++++++++++++++++++++++++++-------------- 1 file changed, 48 insertions(+), 24 deletions(-) diff --git a/searching/EvenPairs.js b/searching/EvenPairs.js index 09b2e48..b1cb402 100644 --- a/searching/EvenPairs.js +++ b/searching/EvenPairs.js @@ -20,41 +20,65 @@ * * ***************************************************************/ -function EvenPairs(str) { - // SOLUTION 1 +/* ============================================================== + SOLUTION 1 + ============================================================== + Iterates through the string and checks numeric sequences + to find two even numbers appearing next to each other. +================================================================ */ + +function EvenPairsSolution1(str) { for (let i = 0; i < str.length; i++) { - if (typeof +str[i] === "number" && typeof +str[i + 1] === "number") { + // Check if current and next characters are numbers + if (!isNaN(str[i]) && !isNaN(str[i + 1])) { for (let j = i + 1; j < str.length; j++) { - if (!+str[j]) { + // Stop when a non-numeric character is found + if (isNaN(str[j])) { break; } - if (+str[j] % 2 === 0 && +str[i] % 2 === 0) { + + // Check if both numbers are even + if (+str[i] % 2 === 0 && +str[j] % 2 === 0) { return true; } } } } return false; +} + +/* ============================================================== + SOLUTION 2 + ============================================================== + Uses string slicing to inspect adjacent numeric values + and determine if an even-number pair exists. +================================================================ */ - /* - SOLUTION 2 - for( let i=0; i Date: Tue, 16 Dec 2025 11:13:02 -0500 Subject: [PATCH 59/74] Palindromic SubString --- searching/Palindromic_Substring.js | 78 +++++++++++++++--------------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/searching/Palindromic_Substring.js b/searching/Palindromic_Substring.js index fa3c3a0..a2a9c95 100644 --- a/searching/Palindromic_Substring.js +++ b/searching/Palindromic_Substring.js @@ -24,53 +24,53 @@ * * ***************************************************************/ -function isPalindrome( string ) { - let leftPointer = 0; - let rightPointer = string.length - 1; +function isPalindrome(string) { + let leftPointer = 0; + let rightPointer = string.length - 1; - while( leftPointer < rightPointer ) { - if( string[leftPointer] !== string[rightPointer] ) { - return false; - } - leftPointer++; - rightPointer--; + while (leftPointer < rightPointer) { + if (string[leftPointer] !== string[rightPointer]) { + return false; } + leftPointer++; + rightPointer--; + } - return true; + return true; } -function reverseString( s ) { - let str = ""; - for( let i = s.length-1; i>=0; i-- ){ - str += s[i]; - } - return str; +function reverseString(s) { + let str = ""; + for (let i = s.length - 1; i >= 0; i--) { + str += s[i]; + } + return str; } -function PalindromicSubstring( str ) { - let PalindromicSubstrings = []; - for( let i=0; i max) { - max = PalindromicSubstrings[i].length; - index = i; - } + } + let max = -1; + let index = -1; + for (let i = 0; i < PalindromicSubstrings.length; i++) { + if (PalindromicSubstrings[i].length > max) { + max = PalindromicSubstrings[i].length; + index = i; } - return index === -1 ? "none" : PalindromicSubstrings[index]; + } + return index === -1 ? "none" : PalindromicSubstrings[index]; } - + // KEEP THIS FUNCTION CALL HERE -console.log(PalindromicSubstring(readline())); \ No newline at end of file +console.log(PalindromicSubstring(readline())); From a289d30d4ed06af68120bcdec540d7bb7b1d70ed Mon Sep 17 00:00:00 2001 From: Hardanish Singh <61027578+Hardanish-Singh@users.noreply.github.com> Date: Wed, 17 Dec 2025 09:13:21 -0500 Subject: [PATCH 60/74] Binary Converter --- math_fundamentals/Binary_Converter.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/math_fundamentals/Binary_Converter.ts b/math_fundamentals/Binary_Converter.ts index 69de6dc..f639bc8 100644 --- a/math_fundamentals/Binary_Converter.ts +++ b/math_fundamentals/Binary_Converter.ts @@ -18,16 +18,16 @@ * * ***************************************************************/ -function BinaryConverter( str: string ): number { - let sum: number = 0; - for( let i:number = str.length-1; i >= 0; i-- ) { - if( str[i] === '1' ) { - sum += Math.pow( 2, ( str.length - 1 ) - i ); - } +function BinaryConverter(str: string): number { + let sum: number = 0; + for (let i: number = str.length - 1; i >= 0; i--) { + if (str[i] === "1") { + sum += Math.pow(2, str.length - 1 - i); } - return sum; + } + return sum; } - + // KEEP THIS FUNCTION CALL HERE // @ts-ignore -console.log( BinaryConverter( readline() ) ); \ No newline at end of file +console.log(BinaryConverter(readline())); From 2d547306d70dcb68ff051fba1b2e916d25b765ef Mon Sep 17 00:00:00 2001 From: Hardanish Singh <61027578+Hardanish-Singh@users.noreply.github.com> Date: Wed, 17 Dec 2025 09:16:25 -0500 Subject: [PATCH 61/74] Consecutive --- math_fundamentals/Consecutive.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/math_fundamentals/Consecutive.ts b/math_fundamentals/Consecutive.ts index ee24b93..0ed5011 100644 --- a/math_fundamentals/Consecutive.ts +++ b/math_fundamentals/Consecutive.ts @@ -21,15 +21,15 @@ * * ***************************************************************/ -function Consecutive( arr: Array ): number { - let number_of_consecutives = 0; - arr = arr.sort( ( a,b ) => a - b ); - for( let i: number = arr[0]; i<=arr[arr.length-1]; i++ ) { - number_of_consecutives++; - } - return number_of_consecutives - arr.length; +function Consecutive(arr: Array): number { + let number_of_consecutives = 0; + arr = arr.sort((a, b) => a - b); + for (let i: number = arr[0]; i <= arr[arr.length - 1]; i++) { + number_of_consecutives++; + } + return number_of_consecutives - arr.length; } -// keep this function call here +// keep this function call here // @ts-ignore -console.log(Consecutive(readline())); \ No newline at end of file +console.log(Consecutive(readline())); From 18d3583fd0cfb39c5a5951f9b566e7d6dd096c9c Mon Sep 17 00:00:00 2001 From: Hardanish Singh <61027578+Hardanish-Singh@users.noreply.github.com> Date: Wed, 17 Dec 2025 09:16:44 -0500 Subject: [PATCH 62/74] Happy Numbers --- math_fundamentals/Happy_Numbers.js | 53 +++++++++++++----------------- 1 file changed, 22 insertions(+), 31 deletions(-) diff --git a/math_fundamentals/Happy_Numbers.js b/math_fundamentals/Happy_Numbers.js index a40e105..70f2096 100644 --- a/math_fundamentals/Happy_Numbers.js +++ b/math_fundamentals/Happy_Numbers.js @@ -3,9 +3,9 @@ * * * Problem Statement * * Have the function HappyNumbers(num) determine if a number is * - * Happy, which is a number whose sum of the square of the * + * Happy, which is a number whose sum of the square of the * * digits eventually converges to 1. Return true if it's a Happy* - * number, otherwise return false. * + * number, otherwise return false. * * * * For example: the number 10 is Happy because 1^2 + 0^2 * * converges to 1. * @@ -18,38 +18,29 @@ * Output 2: false * * * ***************************************************************/ - -function Calculate_Sum_Of_Square_Of_Digits( number ) -{ - let sum = 0; - for( let i=0; i Date: Wed, 17 Dec 2025 09:16:50 -0500 Subject: [PATCH 63/74] Happy Numbers --- math_fundamentals/Happy_Numbers.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/math_fundamentals/Happy_Numbers.js b/math_fundamentals/Happy_Numbers.js index 70f2096..dfb5196 100644 --- a/math_fundamentals/Happy_Numbers.js +++ b/math_fundamentals/Happy_Numbers.js @@ -7,7 +7,7 @@ * digits eventually converges to 1. Return true if it's a Happy* * number, otherwise return false. * * * - * For example: the number 10 is Happy because 1^2 + 0^2 * + * For example: the number 10 is Happy because 1^2 + 0^2 * * converges to 1. * * * * Examples * From 7945d650bd393c71446a5a60a58cda55c198065b Mon Sep 17 00:00:00 2001 From: Hardanish Singh <61027578+Hardanish-Singh@users.noreply.github.com> Date: Wed, 17 Dec 2025 09:16:57 -0500 Subject: [PATCH 64/74] Happy Numbers --- math_fundamentals/Happy_Numbers.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/math_fundamentals/Happy_Numbers.js b/math_fundamentals/Happy_Numbers.js index dfb5196..086c57e 100644 --- a/math_fundamentals/Happy_Numbers.js +++ b/math_fundamentals/Happy_Numbers.js @@ -8,7 +8,7 @@ * number, otherwise return false. * * * * For example: the number 10 is Happy because 1^2 + 0^2 * - * converges to 1. * + * converges to 1. * * * * Examples * * Input 1: 1 * From 3f79f494cedd97692d455ea17777ae2ee58b2ef4 Mon Sep 17 00:00:00 2001 From: Hardanish Singh <61027578+Hardanish-Singh@users.noreply.github.com> Date: Wed, 17 Dec 2025 09:17:04 -0500 Subject: [PATCH 65/74] Happy Numbers --- math_fundamentals/Happy_Numbers.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/math_fundamentals/Happy_Numbers.js b/math_fundamentals/Happy_Numbers.js index 086c57e..5a53ca7 100644 --- a/math_fundamentals/Happy_Numbers.js +++ b/math_fundamentals/Happy_Numbers.js @@ -11,10 +11,10 @@ * converges to 1. * * * * Examples * - * Input 1: 1 * + * Input 1: 1 * * Output 1: true * * * - * Input 2: 101 * + * Input 2: 101 * * Output 2: false * * * ***************************************************************/ From 526332d65d372f002fcd8fa144bfa492f34964af Mon Sep 17 00:00:00 2001 From: Hardanish Singh <61027578+Hardanish-Singh@users.noreply.github.com> Date: Wed, 17 Dec 2025 09:17:33 -0500 Subject: [PATCH 66/74] Happy Numbers --- math_fundamentals/Happy_Numbers.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/math_fundamentals/Happy_Numbers.js b/math_fundamentals/Happy_Numbers.js index 5a53ca7..a7f16fb 100644 --- a/math_fundamentals/Happy_Numbers.js +++ b/math_fundamentals/Happy_Numbers.js @@ -16,7 +16,7 @@ * * * Input 2: 101 * * Output 2: false * - * * + * * ***************************************************************/ function Calculate_Sum_Of_Square_Of_Digits(number) { From b7df5f92f84e1863a62b53f5222eae2b4a937638 Mon Sep 17 00:00:00 2001 From: Hardanish Singh <61027578+Hardanish-Singh@users.noreply.github.com> Date: Wed, 17 Dec 2025 09:17:38 -0500 Subject: [PATCH 67/74] Happy Numbers --- math_fundamentals/Happy_Numbers.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/math_fundamentals/Happy_Numbers.js b/math_fundamentals/Happy_Numbers.js index a7f16fb..5a53ca7 100644 --- a/math_fundamentals/Happy_Numbers.js +++ b/math_fundamentals/Happy_Numbers.js @@ -16,7 +16,7 @@ * * * Input 2: 101 * * Output 2: false * - * * + * * ***************************************************************/ function Calculate_Sum_Of_Square_Of_Digits(number) { From 4edfc6b9fa3b315e169fc3cf68be8a4c10068153 Mon Sep 17 00:00:00 2001 From: Hardanish Singh <61027578+Hardanish-Singh@users.noreply.github.com> Date: Wed, 17 Dec 2025 09:17:43 -0500 Subject: [PATCH 68/74] Happy Numbers --- math_fundamentals/Happy_Numbers.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/math_fundamentals/Happy_Numbers.js b/math_fundamentals/Happy_Numbers.js index 5a53ca7..a7f16fb 100644 --- a/math_fundamentals/Happy_Numbers.js +++ b/math_fundamentals/Happy_Numbers.js @@ -16,7 +16,7 @@ * * * Input 2: 101 * * Output 2: false * - * * + * * ***************************************************************/ function Calculate_Sum_Of_Square_Of_Digits(number) { From 45346113099406b3468b5aa00d64fff24452942e Mon Sep 17 00:00:00 2001 From: Hardanish Singh <61027578+Hardanish-Singh@users.noreply.github.com> Date: Wed, 17 Dec 2025 09:17:49 -0500 Subject: [PATCH 69/74] Happy Numbers --- math_fundamentals/Happy_Numbers.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/math_fundamentals/Happy_Numbers.js b/math_fundamentals/Happy_Numbers.js index a7f16fb..5a53ca7 100644 --- a/math_fundamentals/Happy_Numbers.js +++ b/math_fundamentals/Happy_Numbers.js @@ -16,7 +16,7 @@ * * * Input 2: 101 * * Output 2: false * - * * + * * ***************************************************************/ function Calculate_Sum_Of_Square_Of_Digits(number) { From 3ff4a1eb280f0275aa0ccb12e8ee3ef765616cf9 Mon Sep 17 00:00:00 2001 From: Hardanish Singh <61027578+Hardanish-Singh@users.noreply.github.com> Date: Wed, 17 Dec 2025 09:18:10 -0500 Subject: [PATCH 70/74] Missing Digit II --- math_fundamentals/Missing_Digit_II.js | 89 +++++++++++++-------------- 1 file changed, 43 insertions(+), 46 deletions(-) diff --git a/math_fundamentals/Missing_Digit_II.js b/math_fundamentals/Missing_Digit_II.js index a6419f1..dee8ab9 100644 --- a/math_fundamentals/Missing_Digit_II.js +++ b/math_fundamentals/Missing_Digit_II.js @@ -35,59 +35,56 @@ * * ***************************************************************/ -function parse( str ) { - return Function(`'use strict'; return (${str})`)() +function parse(str) { + return Function(`'use strict'; return (${str})`)(); } -function MissingDigitII( str ) { - let split_equation = str.split("="); - let left_side_expression = split_equation[0].trim(); - let right_side_expression = split_equation[1].trim(); +function MissingDigitII(str) { + let split_equation = str.split("="); + let left_side_expression = split_equation[0].trim(); + let right_side_expression = split_equation[1].trim(); - let i = 0; - while( i <= 9 ) { + let i = 0; + while (i <= 9) { + let equation1 = ""; + for (let k = 0; k < left_side_expression.length; k++) { + if (left_side_expression[k] === "?") { + equation1 += i; + } else { + equation1 += left_side_expression[k]; + } + } - let equation1 = ''; - for( let k = 0 ; k < left_side_expression.length; k++ ) { - if( left_side_expression[k] === "?" ) { - equation1 += i; - } - else { - equation1 += left_side_expression[k]; - } + for (let j = 0; j < 10; j++) { + let equation2 = ""; + for (let l = 0; l < right_side_expression.length; l++) { + if (right_side_expression[l] === "?") { + equation2 += j; + } else { + equation2 += right_side_expression[l]; } - - for( let j = 0; j < 10; j++ ) { - let equation2 = ''; - for( let l = 0 ; l < right_side_expression.length; l++ ) { - if( right_side_expression[l] === "?" ) { - equation2 += j; - } - else { - equation2 += right_side_expression[l]; - } - } - equation1 = equation1.trim(); - equation2 = equation2.trim(); - if( equation1.startsWith("0") ) { - equation1 = equation1.replace(/^0+/, ''); - if( equation1 === "" ) { - equation1 = "0"; - } - } - if( equation2.startsWith("0") ) { - equation2 = equation2.replace(/^0+/, ''); - if( equation2 === "" ) { - equation2 = "0"; - } - } - if( parse( equation1 ) === parse( equation2 ) ) { - return i + " " + j; - } + } + equation1 = equation1.trim(); + equation2 = equation2.trim(); + if (equation1.startsWith("0")) { + equation1 = equation1.replace(/^0+/, ""); + if (equation1 === "") { + equation1 = "0"; + } + } + if (equation2.startsWith("0")) { + equation2 = equation2.replace(/^0+/, ""); + if (equation2 === "") { + equation2 = "0"; } - i++; + } + if (parse(equation1) === parse(equation2)) { + return i + " " + j; + } } + i++; + } } // KEEP THIS FUNCTION CALL HERE -console.log( MissingDigitII( readline() ) ); \ No newline at end of file +console.log(MissingDigitII(readline())); From f54476f44476fee8a8e31b42ae1d3dad68f9e9a8 Mon Sep 17 00:00:00 2001 From: Hardanish Singh <61027578+Hardanish-Singh@users.noreply.github.com> Date: Wed, 17 Dec 2025 09:18:20 -0500 Subject: [PATCH 71/74] Missing Digit II --- math_fundamentals/Missing_Digit_II.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/math_fundamentals/Missing_Digit_II.js b/math_fundamentals/Missing_Digit_II.js index dee8ab9..0351f5a 100644 --- a/math_fundamentals/Missing_Digit_II.js +++ b/math_fundamentals/Missing_Digit_II.js @@ -1,5 +1,5 @@ /**************************************************************** - * CODERBYTE MISSING DIGIT II CHALLENGE * + * CODERBYTE MISSING DIGIT II CHALLENGE * * * * Problem Statement * * Have the function MissingDigitII(str) take the str parameter * From c00112bbf6634face7f734c909e4531bfe7ecf65 Mon Sep 17 00:00:00 2001 From: Hardanish Singh <61027578+Hardanish-Singh@users.noreply.github.com> Date: Wed, 17 Dec 2025 09:18:25 -0500 Subject: [PATCH 72/74] Missing Digit II --- math_fundamentals/Missing_Digit_II.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/math_fundamentals/Missing_Digit_II.js b/math_fundamentals/Missing_Digit_II.js index 0351f5a..dee8ab9 100644 --- a/math_fundamentals/Missing_Digit_II.js +++ b/math_fundamentals/Missing_Digit_II.js @@ -1,5 +1,5 @@ /**************************************************************** - * CODERBYTE MISSING DIGIT II CHALLENGE * + * CODERBYTE MISSING DIGIT II CHALLENGE * * * * Problem Statement * * Have the function MissingDigitII(str) take the str parameter * From 58146a960dde5bad3a210412d1e4abb23cb56b97 Mon Sep 17 00:00:00 2001 From: Hardanish Singh <61027578+Hardanish-Singh@users.noreply.github.com> Date: Wed, 17 Dec 2025 09:18:43 -0500 Subject: [PATCH 73/74] Missing Digit II --- math_fundamentals/Missing_Digit_II.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/math_fundamentals/Missing_Digit_II.js b/math_fundamentals/Missing_Digit_II.js index dee8ab9..0351f5a 100644 --- a/math_fundamentals/Missing_Digit_II.js +++ b/math_fundamentals/Missing_Digit_II.js @@ -1,5 +1,5 @@ /**************************************************************** - * CODERBYTE MISSING DIGIT II CHALLENGE * + * CODERBYTE MISSING DIGIT II CHALLENGE * * * * Problem Statement * * Have the function MissingDigitII(str) take the str parameter * From c47e5b379d2e0c442c9a9cf3b0b82a999c4d81e9 Mon Sep 17 00:00:00 2001 From: Hardanish Singh <61027578+Hardanish-Singh@users.noreply.github.com> Date: Wed, 17 Dec 2025 09:18:51 -0500 Subject: [PATCH 74/74] Missing Digit II --- math_fundamentals/Missing_Digit_II.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/math_fundamentals/Missing_Digit_II.js b/math_fundamentals/Missing_Digit_II.js index 0351f5a..dee8ab9 100644 --- a/math_fundamentals/Missing_Digit_II.js +++ b/math_fundamentals/Missing_Digit_II.js @@ -1,5 +1,5 @@ /**************************************************************** - * CODERBYTE MISSING DIGIT II CHALLENGE * + * CODERBYTE MISSING DIGIT II CHALLENGE * * * * Problem Statement * * Have the function MissingDigitII(str) take the str parameter *