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 Data.List | |
import Data.Char | |
-- Um amigo meu perguntou como eu resolveria o seguinte problema | |
-- em Haskell, na vida real: http://i.imgur.com/Sno61vt.jpg | |
-- Leia ele antes de continuar! Minha resposta é a seguinte: | |
main = do | |
inicio <- getTime -- seja `inicio` um tempo lido do console | |
fim <- getTime -- seja `fim` outro tempo lido do console |
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
:: Generating ring with 16 members... | |
:: Generated PUB/PVT key pairs: | |
MEMBER 0: 3a514119648cf6ed9f0cc6c955de0ad05916bb407c74a07c130416dfef83ee0066f7118e68e3a648bf09d07fab7c0ba66c75cc3cad9122e590baa1c26d7012a4b001e4f48f4154a61acf7201f0c307359bccfa71e03e3b9d49bc9b3bc5d2fccd/21fcf5df638181233aa85e20f164d2fe2969458e972036188b38f8988f36e2ca7fa7439e558aed9cd2d19528607a45a7a1e0fda8e340926c917fd821860bb58715fe4683106e23f2c2954df70ad45d0cfdca2406f024238270b265c1bd1ba6f9 | |
MEMBER 1: 8a651ebc654dffb5d7ae5d40e00a03f15bd90f299680a767ed1f600d004927dc859059782c8c884400cffeff4bd78e6dac338e48855c4e769ef2802d0eed95f550cbc4c6431b56c53d512b150db7fff77443109d70ef11007ade68848c89bc00/df92eea88372ca57e1056327bb5e3409032b0cba09329ffcef1c5fd53abf6ab9ca8e492e9ba7d09cc271904da955357b2ab74a9614994b09586de4a3af0f11b82506516bff0c3a191f378bfbffe123eabdee06a7c1bf2f9c5703efc2e3a7e9b | |
MEMBER 2: 296cf951174b2a5984b53ceada5e5999436aafca466f1d11178087d73d56176aa51a13ab2493e958faf1d75ed8a77e45ba3860d65b1e8db8cf12f589b27d6fc398973566834e0ba857aa7ed6 |
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
-- Church encoded constructors | |
cons = (Data.constructor 0 (List _)) | |
nil = (Data.constructor 1 (List _)) | |
-- Returns the first element of a church-encoded list | |
head = (cons?,nil?) | |
cons? h t = h | |
nil? = nil | |
-- Returns the tail of a church-encoded list |
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
module.exports = (function(){ | |
// Constructors | |
var VAR = 1, LAM = 2, APP = 3, NUM = 4, OPC = 5; | |
function Lam(bod){ return {type:LAM, bod:bod}; }; | |
function App(fun,arg){ return {type:APP, fun:fun, arg:arg}; }; | |
function Var(index){ return {type:VAR, index:index}; }; | |
function Num(num){ return {type:NUM, value:num}; }; | |
function Opc(op,a,b){ return {type:OPC, op:op, a:a, b:b}; }; |
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
{"r":16801,"rule":[1,2,0,1,0,0,2,1,2],"len":63768} | |
{"r":8481,"rule":[0,1,0,2,2,1,2,0,1],"len":63768} | |
{"r":11871,"rule":[0,0,2,1,2,0,1,2,1],"len":63768} | |
{"r":10401,"rule":[0,2,0,1,2,0,2,1,1],"len":63768} | |
{"r":14881,"rule":[1,1,0,2,0,1,2,0,2],"len":63768} | |
{"r":8703,"rule":[0,0,1,1,2,2,2,0,1],"len":63768} | |
{"r":5231,"rule":[2,0,2,1,1,0,1,2,0],"len":63768} | |
{"r":14881,"rule":[1,1,0,2,0,1,2,0,2],"len":63768} | |
{"r":8481,"rule":[0,1,0,2,2,1,2,0,1],"len":63768} |
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 hash(bits, len){ | |
var tt = [1,2,0,0,0,1,1,2,2]; | |
var st = []; | |
for (var i=0; i<128; ++i) | |
st.push(i%3); | |
var os = []; | |
for (var k=0, l=st.length, il=bits.length; k<il+len; ++k){ | |
for (var j=0; j<32; ++j){ | |
if (k < il) | |
st[0] = bits[k]; |
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
#include <stdio.h> | |
void hash(int* bits, int bitsLen, int* out, int outLen){ | |
const int tt[9] = {1,2,0,0,0,1,1,2,2}; | |
int st[128], i, k, j, x, y, a, b, o = 0; | |
for (int i=0; i<128; ++i) | |
st[i] = i%3; | |
for (k=0; k < bitsLen + outLen; ++k){ | |
for (j=0; j<32; ++j){ | |
if (k < bitsLen) |
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
#include <stdio.h> | |
#include <stdlib.h> | |
void add1(long len, long *array){ | |
for (long i = 0; i < len; ++i) | |
array[i] = array[i] + 1; | |
} | |
long sum(long len, long *array){ | |
long sum = 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
module Main where | |
import qualified Data.Vector.Unboxed as V | |
{-# INLINE add1 #-} | |
add1 :: V.Vector Int -> V.Vector Int | |
add1 = V.map (+ 1) | |
main :: IO () | |
main = do |
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
// Bitcoin's hash rate has been doubling once every 75 days in average. It | |
// varies a lot, though, but, assuming it keeps at least a similar pace, and | |
// assuming that guessing one private key has the same cost of a single hash, | |
// then, by the end of 2025, it will be more rewarding for miners to brute | |
// force private keys rather than mining. | |
let pow = x => Math.pow(2, x); | |
let log = x => Math.log(x) / Math.log(2); | |
let blockRate = block => Math.pow(2, 61.602060630030124) * 1.0000693171203765 * Math.pow(2, (block - 454667) / 10000); |