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(n, nums, solveStr='x'): | |
''' Play 24 with nums 1,3,4,6 like so: | |
>>> solve(24, [1,3,4,6]) | |
(6/(1-(3/4))) ''' | |
n = float(n) | |
solved = False | |
if len(nums) == 1: | |
return (solveStr.replace('x', str(int(n))) if n == float(nums[0]) else False) |
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(n, nums, solveStr='x'): | |
''' Solve the game 24 for any solution target and any numbers | |
n = The target number (e.g. 24) | |
nums = Array of numbers (floating point ok) to use | |
solveStr = A helper string for this recursive method that returns a formula | |
This method will return the first (not exhaustive!) possible solution to the game, or False if none exists | |
Example: For the 24 game 1,3,4,6 call it the following way: | |
solve(24, [1,3,4,6]) |
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
''' | |
Created on Mar 18, 2013 | |
@author: Matt Dodge | |
''' | |
from bs4 import BeautifulSoup as BS | |
from httplib2 import Http | |
from urllib import urlencode | |
import json |
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
''' | |
Created on Mar 18, 2013 | |
@author: Matt Dodge | |
''' | |
''' | |
You can put your own probabilities here. It is a dict where the key is the lower seed | |
(lower by number, not by rank) followed by the higher seed, separated by comma, no space. |
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
<?php | |
$the_file = "file.txt"; | |
if (isset($_POST['content'])) { | |
$content = stripslashes($_POST['content']); | |
$fp = fopen($the_file,"w") or die ("Error opening file in write mode!"); | |
fputs($fp,$content); | |
fclose($fp) or die ("Error closing file!"); | |
} |
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
function timeAgo(num_seconds) { | |
function numberEnding (number) { | |
return (number > 1) ? 's ago' : ' ago'; | |
} | |
if (num_seconds <= 0) { | |
return 'just now!'; | |
} | |
var years = Math.floor(num_seconds / 31536000); | |
if (years) { | |
return years + ' yr' + numberEnding(years); |
NewerOlder