This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//My solution to this Hackerank challenge...https://www.hackerrank.com/challenges/30-2d-arrays/problem?isFullScreen=true | |
'use strict'; | |
process.stdin.resume(); | |
process.stdin.setEncoding('utf-8'); | |
let inputString = ''; | |
let currentLine = 0; | |
process.stdin.on('data', function(inputStdin) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const fs = require('fs'); | |
process.stdin.resume(); | |
process.stdin.setEncoding('utf-8'); | |
let inputString = ''; | |
let currentLine = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getTotalX(a, b) { | |
// Write your code here | |
let start = Math.max(...a); | |
let end = Math.min(...b); | |
let count = 0; | |
for(let i = start; i <= end; i++){ | |
let arr_factors = a.filter((e) => i % e == 0); | |
let arr_multiples = b.filter((e) => e % i == 0); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Hackerank challenge...https://www.hackerrank.com/challenges/grading/problem?isFullScreen=true | |
function gradingStudents(grades) { | |
// Write your code here | |
const newArray = grades.map((item) => { | |
if(item >= 38 ){ | |
const quotient = Math.floor(item / 5); | |
const nextMultiple = (quotient + 1) * 5; | |
item = (nextMultiple - item) < 3 ? nextMultiple : item; | |
} | |
return item |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#https://www.hackerrank.com/challenges/30-abstract-classes/problem?isFullScreen=true | |
class MyBook < Book | |
attr_accessor :price | |
attr_accessor :author, :title | |
# Class Constructor | |
# | |
# Parameters: | |
# title - The book's title. | |
# author - The book's author. | |
# price - The book's price. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function birthday(s, d, m) { | |
// Write your code here | |
let count = 0; | |
s.map((item, index) => { | |
let sum = item; | |
for (let i=index+1; i < (index+m) ; i++ ){ | |
if (i < s.length){ | |
sum += s[i]; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//https://www.hackerrank.com/challenges/divisible-sum-pairs/problem?isFullScreen=true&h_r=next-challenge&h_v=zen | |
function divisibleSumPairs(n, k, ar) { | |
// Write your code here | |
let count = 0; | |
let sum = 0; | |
ar.map((item, index) => { | |
for (let i=index + 1; i < ar.length; i++){ | |
sum = item + ar[i] ; | |
if( sum % k == 0){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//https://www.hackerrank.com/challenges/30-linked-list/problem?isFullScreen=true | |
process.stdin.resume(); | |
process.stdin.setEncoding('ascii'); | |
var input_stdin = ""; | |
var input_stdin_array = ""; | |
var input_currentline = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//https://www.hackerrank.com/challenges/sock-merchant/problem?isFullScreen=true | |
function sockMerchant(n, ar) { | |
// Write your code here | |
let count = 0; | |
let checked_numbers = []; | |
for (let item of ar){ | |
if (checked_numbers.includes(item) == false){ | |
let frequency = 0; | |
ar.forEach((value) => value == item && frequency++); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//https://www.hackerrank.com/challenges/migratory-birds/problem?isFullScreen=true | |
function migratoryBirds(arr) { | |
// Write your code here | |
let count = 0; | |
let value = 0; | |
for(let item=1; item<=5; item++){ | |
let frequency = 0; | |
arr.forEach((val) => val == item && frequency++) | |
if (frequency > count || (frequency == count && item < value)){ |
OlderNewer