Skip to content

Instantly share code, notes, and snippets.

Alexander Kojevnikov alexkay

View GitHub Profile
@alexkay
alexkay / gist:1600348
Created Jan 12, 2012
Code Sprint 2 - Picking Cards
View gist:1600348
#!/usr/bin/env python
def calc(a, n):
res = 1
m = 1
for i in xrange(n):
m -= 1
for k in xrange(i + m, n):
if a[k] > i:
break
@alexkay
alexkay / gist:1600579
Created Jan 12, 2012
Code Sprint 2 - Coin Tosses
View gist:1600579
#!/usr/bin/env python
memo = {}
def calc(n, m):
key = n * 10000 + m
if key in memo:
return memo[key]
if n == 0 or n == m:
res = 0
elif m == 0:
@alexkay
alexkay / gist:1600704
Created Jan 12, 2012
Code Sprint 2 - Fraud Prevention
View gist:1600704
#!/usr/bin/env python
import re
def normalise_email(email):
email = email.lower()
i = email.find("@")
prefix = email[:i]
j = prefix.find("+")
if j != -1:
@alexkay
alexkay / gist:1600725
Created Jan 12, 2012
Code Sprint 2 - Subsequence Weighting
View gist:1600725
#include <algorithm>
#include <iostream>
#include <set>
using namespace std;
struct Node {
int a;
long long w;
Node *prev;
@alexkay
alexkay / gist:1600742
Created Jan 12, 2012
Code Sprint 2 - Quora Nearby
View gist:1600742
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <set>
#include <vector>
using namespace std;
struct Topic {
@alexkay
alexkay / gist:2566869
Last active Mar 27, 2020
Mirrored encrypted FreeBSD install
View gist:2566869
# Start with the setup normally, then select "Shell" at the partitioning step.
# Check device names
camcontrol devlist
# Create a gpt and a bootstrap partition
gpart destroy -F ada0
gpart create -s gpt ada0
gpart add -a 4k -t freebsd-boot -s 64k ada0
gpart bootcode -b /boot/pmbr -p /boot/gptboot -i 1 ada0
@alexkay
alexkay / pycon.py
Created Apr 16, 2013
Thumbtack PyCon 2013 challenge
View pycon.py
#!/usr/bin/env python
import collections
import itertools
import re
import sys
words = {
word
for word in re.split(r'\W+', sys.stdin.read().lower())
You can’t perform that action at this time.