Skip to content

Instantly share code, notes, and snippets.

@szimmer1
szimmer1 / confusing_numbers.py
Created May 30, 2022 18:03
Confusable numbers python program
from typing import Iterable, List
import sys
def main(n: int) -> Iterable[int]:
for m in range(1, n + 1):
digits = parse_digits(m)
if is_confusing(digits):
print(m)
class Solution {
public void merge(int[] nums1, int m, int[] nums2, int n) {
int[] nums1Copy = new int[m];
for (int i = 0; i < m; i++) nums1Copy[i] = nums1[i];
int i = 0;
int j = 0;
int k = 0;
while (i < m && j < n) {
if (nums1Copy[i] < nums2[j]) {
from typing import List
from collections import defaultdict
def print_anagrams(l: List[str]):
groups = defaultdict(list)
for s in l:
groups[signature(s)].append(s)
for k, v in groups.items():
print(v)
import sys
import json
import itertools
""" calculator.py is a price calculator for shopping carts. """
def extract_json(file):
""" Decodes the json from a file """
with open(file) as f:
res = json.loads(f.read())
class LNode:
""" Defines linked list node """
def __init__(self, v, n=None):
self.value = v
self.next = n
"""
All linked list functions should return
a reference to a node or None if not found
"""
var fs = require('fs-extra'),
_ = require('lodash');
/**
* Applies callback to all files under directory (recursive) that have extension ext.
* @param dir
* @param predicate(file-extension)
* @param callback(file-path)
* @returns {Function}
*/
cd ~/Documents/Shahar
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
source ~/.profile
alias ll='ls -alp'
alias connect='ssh -x szimmer1@unix.ucsc.edu'
alias learnrails='open $HOME/Documents/Shahar/agile-web-development-with-rails-4_p2_0.pdf'
alias CS101='open $HOME/Documents/Shahar/CS101/intro-algorithms.pdf'
alias CE12='open $HOME/Documents/Shahar/CE12/intro-computing.pdf'
@szimmer1
szimmer1 / start
Last active August 29, 2015 14:18
Docker start script
#!/bin/bash
cd /tmp
# start bash script for Docker container
if [ $# -eq 2 ]
then
USER = $1
REPO = $2
module Jekyll
class LessCssFile < StaticFile
def write(dest)
# do nothing
end
end
# Expects a lessc: key in your _config.yml file with the path to a local less.js/bin/lessc
# Less.js will require node.js to be installed