I hereby claim:
- I am mavant on github.
- I am mavant (https://keybase.io/mavant) on keybase.
- I have a public key whose fingerprint is 6C6F D940 8D96 832D 6CDD 740B DD9B DC4A A11E 21D0
To claim this, I am signing this object:
(use '[clojure.string :as s]) | |
(defn remove-whitespace "Given a string representing some Clojure code as input, remove superfluous whitespace." [c] (s/replace c #"\s+" " ")) | |
(defn parens->indents "Given a list of lines in which each begins an expression, prepends a newline and the appropriate number of tabs to each line." [c] (map (fn [a b] (str "\n" (apply str (repeat a "\t")) b)) (indent-levels (match-parens c)) (split-on-all-parens c))) | |
(defn remove-empty-lines "Given a list of strings, filters out any string which contains no word characters." [l] (filter (fn [c] (< 0 (count (re-seq #"\w" c)))) l)) | |
(defn indent-levels "Given a list of lines of code, determine the appropriate number of tabs for each line." [l] (reduce (fn [a b] (conj a (+ (peek a) (if (= b ")") -1 1)))) [-1] l)) | |
defn line->ints [line] | |
map | |
fn [l] | |
Integer/parseInt l | |
split line #"\s+" | |
defn solutions->outputs [solutions] | |
map | |
fn [n s] | |
str "Case #" |
I hereby claim:
To claim this, I am signing this object:
import csv | |
import re | |
from subprocess import call | |
outputfilename = 'BroCode.pdf' | |
articlecsv = 'Articles.csv' | |
formatfilename = 'page.tex' | |
output = open('latextemp.tex','w') | |
formatfile = open('page.tex', 'r') |
(define (prisoners-dilemma player1 player2) ;;Payoffs correspond to years in prison (lower is better) | |
(let ((p1 (player1 player2 prisoners-dilemma)) ;;Each player is given the other player's source code and the game's source code | |
(p2 (player2 player1 prisoners-dilemma))) | |
(cond | |
((and (equal? p1 'C) (equal? p2 'C)) (cons 1 1)) | |
((and (equal? p1 'C) (equal? p2 'D)) (cons 3 0)) | |
((and (equal? p1 'D) (equal? p2 'C)) (cons 0 3)) | |
((and (equal? p1 'D) (equal? p2 'D)) (cons 2 2))))) | |
(define (nicebot . z) 'C) ;;nicebot ignores the opponent and game; it always cooperates |
(define (generic-agent put drink survive) (lambda (arg) | |
(cond ((null? arg) put) ;; output a glass to put poison into | |
((boolean? arg) (survive arg)) ;; output whether you survive given poison | |
((procedure? arg) (drink arg)) ;; output a glass to drink given the other player's source | |
(else (error "Input type must be one of: Null, boolean, or procedure"))))) | |
(define (contains? list element) (if (member element list) #t #f)) | |
(define (battle-of-wits p1 p2) |
<html> | |
<head> | |
<title>Dice Roller</title> | |
</head> | |
<body> | |
<?php | |
#first things first - if the user didn't specify a name, die. | |
IF ($_POST['name'] != null){ | |
#looks like they gave a name! |
import csv | |
names = [] | |
sum = 0 | |
with open ('names.txt', 'rb') as csvfile: | |
namereader = csv.reader(csvfile, delimiter=',', quotechar='"') | |
for row in namereader: | |
names = names + row | |
names.sort() | |
for i in range(len(names)): |
import itertools | |
ints = range(10) | |
perms = list(itertools.permutations(ints)) | |
print (perms[999999]) |
import math | |
def d(n): | |
sum = 0 | |
for i in range(1, int(math.sqrt(n)+1)): | |
if (n % i == 0): | |
sum += i | |
return sum | |
amicable = [] |