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 Case: | |
"""A Class to simulate case behavior in a more compact way. | |
Optionaly, default value and a conditional function can be passed. | |
cases and **kwargs are for flexibility since you can't have nothing | |
but string keys in kwargs. They both get combined in a single switch. | |
Return value for switches can be either a value or callable. | |
Stupid thingy, I know right! :D |
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 pandas as pd | |
def check_equal(lst): | |
if lst[0] != " ": | |
return lst[1:] == lst[:-1] | |
else: | |
return False | |
def if_win(board): | |
for i in range(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
import csv | |
from requests import post | |
from functools import reduce | |
from bs4 import BeautifulSoup | |
def soup_to_dict(dt): | |
"""Job html soup to dictionary""" | |
main_site = 'http://jobs.bdjobs.com/' | |
data_dict = {}; |
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 copy import deepcopy | |
# Datastructure: [{'r': int, 'c': int, 'd': boolean, 'v': int, 'p': vecotor of int}.....] | |
def related(case, unit, data): | |
grider = [[1,2,3], [4,5,6], [7,8,9]] | |
for g in grider: | |
if unit['c'] in g: | |
cols = g | |
if unit['r'] in g: |
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 verdict(P1,P2,C1,C2,M,N): | |
if (M + N) % 2 == 0: | |
v = 'PAR' | |
else: | |
v = 'IMPAR' | |
if C1 == v: | |
return P1 | |
else: | |
return P2 |
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 itertools import combinations | |
def ifTri (a, b, c): | |
if a + b > c and b + c > a and c + a > b: | |
return True | |
else: | |
return False | |
inp = input().split(" ") | |
pool = [] |
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 get_input(): | |
inp = float(input()) | |
if inp > 10 or inp < 0: | |
print("nota invalida") | |
return get_input() | |
else: | |
return inp | |
def calculate(): | |
a = get_input() |
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 <stdio.h> | |
int main() | |
{ | |
int r, c; | |
float n, s; | |
do{ | |
c=0; | |
s=0.0; | |
while(c<2) | |
{ |
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 math | |
def get_num(): | |
inp = input("Enter a number: ") | |
try: | |
return float(inp) | |
except: | |
print("Enter a valid number.") | |
get_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
def LinearSearch(item, array): | |
return True if item in array else False |