Skip to content

Instantly share code, notes, and snippets.

View berdfandrade's full-sized avatar
🎯
Focusing

Bernardo Andrade berdfandrade

🎯
Focusing
View GitHub Profile
import copy
import random
class Hat:
def __init__(self, **balls):
self.contents = []
for color, count in balls.items():
self.contents.extend([color] * count)
def draw(self, num_balls):
class Category:
def __init__(self, name):
self.name = name
self.ledger = []
def deposit(self, amount, description=""):
self.ledger.append({"amount": amount, "description": description})
def withdraw(self, amount, description=""):
class Category:
def __init__(self, name):
self.name = name
self.ledger = []
def deposit(self, amount, description=""):
self.ledger.append({"amount": amount, "description": description})
def withdraw(self, amount, description=""):
def add_time(start, duration, day=None):
dia_mapa = {
"Saturday": 0,
"Sunday": 1,
"Monday": 2,
"Tuesday": 3,
"Wednesday": 4,
"Thursday": 5,
"Friday": 6
def arithmetic_arranger(problems, solve=False):
first = "" #Definindo o primiero número
second = "" #Segundo...
third = ""
fourth = ""
arranged_problems = ""
for item in problems: # For loop para começar o programa.
#error 1
function checkCashRegister(price, cash, cid) {
const valoresCorrentes = {
"PENNY": 0.01,
"NICKEL": 0.05,
"DIME": 0.1,
"QUARTER": 0.25,
"ONE": 1,
"FIVE": 5,
"TEN": 10,
function telephoneCheck(str) {
// Expressão regular que verifica o se o número de telefone é válido.
const regexTelefone =
/^(1\s?)?(\(\d{3}\)|\d{3})[-\s]?\d{3}[-\s]?\d{4}$/;
return regexTelefone.test(str);
function transformString(str) {
let transformed = "";
for (let i = 0; i < str.length; i++) {
let letter = str[i];
if (/[a-zA-Z]/.test(letter)) {
let ascii = letter.charCodeAt(0);
ascii += 13;
function convertToRoman(num) {
let resultado = "";
const array = {
M: 1000,
CM: 900,
D: 500,
CD: 400,
C: 100,
XC: 90,
L: 50,
function palindrome(str) {
str = str.toLowerCase();
var regex = /[^A-Za-z0-9]/g;
var palavraLimpa = str.replace(regex, "");
let palavraInvertida = palavraLimpa.split("").reverse().join("")