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
name: transposer | |
source code: |- | |
input: '++++' | |
blank: ' ' | |
start state: D | |
table: | |
'Gbb': | |
' ': {R: 'F'} | |
'+': {R: 'Gb'} | |
'-': {R: 'Fb'} |
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
from sample import reverse, add, mult, is_adult, compare | |
from unittest import test | |
# Testing reverse function | |
test("olleh", reverse, "hello") | |
test("ababa", reverse, "hello") | |
# Testing add function | |
test(10, add, 2, 3, 5) | |
test(10, add, 2, 3, 4) |
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
string Huff::buildBytes(string bitflow) | |
{ | |
unsigned char byte = 0; | |
unsigned int currbit = 0; | |
std::string output = ""; | |
while (currbit < bitflow.size()) | |
{ | |
// Concatena o byte construído a cada 8 bits lidos. | |
for (int i = 0; i < BYTE_SIZE; ) |
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 optimal(number): | |
if number >= 2: | |
# Calcula a raiz quadrada de number | |
sqrt_n = int(math.sqrt(number) + 1) | |
for index in range(2, sqrt_n): | |
# Se houver algum divisor entre 1 (exclusive) e a raiz quadrada de number, number não é primo. |
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 fermat(number, trials=20): | |
if number > 2: | |
# Repete o teste até o número de tentativas especificado. | |
for trial in range(trials): | |
# Gera um número aleatório entre 2 e number. | |
random_int = random.randint(2, number - 2 + 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
# Lazy: verifica se um número é primo contando seus divisores. | |
def lazy(number): | |
divisions = 0 | |
# Conta o número de divisores de number. | |
for index in range(1, number + 1): | |
if number % index == 0: | |
divisions += 1 |