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
ceed1c0e2ba80a0a434b8a0e600463624782c1c7
abdurahmanadilovic/elements-of-programming-interviews
/hackathon/column1/test_9_10.py
667
3.609375
4
from unittest import TestCase from .problem_9_10_binary_tree_nodes_in_order import solution, Node class TestSolution(TestCase): def testHeight1(self): root = Node(1) left = Node(2) right = Node(3) root.left = left root.right = right self.assertEqual([[1], [2, 3]], ...
baac5925f16fe9ce743b826f19acfe721c2a79f6
abdurahmanadilovic/elements-of-programming-interviews
/hackathon/column1/problem_7_2_base_conversioni.py
1,308
3.796875
4
def letter_to_number(letter): if letter == 'A': return 10 if letter == 'B': return 11 if letter == 'C': return 12 if letter == 'D': return 13 if letter == 'E': return 14 if letter == 'F': return 15 else: return int(letter) def int_to_...
29e7d98af313c036143b41aa3cb5a1e759959ab6
abdurazzak2002/lesson6
/lesson_6.py
862
3.953125
4
#Кортеж - tuple # products = ('milk', 'orange', 'apple') # for product in products: # print(product) #print(products[::2]) # users = ['Ahmed', 'Askar', 'admin2', 'admin'] # for user in users: # if user == 'admin': # print('Welcom! Admin') # users = ['Ahmed', 'Askar', 'admin2', 'admin'] # baned_user...
b60b821853e52e5f8181ac47834bb9366f3c8002
Mdellasilva/CSE111
/fuel_usage.py
654
3.96875
4
def main(): start_miles = int(input('Enter the first odometer reading (in miles): ')) end_miles = int(input('Enter the second odometer reading (in miles): ')) amount_gallons = float(input('Enter the amount of fuel used (in gallons): ')) mpg = miles_per_gallon(start_miles, end_miles, amount_gallons) ...
1712892d8d87ea7ffc0532bedeb31afd088c47bc
damianserrato/Python
/TypeList.py
693
4.46875
4
# Write a program that takes a list and prints a message for each element in the list, based on that element's data type. myList = ['magical unicorns',19,'hello',98.98,'world'] mySum = 0 myString = "" for count in range(0, len(myList)): if type(myList[count]) == int: mySum += myList[count] elif type(m...
2d5273b86616f827bed2a4496b4fe6854acf5ac3
damianserrato/Python
/FindCharacters.py
388
4.15625
4
# Write a program that takes a list of strings and a string containing a single character, and prints a new list of all the strings containing that character. word_list = ['hello','world','my','name','is','Anna'] char = 'o' newList = [] for count in range(0, len(word_list)): for c in word_list[count]: if ...
bbc24bbb74f2ee4a73e23d885f956c572abb418e
Winston1011/PythonTests
/RANGE AND WHILE.py
100
3.515625
4
for x in range(10, 40, 5): print(x) crack = 5 while crack < 10: print(crack) crack += 1
9609f68a050e686760b8dd6b7a3e49541e900307
Winston1011/PythonTests
/Dictionary.py
426
3.984375
4
classmates = {'Tony': ' cool but smells', 'Emma': ' sits behind me', 'Lucy': ' asks too many questions'} dic = {'A': 1, 'B': 2, 'C': 3, 'D': 4} print(classmates) print(classmates['Emma']) print(dic) print(dic['A']) print(dic.keys()) print(dic.values()) print(dic.items()) for k, v in classmates.items(): print(k + ...
91ccd982ae5c52e4eda5f83bba7de75c874d0a00
kevin-meyers/data-struct-algo
/data_struct_algo/hashtable/hashtable.py
2,418
3.546875
4
from dataclasses import dataclass from linked_lists.singly_linked_list import SinglyLinkedList @dataclass class KV_pair: key: object value: object def __eq__(self, other): return self.key == other.key class HashTable(object): def __init__(self, init_size=8): # Create a new list (us...
fa35a484aa7275dfd55aa4de42a2ea00b97bacd5
kevin-meyers/data-struct-algo
/data_struct_algo/queues/deque.py
1,813
3.96875
4
class Node: def __init__(self, data): self.data = data self.next = None self.previous = None class Deque: def __init__(self): self.head = None self.tail = None self.length = 0 def __len__(self): return self.length def __iter__(self): wh...
6938dc413c0e87946eb02582257494ae2f982c8c
antlaw0/Capstone-Group3-Encyclopedia-Web-App
/models.py
3,095
4.15625
4
""" This is used to hold database functions """ import sqlite3 as sql def insertUser(email, username,password): con = sql.connect("database.db") cur = con.cursor() cur.execute("INSERT INTO users (email, username, password) VALUES (?,?, ?)", (email, username,password)) con.commit() con.close() d...
2f7996f682ae20bff0aab732a438b2539b0761cc
jansk32/Chexers_3
/part-B-skeleton/astar/player.py
17,365
3.9375
4
from collections import defaultdict import math import numpy as np # coordinate indexes X = 0 Y = 1 # directions relative to a space DIRECTION_E = 0 DIRECTION_SE = 1 DIRECTION_SW = 2 DIRECTION_W = 3 DIRECTION_NW = 4 DIRECTION_NE = 5 # PLAYER_TYPE = '' BOARD_EDGE = 3 MAX_DISTANCE = 7 MOVE_DISTANCE = 1 JUMP_DIST...
ed26125876995eb402ce4e8ddbb01bf85740522e
lucasmunizz/CaixaEletronico
/Cliente/Menu_Cliente/MenuCliente.py
1,425
3.921875
4
import os import time def menu(): lista = [] # lista vazia while True: time.sleep(2) os.system("cls") print("======== MENU CLIENTE =======") print("1 - Cadastrar Banco ou Fintech") print("2 - Alterar Banco ou Fintech") print("3 - Listar Bancos e Fintec...
c9d041de20c12e5dcac2445fe21af779c36b367a
isaacton/Clean-cal
/CALCULATOR.py
3,489
3.734375
4
from tkinter import * def btnClick(numbers): global operator operator = operator + str(numbers) text_input.set(operator) def btnClearDisplay(): global operator operator="" text_input.set("") def btnEqualsInput(): global operator sumup = str(eval(operator)) text_input.set(sumup) ...
9280f671ea01ce5ac0b950d14513c1873a3ac6dd
CHOIJUNGWON/big_data_web
/python/if/4-1.py
154
3.875
4
a=int(input("첫번째 수 :")) b=int(input("두번째 수 :")) if ((a<0) and (b>0)) or ((a>0) and (b<0)): print("음수") else : print("양수")
4f60622ec71dbd2fccd52cc42dd2f6853cacd8d0
CHOIJUNGWON/big_data_web
/python/if/avg.py
251
3.828125
4
a=int(input("첫번째과목: ")) b=int(input("두번째과목: ")) c=int(input("세번째과목: ")) avg=(a+b+c)/3 if avg >=60: if a>40 and b>40 and c>40 : print("합격") else : print("과락") else : print("불합격")
07408d6aba13c4c9038c93e41da24a4ad098944a
CHOIJUNGWON/big_data_web
/python/list1.py
356
3.640625
4
list_1 = ["risk", "issue", "test", "maintenance", "maturity"] list_2 = ["security", "plan", "design", "systematic", "safety"] list_3 = ["maintenance", "verification", "vlaidation"] if ('maintenance' in list_1) and len(list_1) >= 5: print("list_1 will be tested") elif ('maintenance' in list_2) and len(list_2) >= 5:...
5d36bbfdf81c5c56b5c4fb5b6f663e770947d59a
CHOIJUNGWON/big_data_web
/python/for,while/(for,while)practice5.py
145
3.875
4
i = 1 a=int(input("숫자를 입력해주세요 :")) while i<a+1: if i%3==0: print("짝") else: print("%d"%i) i+=1
a83bd11e714aafc8e7670c908df9fe5b1a81ab39
CHOIJUNGWON/big_data_web
/python/if/3multiple.py
131
3.890625
4
a=int(input("숫자를 입력해 주세요: ")) if a%3==0 : print("3의 배수") else : print("3의 배수가 아니다")
081a42ff67b1c19b500e608e8cb8029cfce3f9f2
ederross/pythonExerc-cios
/Desafio3.py
481
4.03125
4
def main(): # a_str e b_str guardam strings a_str = input("Digite o primeiro numero: ") b_str = input("Digite o segundo numero: ") # a_int e b_int guardam inteiros a_int = int(a_str) # converte string/texto para inteiro b_int = int(b_str) # converte string/texto para inteiro # calcule a so...
de2fbf91ff7b8c761b753a30d2898ec1180ec92d
DiracMG3/Cirq-Quantum-Computing-OLD
/simon/simon.py
11,327
3.828125
4
''' --------------------------------- SIMONS'S ALGORITHM - OVERVIEW --------------------------------- Simon's Algorithm solves the problem of finding a particular value of s when some function f:{0, 1}^n --> {0, 1}^n is inputted into the program that follows this rule: "f(x) = f(y) if and only if x (+) y is in the set ...
b2022d97eca35cffaea7269505b9f49fbfc5dfaf
KhienghThenYang/DecoderToolbox
/decoder/vigenere.py
962
3.5
4
from decoder.basic import * def encode_vigenere(plaintext="", key=""): return ''.join([rot_by_char(s, key[i % len(key)]) for i, s in enumerate(plaintext)]) def decode_vigenere(cipher="", key=""): return ''.join([rot_by_char(s, key[i % len(key)], reverse=True) for i, s in enumerate(cipher)]) def encode_aut...
de003901c2b4cb44ab851f108c78d790010cb070
steventasong/test2
/Shakespear.py
1,379
4
4
import csv opened_file = open('Documents/shakespeare.txt') text_data = list(opened_file) # not sure if these should be removed from words -- punctuation=['(', ')', '?', ':', ';', ',', '.', '!', '/', '"', "'"] punctuation=['(', ')', '?', ':', ';', ',', '.', '!', '/', '"', "'", "-", "[", "]", "*", "&", "<", ">", "_...
17c44b7d80bb5d7e25f99a12789c960ca9223427
hyun-park/__Python__SogangPythonClass
/programmers/Level5/124나라의_숫자.py
455
3.78125
4
def change124(num): numbers = ['1','2','4'] numberList = [] while num>=3: numberList.append(numbers[(num%3)-1]) if num%3 ==0: num=(num-1)//3 else: num=num//3 if num != 0: numberList.append(numbers[num-1]) numberList.reverse() answer = "".join(num...
0e585220d9d99fa3bf6c83360c2692b9e18683f1
KuKuXia/DL-02-MiniFlow
/Code/MF_nn.py
2,021
3.59375
4
# @Time: 2019/1/2 0002 10:02 # @Author: KuKuXia # Note: """ This script builds and runs a graph with miniflow. There is no need to change anything to solve this quiz! However, feel free to play with the network! Can you also build a network that solves the equation below? (x + y) + y """ """ No need to change anyth...
707a9712bcc3b0f7ff9e9bdcd2d6bdb0eae43b17
JadyVella/News
/app/article_test.py
566
3.625
4
import unittest from models import articlezzz Article = article.Article class ArticleTest(unittest.TestCase): ''' Test class to test the behaviours of the Article class ''' def setUp(self): ''' Set up method that will run before every test ''' self.new_article = Articl...
228d82846bf45d1428e216cc7275ad03d4174e8c
pargles/lru-exercise
/src/DoubleLinkedList.py
1,935
3.9375
4
class Node: def __init__(self, previous_node, next_node, key, value): self.previous_node = previous_node self.next_node = next_node self.value = value self.key = key class DoubleLinkedList: # tail will always have the latest element def __init__(self): self.head = ...
404fc791f55cb22ca0483da1d26faf0aeb5c7560
jeflucas/pyQuizGame
/index.py
720
3.9375
4
points = 0 print('Welcome to capital game:') playing = input("Do you wwant to play this game? (y/n) ") if playing.lower() != 'y': quit() print('Lets play!') answer = input('What is the capital of Brazil? ') if answer == 'brasilia': print('Excellent!') points = points + 1 else: print('Incorre...
a182c36e53adbbe7d5daf94bf2d7a6d9551d3a66
brendalima/python-exercises
/media.py
347
4
4
def main(): N = input ("quantas notas deseja calcular a media?") print media (N) def media (N): cont = 1 soma=0 while cont <= N: nota = input ("digite uma nota:") soma = nota+soma cont = cont + 1 media = float(soma/N) return media if __name__ =...
50b58ff98538192993f1fd6ad8d022568dab1b96
Ko-ch/hello-cli
/app.py
233
3.734375
4
print("What's your name? > ") yourname = input() print('Hi! Fucking {}'.format(yourname)) print(f"Hi! Fucking {yourname}") print("Hi! Fucking " + yourname) print("Hi! Fucking ") print('koichiro' + str(1) + yourname) breakpoint()
0261a897b8138dbd6d10f6ca508252788a61e8a9
RolandaLiu1234/-1234--
/2020.1017-2.py
296
3.609375
4
style=["mini","short","odinary","long","very long"] color=["white","pink","orange","blue","Navy"] season=["Spring and autumn","summer","winter"] for i in style: for j in color: for k in season: print(i, j, sep="-") print(i, j, k, sep="-")
3cec058760beac88450e5f7e1bf5e869f7a7967d
mariaIFPB/IFNetwork
/IFNetwork/model/amigo_usuario.py
519
3.734375
4
import sqlite3 class Amigo_Usuario(): def __init__(self, email1, email2): self.email1 = email1 self.email2 = email2 conn = sqlite3.connect('IFNetwork.db') cursor = conn.cursor() email1 = int(input("informe seu email: ")) email2 = int(input("informe o ema...
8a833841f94024fa0c6e5185a78d4b404716ba8c
Hikareee/Phyton-exercise
/Programming exercise 1/Area of hexagon.py
266
4.3125
4
import math #Algorithm #input the side #calculate the area of the hexagon #print out the area #input side of hexagon S = eval(input("input the side of the hexagon: ")) #area of the hexagon area=(3*math.sqrt(3)*math.pow(S,2))/2.0 #print out the area print (area)
57dade26618bcc78be53ac5349a88a1f13a778e4
Hikareee/Phyton-exercise
/Function assignment/All of em in one file.py
3,085
4.34375
4
#%% #name the function "convert_to_days" def convert_to_days(): #input hours hours = int(input("Enter number of hours: ")) #input minutes minutes = int(input("Enter number of minutes: ")) #input seconds seconds = int(input("Enter number of seconds: ")) def get_days(): days = (hours/2...
20f40e8835694cd81b358e99604344c5b4df70cd
qingdaodahui/PSI_KOMI_PYTHON
/Point.py
859
3.984375
4
import math class Point(object): """ Description of Point class """ def __init__(self, x = None, y = None): if x is None: self.x_location = 0 else: self.x_location = x if y is None: self.y_location = 0 else: self.y_location...
46edfa97e99785f6f66cf47f1ab82d4f1334394a
gopi101/pythonprog
/factorial of a number.py
90
3.609375
4
n = 5 fact = 1 for i in range(1,n+1): fact = fact * i print (end="") print (fact)
13da155d6a25d4f25d0c40b58e6c7e6a95898000
joja6309/InterviewScripts-
/Charter_BlackJack_Jackson/Charter_BlackJack_Jackson/Charter_BlackJack_Jackson.py
3,528
3.765625
4
import sys import os import random # Ok so the entire program doesn't work I know you said to keep my solution time # down to an hour. I did get the player part working. The game function just needs a little more # code to implement a black jack dealer SUITS = ['Clubs', 'Spades', 'Hearts', 'Diamonds'] VALUE ...
6c42e82aa643170526f1d36aa37408e913f64168
duodecimo/spk
/python3/lembretes/classes.py
1,827
3.5
4
class nodados: # possui atributos para processar e gerar o No da arvore def __init__(self, indice, palavras, mensagens): self.__indice = indice # vai ser o índice do dicionario arvore self.__palavra = None # a melhor palavra que divide os nós self.__respostas = None # uma lista de ...
0ad4f893ccc66bf65d96e3aaa8d5cc0f2474049d
AaronNolan/Email-Admin-App-Python
/Email.py
2,109
3.71875
4
#!/usr/bin/env python import random class Email: defaultpasswordlength = 10 company_url = "company.com" emailcapacity = 500 def __init__(self, firstname, lastname): self.firstname = firstname self.lastname = lastname self.password = Email._randompassword(self) ...
51150a87bda43b7f1a9c1787005001a034b73232
rvrn2hdp/informatorio2020
/FuncionesComp/func9.py
1,182
4.21875
4
'''Ejercicio 9: ¿Un string representan un entero? En este ejercicio escribirá una función llamada es_entero que determina si los caracteres en una cadena representan un número entero válido. Al determinar si un string representa un número entero, debe ignorar cualquier espacio en blanco inicial o final. Una vez que...
9d0d3dd9396aa1135f9d3f84d5d6ba7c76c3cffa
rvrn2hdp/informatorio2020
/FuncionesComp/func6.py
731
4.125
4
'''Ejercicio 6: Centrar una cadena en la terminal Escriba una función que tome una cadena de caracteres como primer parámetro y el ancho de la terminal en caracteres como segundo parámetro. Su función debe devolver una nueva cadena que consta de la cadena original y el número correcto de espacios iniciales para que...
1659e7e9cf8105b6b66b90fe2764d7feb6c10f4f
rvrn2hdp/informatorio2020
/3_lists_documentation_examples.py
17,339
4.71875
5
''' Son un tipo de dato que nos permite manejar grandes cantidades de datos. Este tipo de dato es similar a los arreglos con la diferencia de que en este caso las listas pueden cambiar de tamaño pueden crecer o decrecer, los arreglos no. Son mutables: lo que significa que sus elementos pueden cambiar o reordenarse. ...
bba6fba3ed8997017a9bf2d99f2c64d8fd3da4be
rvrn2hdp/informatorio2020
/Desafios1/desafiorepetitiva2.py
555
3.875
4
""" Se inicia una campaña de recolección de colillas de cigarrillos en los barrios. Realizá un programa que permita registrar cantidad de colillas recolectadas por un número determinado de personas. Luego obtener estadísticas al respecto informando porcentaje de personas que han encontrado menos de 100 colillas, más...
2580e93a9665e26326c9478950be89a27e1709e0
rvrn2hdp/informatorio2020
/Desafios1/desafiorepetitiva5.py
1,350
4.125
4
"""Se está desarrollando un sistema de control de vehículos desde donde se han tirado restos de basura a la vía pública. Para ello la ciudad cuenta con sistemas de monitoreo de patentes que devuelve 3 letras y un valor numérico de 5 dígitos a la Central con el siguiente significado: 3 letras: Correspondientes a...
7633108013a04f6e5ef0c4287c65002bd12e70c6
rvrn2hdp/informatorio2020
/FuncionesComp/func10.py
1,074
4.21875
4
'''Ejercicio 10: Precedencia del operador Escriba una función llamada precedencia que devuelve un número entero que representa la precedencia de un operador matemático. Una cadena que contiene el operador se pasará a la función como su único parámetro. Su función debe devolver 1 para + y -, 2 para * y /, y 3 para ˆ...
0c3f681c19d3fa3dcd8c854628d9656f0c02decd
rvrn2hdp/informatorio2020
/DesafiosListasTuplasDict/ejercicio_e.py
343
3.796875
4
from copy import copy ''' Cargar m elementos en una pila, y luego copiarlos en una nueva lista. ''' pila = [] while True: m = input("Ingrese un elemento a la pila: ") pila.append(m) seguir = input("¿Seguir agregando? (s/n): ") if seguir == 'n': break lista_nueva = copy(pila) for i in lis...
2750efbff4ce55c01c48c983f0004777428d1412
isikdos/N-Snake
/N-Snake/Snake.py
4,060
4.3125
4
# -*- coding: utf-8 -*- """ Created on Thu May 24 20:15:48 2018 @author: Isik """ from Direction import Direction from Position import Position class Snake: """ This class represents a snake itself. It has, most importantly, a body and a direction. This snake can exist in N dimensions...
063a96456ce2ab1e569d2ba9c36b9e07dca2dbc6
okamotomasatosi/py_doc
/selection_sort.py
673
3.765625
4
### 選択ソート target_list = [15, 9, 10, 14, 4, 11, 8, 1, 12, 7, 3, 5, 13, 2, 6] listlen = len(target_list) print("リストサイズ:" + str(listlen)) print("ソート前") print(target_list) #先頭から末尾まで順番に確定していく for i in range(listlen): ### 判定中の位置より後ろの値と順番に比較を実施 for j in range(i+1, listlen): chekval = target_list[j] ...
f6e83bdd7eefe005205e130099bc4cad22f24951
mohd-hussain/PYTHON
/tkinter.py
858
3.90625
4
from Tkinter import * win=Tk() #adding edit text field s1=Entry(win) s2=Entry(win) #Implementing Add,Sub,Multi and Div Functions def add(): c=int(s1.get())+int(s2.get()) label.config(text="Addition=%d"%c) def sub(): c=int(s1.get())-int(s2.get()) label.config(text="Subtraction=%d"%c) def multi(): c=int(s1.g...
1bc2173e42c72332516a026dec226808acf047a6
Mahmoud-Dinah/data-structures-and-algorithms
/python/code_challenges/hashmap-tree-intersection/hashmap_tree_intersection/hashmap_tree_intersection.py
2,918
3.78125
4
from typing import Hashable class Node: def __init__(self, value): self.value = value self.next = None class LinkedList: def __init__(self): self.head = None def insert(self, value): node = Node(value) if not self.head: self.head = node ...
b93223ddcd0c590034c1191100d7e88f7a00432b
Mahmoud-Dinah/data-structures-and-algorithms
/python/code_challenges/graph-depth-first/graph_depth_first/graph_depth_first.py
2,472
3.84375
4
class Vertix: def __init__(self,value): self.value = value class Edge: def __init__(self,vertix, weight=1): self.vertix = vertix self.weight = weight class Graph: def __init__(self): self.adjacency_list = {} def add_vertix(self, value): v = Vertix(value) ...
660f80aab4e31e072fc186c9b9b52dfef4ca443c
duxun93/LeetCodeProject
/Leetcode_easy/217. Contains Duplicate/217_Contains Duplicate.py
820
3.671875
4
#https://leetcode.com/problems/contains-duplicate/ #我想到了两种方法: # 第一个是,我循环从list里面拿数,拿出以后pop这个数,判断原列表是否还有; # 第二是从列表里面去数,取出以后放入另一个list,每次取数都去新建的list里面查找一下是否已经有了。 def containsDuplicate1(nums): for i in reversed(range(0,len(nums))) : tmp = nums.pop(i) if tmp in nums : return True return Fa...
fece949393af9a7a75bc6af808918f09aefa4dfb
duxun93/LeetCodeProject
/Leetcode_easy/258. Add Digits/258_Add Digits.py
256
3.765625
4
#https://leetcode.com/problems/add-digits/ def addDigits(num): s = str(num) while 1 : tmp = 0 for i in s : tmp = tmp + int(i) s = str(tmp) if len(s) == 1 : return int(s) print(addDigits(38))
9796730d64e77034f3a10e88e32b8d8cc46abc53
duxun93/LeetCodeProject
/Leetcode_easy/415. Add Strings/415_Add Strings.py
1,375
3.515625
4
#https://leetcode.com/problems/add-strings/ def ddStrings(num1, num2): k = 0 sumstr = [] sumtmp = '' len1 = len(num1) len2 = len(num2) if len1 <= len2 : num1 = (len2-len1)*'0' + num1 for i in range(len2-1,-1,-1) : if i != 0 : tmp = int(num1[i]) + int(n...
2dc3a7e1f9e25897975246a5e8e2929584b11fb6
duxun93/LeetCodeProject
/Leetcode_easy/70. Climbing Stairs/70_Climbing Stairs cycle.py
549
3.84375
4
#https://leetcode.com/problems/climbing-stairs/ #跟斐波那契数列结合是有点搞事情了,不过确实是斐波那契数列,但是递归最大的问题就是真的很费时间。 #网上有一个动态规划记录历史数据的方法,就是用一歌list把前面所有的值都记录下来。 #但是怎么感觉这个动态规划还是递归呢,总感觉跟递归没啥区别呀。 #这里用的是循环。 def climbStairs(n): a = 1 b = 1 for i in range(1,n): a , b = b , a+b return b print(climbStairs(3))
fad7ab33f9f75105d49cc56061e6ab867ab370b8
Lordtrituze/Airline-Managerment-System
/services/passengermanager.py
2,930
3.53125
4
from repositories.passenger import Passenger class PassengerManager(): passengers = [] def __init__(self): with open("../files/passengers.txt", "rt") as passengerfile: next(passengerfile) for read in passengerfile.readlines(): read = read.split() ...
d4e385ff7da8641c6c375b0d8d4627575508dfec
josiah14/Algo1-Coursera
/Ch1-Introduction/Merge-Sort/Python/merge_sort_naiive.py
860
3.890625
4
def mergesort(xs): if len(xs) < 2: return xs left_xs, right_xs = _divide(xs) return _conquer(mergesort(left_xs), mergesort(right_xs)) def _divide(xs): return split_at(xs, len(xs) / 2) # not thread safe def _conquer(left_xs, right_xs): # copy the lists to avoid side-effects left = list(...
972caacc1052b0c7f10a71b09eeff49b0e71e39a
SquidMage/Hangman
/hangman.py
2,683
4.09375
4
#! python3 # hangman.py import random, logging logging.basicConfig(level=logging.DEBUG, format=' %(asctime)s - %(levelname)s - %(message)s') logging.disable(logging.CRITICAL) # Declaring important variables. maxAttempts = 0 attemptsLeft = 0 currentGuess = "" prevGuesses = [] correctWord = "" hiddenWord...
87c46da347c92a59219be4c76d824945be1b7e5c
HunterHeidy/leetcode
/动态规划/不同路径2.py
2,058
3.640625
4
# 一个机器人位于一个 m x n 网格的左上角 (起始点在下图中标记为“Start” )。 # 机器人每次只能向下或者向右移动一步。机器人试图达到网格的右下角(在下图中标记为“Finish”)。 # 现在考虑网格中有障碍物。那么从左上角到右下角将会有多少条不同的路径? # 网格中的障碍物和空位置分别用 1 和 0 来表示。 # 说明:m 和 n 的值均不超过 100。 # 示例 1: # 输入: # [ # [0,0,0], # [0,1,0], # [0,0,0] # ] # 输出: 2 # 解释: # 3x3 网格的正中间有一个障碍物。 # 从左上角到右下角一共有 2 条不同的路径: # 1. 向右 ...
be71a9b4d1e95c71b52006647ae76a6c8c5b1e4a
HunterHeidy/leetcode
/数组/搜素插入位置.py
946
4.03125
4
# 给定一个排序数组和一个目标值,在数组中找到目标值,并返回其索引。如果目标值不存在于数组中,返回它将会被按顺序插入的位置。 # 你可以假设数组中无重复元素。 # 示例 1: # 输入: [1,3,5,6], 5 # 输出: 2 # 示例 2: # 输入: [1,3,5,6], 2 # 输出: 1 # 示例 3: # 输入: [1,3,5,6], 7 # 输出: 4 # 示例 4: # 输入: [1,3,5,6], 0 # 输出: 0 # 来源:力扣(LeetCode) # 链接:https://leetcode-cn.com/problems/search-insert-position # 著作权归领扣网络...
6a35c3726c000c61a13fd79352aedb4abc153253
shchepinova/ingatlan-com-parser
/main.py
1,140
3.671875
4
"""Current Python code parses ingatlan.com links for all the listings, requests necessary inforamtion from Google Maps API and dumps it to a JSON. Some HTML/JS magic visualizes it on a Google Maps canvas.""" import IngatlanCom as ic import MapVisualizer as mv def populate_mapvisualizer(to_parse): "Creates, popula...
cf08acb090df3f6e429715a9a972d1cda99df1fa
Johnnyboycurtis/BayesNets
/NaiveBayesNets/TAN/treenb/oldcode/toy-script.py
1,802
3.671875
4
# -*- coding: utf-8 -*- """ Created on Tue Nov 7 15:58:30 2017 @author: jn107154 """ parent = dict() def make_set(vertice): parent[vertice] = vertice # returns first element of set, which includes 'vertice' def find_set(vertice): if parent[vertice] != vertice: parent[vertice] = find_set(parent[ve...
bb33bc654729a3849cc89b76cc87834081bcdd50
Johnnyboycurtis/BayesNets
/References/src/SimpleGraphPlot.py
1,127
3.65625
4
# -*- coding: utf-8 -*- """ Created on Tue Nov 7 12:59:39 2017 @author: jn107154 """ import networkx as nx import matplotlib.pyplot as plt def draw_graph(graph, labels=None, edge_text_pos=0.5): # extract nodes from graph nodes = set([n1 for n1, n2 in graph] + [n2 for n1, n2 in graph]) # create network...
2b204df6012f17b35e2ca648a54411b08d0b8f39
Rangerssoul/sky
/string.py
550
3.9375
4
# coding:UTF-8 # DATE :2018/12/23 # TIME :18:24 # FILENAME :string.py # IDE :PyCharm # AUTHOR : puhaiming # COPYRIGHT:Rangerssoul # str1 = "安检时,需要检查刀的长度,判断是否超过20厘米" str1 = "knife_length = int(input())" # str1 = "Kerchin 科尔沁 筋头巴脑" l1 = len(str1) l2 = len(str1.encode('utf-8')) l3 = len(str1.encode('gbk'))...
144adffdeed3ed540b7f62be6fa3f11e50a04cb7
YafuDeng/CPSC481_HW2_Team1337crew
/CPSC481_HW2/dlgo/nn/average_digits.py
2,160
3.546875
4
import numpy as np from dlgo.nn.load_mnist import load_data from dlgo.nn.layers import sigmoid_double def average_digit(data, digit): # compute the average over all samples in your data representing a given digit filtered_data = [x[0] for x in data if np.argmax(x[1]) == digit] filtered_array = np.asarray(fil...
410b45912c5d1acfb599df47bbe7660386427e30
congyingTech/Basic-Algorithm
/medium/binary_tree/145-binary-tree-postorder-traversal.py
1,401
3.890625
4
# -*- coding: utf-8 -*- # @Time : 2021/5/6 2:44 下午 # @Author : Mohn # @FileName: 145-binary-tree-postorder-traversal.py """ 二叉树后序遍历 """ # Definition for a binary tree node. class TreeNode(object): def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.r...
ae749c127feb0d76eb0ec010e14e8ef66ded0c86
congyingTech/Basic-Algorithm
/old-leetcode/older/492ConstructtheRectangle.py
476
3.71875
4
import math class Solution(object): def constructRectangle(self, area): """ :type area: int :rtype: List[int] """ sqrtval = int(math.sqrt(area)) #从sqrtval到0的递减遍历 for i in range(sqrtval, 0 ,-1): if area % i == 0: L, W = int(area/i), ...
21309a6c4aae52a6be1444450450f1897599dcd0
congyingTech/Basic-Algorithm
/medium/hot100/208-implement-trie-prefix-tree.py
1,485
3.84375
4
# -*- coding: utf-8 -*- # @Time : 2021/10/20 10:44 上午 # @Author : Mohn # @FileName: 208-implement-trie-prefix-tree.py """ Trie树是一颗多叉树 children记录的是trie树的多个叉,isEnd是trie树insert word是否终止的标志 """ class Trie(object): def __init__(self): self.children = [None]*26 self.isEnd = False def insert(s...
90ea6437030ace2d0980b671a2b4e01181ef912c
congyingTech/Basic-Algorithm
/easy/di-string-match.py
465
3.5
4
class Solution(object): def diStringMatch(self, S): """ :type S: str :rtype: List[int] """ ans = [] lo, hi = 0, len(S) for s in S: if s=='I': ans.append(lo) lo+=1 else: ans.append(hi) ...
a554aa16d41b52beaf72c42e09e6c069b9901ff4
congyingTech/Basic-Algorithm
/old-leetcode/GetOffers/6.py
759
4.09375
4
# 把一个数组最开始的若干个元素搬到数组的末尾,我们称之为数组的旋转。 # 输入一个非递减排序的数组的一个旋转,输出旋转数组的最小元素。 # 例如数组{3,4,5,1,2}为{1,2,3,4,5}的一个旋转,该数组的最小值为1。 # NOTE:给出的所有元素都大于0,若数组大小为0,请返回0。 # -*- coding:utf-8 -*- class Solution: def minNumberInRotateArray(self, rotateArray): i = 0; j = i+1; n = len(rotateArray) while i<n and j< n: ...
c946a642cd1ed39c55fe6859e44666259be3528b
congyingTech/Basic-Algorithm
/medium/others/group-the-people-given-the-group-size-they-belong-to.py
1,961
3.625
4
# encoding:utf-8 """ 问题描述: input一个groupSizes,这个list里面的第i个元素的值代表这个元素在的groupSize的大小 比如[2,1,3,3,3,2]中2表示index=0的人所在的组别是大小为2的组 解决方法: 1)将groupSizes从小到大排序得到sorted_group,对应的index也重新排序得到sorted_index 2)将相同的元素分为一组,记录分割的split 3)将相同元素组里多于组大小的元素重新分为子组 [2,1,3,3,3,2] -> [1,2,2,3,3,3] res_split = [0, 1, 3, 6] [3,3,3,3,3,1,3]->[1,3,3,3...
029a1d114d787fc0187c7eb99c408fccbe885491
congyingTech/Basic-Algorithm
/medium/others/binary-search-tree-to-greater-sum-tree.py
1,507
3.9375
4
# encoding:utf-8 # Definition for a binary binary_tree node. # 问题描述:寻找到二叉搜索树的和值都大的root class TreeNode(object): def __init__(self, x): self.val = x self.left = None self.right = None class Solution(object): cursum = 0 def bstToGst(self, root): """ :type root: TreeNod...
8a7f1782e4e89a4cb46d871a996f7e807ac4230b
congyingTech/Basic-Algorithm
/medium/hot100/221-maximal-square.py
1,542
3.859375
4
# -*- coding: utf-8 -*- # @Time : 2021/10/26 2:01 下午 # @Author : Mohn # @FileName: 221-maximal-square.py """ 矩阵中组成的最大的正方形的面积 输入:matrix = [["1","0","1","0","0"],["1","0","1","1","1"],["1","1","1","1","1"],["1","0","0","1","0"]] 输出:4 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/maximal-square 动态规划的思想: dp[i]...
28d17797ced029b0bf8b7c3a5349afff5bd6f69a
congyingTech/Basic-Algorithm
/medium/others/max-increase-to-keep-city-skyline.py
1,802
3.515625
4
#encoding:utf-8 # The grid is: # [ [3, 0, 8, 4], # [2, 4, 5, 7], # [9, 2, 6, 3], # [0, 3, 1, 0] ] # gridNew = [ [8, 4, 8, 7], # [7, 4, 7, 7], # [9, 4, 8, 7], # [3, 3, 3, 3] ] # gridNew的由来:gridNew x=0,y=0的计算是x行y列最大值中的最小值 class Solution(object): def maxIncreaseKeepingSk...
05fd11803f8ffaf7b101f9142fed7605db1aa20a
congyingTech/Basic-Algorithm
/medium/binary_tree/106-construct-binary-tree-from-inorder-and-postorder-traversal.py
1,529
4.0625
4
#!/usr/bin/env python # encoding: utf-8 """ @author:Mohn @email:wangcongyinga@gmail.com @time: 2021-07-20 01:28 """ class TreeNode(object): def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right class Solution(object): def buildTree(self,...
ad626199411a4827c972454db3690cb988c6766e
congyingTech/Basic-Algorithm
/medium/dynamic_program/139-word-break.py
1,495
3.6875
4
""" 给定一个非空字符串 s 和一个包含非空单词的列表 wordDict,判定 s 是否可以被空格拆分为一个或多个在字典中出现的单词。 说明: 拆分时可以重复使用字典中的单词。 你可以假设字典中没有重复的单词。 示例 1: 输入: s = "leetcode", wordDict = ["leet", "code"] 输出: true 解释: 返回 true 因为 "leetcode" 可以被拆分成 "leet code"。 示例 2: 输入: s = "applepenapple", wordDict = ["apple", "pen"] 输出: true 解释: 返回 true 因为 "applepenapple" 可...
15f78a37854fccb220e0d93aa06a2c6a9295f40f
congyingTech/Basic-Algorithm
/getOffer/26.copy-random-linkedlist.py
1,593
4.03125
4
# encoding:utf-8 """ 问题描述:复杂链表的复制 解决方案: 1)主链表上节点的复制 2)random节点的指向复制 3)主链表与复制链表的拆离 """ class RandomLinkedList(object): def __init__(self,val): self.val = val self.next = None self.random = None class Solution(object): def copyRandomLinkedList(self, head): pre = head # 1)...
fe1908e5d6b32162764066d16b7ed6a230f0e352
congyingTech/Basic-Algorithm
/medium/binary_tree/236-lowest-common-ancestor-of-a-binary-tree.py
1,844
4
4
#!/usr/bin/env python # encoding: utf-8 """ @author:Mohn @email:wangcongyinga@gmail.com @time: 2021-04-18 00:42 二叉树的最近公共祖先: https://leetcode-cn.com/problems/lowest-common-ancestor-of-a-binary-tree/solution/236-er-cha-shu-de-zui-jin-gong-gong-zu-xian-hou-xu/ 后序遍历,可以左右根,保证了遍历到p和q的同时,遍历了最近公共祖先。 """ # Definition for a ...
401734511be2d9121b59c92fba3d60e6087c6b81
congyingTech/Basic-Algorithm
/medium/others/continuous-subarray-sum.py
1,893
3.53125
4
# encoding:utf-8 """ 问题描述: 有一组非负的数组,和值为k,求是否存在连续的子序列(长度至少是2)的和值为k或者k的倍数 解决方案: 如果sum(nums[i:j])%k==0且i<j,那么sum(nums[:i])%k == sum(nums[:j])%k, 例如(23 , 2, 4)中, (2+4)%6=0,那么(23+2+4)%6=23%6 有了这个规律就很好求了,g根据玉树相同求出来这么一个i和j 如果j-i>=1那么,返回True。 所以需要一个dict记录sum(nums[:i]) % k,然后在dict中看,如果有相同的余数的元素,就return True Time complexity: O...
d1ab5e82f5c4ff2505d78a63234007b5b1510cdc
congyingTech/Basic-Algorithm
/getOffer/68.max-profit.py
1,175
3.890625
4
""" 问题描述: 假设把某股票的价格按照时间先后顺序存储在数组中,请问买卖该股票一次可能获得的最大利润是多少? 示例 1: 输入: [7,1,5,3,6,4] 输出: 5 解释: 在第 2 天(股票价格 = 1)的时候买入,在第 5 天(股票价格 = 6)的时候卖出,最大利润 = 6-1 = 5 。 注意利润不能是 7-1 = 6, 因为卖出价格需要大于买入价格。 示例 2: 输入: [7,6,4,3,1] 输出: 0 解释: 在这种情况下, 没有交易完成, 所以最大利润为 0。   限制: 0 <= 数组长度 <= 10^5 解题思路: 假设minPrice是最低点买入,假设我们在最低点买入 """ class ...
d1e3a7610d49a9af1a6150e876d17e63b104660d
congyingTech/Basic-Algorithm
/medium/hot100/79-word-search.py
1,374
3.8125
4
#!/usr/bin/env python # encoding: utf-8 """ @author:Mohn @email:wangcongyinga@gmail.com @time: 2021-08-18 00:09 """ class Solution(object): def exist(self, board, word): """ :type board: List[List[str]] :type word: str :rtype: bool """ def check(i, j, k): ...
c4e76dce0425c497ee11754c4c4ce114ddb67afb
congyingTech/Basic-Algorithm
/old-leetcode/older/530MinimumAbsoluteDifferenceinBST.py
1,092
3.71875
4
# Definition for a binary binary_tree node. class TreeNode(object): def __init__(self, x): self.val = x self.left = None self.right = None #中序遍历二叉树,然后求相邻数字的差求最小 class Solution(object): def getMinimumDifference(self, root): """ :type root: TreeNode :rtype:...
e74ddfcc4b04789ce051adee50598c592547d7fb
congyingTech/Basic-Algorithm
/medium/hot100/2-add-two-numbers.py
2,341
4.25
4
""" 给你两个 非空 的链表,表示两个非负的整数。它们每位数字都是按照 逆序 的方式存储的,并且每个节点只能存储 一位 数字。 请你将两个数相加,并以相同形式返回一个表示和的链表。 你可以假设除了数字 0 之外,这两个数都不会以 0 开头。 输入:l1 = [2,4,3], l2 = [5,6,4] 输出:[7,0,8] 解释:342 + 465 = 807. 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/add-two-numbers 解题思路: 每个数位都是逆序的,所以可以从头遍历两个链表,把两个链表的值相加 """ # Definition for sing...
6db9460ef6b79fc97de832e47bc131c7492fb664
congyingTech/Basic-Algorithm
/getOffer/45.circle-last-num.py
1,074
3.84375
4
# encoding:utf-8 """ 问题描述: 0~n-1排成一个圆圈,从数字0开始删除圆圈里的第m个数字,求圆圈中最后剩下的数字。 解决方案: 循环链表删除操作 """ class CircleNode(object): def __init__(self, val): self.val = val self.next = None class Solution(object): def findCircleLastNum(self, circle, m): res = [] p1 = circle while p1 ...
402b98699c318c3120c8fa7e0147e8a4abf175e3
congyingTech/Basic-Algorithm
/easy/third-maximum-number.py
402
3.9375
4
class Solution(object): def thirdMax(self, nums): """ :type nums: List[int] :rtype: int """ nums = set(nums) if len(nums)<3: return max(nums) nums.remove(max(nums)) nums.remove(max(nums)) return max(nums) if __name__ == "__main__":...
691f9721057cc0bc32c9f1494401a766a6282152
congyingTech/Basic-Algorithm
/medium/hot100/84-largest-rectangle-in-histogram.py
953
3.625
4
#!/usr/bin/env python # encoding: utf-8 """ @author:Mohn @email:wangcongyinga@gmail.com @time: 2021-08-13 00:10 找出柱状图中最大的矩形面积 """ class Solution(object): def largestRectangleArea(self, heights): """ :type heights: List[int] :rtype: int """ n = len(heights) i = 0 ...
8493f999d001387a018e53c12874ca28d44e0f0e
congyingTech/Basic-Algorithm
/medium/others/lowest-common-ancestor-of-a-binary-tree.py
3,609
3.671875
4
# encoding:utf-8 """ 问题描述: 给定一棵树,和两个结点,寻找这两个结点的最近的父节点,LCA问题 解决方案: 1)递归的思想+flag标签 2)非递归遍历+dict的思路 """ class TreeNode(object): def __init__(self, x): self.val = x self.left = None self.right = None class Solution1(object): # 递归的解法 def __init__(self): self.ans = None def l...
1d7532ff8687d97f035904756b3e0a270fba6271
congyingTech/Basic-Algorithm
/greedy/job-sequencing-problem-loss-minimization.py
951
3.90625
4
#encoding=utf-8 # 问题描述:有N个job,每个job有对应的完成的时间和规定完成时间内没有完成的损失 # 求最小损失的job完成顺序,其中L是每个job的损失,T是每个job完成所需要的时间。 # 思路:考虑两种极端的情况 # 1)每个job完成花费的时间相同:按照损失从大到小排序,先完成损失大的,这样可以保证最后损失最小。 # 2)每个job没完成的损失相同:按照完成时间从小到大排序,先完成时间短的job,这样可以保证剩下的job数量少,从而损失最小。 # 解决:不能单纯的只考虑时间或者损失,需要考虑的是L/T比率的问题 import math def printJobsequence(L, T): ...
070b897a2f9365ae21c150490d0949a4b3d47960
congyingTech/Basic-Algorithm
/data_structure/3.directed-graph.py
1,586
4.21875
4
# encoding:utf-8 """ 问题描述:有向(可能有环图)图 """ class DirectedGraph(object): def __init__(self,vertices): self.vertices = vertices self.graph = [[0]*self.vertices for i in range(self.vertices)] def add_edges(self, src, dest): self.graph[src][dest] = 1 def print_graph(self): for i ...
ec4ab8c3afd9a6c1aea12621e364d9ead200fa43
congyingTech/Basic-Algorithm
/backtracking/5.m-coloring.py
1,508
3.9375
4
# encoding:utf-8 """ m着色问题 m是可以选择着色的颜色数 v_num是点的个数 """ class Graph(): """ 图的邻接图的表达法 """ def __init__(self, vertices): self.vertices = vertices self.graph = [[0]*self.vertices for j in range(self.vertices)] def add_edges(self, src, dest): self.graph[src][dest] = 1 ...
d32c0bac75ce9ad66ff38d0029336b147ff89405
congyingTech/Basic-Algorithm
/medium/dynamic_program/5-longest-palindromic-substring.py
2,490
3.671875
4
#!/usr/bin/env python # encoding: utf-8 """ @author:Mohn @email:wangcongyinga@gmail.com @time: 2021-01-28 09:17 给你一个字符串 s,找到 s 中最长的回文子串。 示例 1: 输入:s = "babad" 输出:"bab" 解释:"aba" 同样是符合题意的答案。 示例 2: 输入:s = "cbbd" 输出:"bb" 示例 3: 输入:s = "a" 输出:"a" 示例 4: 输入:s = "ac" 输出:"a" 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/probl...
8eba4c321dcf6a3c6700f23c0fdaf58556c46db2
congyingTech/Basic-Algorithm
/getOffer/59.symmetric-tree.py
1,689
3.734375
4
# encoding:utf-8 """ 问题描述: 判断一棵树是不是镜像二叉树 解决方案: 1)递归的方法:如果二叉树是镜像二叉树,那么它的左子树是等于右子树的 2)非递归的方法:可以用BFS层序遍历二叉树,然后设置两个队列,分别存左边的子树和右边的子树 """ class TreeNode(object): def __init__(self, x): self.val = x self.left = None self.right = None class Solution(object): def isSymmetric(self, root): ...
328e4fe7fded3838d357bd153648cb7606754cff
congyingTech/Basic-Algorithm
/medium/dynamic_program/64-minimum-path-sum.py
1,417
3.90625
4
""" 给定一个包含非负整数的 m x n 网格 grid ,请找出一条从左上角到右下角的路径,使得路径上的数字总和为最小。 说明:每次只能向下或者向右移动一步。 输入:grid = [[1,3,1],[1,5,1],[4,2,1]] 输出:7 解释:因为路径 1→3→1→1→1 的总和最小。 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/minimum-path-sum dp思想: dp[i][j] = min(dp[i-1][j], dp[i][j-1])+dp[i][j] i>0, j>0 dp[i][j] = dp[i][j-1]+grid[i][j-1] i...
3e75dc2ce286bdca02599a4bcd5ef58f781f759b
congyingTech/Basic-Algorithm
/getOffer/37.two-list-first-common-node.py
1,492
3.921875
4
# encoding:utf-8 """ 问题描述: 输入两个链表,找出它们的第一个公共结点。 解决方案: 有公共结点的链表的特点是:遇到第一个公共结点之后,所有的结点就都是重合的了,不可能再出现分叉。 首先遍历出两个两边的长度,较长的那个先走差值步,然后两个链表一起遍历,直到遇见相同的公共结点。 """ class LinkedNode(object): def __init__(self, val): self.val = val self.next = None class Solution(object): def findFirstCommonNode(self, l1,...
30698c43e3ce59495f42fb6d0bff2c5cce4a525b
congyingTech/Basic-Algorithm
/getOffer/17.merge-two-sorted-lists.py
2,753
4.125
4
# encoding:utf-8 """ 问题描述:合并两个上升排序的链表,使之合并后有序 解决方案:递归的方案, 非递归的方案:先比较第一个节点,节点小的那一个作为主链表,把循环遍历另一条链表,把其中的元素插入到主链表中 在主链表设置两个指针:mainHead/mainNext,次链表只有secondHead一个指针,做次链表单节点插入主链表的动作。 """ # Definition for singly-linked list. class ListNode(object): def __init__(self, x): self.val = x self.next = None cla...
d98c2b0c0f09b90c8065e86ddf2e5763b06a92a1
congyingTech/Basic-Algorithm
/medium/dynamic_program/131-palindrome-partitioning.py
546
4.03125
4
""" 分割回文子串 给定一个字符串 s,将 s 分割成一些子串,使每个子串都是回文串。 返回 s 所有可能的分割方案。 示例: 输入: "aab" 输出: [ ["aa","b"], ["a","a","b"] ] 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/palindrome-partitioning """ class Solution(object): def partition(self, s): """ :type s: str :rtype: List[List[str]] ...
04f56d096164b38890fcd80238d1ece9005489a7
erikdengerud/tma4215-p2
/Area_Plot.py
1,075
3.578125
4
################################################################################ import numpy as np import splipy as spl from splipy.io import G2 import splipy.surface_factory as spf import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D #################################################################...
a1aa79ffd185db4cf0314e4ce1e655b02673622f
Al-Dor/lesson1
/answers.py
1,076
3.703125
4
#def get_answer(question_dictionary, question): # return question_dictionary[question] answers = { 'Привет': 'И тебе привет',\ 'Как дела?': 'Лучше всех',\ 'Когда в отпуск': 'Еще нескоро'} # while True: # user_question = input('О чем хочешь спросить? ') # if user_question == 'Пока': # ...
737a2a1f198d1a78e3ba621456037c87b57ccea2
Crinale/example_scripts
/collection.py
289
3.515625
4
import collections howmany = int(raw_input()) shoes = collections.Counter(map(int, raw_input().split())) cust = int(raw_input()) print shoes income = 0 for i in range(cust): size, price =map(int, raw_input().split()) if shoes[size]: income += price shoes[size] -= 1 print income
71c2442df213240469ffecd3af6d3fdd2fa1f7ab
Crinale/example_scripts
/backwardsll.py
232
3.6875
4
def reverse(head): prevNode = None nextNode = None while head is not None: nextNode = head.next; head.next = prevNode; prevNode = head; head = nextNode; head = prevNode return head