Skip to content

Instantly share code, notes, and snippets.

def doit(input):
index = 0
jumps = [int(num) for num in input.split()]
count = 0
while index < len(jumps):
count += 1
jump = jumps[index]
if jump >= 3:
jumps[index] -= 1
else:
def is_valid(phrase):
parts = phrase.split()
return phrase and len(parts) == len(set([''.join(sorted(part)) for part in parts]))
len(filter(is_valid, input.split('\n')))
small = `5 9 2 8
9 4 7 3
3 8 6 5`
getLines = (s) => s.split('\n').map((line) => line.split(/\s+/).map(s => parseInt(s)))
minmax = line => Math.max(...line) - Math.min(...line)
summer = (accumulator, currentValue) => accumulator + currentValue
result = getLines(s).map(minmax).reduce(summer)
def doit(num):
nums = str(num)
prev = nums[-1]
count = 0
for c in nums:
if c == prev:
count += int(c)
prev = c
return count
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
config.vm.box = "patricks/nasos_sdk_7"
config.vm.box_check_update = false
config.vm.box_version = "1.0.1464032836"
config.ssh.username = "rainbow"
config.ssh.password = "rainbow"

Keybase proof

I hereby claim:

  • I am patricksmith on github.
  • I am patrick_smith (https://keybase.io/patrick_smith) on keybase.
  • I have a public key whose fingerprint is 273F 2417 5CD8 4C4A F72D 387E EA9E 5BD1 744A AABC

To claim this, I am signing this object:

@patricksmith
patricksmith / gist:3ae8505321e65cb6789d
Created July 9, 2014 14:47
Efficiency of iterating numpy array
import numpy as np
import time
def use_enumerate(a):
for i, x in enumerate(np.nditer(a)):
index = i
value = x
@patricksmith
patricksmith / gist:4111041
Created November 19, 2012 14:50
Gunicorn install error
$ pip install gunicorn
Downloading/unpacking gunicorn
Downloading gunicorn-0.16.0.tar.gz (130Kb): 130Kb downloaded
Running setup.py egg_info for package gunicorn
Traceback (most recent call last):
File "<string>", line 14, in <module>
File "/Volumes/Envs/gunicorn/build/gunicorn/setup.py", line 43, in <module>
with open(fname) as f:
IOError: [Errno 2] No such file or directory: '/Volumes/Envs/gunicorn/build/gunicorn/requirements_dev.txt'
Complete output from command python setup.py egg_info: