Instantly share code, notes, and snippets.

View index.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>IKEv2 configurator</title>
<h2>Use this tool to create an 'on demand' IKEv2 profile.</h2><br />Set an OpenVPN user/pass in Dashboard first.<br />This is not your ProtonMail password.<br />For use with ProtonVPN only.<br />
<form name="mainForm" method="get" id="Main">
<h5><textarea id="input1" cols="20" rows="2" style="display:none;><?xml version="1.0" encoding="UTF-8"?>
View shapes.js
const log = console.log
class Grid {
constructor() {
this.width = 60
this.height = 24
this.grid = new Array(this.height)
for (let row = 0; row < this.height; row++) {
this.grid[row] = new Array(this.width)
View hungryRabbit.js
Given an NxM matrix representing a garden, each entry contains a number, which is the number of carrots in that plot. A rabbit starts in the middle, or plot closest to middle with the most carrots and always goes up down left or right after eating to the plot with the most carrots. The values of the matrix will represent numbers of carrots available to the rabbit in each square of the garden. If the garden does not have an exact center, the rabbit should start in the square closest to the center with the highest carrot count.
On a given turn, the rabbit will eat the carrots available on the square that it is on, and then move up, down, left, or right, choosing the the square that has the most carrots.If there are no carrots left on any of the adjacent squares, the rabbit will go to sleep.You may assume that the rabbit will never have to choose between two squares with the same number of carrots.
Write a function which takes a garden matrix and returns the number of carrots the rabbit eats. You may
View ticketPurchasingWaitingTime.js
A line has formed to buy tickets for a concert. In order to delay a shortage caused by brokers buying large blocks of tickets, venue management has decided to sell only one ticket at a time. Buyers have to to wait through line again if they want to buy more tickets. Jesse is standing in line and has a number of tickets to purchase.
Given a list of ticket buyers with their numbers of desired tickets, determine how long it will take Jesse to purchase his tickets. Jesse's position in line will be stated, and each transaction takes 1 unit of time. For your purposes, no time is spent moving to the back of the line.
Sample Input
View getMovieTitles.js
Given a string `substr`, getMovieTitles() must perform the following tasks:
1. Query (replace substr).
2. Initialize the titles array to store total string elements. Store the Title of each movie meeting the search criterion in the titles array.
3. Sort titles in ascending order and return it as your answer.
const https = require('https')
const log = console.log
View letterCombinations.js
Given a digit string, return all possible letter combinations that the number could represent on a T9 dialpad.
Input: Digit string '23'
Output: [ 'ad', 'ae', 'af', 'bd', 'be', 'bf', 'cd', 'ce', 'cf' ]
const log = console.log
const getPossibilities = digitString => {
const digitMap = {
View balancedBraces.js
const log = console.log
const topOfStack = stack => {
return stack[stack.length - 1]
const isOpening = char => {
return char === '(' || char === '[' || char === '{'
View numberOfIslands.js
const log = console.log
const dfs = (grid, i, j) => {
if (i < 0 || i >= grid.length
|| j < 0 || j >= grid[0].length
|| grid[i][j] !== 1) {
return // out of bounds or already visited
grid[i][j] = 0 // mark as visited
View boggleSolver.js
Create an application that prints all the words in a Boggle board represented by a 2D matrix.
* Input: Board represented as 2D matrix.
* Input: Set of valid words.
* Output: Words contained in the boggle board.
* Notes:
* Can’t re-use the same letter for a given word.
* Letters can’t be connected diagonally.
* Print the word every time it appears
* Runnable solution
View serializationOfABST.js
/ \
1 7
/ \ \
0 3 9