Skip to content

Instantly share code, notes, and snippets.

<input type="checkbox" id="offcanvas" class="toggle" />
<div class="wrapper">
<!--- wrapper content here --->
</div>
<section>
<div class="container">
<div class="row">
<h2>Lorem ipsum dolor sit amet.</h2>
<p>Lorem ipsum......</p>
</div>
<!--- add as many rows needed --->
</div>
</section>
<div class="wrapper">
<aside>
<nav>
<ul>
<li>nav_1</li>
<li>nav_2</li>
<li>nav_3</li>
<li>nav_4</li>
<li>nav_5</li>
</ul>
@adyngom
adyngom / rolls.js
Created June 1, 2019 16:38
exercise solution for the rolls challenge
import { coinsJar } from './oneKCoins';
import { displayRollsMessage, getQuotientRemainder, groupBy } from './Utils';
const coinRolls = { "1": 50, "5": 40, "10": 50, "25": 40 };
const coinLabels = {
"1": "Pennies",
"5": "Nickels",
"10": "Dimes",
"25": "Quarters"
};
@adyngom
adyngom / oneKCoins.js
Created June 1, 2019 04:24
Array of thousand coins
export const coinsJar = [
5,
25,
1,
5,
1,
1,
1,
5,
5,
var tenkTickets=[50,80,10,60,60,20,10,50,60,30,10,50,20,20,30,10,20,10,50,20,80,50,20,60,30,40,10,80,20,20,10,20,90,70,60,90,30,10,80,50,70,30,20,80,60,90,90,30,80,90,80,60,10,60,60,90,70,10,80,20,70,50,40,70,40,90,90,50,30,70,50,50,90,40,50,70,10,20,10,90,70,50,70,70,20,10,70,70,60,80,90,70,80,50,20,80,70,20,80,70,90,70,10,50,30,40,20,40,90,10,90,40,90,10,10,40,30,80,90,70,50,10,10,60,30,20,70,80,40,10,70,60,70,10,10,50,40,60,60,80,50,10,10,20,90,30,40,40,90,10,90,20,90,80,80,80,20,80,80,80,20,70,40,20,30,20,10,40,60,90,90,90,70,20,30,50,30,10,80,50,10,60,10,80,70,80,20,90,40,80,70,90,10,80,10,30,10,70,90,10,20,50,70,30,10,70,90,40,50,60,80,30,70,80,50,10,50,60,80,30,20,10,30,80,60,60,40,10,90,70,60,20,80,80,10,70,90,80,30,50,60,80,50,30,30,10,20,80,50,90,10,70,60,20,80,60,70,40,80,30,60,10,90,50,10,40,50,20,80,10,20,40,20,80,50,80,30,30,40,40,30,40,10,60,60,90,10,80,50,80,90,30,90,60,80,60,30,90,10,30,10,20,80,60,70,50,50,60,30,30,50,80,60,90,90,60,90,50,80,40,90,20,50,70,10,30,70,70,30,30,20,70,60,60,10,10
var onekTickets=[40,80,70,50,30,90,30,50,40,50,80,10,40,60,60,20,70,60,90,20,20,90,70,60,40,20,20,60,70,60,20,30,50,50,40,90,50,40,30,40,60,80,50,60,60,90,90,80,40,20,50,80,20,90,90,80,40,20,80,50,20,60,30,30,80,60,70,90,80,30,40,40,60,10,30,90,70,50,70,80,70,40,20,20,10,70,30,60,60,20,50,50,50,70,20,40,70,30,80,70,40,80,20,60,40,10,30,10,30,80,70,70,90,20,40,50,90,30,70,50,60,70,60,90,80,30,30,50,40,20,10,30,80,70,80,80,40,50,50,30,50,20,50,60,50,60,60,90,70,60,90,70,20,20,30,10,30,70,30,20,10,20,40,70,20,20,70,50,10,80,50,70,40,20,40,90,90,90,90,60,80,30,50,70,30,60,90,30,30,10,10,40,40,30,50,90,50,10,90,30,30,40,80,90,50,30,80,50,50,20,40,90,90,50,50,60,30,20,90,90,20,30,10,90,50,20,10,10,90,60,50,60,40,50,40,90,80,40,10,40,80,60,50,80,30,40,10,30,20,70,10,30,80,10,90,30,90,30,10,60,90,20,10,90,50,30,80,10,70,20,70,10,60,70,20,30,90,70,80,30,30,10,60,90,10,30,70,70,90,30,20,20,80,20,20,30,60,60,30,60,50,80,10,30,80,30,80,60,90,70,30,30,90,40,40,60,20,30,50,30,60,50,60,30,50,60,50,80,90,90,60,20,80,30,20,10
function randomCoins(x = 1000) {
const coins = [10,20,30,40,50,60,70,80,90];
const lt = coins.length;
let bag = [];
let ct = 0;
function randomCoin() {
return coins[Math.floor((Math.random() * Math.floor(lt)))]
}
while (ct < x) {
if(!Array.prototype.uniq) {
Array.prototype.uniq = function() {
return this.reduce( (arr, val) => {
if (!arr.includes(val)) arr.push(val);
return arr;
}, [] )
}
}
/**
* Couple of possible solutions to the Sock Merchant challenge on Hacker Rank
* https://www.hackerrank.com/challenges/sock-merchant/problem
**/
// Solution 1
// Video tutorial can be viewed: https://youtu.be/DRp6naqL5uc
function sortAndCount( n, arr ) {
let sorted = arr.sort( (a,b) => a - b);
let pairs = 0;