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
euler97 = reverse . (take 10) . reverse . show $ (28433*2^7830457+1) |
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
// BEGIN CUT HERE | |
// PROBLEM STATEMENT | |
// NOTE: This problem statement contains images that may not display properly if | |
// viewed outside of the applet. | |
/* | |
* Taro shows a magic trick to Hanako. | |
* | |
* | |
* |
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 java.util.ArrayList; | |
import java.util.Arrays; | |
import java.util.List; | |
public class AverageAverage { | |
/* | |
* perm [] = [[]] | |
* perm (x:xs) = (list ++ (map (x:) list)) |
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
module HarfAdder where | |
import Data.Bits | |
import Data.Word | |
import Control.Applicative | |
harfAdder True True = (False,True) | |
harfAdder True False = (True, False) | |
harfAdder False True = (True, False) | |
harfAdder False False = (False,False) |
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
def harfAdder(a, b): | |
s = a ^ b | |
c = a & b | |
return (c,s) | |
def fullAdder(a,b,x): | |
(c1, s1) = harfAdder(a,b) | |
(c2, s2) = harfAdder(s1,x) | |
return ((c1|c2),s2) |
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
def harfAdder(a, b): | |
s = a ^ b | |
c = a & b | |
return (c,s) | |
def fullAdder(a,b,x): | |
(c1, s1) = harfAdder(a,b) | |
(c2, s2) = harfAdder(s1,x) | |
return ((c1|c2),s2) |
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
function binSearch(A,l,n,x) | |
m = l+math.floor((n-l)/2) | |
if A[m] == x then | |
return m | |
elseif n-l < 1 then | |
return false | |
else | |
tmp1 = binSearch(A,l,m,x) | |
if not tmp1 == false then | |
return tmp1 |
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
#define _ 1 | |
#define __ main=print | |
import Data.Char(chr) | |
(%%) = chr | |
-- | |
(&&&) = (_+_+_+_) ^ (_+_+_) -- 64 | |
(@@) = (&&&) + (_+_) ^(_+_+_) -- H | |
(@@@) = (&&&) + (_+_+_+_+_) -- E | |
(@@@@) = (&&&) + (_+_+_+_) * (_+_+_) -- L | |
(@@@@@) = (&&&) + (_+_+_) * (_+_+_+_+_) -- O |
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
define i32 @fib(i32 %n) | |
{ | |
%1 = icmp ule i32 %n, 1 | |
br i1 %1, label %b1, label %b2 | |
b1: | |
ret i32 %n | |
b2: | |
%2 = sub i32 %n, 1 | |
%3 = call i32 @fib(i32 %2) |
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
(use math.mt-random) | |
(define (random-maker) | |
(let ((m (make <mersenne-twister> :seed (sys-time)))) | |
(lambda (a b) | |
(let ((upper (- b a))) | |
(+ a (mt-random-integer m (+ upper 1))))))) | |
(define random (random-maker)) |