Skip to content

Instantly share code, notes, and snippets.

View yashikagarg13's full-sized avatar

Yashika Garg yashikagarg13

View GitHub Profile
@yashikagarg13
yashikagarg13 / ChristmasTree.js
Created February 16, 2016 12:08
Hacker Rank - JS Challenged
function processData(input) {
var flag = true;
var rows = 8;
var str = '';
for(var i=0; i<=rows; i++) {
for(j=rows-i; j > 0; j--) {
str += ' ';
}
if (i == 0 && flag) {
const fns = [
function () {
console.log(1)
},
function () {
console.log(2)
},
function () {
console.log(3)
}
var R = require("ramda");
var sales = [ {id: 1, price: 500}, {id: 2, price: 1500}, {id: 3, price: 750}, {id: 4, price: 1750}, {id: 5, price: 150}, {id: 3, price: 750}, ];
var resultWithoutRamda = sales.filter(sale => sale.price < 1000)
.map(sale => sale.price)
.sort((a, b) => a-b);
console.log(resultWithoutRamda);
var R = require("ramda");
//
// get top 3 vetted Frontend Developers names,
// who completed hackerrank with the score >=90
// ordered by rate: from lower to higher.
var hackerrankResults = [
{hackerrank: 90, name: "Maria", category: "Frontend", vetted: true, rate: "1000"},
{hackerrank: 20, name: "Maria", category: "Frontend", vetted: true, rate: "1000"},
{hackerrank: 100, name: "Maria", category: "Frontend", vetted: true, rate: "1000"},
"use strict";
var R = require("ramda");
var hackerrankResults = [
{hackerrank: 90, name: "Maria", category: "Frontend", vetted: true, rate: "1000"},
{hackerrank: 20, name: "Maria", category: "Frontend", vetted: true, rate: "1000"},
{hackerrank: 100, name: "Maria", category: "Frontend", vetted: true, rate: "1000"},
{hackerrank: 100, name: "Galina", category: "Frontend", vetted: true, rate: "2000"},
{hackerrank: 95, name: "Olga", category: "Frontend", vetted: true, rate: "3000"},
@yashikagarg13
yashikagarg13 / HackerRank - Circular Array Rotation
Created September 16, 2016 09:42
Problem Solving in Funtional Programming Way - Sep 16, 2016
//https://www.hackerrank.com/challenges/circular-array-rotation
function processData(input) {
var inputSplit = input.split("\n");
var n = Number(inputSplit[0].split(" ")[0]);
var k = Number(inputSplit[0].split(" ")[1]);
var q = Number(inputSplit[0].split(" ")[2]);
var arr = inputSplit[1].split(" ").map(Number);
var newArr = (Array(k).fill()).reduce(function(memo, item) {
var ele = memo.pop();
@yashikagarg13
yashikagarg13 / HackerRank - Algorithms - Compare the Triplets
Last active February 23, 2017 14:19
Hacker Rank - Algorithms Practise 1
// https://www.hackerrank.com/challenges/compare-the-triplets
process.stdin.resume();
process.stdin.setEncoding('ascii');
var input_stdin = "";
var input_stdin_array = "";
var input_currentline = 0;
process.stdin.on('data', function (data) {
@yashikagarg13
yashikagarg13 / Hacker Rank - Algorithms - A Very Big Sum
Last active February 23, 2017 14:23
Hacker Rank - Algorithms Practise 2
process.stdin.resume();
process.stdin.setEncoding('ascii');
var input_stdin = "";
var input_stdin_array = "";
var input_currentline = 0;
process.stdin.on('data', function (data) {
input_stdin += data;
});
@yashikagarg13
yashikagarg13 / Hacker Rank - Algorithms - Diagonal Difference
Created February 23, 2017 14:22
Hacker Rank - Algorithms - Diagonal Difference
// https://www.hackerrank.com/challenges/diagonal-difference
process.stdin.resume();
process.stdin.setEncoding('ascii');
var input_stdin = "";
var input_stdin_array = "";
var input_currentline = 0;
process.stdin.on('data', function (data) {
@yashikagarg13
yashikagarg13 / flatten-array.js
Created February 28, 2017 16:49
Flatten Arrays
function flatten(arr) {
return arr.reduce(function (acc, item) {
if (item instanceof Array) {
return acc.concat(flatten(item))
} else {
return acc.concat(item)
}
}, []);
}