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
function palindrome(str) { | |
str = str.toLowerCase(); | |
var regex = /[^A-Za-z0-9]/g; | |
var palavraLimpa = str.replace(regex, ""); | |
let palavraInvertida = palavraLimpa.split("").reverse().join("") | |
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
function convertToRoman(num) { | |
let resultado = ""; | |
const array = { | |
M: 1000, | |
CM: 900, | |
D: 500, | |
CD: 400, | |
C: 100, | |
XC: 90, | |
L: 50, |
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
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; |
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
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); |
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
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, |
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 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 |
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 add_time(start, duration, day=None): | |
dia_mapa = { | |
"Saturday": 0, | |
"Sunday": 1, | |
"Monday": 2, | |
"Tuesday": 3, | |
"Wednesday": 4, | |
"Thursday": 5, | |
"Friday": 6 |
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
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=""): |
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
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=""): |
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
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): |