For Nix we require some extra packages. Use this shell.nix
, it gets you everything in one shot:
with import <nixpkgs> {};
pkgs.stdenv.mkDerivation rec {
name = "yarn";
buildInputs = with pkgs; [
xorg.libX11
# https://leetcode.com/problems/search-insert-position/ | |
class Solution(object): | |
def searchInsert(self, nums, target): | |
""" | |
:type nums: List[int] | |
:type target: int | |
:rtype: int | |
""" | |
l = 0 |
""" | |
Clean historical bitcoin price data | |
- from min to 12 hours | |
""" | |
source_fn = 'bitstampUSD_1-min_data_2012-01-01_to_2021-03-31.csv' | |
dest_fn = 'bitstampUSD_12-hours_data_2012-01-01_to_2021-03-31.csv' | |
# source = open("bitstampUSD_1-min_data_2012-01-01_to_2021-03-31.csv", "r") | |
# dest = open("bitstampUSD_12-hours_data_2012-01-01_to_2021-03-31.csv", "w+") |
def twoSum(nums, target): | |
seen = {} | |
for i in range(len(nums)): # O(N) | |
if (target - nums[i]) in seen: # O(1) | |
prev = seen[target - nums[i]] | |
return [prev, i] | |
else: | |
seen[nums[i]] = i #O(1) | |
print(twoSum([2, 13, 16, 8], 10)) |
def mergeSort(arr): | |
def combine(L, R): | |
i = j = k = 0 | |
while i < len(L) and j < len(R): | |
if L[i] < R[j]: | |
arr[k] = L[i] | |
i += 1 | |
else: | |
arr[k] = R[j] |
// $ node index.js celcius fahrenheit 1 2 3 | |
const CELCIUS = "celcius"; | |
const FAHRENHEIT = "fahrenheit"; | |
const source = process.argv[2]; | |
const dest = process.argv[3]; | |
process.argv // ['node', 'index.js', 'celcius', 'fahrenheit', '1', '2', '3'] | |
.slice(4) // ['1', '2', '3'] | |
.map(s => parseInt(s, 10)) // [1, 2, 3] | |
.map(convert) // [33.8, 35.6, 37.4] |
#include <iostream> | |
#include <vector> | |
#include <string> | |
#include <fstream> | |
#include <ctype.h> | |
using namespace std; | |
// === LEXER === // |
Note: Alternatively, you can spin up a AWS EC22 t2.micro
instance and skip steps 1 and 2!
Ubuntu 20.04.2.0 LTS
from https://ubuntu.com/download/desktop
// Source Program
const x = 1;
{
const x = 2;
if (x * 2 === 4) {
display("Hello world!");
} else {
display("boo");
}
def count_water(walls): | |
n = len(walls) | |
stack = list() # use a list as a stack | |
stack.append((walls[0], 0)) # base case | |
# go over the list of walls once | |
for i in range(1, n): | |
current_wall_height = walls[i] | |
prev_wall_height = stack[-1][0] |