This file contains hidden or 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 sys | |
| import math | |
| # yes, stolen from wikipedia. | |
| def binomialCoefficient(n, k): | |
| if k < 0 or k > n: | |
| return 0 | |
| if k > n - k: # take advantage of symmetry | |
| k = n - k |
This file contains hidden or 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 <vector> | |
| #include <iostream> | |
| #include <algorithm> | |
| #include <cstring> | |
| #define foreach(x) for (typeof((x).begin()) it = (x).begin(); it != (x).end(); ++it) | |
| using namespace std; | |
| vector<pair<int, int> > ateam, bteam, *teams, *oldteams; |
This file contains hidden or 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
| Tracing route to newark1.linode.com [207.192.68.6] | |
| over a maximum of 30 hops: | |
| 1 <1 ms <1 ms <1 ms 192.168.20.1 | |
| 2 11 ms 9 ms 9 ms 177.17.88.1.static.host.gvt.net.br [177.17.88.1] | |
| 3 12 ms 10 ms 8 ms corporativo.host.gvt.net.br [189.115.192.1] | |
| 4 26 ms 23 ms 23 ms gvt-ge-5-0-0-rt01.rjo.gvt.net.br [189.59.244.230] | |
| 5 20 ms 24 ms 23 ms TenGigabitEthernet7-4.ar1.GIG1.gblx.net [64.214.130.113] | |
| 6 143 ms 143 ms 144 ms te2-1-10G.asr1.EWR2.gblx.net [67.16.136.230] | |
| 7 149 ms 151 ms 148 ms xe-1-0-2.ar2.ewr1.us.nlayer.net [69.31.94.133] |
This file contains hidden or 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
| <!-- gist --> | |
| <div class="alert gist"><div class="body"><span class="mini-icon mini-icon-gist"></span> | |
| <div class="title"> | |
| <a href="/saml">saml</a> <span>created</span> <a href="https://gist.github.com/2854398">gist: 2854398</a> | |
| <time class="js-relative-date" datetime="2012-06-01T19:00:27Z" title="2012-06-01 19:00:27">a day ago</time> | |
| </div> | |
| <div class="details"> | |
| <div class="gravatar"><img height="30" src="https://secure.gravatar.com/avatar/ed429134d47c8baa4a9a419ed4c4eeeb?s=140&d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png" width="30"></div> |
This file contains hidden or 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
| 13:57 < lzm> saml: also, why are sql databases natural transmorfism endofunctors? | |
| 13:59 < saml> you know relation/ | |
| 13:59 < saml> relation | |
| 13:59 < saml> relation is a pair or tuple | |
| 13:59 < saml> (a,b) a is related to b | |
| 14:00 < saml> and database table is a collection of those tuples | |
| 14:00 < saml> so a table can represent a function (like truth table, for example) | |
| 14:01 < saml> now, if you go up one category, you can store functions (tables) in columns of a table | |
| 14:01 < saml> for practicality, you store table ids | |
| 14:01 < saml> (table_id_1, table_id_2, ...) that's a row of this meta table |
This file contains hidden or 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
| 16:03 < saml> that's fun | |
| 16:03 < saml> SQL is a fun language | |
| 16:03 < saml> structured query language | |
| 16:03 < saml> it's pretty nice... you get to query relational databases | |
| 16:03 < saml> relations are superset of functions | |
| 16:04 < saml> so, in a way SQL is querying categories | |
| 16:04 < quanticle> saml: SQL is Haskell? :D | |
| 16:04 < saml> natural transmorphism endofunctors some might say | |
| 16:05 < lzm> saml: cant tell if trolling or way too smart |
This file contains hidden or 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
| 0 | |
| 2 | |
| 7 | |
| 2 | |
| 5 8 | |
| 2 3 | |
| 1 6 | |
| 5 | |
| 4 | |
| 0 |
This file contains hidden or 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
| class A | |
| { | |
| private int memberint; | |
| public int someMethod(int memberint) | |
| { | |
| // memberint being shadowed by the parameter | |
| this.memberint = memberint; | |
| } |
This file contains hidden or 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 Data.Char (ord) | |
| import Data.List (sort, group, intersperse) | |
| import Text.ParserCombinators.Parsec | |
| -- types | |
| type Card = Int | |
| type Suit = Int | |
| type SuitCard = Int |
This file contains hidden or 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
| class Dictdb: | |
| def __init__(self): | |
| self.db = {} | |
| self.rdb = {} | |
| self.rdiff = [] | |
| def rinc(self, val): | |
| if val not in self.rdb: | |
| self.rdb[val] = 0 | |
| self.rdb[val] += 1 |