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
opcion_invalida = "Opción inválida. ¡Intente de nuevo!" | |
msg_despedida = "¡Muchas gracias! ¡Que tenga un buen día!" | |
porc_comunes = ["1.1", "2.2", "3.3", "4.4", "5.5"] | |
while True: | |
dar_propina = input("¿Desea dejar propina? ").lower() | |
if dar_propina not in ["si", "no"]: | |
print(opcion_invalida) | |
continue | |
elif dar_propina in ["no"]: |
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
/* -------- Partial utility type ---------- */ | |
interface FrontendDeveloper { | |
name?: string; | |
country?: string; | |
languages?: string[]; | |
} | |
type BackendDeveloper = Partial<FrontendDeveloper>; |
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 typing import List, Any | |
from tabulate import tabulate # type: ignore | |
from datetime import datetime | |
import uuid | |
def is_promo_day(str_date: str, order_promo_day: str) -> bool: | |
""" | |
Check if a given date falls on a promotional day. | |
Args: |
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
SELECT *, | |
(SELECT brand FROM order_items | |
JOIN products on order_items.product_uid = products.uid AND order_items.order_uid = orders.uid | |
ORDER BY order_items.quantity desc limit 1) AS popular_brand | |
FROM orders | |
SELECT * FROM orders | |
JOIN order_items ON orders.uid = order_items.order_uid | |
JOIN products on products.uid = order_items.product_uid |
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 typing import Any, KeysView | |
from decouple import config # type: ignore | |
import psycopg2 # type: ignore | |
import pymongo # type: ignore | |
from tabulate import tabulate # type: ignore | |
from utils import is_promo_day, unique_id, print_table | |
# Import schemas | |
from schemas import order_schema, order_items_schema |
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
// 6 - Closest to Zero | https://www.codewars.com/kata/59887207635904314100007b | |
function closestToZero(arr) { | |
arr.sort((a, b) => a - b); | |
let closest = arr[0]; | |
let distance = Math.abs(closest); | |
for (let num of arr) { | |
const currentDistance = Math.abs(num); | |
if (currentDistance <= distance) { | |
distance = currentDistance; | |
closest = num; |
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
const sortGrades = lst => { | |
const grades = [ | |
"VB", "V0", "V0+", "V1", "V2", "V3", "V4", "V5", "V6", "V7", | |
"V8", "V9", "V10", "V11", "V12", "V13", "V14", "V15", "V16", "V17" | |
]; | |
const result = new Array(grades.length).fill(null); | |
if (lst.length === 0) { | |
return []; | |
} |
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
// // 12 - Is it a letter? | https://www.codewars.com/kata/57a06b07cf1fa58b2b000252 | |
const isItLetter = (c) => /[a-zA-Z]/.test(c); | |
console.log(isItLetter("a")); // true, `'a' is a letter` | |
console.log(isItLetter("1")); // false, `'1' is not a letter` |
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
// 11 - Bouncing Ball | https://www.codewars.com/kata/5a40c250c5e284a76400008c | |
const bouncingBall = (initial, proportion) => { | |
let totalBounces = 0; | |
while (initial > 1) { | |
totalBounces++; | |
initial *= proportion; | |
} | |
return totalBounces; | |
} |
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
// 8 - Is n divisible by | https://www.codewars.com/kata/558ee8415872565824000007 | |
const isDivisible = (...args) => { | |
console.log(args); | |
if (args.length <= 1) { | |
return true; | |
} | |
if (args.length === 2) { | |
return Number.isInteger(args[0] / args[1]); | |
} else { |
NewerOlder