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
<startup useLegacyV2RuntimeActivationPolicy="true"> | |
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/> | |
</startup> |
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
head [ (a, b, c) | c <- [1..], b <- [1..c], let a = 1000 - b - c, a^2 + b^2 == c^2 ] |
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 static void main(String[] args) { | |
int max = 0; | |
int bestP = 0; | |
for (int p = 1; p <= 1000; p++) { | |
int found = 0; | |
for (int a = 1; a <= p / 4; a++) { | |
for (int b = 1; b <= (p - a) / 2; b++) { | |
double c = Math.sqrt(a * a + b * b); | |
if (a + b + c == p) | |
found++; |
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
# http://henrik.nyh.se/2008/12/git-dirty-prompt | |
# http://www.simplisticcomplexity.com/2008/03/13/show-your-git-branch-name-in-your-prompt/ | |
# username@Machine ~/dev/dir[master]$ # clean working directory | |
# username@Machine ~/dev/dir[master*]$ # dirty working directory | |
function parse_git_dirty { | |
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*" | |
} | |
function parse_git_branch { | |
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/" |
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 | |
class PythagoreanTriple(object): | |
def __init__(self, a, b, c): | |
self._a = a | |
self._b = b | |
self._c = c | |
def __hash__(self): | |
return hash(self._a) * hash(self._b) - hash(self._c) | |
def __eq__(self, other): |
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 digits(n): | |
result = [] | |
while n > 0: | |
result = [n % 10] + result | |
n /= 10 | |
if not result: | |
return [0] | |
return result |
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 digits(n): | |
result = [] | |
while n > 0: | |
result = [n % 10] + result | |
n /= 10 | |
if not result: | |
return [0] | |
return result | |
def factorial(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
#!/usr/bin/env python | |
import sys | |
import BaseHTTPServer | |
from SimpleHTTPServer import SimpleHTTPRequestHandler | |
HandlerClass = SimpleHTTPRequestHandler | |
ServerClass = BaseHTTPServer.HTTPServer | |
Protocol = "HTTP/1.0" |
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
/** | |
* jQuery.stringify (https://gist.github.com/953765) | |
* | |
* converted stringify() to jQuery plugin. | |
* serializes a simple object to a JSON formatted string. | |
* uses browser's native JSON.stringify() if it exists. | |
* Note: stringify() is different from jQuery.serialize() which URLEncodes form elements | |
* | |
* UPDATES: | |
* Added a fix to skip over Object.prototype members added by the prototype.js library |
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 scala.util.Random | |
import scala.collection.immutable._ | |
import scala.math._ | |
class FermatPrimalityTester(rounds: Int) { | |
private val this.rounds = rounds | |
private val random = new Random | |
def isPrime(subject: Int): Boolean = { | |
return this.getRandomIntegers(subject) |