This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "stdio.h" | |
typedef struct tree tree; | |
struct tree{ | |
int value; | |
tree *left ; | |
tree *right; | |
}; | |
tree *tree_first_bigger(tree *t) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import Image, colorsys, sys | |
if len(sys.argv) < 2: | |
print 'usage: {} <file> [<output>]'.format(sys.argv[0]) | |
sys.exit(0) | |
img = Image.open(sys.argv[1]) | |
width, height = img.size |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let enumerateSquares (bitboard: uint64) = | |
bitboard | |
|> Seq.unfold(fun x -> | |
if x = 0UL then None | |
else Some(x &&& (~~~x + 1UL), x &&& (x - 1UL))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let rec enumerateSquares (x: uint64) = seq { | |
if x<>0UL then | |
yield x &&& (~~~x+1UL) | |
yield! enumerateSquares(x &&& (x - 1UL)) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def is_change_possible(coins, change): | |
if change==0: return True | |
if change<0 or len(coins)==0: return False | |
return (is_change_possible(coins[1:], change) or | |
is_change_possible(coins[1:], change-coins[0])) | |
print is_change_possible([1, 2, 5], 8) | |
print is_change_possible([1, 2, 5], 4) | |
print is_change_possible([1]*2000, 2000) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
GitHub keygen | |
Creates an OAuth2 token and adds a server entry at ~/.m2/settings.xml. | |
Makes it easy to either use a github private repository as a maven repository, | |
and to deploy artifacts to a private or public repository using github site | |
plugin. | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <queue> | |
#include <cmath> | |
using namespace std; | |
priority_queue<int> Q, T; | |
int main() { | |
int test=0, tests; cin >> tests; | |
int D; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.google.common.collect.Lists; | |
import com.google.common.collect.Queues; | |
import com.google.common.primitives.Ints; | |
import com.google.common.primitives.Longs; | |
import java.util.List; | |
import java.util.PriorityQueue; | |
import java.util.concurrent.ScheduledExecutorService; | |
import java.util.concurrent.TimeUnit; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface IntComparator { | |
public static final IntComparator DEFAULT = new IntComparator() { | |
@Override | |
public boolean lesser(int a, int b) { | |
return a < b; | |
} | |
}; | |
public static final IntComparator REVERSE = new IntComparator() { | |
@Override |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def solve(number, k): | |
n = len(number) | |
stack = [] | |
for i, digit in enumerate(str(number)): | |
while stack and digit < stack[-1] and n-i+len(stack) > k: | |
stack.pop() | |
if len(stack) < n - k: | |
stack.append(digit) | |
return int(''.join(stack[:k])) | |