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 itertools | |
def look_and_say(n) : | |
a = "0" | |
for i in xrange(n) : | |
b = "" | |
for c,l in itertools.groupby(a) : | |
b += bin(len(list(l)))[2:] + c | |
yield a | |
a = b |
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 <vector> | |
#include <cstdlib> | |
#include <ctime> | |
#include <cassert> | |
using namespace std; | |
int count; // to experiment a bit... | |
// divide and conquer shellsort with powers of two... |
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
$dp = nil | |
def try(l,r,s) | |
case s[l] | |
when '(' | |
((l+1)..r).each do |i| | |
return true if s[i] == ')' && go(l+1,i-1,s) && go(i+1,r,s) | |
end | |
false | |
when ':' |
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
MOD = 1000000007 | |
MAX = 10000 | |
$dp = Array.new(MAX+1) | |
$dq = Array.new(MAX+1) | |
$dp[0] = 1 | |
$dq[0] = 1 | |
def inv(a,n) |
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
{-# OPTIONS -XFlexibleInstances -XMultiParamTypeClasses #-} | |
-- integrate on the unit cube | |
-- first argument indicates approximate error | |
class Integrable a b where | |
int :: b -> (b->a) -> b | |
instance (Ord a, Floating a) => Integrable a a where | |
int e f = within (e / 2) (integrate f 0 1) |
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
require 'cairo' | |
#input and output come as arguments | |
input, output = ARGV | |
surface = Cairo::ImageSurface.from_png input | |
goal_data = surface.data | |
HEIGHT, WIDTH = surface.height, surface.width |
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 ruby | |
# [Gedit Tool] | |
# Name=CodeForces | |
# Shortcut=<Control>F6 | |
# Languages=cpp | |
# Applicability=all | |
# Output=output-panel | |
# Input=nothing | |
# Save-files=document |
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
gets.to_i.times do |i| | |
n, m, ps = gets.split.map(&:to_i) | |
players = (1..n).map do | |
name, sp, h = gets.split | |
sp, h = sp.to_i, h.to_i | |
[sp,h,name] | |
end | |
players.sort! | |
players.reverse! | |
team1, team2 = [], [] |
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 <cstdio> | |
#include <vector> | |
using namespace std; | |
#define oo (1<<28) | |
int solve(vector <string> m) | |
{ | |
int N = m.size(), M = m[0].length(); |
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 runhaskell | |
-- Haskell traceroute over icmp | |
-- now with ByteString to avoid new errors produced | |
-- by the deprecated recvFrom from Network.Socket | |
import Control.Monad | |
import Data.Bits(complement) | |
import Data.ByteString(unpack,pack) | |
import Data.List |
OlderNewer