Skip to content

Instantly share code, notes, and snippets.

View Aldizh's full-sized avatar

Aldi Zhupani Aldizh

View GitHub Profile
@Aldizh
Aldizh / matchingRects.js
Created January 25, 2021 16:32
Pairs of similar rectangles
/*
Given a 2D array A[][2] of size N (1 ≤ N ≤ 103), where A[i][0] and A[i][1] denotes the length and breadth of rectangle i respectively.
Two rectangle i and j where (i < j) are similar if the ratio of their length and breadth is equal
A[i][0] / A[i][1] = A[j][0] / A[j][1]
Input : A[][2] = {{4, 8}, {15, 30}, {3, 6}, {10, 20}}
Output: 6
@Aldizh
Aldizh / bowling.js
Created September 8, 2021 04:39
Bowling game calculator
// Installed npm packages: jquery underscore request express
// jade shelljs passport http sys lodash async mocha chai sinon
// sinon-chai moment connect validator restify ejs ws co when
// helmet wrench brain mustache should backbone forever debug jsdom
/*
Please write a function to score a game of bowling,
special scoring considerations
======================================
@Aldizh
Aldizh / string_compression.txt
Last active September 28, 2023 15:20
Compress/Decompress a string input using a reversible formula
// Write a compression and decompression algorithm that results in a smalller string
// You can assume all the input parameters are letters of the alphabet
function isNumber(char) {
return !Number.isNaN(parseInt(char)) && typeof parseInt(char) === 'number'
}
// str is in this format, number then letter => "2a4f7s154v..."
function decompress(str) {
if (!str) return str