blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
545k
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
545k
feeae65408b01a97cdbf1b941e85663a4fb0a8f8
Maruf-S/Competitve-programing
/Week 1/selection_sort.py
426
3.65625
4
#User function Template for python3 class Solution: def select(self, arr, i): # code here pass def selectionSort(self, arr,n): #code here for i in range(n-1): current_min = i for j in range(i+1,n): if(arr[j]<arr[current_min]): ...
a477054b816ae390274554db5ba6edb4d5d09dc9
Maruf-S/Competitve-programing
/129-sum-root-to-leaf-numbers/129-sum-root-to-leaf-numbers.py
618
3.5625
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: def sumNumbers(self, root: Optional[TreeNode]) -> int: tsum = 0 def dfs(node,path): ...
edc3134810b608538d1efedd5049c6ead85dfe6e
Maruf-S/Competitve-programing
/Week 2/evaluate-reverse-polish-notation.py
540
3.640625
4
def evalRPN(tokens): """ :type tokens: List[str] :rtype: int """ stack = [] for i in tokens: if i == "+": stack.append(stack.pop() + stack.pop()) elif i =="-": stack.append(-stack.pop()+ stack.pop()) elif i == "*": stack.append(stack.po...
f303128e8b5a7d3071d49a026d95fbb8b3c3595b
ryokugyu/Algorithms
/bubble_sort/bubbleSort-Python/bubbleSort.py
419
4.21875
4
#!/usr/bin/env python2 # -*- coding: utf-8 -*- """ Created on Sun Oct 7 15:33:03 2018 @author: ryokugyu """ def bubbleSort(alist): for passnum in range(len(alist)-1,0,-1): for i in range(passnum): if alist[i]>alist[i+1]: temp = alist[i] alist[i] = alist[i+1] ...
d5f1120ba818903ca73aaa4523eb4d2ed286207c
gimquokka/problem-solving
/Programers/Lv_2/소수 찾기.py
760
3.625
4
from itertools import permutations def findPrime(num): is_prime = True if num in [0, 1]: return False for divisor in range(2, int(num**0.5) + 1): if num % divisor == 0: is_prime = False return is_prime return is_prime def solution(numbers): cnt = 0 ...
946181ca9e201313de72dec3b17cb5c2cb1fb74e
gimquokka/problem-solving
/이코테 (동빈북)/Part2/10_graph/10_3_unionfind.py
659
3.765625
4
import sys input = sys.stdin.readline def find_parent(parent, x): if parent[x] != x: parent[x] = find_parent(parent, parent[x]) return parent[x] ''' if parent[x] == x: return x else: find_parent(parent, parent[x]) ''' def union_parent(parent, a, b): a = find_parent(parent, a) b = find_parent(parent, b) ...
36ef0cb8002859293c81eb121b15aa0d5bc749e1
gimquokka/problem-solving
/Programers/Lv_3/네트워크b/my_union_find.py
804
3.703125
4
def solution(n, computers): parent = [i for i in range(n)] for i, connections in enumerate(computers): for j, connected in enumerate(connections): if i == j: continue if connected: union_parent(parent, i, j) for i in range(n): pa...
875c6f49e9ce07ab69ee36918cc6b3b4c2755c1e
gimquokka/problem-solving
/Programers/Lv_2/전화번호 목록/ref.py
169
3.6875
4
def solution(phone_book): phone_book.sort() for p1, p2 in zip(phone_book, phone_book[1:]): if p2.startswith(p1): return False return True
d407fa888d0f26c4159ea50ed13a0a778f96ee55
gimquokka/problem-solving
/CodeUp/Hard_to_once(한번에 맞추기 어려운 문제)/cu_2023.py
289
3.6875
4
def change_base(n, base): T = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' q, r = divmod(n, base) # Last character process if r == 0: r = 26 q -= 1 # Refer base chage method if q == 0: return T[r-1] else: return change_base(q, base) + T[r-1] n = int(input()) print(change_base(n, 26))
a68829830647834c0372ce8f7ff76219e715c874
gimquokka/problem-solving
/CodeUp/Basic_100 (기초100제)/cu_1064.py
158
3.640625
4
# Find a minimum value using ternery operation a, b, c = input().split() a = int(a) b = int(b) a1 = (a if a>b else b) a2 = (a1 if a1 > c else c) print(a2)
c33a7a487691c6ad4adfbdbb42473c5e065d4737
gimquokka/problem-solving
/이코테 (동빈북)/python_basic.py
4,204
4
4
#===================== #python basic practice #===================== ''' # remove all element in arrary not like a.remove a = [1, 2, 2 , 3, 3, 3, 4, 5, 5, 5] remove_set= {3, 5} array = [i for i in a if i in remove_set] print(array) ''' ''' # 문자열 예시 string = "Hello World!" print(string) data = "Let's use \"python\"...
3ce1a459cb6ffcbc9630c5944134b68c71c2d4ba
Manjunath823/Assessment_challenge
/Challenge_3/nested_dictionary.py
844
4.34375
4
def nested_key(object_dict, field): """ Input can be nested dict and a key, the function will return value for that key """ keys_found = [] for key, value in object_dict.items(): if key == field: keys_found.append(value) elif isinstance(value, dict): #t...
2644d1abdce91fb1eda8891970f81d80c56d03ce
robbai/NVDerevo
/bot/defending.py
3,313
3.65625
4
""""Module that handles the defending strategy""" import math from rlutilities.linear_algebra import normalize, rotation, vec3, vec2, dot from rlutilities.mechanics import Dodge from util import line_backline_intersect, cap, distance_2d, sign, get_speed, can_dodge, velocity_forward from steps import Step from halffli...
e10b4338107b0f0adf0f7504787e228e9ba4fa7e
SparshKhanna0001/SearchAlgorithms
/TestingFile1.py
613
3.71875
4
import random import math ar = [] for x in range(10): ar.append(random.randint(1, 100)) print(ar) def jump_measure(length_of_array): return int(math.sqrt(length_of_array)) def jump_indices(length_of_array): jump_indices = [] jump_measuree = jump_measure(length_of_array) item = jump_measure(...
41c79387bae3ed9d3a045bfc672eda6b899d7bde
PeterM358/python_OOP
/SOLID LAB/02_OCP/animal.py
1,532
4.25
4
# class Animal: # def __init__(self, species): # self.species = species # # def get_species(self): # return self.species # # # def animal_sound(animals: list): # for animal in animals: # if animal.species == 'cat': # print('meow') # elif animal.species...
92731fa92fdba7f52fa557e59d32e7eb1556c8e6
Amalvir/TP_Info
/correction/TP12/tp12.py
1,914
3.828125
4
A = [[1, -2, 4, 5], [0, -1, -3, 8]] # Mathématiquement, # 1 est le terme (1,1), #-2 le terme (1,2), # 8 le terme (2,4) # En Python # 1 est le terme A[0][0], #-2 le terme A[0][1], # 8 le terme A[1][3] def init_matrice(n, p): return [[0]*p for i in range(n)] def init_matrice(n, p): m = [0]*n for i ...
a10052a9c384070f11e9749c54954ea96f1ddf63
Amalvir/TP_Info
/correction/TP05/TP05_test_dicho.py
880
3.890625
4
def dichotomie(x, L): '''Recherche par dichotomie de x dans la liste L triée par ordre croissant''' n = len(L) g = 0 # indice de début de recherche d = n-1 # indice de fin de recherche # Tant qu'il y a des éléments dans la # portion de liste considérée while d >= g: m = (g+d)//2 ...
1480e4f71cc8b0bc2b27f113937ba4b1cafe8cfb
saif93/simulatedAnnealingPython
/LocalSearch.py
2,948
4.125
4
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" implementation of Simulated Annealing in Python Date: Oct 22, 2016 7:31:55 PM Programmed By: Muhammad Saif ul islam """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" import math import random from copy import deepcopy ...
0a001ed673a9e3a02759edf0042de5dc62e09d06
samshome/spoj
/#11.py
214
3.875
4
def numzero(num): count=num/5 while(num>5): num/=5 count+=num/5 print count tcases= int(raw_input()) for _ in xrange(tcases): num=int(raw_input()) numzero(num)
1bec66f1c4fb052b1e280b31e94205792395e720
sahil2608/python-practice
/filehandle.py
488
3.625
4
employee_file = open("employees.txt", "r") # "w" for write, "a" for append, "r+" both read and write print(employee_file.readable()) # readable tell if readable or not #print(employee_file.read()) # or readline() only specfic line print(employee_file.readlines()) # print(employee_file.readlines()[1]) for specfic numb...
8489ee5a0c8ae8ac1d75fc1e80d4d4f800dd82fb
sahil2608/python-practice
/liste.py
662
3.953125
4
num_luck = [28,56,89,45,75,15,35] friends = ["carl", "david", "cook", 2, 2.45] a=type(friends) print(a) num_luck.sort() #friends.sort() only if all values of same type print(friends[2]) print(friends[-2]) print(friends[1:]) #print after starting specfic [ositon print(friends[1:3]) friends[1]="Mike" #modify list print(f...
bd904dd4356f7c3e2d641d7dd5de4c10be82a9c2
paulchung231/CommentTraining-Website
/Python Scripts for Comments/sample_comments.py
1,361
3.625
4
from sys import argv import os import pandas as pd import numpy as np import random from datetime import datetime from enum import Enum #Data types within the csv. Enumeration is the label of column and the value is the column number in the csv. # Meaning of column numbers in the csv -- # 3: Actual Comment # 7: commen...
0ee7bf02a8f22d82e6fa42e8ba5f473f3b515adf
BrenoSDev/PythonStart
/Introdução a Programação com Python/EX06,7v2.py
647
3.890625
4
#Verificador de parênteses V2 print('Digite uma expressão com parênteses e nós verificaremos se eles foram abertos e fechados corretamente!') expressão = input('Expressão: ') lista_parênteses = [] c = 0 while c < len(expressão): if expressão[c] == '(': lista_parênteses.append(expressão[c]) print(exp...
658e45b2982518385e8118a407abd6f003ff7923
BrenoSDev/PythonStart
/Introdução a Programação com Python/EX06,15.py
384
3.859375
4
#Usando o método de bolha com uma lista com elementos iguais L=[3,3,1,5,4] fim=5 while fim>1: trocou=False x=0 while x<(fim-1): if L[x] > L[x+1]: trocou=True temp=L[x] L[x]=L[x+1] L[x+1]=temp x+=1 if not trocou: break fim -=1 for e in L: print(e) #Com elementos iguais, o programa organiza os ele...
0526d8b3dec15a1fe8347117e2512915321bb32f
BrenoSDev/PythonStart
/Introdução a Programação com Python/Tuplas00.py
724
4.03125
4
#Usando tuplas tupla = ("a", "b", "c") print(tupla) print(tupla[0]) print(tupla[2]) print(tupla[1:]) print(tupla*2) print(len(tupla)) #Tuplas não podem ter elementos alterados for elemento in tupla: print(elemento) #Também pode-se criar tuplas usando valores separados por vírgulas sem parênteses tupla2 = 100...
6e14695b8fa95964275c374de6ca25afdcec97ce
BrenoSDev/PythonStart
/Introdução a Programação com Python/EX03,15.py
293
3.921875
4
#Redução de vida de um fumante cigarros = int(input('Digite a quantidade de cigarros fumados por dia: ')) anos = int(input('Há quantos anos você fuma? ')) redução_de_vida = ((anos*365*cigarros)*10)/(24*60) print('Seu estilo de vida fará você perder %d dias de vida!'%redução_de_vida)
acf32d551fd0339ad3b74cb63d233d9f154d721c
BrenoSDev/PythonStart
/Introdução a Programação com Python/Listas06.py
255
3.765625
4
#Cálculo da média com notas digitadas notas = [0, 0, 0, 0, 0] soma = 0 x = 0 while x < 5: notas[x]=float(input('Nota %d: '% x)) soma += notas[x] x += 1 x = 0 while x < 5: print('Nota %d: %6.2f'%(x, notas[x])) x += 1 print('Média: %5.2f'%(soma/x))
43b0f70793519b645bb599955d56b52a2c801c5b
BrenoSDev/PythonStart
/Introdução a Programação com Python/EX07,6.py
724
4.125
4
#Programa que lê três strings e imprime o resultado da substituição da primeira, dos caracteres da segunda pelos da terceira print('Digite três strings e nós substituiremos os caracteres da segunda pelos da terceira na primeira!') string1 = list(input('String 1: ')) string2 = ' ' string3 = '' while len(string2) != le...
638908e620170178b45486845910450c8f5177aa
BrenoSDev/PythonStart
/Introdução a Programação com Python/EX06,12.py
112
4
4
#Menor elemento de uma lista L=[1,7,-2,4] mínimo=L[0] for v in L: if v < mínimo: mínimo = v print(mínimo)
45480308fb4692f43dbd86aebbf774fb80f4804a
BrenoSDev/PythonStart
/Introdução a Programação com Python/EX07,2.py
415
4.0625
4
#Gerador de string com caracteres em comum de duas outras strings print('Digite 2 strings e nós geraremos uma terceira com os caracteres em comum!') string1 = input('String 1: ') string2 = input('String 2: ') string3 = [] lista_caractere = list(string2) for c in lista_caractere: if c in string1: string3.app...
0ca440e7d6feb522580d8e56ac04aaad1980f398
BrenoSDev/PythonStart
/Introdução a Programação com Python/EX05,13.py
644
3.625
4
#Quitação de uma dívida dívida = float(input('\033[1;34;107mQual o valor total da sua dívida: R$')) taxa = float(input('Qual a taxa de juros(%): ')) parcela = float(input('Quanto você pagará por mês: \033[m')) total_pago = 0 valor_inicial = dívida m = 0 while dívida > 0: dívida*= ((taxa/100)+1) if dívida < parc...
012308591961b3cbd04b5a7a0d5fa44932614dd9
BrenoSDev/PythonStart
/Introdução a Programação com Python/TrabalhandoStrings20.py
155
3.671875
4
#Remoção de caracteres com strip, lstrip e rstrip s="...///Olá///..." print(s.lstrip(".")) print(s.rstrip(".")) print(s.strip(".")) print(s.strip("./"))
27242d93a2e2e16b9fbe855e01cc0a244e4aa38c
BrenoSDev/PythonStart
/Introdução a Programação com Python/TrabalhandoStrings22.py
128
3.59375
4
#Validação de strings com números print("771".isdigit()) print("10.4".isdigit()) print("+10".isdigit()) print("-5".isdigit())
7d4023f055efae7178d4e4d3850d72b100c334ef
BrenoSDev/PythonStart
/Treinos Py/T1.py
913
3.953125
4
#Tabuada v2 import time print('Seja bem vindo a tabuada virtual! Digite um valor e a tabuada de multiplicar irá aparecer na tela!') while True: n = ' ' while n.isdigit() == False: n = input('Tabuada de: ') n = int(n) início = ' ' while início.isdigit() == False: início = input('Por q...
df12deb6b7c07e3222d9424d1adf58266285dd5a
BrenoSDev/PythonStart
/Introdução a Programação com Python/EX05,15.py
860
3.71875
4
#Máquina registradora simples total_compra = 0 produtos = 0 while True: código = int(input('Digite o código do produto ou 0 para sair: ')) while código != 0 and código != 1 and código != 2 and código != 3 and código != 5 and código != 9: print('\033[1;31mERRO! Código Inválido!\033[m') código = i...
25a8ce3074fb682a23763f3e350e20484753a9bd
BrenoSDev/PythonStart
/Treinos Py/T6.py
1,009
4.15625
4
#Validação de informações nome = input('Nome: ') while len(nome) <= 3: print('\033[31mERRO! O nome deve possuir mais de 3 caracteres!\033[m') nome = input('Nome: ') idade = input('Idade: ') while int(idade) < 0 or int(idade) > 150: print('\033[31mERRO! Digite uma idade entre 0 e 150 anos:\033[m') idade = inpu...
3fafcfb7d264c2f64eb49816328511c9696c3308
BrenoSDev/PythonStart
/Introdução a Programação com Python/Listas12.py
86
3.859375
4
#Repetição com tamanho fixo da lista L=[1,2,3] x = 0 while x<3: print(L[x]) x += 1
b8f0013c4e83ae114bb5455e3744d1ac1c73a2ea
BrenoSDev/PythonStart
/Introdução a Programação com Python/Listas42.py
244
3.515625
4
#Impressão das compras produto1=['maçã',10,0.30] produto2=['pera',5,0.75] produto3=['kiwi',4,0.98] compras=[produto1, produto2, produto3] for e in compras: print('Produto: %s'%e[0]) print('Quantidade: %d'%e[1]) print('Preço: %5.2f'%e[2])
47da5cbb1e202e3f32a23df5d43a32ee7901f7fd
BrenoSDev/PythonStart
/Introdução a Programação com Python/EX05,24.py
572
3.9375
4
#Os n primeiros primos from time import sleep print('Digite um valor n e nós mostraremos os n primeiros primos!') n = int(input('Digite um valor: ')) while n <= 0: print('\033[1;31mDigite apenas valores positivos maiores que 0!\033[m') n = int(input('Digite um valor: ')) c = 0 primos = 2 print('\nOs %d primeiros prim...
80c11dc5c300e3e60c6722ac2665537b8d9b6dc9
SarwarSaif/Python-Problems
/Hackerank-Problems/PythonPrintFunction.py
234
3.84375
4
# -*- coding: utf-8 -*- """ Created on Sat Sep 29 02:02:40 2018 @author: majaa """ def printNumber(n): for i in range(1,n+1): print(i, end = '') if __name__ == '__main__' : n=int(input()) printNumber(n)
31d9dc0b6c3e23b9c7dbee6a63139df021b69b27
SarwarSaif/Python-Problems
/Hackerank-Problems/Calendar Module.py
842
4.28125
4
# -*- coding: utf-8 -*- """ Created on Tue Oct 2 14:20:23 2018 @author: majaa """ import calendar if __name__ == '__main__': user_input = input().split() m = int(user_input[0]) d = int(user_input[1]) y = int(user_input[2]) print(list(calendar.day_name)[calendar.weekday(y, m, d)].upper()) ...
0dfcd53fb2f4d82b58ce43b5726c6d682b61dc95
SarwarSaif/Python-Problems
/Hackerank-Problems/NestedList.py
1,897
4.25
4
# -*- coding: utf-8 -*- """ Created on Sat Sep 29 12:30:26 2018 @author: majaa """ if __name__ == '__main__': marksheet=[] """ for _ in range(int(input())): marksheet.append([input(),float(input())]) """ n = int(input()) marksheet = [[input(), float(input())] for _ in ra...
295b3f8c07c5b77be0080c28209f39decba4138d
SarwarSaif/Python-Problems
/Hackerank-Problems/String Split and Join.py
273
3.796875
4
# -*- coding: utf-8 -*- """ Created on Fri Oct 19 19:45:47 2018 @author: majaa """ def split_and_join(line): line=list ( line.split(" ") ) return "-".join(line) if __name__ == '__main__': line = input() result = split_and_join(line) print(result)
780ec1ab2cd62a2e2884cdb0918c507f35b6fe08
SarwarSaif/Python-Problems
/Hackerank-Problems/myCode.py
1,288
4.09375
4
# -*- coding: utf-8 -*- """ Created on Tue Dec 25 18:22:37 2018 @author: majaa """ import sys def main(argv): # このコードは引数と標準出力を用いたサンプルコードです。 # このコードは好きなように編集・削除してもらって構いません。 # --- # This is a sample code to use arguments and outputs. # Edit and remove this code as you like. for i, v in enum...
459ab7cd51cfce5ffed812ef41891c4b76d2b3f0
maximx1/checktheplug
/checktheplug/utilities/StringOps.py
260
3.90625
4
import random import string """ Generates a random string of alphanumeric characters with length of n (8 by default) """ def random_alpha_numeric(n=8): return ''.join(random.SystemRandom().choice(string.ascii_letters + string.digits)for _ in range(n))
afb1f832a96caef7312c407477962a7b7ccbd0e5
kubawyczesany/python
/case_swapping.py
253
4.375
4
# Given a string, simple swap the case for each of the letters. # e.g. HeLLo -> hEllO string = input ("Give a string to swap: ") def swap(string_): _string = ''.join([i.upper() if i.islower() else i.lower() for i in string_]) return (_string)
1307ca14b41aa2ae332917e7ff7dc3aa1d79472a
Micromegass/Python_20190430_S12
/02_Modulos/02_numpy/03_arange_07_Multi_Dimension_3x3.py
574
3.515625
4
import numpy def informar(el_vector): print("el_vector:",el_vector) print("len(el_vector):",len(el_vector)) print("type(el_vector):",type(el_vector)) print("el_vector.dtype:",el_vector.dtype) print("el_vector.size:",el_vector.size) #CUANTOS ELEMENTOS TIENE EL VECTOR print("el_vector.shape:",el_...
dc31d568218f5f710d20afc46f9b876c0e09c8a9
lsaggu/introduction_to_python
/programs/programs.py
1,874
4.28125
4
#! /usr/bin/python import sys ''' her is the task i like you to do to reinforce the learning experience once you are done with the tutorial. a) write a program that uses loops over both x and y coordinates while x is in 1,2,3,4,5 and y is in 5,4,3,2,1 and prints the x and y coordinate b) write a program that sums u...
5649dfb54145b7107109a5a6c2471e490e1241ae
MastanAbdulkhaligli/Artificial-Inteligence-CS461
/River_Crossing_Problem/River_Crossing_Problem.py
6,475
3.875
4
""" Created on Sat Feb 8 2021 - 13:28 Mastan Abdulkhaligli (CONTACT) 21403007 Okan Sen 21202377 Asadullah Farooqi Nurlan Farzaliyev 21503756 Utku Baris Yuksek 21602412 This program solves the river crossing problem of the cannibals and missionaries using NDS. The homework consists of 6 missionaries, 6...
1e633e8fe936b99437c8c8b3c8fac6976565b15d
MastanAbdulkhaligli/Artificial-Inteligence-CS461
/BNB_Search/Board.py
8,873
4.1875
4
import random import copy from copy import deepcopy MAX_PRINT = 2 CUR_PRINT = 0 MAX_COLUMN = 4 MAX_ROW = 4 solution_length_from_board = 0 goal = [["1", "2", "3","4"], ["2", "3", "4","5"], ["3", "4", "5","5"], ["4", "5", "5","_"]] # Rather than normal copying we use deepcopy t...
c74ec9c921525d34e04c1adc7f3a7b0f008ef83c
AbdulMoizChishti/python-practice
/Pfundamental Lab/Lab 6/Nested for loop.py
149
3.796875
4
for i in range (1,6): print ("\tTable of ",i,"\n") for j in range(1,11): print(i,"x",j,"=","{:2d}".format(i * j) ) print("\n")
e689091397f37f3b4b166d1510e3dac045b8f799
AbdulMoizChishti/python-practice
/Pfundamental Lab/Lab 7/task 2.py
269
4.25
4
def max(a, b, c): if a>b and a>c: print(a) elif b>c and b>a: print(b) else: print(c) a=int(input("first number=")) b=int(input("second number=")) c=int(input("third number=")) max(a, b, c) print("is the maximum of three integers")
db747e94baa3548260f1c09685183698a852a701
AbdulMoizChishti/python-practice
/Pfundamental Theory/Assignment 2.py
858
3.890625
4
# Abdul Moiz Chishti BSE=20F-022 str = input("Enter the string phrase : ") vowels = 0 characters = 0 consonants = 0 spaces = 0 words = 0 str = str.lower() #Vowels, Consonents and space count for i in range(0, len(str)): if (str[i] == 'a' or str[i] == 'e' or str[i] == 'i' or str[i] == 'o' or str[i] == 'u'): ...
d9f003ef75fb0c535754b8fff980b8d1e9ae9cd2
AbdulMoizChishti/python-practice
/Pfundamental Lab/Lab 8/list.py
131
3.6875
4
print("\t ***Names of my Friends***") names=["Talal Moin","Abdul Moiz Khan","Shaheer Khan Qureshi","Komal Shakeel","Tooba Shakeel","Asma Hashim Khan"] for i in names: print (i)
8eed3b59e25c2e93ad6d2648e64d37fe0acfba2f
CharlieCarlon/EstructuraDeDatos20188
/ExamenUnidad3.py
3,935
4.03125
4
class Nodo():#"""Se crea la clase nodo y se inicia el metodo constructor""" def __init__(self,dato): #Se inicializan los campos del objeto self.dato=dato self.next=None self.prev=None def peek():#Metodo peek se manda p a la raiz y recorre toda la lista para ir imprimiendo los datos...
3325e3c1310730fcc1656de777fd3e2d5c344d66
CharlieCarlon/EstructuraDeDatos20188
/Practica23Unidad3Listasdoblespush.py
2,539
3.9375
4
import sys class Nodo(object):#"""Se crea la clase nodo y se inicia el metodo constructor""" def __init__(self,dato): #Se inicializan los campos del objeto self.dato=dato self.next=None self.prev=None def PushNodo(self,nodo):#Metodo push es el metodo el cual va a enlazar a los no...
0ec6649be950c71297dbc01a294c67b4ba388fc2
CharlieCarlon/EstructuraDeDatos20188
/Actividad2Unidad1.py
1,693
4.21875
4
"""Iciciamos variables""" n=0 """Creamos la libreria cache esta va a guardar las llamadas a la fuuncion mas renciente para que no gaste tanto en memoria volviendo a llamar a la funcion""" fibonacci_cache = {} def fibonacci(n): """Se revisa si el valor esta guardado en nuestra libreria, si no calculamos el te...
69c9c2706f44cccee58f52386237eec93ea0fcc3
Jamie-Chang/advent2019
/d3/main.py
1,103
3.765625
4
from __future__ import annotations from typing import Iterator, Tuple, List Wire = List[Tuple[str, int]] Coord = Tuple[int, int] def read_code() -> Iterator[Wire]: with open("input.txt", "r") as f: for l in f: line = l[:-1] yield [(i[0], int(i[1:])) for i in line.split(",")] de...
61a0647669761f04e638a44c8bdcfa315aa6c60e
akshaali/Competitive-Programming-
/Hackerrank/DayOfTheProgrammer.py
3,484
4.8125
5
""" Marie invented a Time Machine and wants to test it by time-traveling to visit Russia on the Day of the Programmer (the day of the year) during a year in the inclusive range from to . From to , Russia's official calendar was the Julian calendar; since they used the Gregorian calendar system. The transition from...
461ad5fff551ecfbb109842b78c03a33c3fe6156
akshaali/Competitive-Programming-
/Hackerrank/minimumDistances.py
1,525
4.375
4
""" We define the distance between two array values as the number of indices between the two values. Given , find the minimum distance between any pair of equal elements in the array. If no such value exists, print . For example, if , there are two matching pairs of values: . The indices of the 's are and , so their ...
34240c8a1cd3c2132e6bd8121ae449b44ec92c58
akshaali/Competitive-Programming-
/Hackerrank/TimeConversion.py
1,432
4.1875
4
""" Given a time in -hour AM/PM format, convert it to military (24-hour) time. Note: Midnight is 12:00:00AM on a 12-hour clock, and 00:00:00 on a 24-hour clock. Noon is 12:00:00PM on a 12-hour clock, and 12:00:00 on a 24-hour clock. Function Description Complete the timeConversion function in the editor below. It sh...
689a7f8c2643819de8930cfc93ceab46697b605a
akshaali/Competitive-Programming-
/Hackerrank/pickingNumbers.py
2,479
4.5625
5
""" Given an array of integers, find and print the maximum number of integers you can select from the array such that the absolute difference between any two of the chosen integers is less than or equal to . For example, if your array is , you can create two subarrays meeting the criterion: and . The maximum length su...
c9488b2c6856e3c6b87db68ee117bb4e01380325
akshaali/Competitive-Programming-
/Hackerrank/designerPDFViewer.py
2,008
4.21875
4
""" When you select a contiguous block of text in a PDF viewer, the selection is highlighted with a blue rectangle. In this PDF viewer, each word is highlighted independently. For example: PDF-highighting.png In this challenge, you will be given a list of letter heights in the alphabet and a string. Using the letter ...
0e016e34e46435270dc0bba650016e7ba56a2ced
akshaali/Competitive-Programming-
/Hackerrank/gridChallenge.py
2,281
4.15625
4
""" Given a square grid of characters in the range ascii[a-z], rearrange elements of each row alphabetically, ascending. Determine if the columns are also in ascending alphabetical order, top to bottom. Return YES if they are or NO if they are not. For example, given: a b c a d e e f g The rows are already in alphabe...
85cff04c62bb855860c2ec7c59c365483979388a
akshaali/Competitive-Programming-
/Geeks For Geeks/maximumSubSequence.py
1,104
3.765625
4
""" Given an array A of N positive integers. Find the sum of maximum sum increasing subsequence of the given array. Input: The first line of input contains an integer T denoting the number of test cases. The first line of each test case is N(the size of array). The second line of each test case contains array elements...
918519d14aa6d0984c66c9bd431c51d9ac82c263
akshaali/Competitive-Programming-
/Hackerrank/anagram.py
2,668
4.4375
4
""" Two words are anagrams of one another if their letters can be rearranged to form the other word. In this challenge, you will be given a string. You must split it into two contiguous substrings, then determine the minimum number of characters to change to make the two substrings into anagrams of one another. For e...
54c0a48e87f31af1f129a16230921cce367a1dbc
akshaali/Competitive-Programming-
/Hackerrank/AppendandDelete.py
2,682
4.125
4
""" You have a string of lowercase English alphabetic letters. You can perform two types of operations on the string: Append a lowercase English alphabetic letter to the end of the string. Delete the last character in the string. Performing this operation on an empty string results in an empty string. Given an integer...
7b06035d7aff5790301a6481bb1943ed25c7e37d
jfan3/pharmacy_count
/src/pharmacy_counting.py
4,213
4.21875
4
import sys import os import csv class Drugbook: ''' The Drugbook class is an aggregate of Drugs ''' class Drug: '''The Drug class is a subclass of Drugbook class. It keeps tracks of all the prescriptions taken place, down to the individual level, and the total costs''' def __ini...
8dc43a163d1d0f0aef30ae8389040876d24f6c2c
AndreyIvantsov/PythonEx
/ex40.py
643
3.578125
4
#!/usr/bin/python3 # -*- coding: utf-8 -*- class Song(object): def __init__(self, lyrics): self.lyrics = lyrics def sing_me_a_song(self): for line in self.lyrics: print(line) happy_bday = Song([ 'Не могу я тебе в день рождения', 'Дорогие подарки дарить', 'Но зато в эт...
bbd275e02fe524a23e27dfcb414e9e2fbf2588fa
connorsadler/pythonpublic
/advent_of_code_2020/day2.py
3,251
4.0625
4
print("hello day 2") print('__file__: ', __file__) f = open("advent_of_code_2020/day2_input.txt", "r") # fileLines = f.readlines() # for line in fileLines: # print(f"file line: {line}") def parseLine(line): parts = line.split(":") return parts[0].strip(), parts[1].strip() # # A range from-> to e.g. ...
ce478a6ae35501cd55525ebe7526d08075507965
ariv14/python
/Day2_number_manipulation/life_left_mini_project/life_left_mini_project.py
676
4.15625
4
# Lifetime calculator print("Lifetime calculator\nEnter your age and maximum expected age\n") age = input("Enter your age : ") max_age = input("Enter your maximum lifetime age :") print("\n") age_in_months = int(age) * 12 age_in_days = int(age) * 365 age_in_weeks = int(age) * 52 max_age_years = int(max_age) max_age_mo...
83e4ae0872601c41974ea40725d6dace62e0d338
ariv14/python
/Day3_if_else/ifelse.py
328
4.4375
4
# Even or odd number finder print("Welcome!! Please input any number to check odd or even !!\n") # Get the input number as integer number = int(input("Which number do you want to check? ")) #Write your code below this line if number % 2 == 0: print("The number is even number") else: print("The number is odd n...
6159694c12f7f50d04bec6e26e6ff930a73361e3
MMGroesbeck/CS-Build-Week-2
/merge-two-sorted-lists.py
1,397
3.984375
4
# https://leetcode.com/problems/merge-two-sorted-lists/ # Definition for singly-linked list. class ListNode: def __init__(self, val=0, next=None): self.val = val self.next = next class Solution: def mergeTwoLists(self, l1, l2): this1 = l1 this2 = l2 if this1.val >= this2...
fd9aa60a03032bf76aed1ab274589ac40819fc4d
Pikselas/decimal-converter
/pj.py
3,333
4.125
4
#decimal to binary,hexa,octal converter #All functions for Binary conversion import tkinter as ui def BinaryConverter(num): print("**Steps For Binary Conversion**") BinaryList = [] BinaryResult = "" result = num quationt = "" print("Taken number: "+str(num)) while result >= 2: ...
8951ac6f31c566677fbaed51f84b73ba14fec279
uygnef/test-and-try
/dp.py
2,192
3.5
4
''' 题目一:买书        有一书店引进了一套书,共有3卷,每卷书定价是60元,书店为了搞促销,推出一个活动,活动如下:               如果单独购买其中一卷,那么可以打9.5折。        如果同时购买两卷不同的,那么可以打9折。        如果同时购买三卷不同的,那么可以打8.5折。               如果小明希望购买第1卷x本,第2卷y本,第3卷z本,那么至少需要多少钱呢?(x、y、z为三个已知整数)。          当然,这道题完全可以不用动态规划来解,但是现在我们是要学习动态规划,因此请想想如何用动态规划来做?   ''' import numpy as...
e31ff46189bcaba54662e5db13ced8ec2043c7ed
Rich-Clack/Python
/replace.py
240
3.734375
4
table=[] msg=input("Enter your message here :") find=input("Enter the word you want to replace :") word="" count=0 while i<len(msg): if msg[i]==find[0]: if msg[i:len(find)+i]==find: count+=1 i=i+len(find)-1 i+=1 print (count)
4d071972c0e7cb240b376ab2bf385f584ce335ef
Rich-Clack/Python
/Result3.py
199
3.875
4
phy= input ("enter Physics:") che = input ("enter Chemistry") mat = input ("enter Maths") total = int(phy)+int(che)+int(mat) per=total*100/450 print("Total Results:", total) print("Percentage:",per)
c16a7c84ce80bec4ca01d23dd3b5c7a452cb2507
Rich-Clack/Python
/addfunction.py
90
3.609375
4
def addition(A,B): Result=A+B print("The Result is :", Result) addition(10,20)
b11914772909f0733c531bf437f5034c939ec0f7
Rich-Clack/Python
/replace2.py
165
3.5625
4
file_read=open("test2.txt","r") for data in file_read: i=0 while i<len(data)-1: if data[i]=="o": print("#",end="") else: print(data[i],end=" ") i+=1
d5cc770192a6d1290fde830817b83492de6f4de4
Rich-Clack/Python
/lettercount2.py
125
3.765625
4
letters=[] while True: msg=input("Enter letters here :") if msg=="": break else: letters.append(msg) print(letters)
cf500c5ff6d5e288fad350e3b905e82e537db422
Rich-Clack/Python
/lettercount4.py
379
3.53125
4
alpha=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] message=input("Enter your message here :") i=0 while i<len(message): message = message.upper() alpha[ord(message[i])-65]+=1 i+=1 i=0 print("There are the below letters included in your message :") while i<=25: if alpha[i]>0: print(chr(i+65)," = ",alpha[i...
0b0c50bf74a57e8a2491b3802d65ca1f7da91427
Rich-Clack/Python
/word.py
161
3.75
4
word=0 msg=input("Enter your message here :") i=0 while i<len(msg): if msg[i]==" ": word=word+1 i=i+1 print("There are ",word+1,(" words in your message"))
cd874a45a5e67551c9d11d0e77b688d4e1a7582f
yurokji/omok
/omok_2players/omok.py
4,423
3.5
4
import pygame from pygame import QUIT, MOUSEBUTTONDOWN, MOUSEBUTTONUP OMOK_NUM = 5 NO_DOL = 0 BLACK_DOL = 1 WHITE_DOL = 2 RED = (255, 0, 0) WHITE = (255, 255, 255) BLACK = (0, 0, 0) YELLOW = (255,200,0) pad = 40 cell_size = 50 dol_size = 40 board_width, board_height = 19, 19 w = cell_size * (board_width...
da17f8e8ce5e11def28326eb526d983c5010a3b0
brosner/cleese
/necco/kernel/listtest.py
318
3.703125
4
# test for list support print "LIST TEST" m = list("!a!b!c!") print "got here!" print m print m.count("!") print m.index("a") print tuple(m[2:4]) for x in m: print x d = {1: 1, 2:2 } print d[1] e = {"1": "1", "2": "2"} print e["1"] if 1 in (1,2): print "yes" print "a" == "b" print "a" == "a"
5b05abfb21bf9b8dea2dd9de4d1d859b09dc0dd5
selinoztuurk/koc_python
/inclass/day1Syntax/lab1.py
1,416
4.25
4
def binarify(num): """convert positive integer to base 2""" if num<=0: return '0' digits = [] division = num while (division >= 2): remainder = division % 2 division = division // 2 digits.insert(0, str(remainder)) digits.insert(0, str(division % 2)) return ''.join(digits) print(binarify(10)...
b84e8d6e8d9e56c994619d27c5e8bd241e5388e8
dogiergin/stok-takip
/4_5893174968153277969.py
1,500
3.5
4
urun_listesi = {'elma': 10, 'armut': 58, 'kivi': 47, 'karpuz': 26, 'kavun': 12} alis_fiyatı = {'elma':2,'armut':6,'kivi':7,'karpuz':8,'kavun':5} satis_fiyati = {'elma':4,'armut':11,'kivi':12,'karpuz':10,'kavun':8} toplam_kar = {} while True: print('ürün satışı=1 ,karlılık hesapla = 2 , gün sonu =3 ,ürün ekle veya d...
2e838b2b8826518cdef71b91ecb7a19adf0cc58a
G-Vicky/30-days-of-code
/Day 8: Dictionaries and Maps/python.py
329
3.84375
4
phoneBook = {} n = int(input()); for _ in range(n): name, phone = input().split(" ") phoneBook.update({name : phone}) try: while True: q = input() if q in phoneBook.keys(): print("{}={}".format(q, phoneBook.get(q))) else: print("Not found") except: pass...
cdedd4eb4ac38c81ab4a9c046c09112d49ec692f
1226tmxpvksh/leaning_python
/py_1118/py_1118/py_1118.py
719
3.671875
4
statement=input("문자열을 입력하시오: ") #문자열 조사 alphas=0 digits=0 spaces=0 for c in statement: if c.isalpha(): alphas=alphas+1 if c.isdigit: digits=digits+1 if c.isspace(): spaces=spaces+1 print("알파벳 문자의 개수=",alphas) print("숫자 문자의 개수=",digits) print("스페이스의 개수=",spaces) def get_sum(start, end): #1부터10까지 함수 sum=0 f...
38cbb3d8afadcdb3616c317f0d5c2a1dd7b46092
needanyhelp/MyleetcodeSolution
/76. Minimum Window Substring.py
631
3.578125
4
from typing import List import collections def solution(s, t): if not(s and t): return False window_size=len(t) i=0 while True: next=0 if(window_size>len(s)): return False if(i==len(s)-window_size+1): i=0 window_size+=1 ...
6eb19186252d9b7898e81313c9b6abba3d90d93f
marxjoy/Tic-Tac-Toe-Using-Minimax
/test_tictactoe.py
3,372
3.609375
4
import unittest from tictactoe import * class TestFunctions(unittest.TestCase): def test_player(self): board = [[EMPTY, EMPTY, X], [EMPTY, EMPTY, EMPTY], [EMPTY, EMPTY, O]] self.assertTrue(player(board)==X) board = [[EMPTY, EMPTY, EMPTY], [...
af9837bb5023f21b3f36c1356fc40dbc2351fa58
LD1016/Data-Structures-and-Algorithms
/Coding_Challenge/Backtracing/permutations.py
629
3.921875
4
""" Given a collection of numbers, return all possible permutations. Example: [1,2,3] will have the following permutations: [1,2,3] [1,3,2] [2,1,3] [2,3,1] [3,1,2] [3,2,1] """ class Solution: # @param A : list of integers # @return a list of list of integers def permute(self, A): if len(A) =...
a525089eded646116e7485530e8af8c020205b7c
LD1016/Data-Structures-and-Algorithms
/Coding_Challenge/Graph_DataStructure_Algorithm/dfs1.py
384
3.6875
4
def dfs(graph, node, visit=None): if visit is None: visit = set() visit.add(node) print(node) for i in graph[node]: if i not in visit: dfs(graph, i, visit) graph = {'0': set(['1', '2']), '1': set(['0', '3', '4']), '2': set(['0', '4']), '3': set(['...
e69df8453d5b500cd4fa7c0f416bd7b1ba752040
LD1016/Data-Structures-and-Algorithms
/Coding_Challenge/Microsoft_Problems/microsoftInsertdigit5.py
876
3.828125
4
""" You are given an integer (in finite range [-N, N]) and you wish to maximize the number by inserting somewhere the digit '5'. example: '128' -> '5128' '0' -> '50' '678' -> '6785' '748' -> '7548' '-999' -> '-5999' """ def solution(A): res = [] stringNum = str(A) allGreater = True neg =...
e74e781d9311cece7ff02fb7ec51555df179c6ff
LD1016/Data-Structures-and-Algorithms
/Coding_Challenge/Tree_Data_Structure/validBSTfromPreorder.py
626
3.734375
4
""" Check if a given array can represent Preorder Traversal of Binary Search Tree Input: pre[] = {40, 30, 35, 80, 100} Output: true Given array can represent preorder traversal of below tree 40 / \ 30 80 \ \ 35 100 Input: pre[] = {40, 30, 35, 20, 80, 100} Output: false Given array cann...
c190d3ebdec66fa7d9e648fca5446d257bf4fa9f
LD1016/Data-Structures-and-Algorithms
/Recursion_Algorithm/fibonacciRecursive.py
189
4.09375
4
def fibonacciRecursive(n): if n == 0 or n == 1: return n return fibonacciRecursive(n-1) + fibonacciRecursive(n-2) print(fibonacciRecursive(8)) print(fibonacciRecursive(3))
c20ae3b4e1bfb3e8d2ab12dfb571744cdc49bc65
LD1016/Data-Structures-and-Algorithms
/Coding_Challenge/Link_List/kReverselinkedList.py
1,168
3.921875
4
""" Given a singly linked list and an integer K, reverses the nodes of the list K at a time and returns modified linked list. NOTE : The length of the list is divisible by K Example : Given linked list 1 -> 2 -> 3 -> 4 -> 5 -> 6 and K=2, You should return 2 -> 1 -> 4 -> 3 -> 6 -> 5 """ # Definition for singly-l...
3929b167426e15020c8065658af658493e47ab70
LD1016/Data-Structures-and-Algorithms
/Coding_Challenge/Math/isPrime.py
569
3.875
4
class Solution: # Because if a number has a factor D, it can be expressed as N = D * (N/D). # Now one of D or N/D has to be smaller or equal to Sqrt(N) # One factore should be <= sqrt(n) and another should be >= sqrt(n) # @param A : integer # @return an integer def isPrime(self, A): if ...
3b119dace61de731d398f82b5278ae600ef6ad68
LD1016/Data-Structures-and-Algorithms
/Sorting_Algorithm/mergeSort.py
629
4.09375
4
def merge(left, right): result = [] leftIndex = 0 rightIndex = 0 while leftIndex < len(left) and rightIndex < len(right): if left[leftIndex] > right[rightIndex]: result.append(right[rightIndex]) rightIndex += 1 else: result.append(left[leftIndex]) ...
02bc3f8082ebfc059c92085d9599a452565aed51
HappyAnony/studynotes-of-python
/DataType/set.py
1,286
4
4
#!/usr/bin/env python # -*-coding :uft-8 -*- # Author:Anony ''' 集合是一个无序的,不重复的数据组合。它的应用场景: 去重:把一个列表变成集合,自动去重 关系测试:测试两组数据之前的交集、差集、并集等关系 ''' list1 = [1,3,4,5,6,4,2,1,2,3] set1 = set(list1) print(set1,type(set1)) set2 = set([1,4,6,8,9,44]) print(set2.intersection(set1)) #取交集 print(set2 & set1) print(set2.i...
96e358a7f5a93960c58b36ed16d74be5c175c63b
HappyAnony/studynotes-of-python
/Modules/进程线程/threading_t.py
7,747
4.09375
4
#!/usr/bin/env python # -*-coding :uft-8 -*- # Author:Anony #********************************************线程的调用方式************************************************************* # 方法一:直接调用 ''' import threading import time def sayhi(num): # 定义每个线程要运行的函数 print("running on number:%s" % num) time.sleep(2) if __name__ ...