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
<!doctype html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title>AES client/server test</title> | |
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/normalize/3.0.3/normalize.min.css"> | |
<style> | |
body { font-size: 80%; padding: 1em; } | |
form { margin-top: 2em; } | |
label { display: inline-block; width: 6em; } |
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
<?php | |
/** | |
* Bcrypt hashing class | |
* | |
* @author Thiago Belem <contato@thiagobelem.net> | |
* @link https://gist.github.com/3438461 | |
*/ | |
class Bcrypt { |
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 isqrt(n): | |
if n < 0: | |
raise ValueError | |
elif n < 2: | |
return n | |
else: | |
a = 1 << ((1 + n.bit_length()) >> 1) | |
while True: | |
b = (a + n // a) >> 1 | |
if b >= a: |
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
const N: usize = 8; | |
fn try(mut board: &mut [[bool; N]; N], row: usize, mut count: &mut i64) { | |
if row == N { | |
*count += 1; | |
for r in board.iter() { | |
println!("{}", r.iter().map(|&x| if x {"x"} else {"."}.to_string()).collect::<Vec<String>>().join(" ")) | |
} | |
println!(""); | |
return |
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 std::fmt; | |
const SIZE: usize = 8; | |
const MOVES: [(i32, i32); 8] = [(2,1), (1,2), (-1,2), (-2,1), (-2,-1), (-1,-2), (1,-2), (2,-1)]; | |
#[derive(Copy, Clone, Eq, PartialEq, PartialOrd, Ord)] | |
struct Point { | |
x: i32, | |
y: i32 | |
} |
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 eratosthenes2(n): | |
multiples = set() | |
for i in range(2, n+1): | |
if i not in multiples: | |
yield i | |
multiples.update(range(i*i, n+1, i)) | |
print(list(eratosthenes2(100))) |
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 factors(n): | |
return [i for i in range(1, n//2 + 1) if not n%i] + [n] | |
print(factors(45)) |
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
struct Matrix { | |
dat: [[f32; 3]; 3] | |
} | |
impl Matrix { | |
pub fn mult_m(a: Matrix, b: Matrix) -> Matrix | |
{ | |
let mut out = Matrix { | |
dat: [[0., 0., 0.], | |
[0., 0., 0.], |
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
listnumbers = range(1,500) | |
for i in listnumbers: | |
sum = 0 | |
value = 1 | |
while value <= i-1: | |
sum+=value**(i-1) | |
value+=1 | |
if ((sum%i)+1)%i == 0: | |
print("%d é primo pela conjectura de Agoh-Giuga!"%(i)) |
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
''' | |
número euler calculado limite de (1+1/n)^n com n se aproximando ao | |
infinito calculando os 200 primeiros dígitos, através da | |
biblioteca decimal | |
''' | |
from decimal import Decimal, getcontext | |
def euler(precisao): | |
prec_n = precisao |
OlderNewer