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 django import template | |
import re | |
register = template.Library() | |
def isNumber(x): | |
return (type(x) is int) or (type(x) is float) | |
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 <iostream> | |
int soma(int a, int b); | |
int main() | |
{ | |
printf("Total: %i", soma(2,3)); | |
} | |
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 strandComplRev(s) | |
local complements = | |
{ | |
A = "T", | |
T = "A", | |
C = "G", | |
G = "C", | |
} | |
local s2 = "" |
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
-- Functions based on this problem: http://rosalind.info/problems/revc/ | |
complements = | |
{ | |
A = "T", | |
T = "A", | |
C = "G", | |
G = "C", | |
} |
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
num = int(input("Escolha um número decimal para transformar em binario: ")) | |
result = [] | |
while num >= 1: | |
bit = num % 2 | |
result.append(bit) | |
num = int(num/2) | |
# Imprimir em ordem inversa | |
print("".join(map(str, result))[::-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
class Player: | |
def __init__(self, name, customMsg = "com"): | |
self.score = 0 | |
self.name = name | |
self.customMsg = customMsg | |
def __str__(self): | |
return "{}: {} pontos".format(self.name, self.score) | |
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 string | |
def minLengthCriterion(minLength): | |
def f(password): | |
return len(password) > minLength | |
return f | |
def hasCharInGroup(text, group): |
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
/* pair.h */ | |
#ifndef __PAIR_H__ | |
#define __PAIR_H__ | |
typedef struct SPair Pair; | |
Pair* createPair(int x, int y); | |
void destroyPair(Pair *pair); | |
int getX(Pair *pair); |
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 map(f, l) | |
local nl = {} | |
for i, v in ipairs(l) do | |
nl[i] = f(v) | |
end | |
return nl | |
end | |
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
class ValidationError(Exception): | |
def __init__(self, msg): | |
super().__init__(msg) | |
def weightValidator(minWeight = None, maxWeight = None): | |
def validator(val): | |
val = float(val) | |
isValid = (minWeight == None or val >= minWeight) and (maxWeight == None or val <= maxWeight) |
OlderNewer