Skip to content

Instantly share code, notes, and snippets.

View cardstdani's full-sized avatar
🎯
Focusing

Daniel García Solla cardstdani

🎯
Focusing
View GitHub Profile
DROP TABLE IF EXISTS SportSanction;
DROP TABLE IF EXISTS PoolSanction;
DROP TABLE IF EXISTS DrivingSanction;
DROP TABLE IF EXISTS BusTicket;
DROP TABLE IF EXISTS Participation;
DROP TABLE IF EXISTS CarRegistration;
DROP TABLE IF EXISTS Membership;
DROP TABLE IF EXISTS CruiseBooking;
DROP TABLE IF EXISTS Residence;
DROP TABLE IF EXISTS Entry;
DROP TABLE IF EXISTS Rental;
DROP TABLE IF EXISTS Bike;
DROP TABLE IF EXISTS Person;
CREATE TABLE Person (
PersonID INT NOT NULL,
Name VARCHAR(50) NOT NULL DEFAULT 'No name',
Birth DATE NOT NULL,
Email VARCHAR(50) NOT NULL UNIQUE,
CONSTRAINT PersonPK PRIMARY KEY (PersonID),
CONSTRAINT ConstraintPersonBirth CHECK (Birth <= CURRENT_DATE)
import random
import math
import urllib, json
from pyvis.network import Network
import matplotlib.pyplot as plt
class TrieNode:
def __init__(self, inputChar):
self.char = inputChar
self.end = False
import java.util.Scanner;
class Ejercicio3 extends Practicas {
public String name = "3---Inversor dígitos";
public String description = "Devuelve el número con los dígitos invertidos";
public void mainExec() {
showDescription(name, description);
int b = in.nextInt();
import re
import math
import json
import os
import concurrent
from concurrent.futures import ProcessPoolExecutor
import requests
import numpy as np
if __name__ == '__main__':
combinations = ["00000", "00001", "00002", "00010", "00011", "00012", "00020", "00021", "00022", "00100", "00101",
"00102", "00110", "00111", "00112", "00120", "00121", "00122", "00200", "00201", "00202", "00210",
"00211", "00212", "00220", "00221", "00222", "01000", "01001", "01002", "01010", "01011", "01012",
"01020", "01021", "01022", "01100", "01101", "01102", "01110", "01111", "01112", "01120", "01121",
"01122", "01200", "01201", "01202", "01210", "01211", "01212", "01220", "01221", "01222", "02000",
"02001", "02002", "02010", "02011", "02012", "02020", "02021", "02022", "02100", "02101", "02102",
"02110", "02111", "02112", "02120", "02121", "02122", "02200", "02201", "02202", "02210", "02211",
"02212", "02220", "02221", "02222", "10000", "10001", "10002", "10010", "10011", "10012", "10020",
"10021", "10022", "10100"
def scoreWord(word, d):
global combinations
finalScore = 0
for c in combinations:
entrada = [int(i) for i in c]
pattern = generatePattern(entrada, word)
p = 0
for i in d.keys(): p += 1 if re.match(pattern, i) else 0
p /= len(d)
def updateDict(d, pattern):
d = {k: 0 for (k, v) in d.items() if re.match(pattern, k)}
n = os.cpu_count()
chunkSize = math.ceil(len(d) / n)
out = {}
with ProcessPoolExecutor(n) as executor:
futures = [executor.submit(paralelDict, list(d.keys())[chunkSize * i:chunkSize * (i + 1)], d) for i in range(n)]
for future in concurrent.futures.as_completed(futures):
out.update(future.result())
def validarEntrada(entrada, word, globalPattern):
procesed = {}
for i in range(len(entrada)):
letra = word[i]
if letra not in procesed:
if entrada[i] == 0:
if (f"(?=.{{{i}}}{letra})" in globalPattern) or (f"(?=.*{letra})" in globalPattern and not max(
[entrada[j] == 2 and word[j] == letra for j in range(i + 1, len(entrada))] + [False])) or max([entrada[j] == 1 and word[j] == letra for j in range(i + 1, len(entrada))] + [False]):
print(f"Error en 0 letra {letra}")
return False
def generatePattern(entrada, word):
pattern = ""
procesed = {}
for j in range(len(entrada)):
letra = word[j]
if letra not in procesed:
condition = [k for k in range(j + 1, len(entrada)) if word[k] == letra and entrada[k] == 2]
if entrada[j] == 0:
if condition == []: procesed[letra] = 0