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 x(k): | |
"""Numerically investigate the continued fraction x = | |
1 + 1 | |
________________ | |
1 + 1 | |
__________ | |
1 + 1 | |
_____ | |
... | |
We won't be able to go out to infinity, so we'll use a counter to take only |
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/local/bin/sbcl --script | |
;;;; craps.lisp | |
;;;; | |
;;;; My submission to http://programmingpraxis.com/2011/11/04/craps/ | |
;;;; Simulates games of Craps, outputs statistics; REQUIRES SBCL (*posix-argv*) | |
;;;; GRE, 11/4/11 | |
(defun two-dice () | |
"The sum of rolling two dice" | |
(+ (1+ (random 6)) (1+ (random 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
/* shamir_threshold_scheme.c | |
* | |
* My C implementation of Shamir's (k, n) Theshold scheme. | |
* Uses a single flag as opposed to an array; idea from Razvan's great implementation. | |
* GRE, 6/23/11 | |
*/ | |
#include <stdio.h> | |
#include <stdlib.h> | |
#define uint unsigned int |
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
/* shamir_threshold_scheme.c | |
* | |
* My C implementation of Shamir's (k, n) Theshold scheme. | |
* GRE, 6/23/11 | |
*/ | |
#include <stdio.h> | |
#include <stdlib.h> | |
#define uint unsigned int | |
#define ulong unsigned long |
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
;;; shamir_threshold_scheme.lisp | |
;;; | |
;;; Implements Adi Shamir's (k, n) threshold secret sharing scheme. | |
;;; GRE, 6/17/11 | |
(defun prod (nums) | |
"Product of nums" | |
(reduce #'* nums :initial-value 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
{- shamir_threshold_scheme.hs | |
- | |
- My Haskell implementation of Shamir's (k, n) Threshold scheme. | |
- GRE, 6/23/11 | |
-} | |
import Data.Bits (shiftR, testBit) | |
import Data.List (foldl', nub) | |
import Random (mkStdGen, randomRs) |
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
main(int c,char **v){int n=atoi(v[1]);while(n-1){n=n&1?3*n+1:n/2;printf("%d\n",n);}} |