blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
de53f0c53f2535a5f9336d0bdf67d3a17efde0d9 | afeinsod/Computer-Science-Curricula | /Python/In Class Examples/Lists.py | 1,195 | 4.59375 | 5 | #Initializing lists:
#To initiazlie an empty list:
my_list = []
#To initiate a list with values (can contain mixed types):
list2 = [1, "yay", 140.76]
#Finding information about a list:
#To get an item from a list by index:
my_list= [1, 2, 3, 4, 5, 6]
print my_list[0] #will give the first item in the list, which... |
ef897518c402fdd4dcdba43b882111447226f6a1 | gameinskysky/dspnet | /data/VOC2007/utils.py | 547 | 3.53125 | 4 |
def getpalette(num_cls):
# this function is to get the colormap for visualizing the segmentation mask
n = num_cls
pallete = [0]*(n*3)
for j in xrange(0,n):
lab = j
pallete[j*3+0] = 0
pallete[j*3+1] = 0
pallete[j*3+2] = 0
i = 0
while (lab > 0):
... |
25b8567493939e065b0172f217f3a9cac98096f6 | Maarten-Vandaele/PyGame | /pygame_1_BasicJumpingSquare.py | 1,613 | 3.703125 | 4 | import pygame
pygame.init()
win = pygame.display.set_mode((500, 500))
pygame.display.set_caption('First Game')
x = 50
y= 425
width = 40
height = 60
vel = 5
isJump = False
jumpCount = 10
run = True
while run:
# clock to make actions not to quick
pygame.time.delay(100)
# when pres... |
5754752683d770f31a79b3c69f5986ae3c45c43c | crishonsou/modern_python3_bootcamp | /definindo_uma_classe_com_atributos_para_conta_bancaria.py | 681 | 3.65625 | 4 | class BankAccount:
def __init__(self, name, balance = 0):
self.name = name
self.balance = 0
def owner(self):
return f'Hi {self.name}.'
def getBalance(self):
return f'Your balance is ${self.balance:.2f}'
def deposit(self, amount):
self.balance += amount
... |
711efa8470ffac6144547d82a28737903b2cceaa | Stheven-Chen/python | /07-Operasi Logika/Main.py | 1,297 | 3.578125 | 4 | # ada operasi logika not, or, and, xor
# Not
print('===========Not')
a = True
c = not a
print('data a: ',a)
print('jika di not')
print('data c: ',c)
# OR (Jika ada truenya maka akan menjadi true)
print('===========OR')
a = True
b = False
c = a or b
print(a, ' OR', b, '=', c)
print('===========OR')
a = True
b = Tr... |
269e1ba211dd4a3c9e8b6e7b47a8c7ab5bf84e10 | itsolutionscorp/AutoStyle-Clustering | /assignments/python/wc/src/1279.py | 153 | 3.578125 | 4 | def word_count(sent):
words = {}
for w in sent.split():
if w not in words:
words[w] = sent.split().count(w)
return words
|
5da20e2fe116b32a60dd7c6fc92746be6fbe0ba2 | painfield/m02_boot_0 | /carreraTortugas/main.py | 1,329 | 3.734375 | 4 | import turtle
import random
class Circuito():
corredores = []
__turtleColor = ('blue','purple','red','orange')
def __init__(self, width, height):
self.__screen = turtle.Screen()
self.__screen.setup(width,height)
self.__screen.bgcolor('lightgray')
self.__startLine = -(wi... |
6e9fd596a1650bc9d9a91244bfa18936db4e3cd6 | ryuhhhh/us_stock_rnn | /get_data/split_data.py | 881 | 3.578125 | 4 | """
csvから以下を取得
- X_train,y_train
- X_valid,y_valid
- X_test,y_test
"""
import numpy as np
import pandas as pd
if __name__ == '__main__':
csv_name = '1day_data.csv'
save_name = '1day'
folder_name = 'not_standard'
day_1_csv = pd.read_csv(f'./got_data/{csv_name}')
day_1_csv = day_1_csv.sample(frac... |
6d40c1f38d0206f28511c7e3280697458553d771 | venanciomitidieri/Exercicios_Python | /019 - Sorteando um item na lista.py | 435 | 3.9375 | 4 | import random
primeiro_nome = input('Digite o primeiro nome: ')
segundo_nome = input('Digite o segundo nome: ')
terceiro_nome = input('Digite o terceiro nome: ')
quarto_nome = input('Digite o quarto nome: ')
lista = [primeiro_nome, segundo_nome, terceiro_nome, quarto_nome]
print('Dos nomes {}, {}, {}, {}. O alu... |
bbb9e999cb6d73371115ae32007b2322b54aab7a | Vaan525/Bit_seoul | /Keras/2020-11-10/keras09_split.py | 1,006 | 3.65625 | 4 |
# 1. 데이터
import numpy as np
x = np.array(range(1, 101)) # 테스트 하고싶은 데이터
y = np.array(range(101, 201))
x_train = x[:70]
y_train = y[:70]
x_test = x[:30]
y_test = y[:30]
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense
# 2. 모델 구성
model = Sequential()
model.add(Dense(300, input... |
965b8331fd9baed4f2b51b2df2802433bd169dce | jntushar/Hacker-Earth | /Strange Game.py | 1,375 | 3.75 | 4 | """
Alice and Bob are very good friends. They keep on playing some strange games. Today Alice came up with a new game, in which each player gets cards at the start. Each card has it's value printed on it.
The game proceeds as each player chooses a random card and shows it's value. The player having card with higher va... |
da262767c6b76e67ebdf5bad0f60d1172570ff3e | Guoli-Zhang/Code | /HelloWorld/Day6/高阶函数.py | 594 | 3.609375 | 4 | num_list = [1, 2, 3, 1, 5, 1, 0, 0, 8, 6]
# def f(x):
# return x * 10
result = list(map(lambda x: x * 10, num_list))
print(result)
word = ["apple", "james", "rose", "enumerate", "print", "functions"]
def f(x):
return x[0].upper() + x[1:]
result = list(map(f, word))
print(result)
words = ["Apple", "ja... |
5254d093708ad3804e20b1a5d259cd921a36bb79 | aboua0949/Assignment.2 | /AliAPConcA2Q1.py | 437 | 4.3125 | 4 | #Programming concepts
#Assignment 1
#Question 1
# Ali Abouei / aboua0949
#setpember 28
print("Welcome , This is a length unit convertor ")
print()
x = int(input("Enter the number you want to convert, in meters!"))
inches = (x * 100/2.54)
feet = (inches/12)
yards = (feet/3)
miles = (yards/1760)
print(x,"meters is",in... |
58956ebff428752b0cc00c63ac656bf9bfc39efc | kashikakhatri08/Python_Poc | /python_poc/python_array_program/array_rotation.py | 1,508 | 4.125 | 4 | def user_input():
global array_container
array_length = int(input("Enter the array length : "))
array_container = [None] * array_length
for i in range(0, array_length):
array_input = int(input("Enter the array element for array[{}] : ".format(i)))
array_container[i] = array_input
s... |
cf1ccd180163fbbb7770c287bbb2f8af94c3b054 | asmaalsaada/python_stack | /_python/python_fundamentals/hello_world.py | 529 | 4.15625 | 4 | # 1.
print( "Hello World!" )
#2.
name = "Asma"
print( "Hello ", name ) # Hello Asma
print( "Hello "+ name ) # HelloAsma
#3.
name = 23
print( "Hello", name ) # Hello 23
print( "Hello"-- name )
print( "Hello" + name ) # with a + , -- TypeError: can only concatenate str (not "int") to str
# 4.
fave_food1 = "fettuccine"
... |
3f1ada25f08436c2bd922d04b81d0cb388a192c9 | tell-k/code-snippets | /python/snippets/dict_merge.py | 912 | 3.671875 | 4 | #!/usr/bin/env python
#-*- coding:utf8 -*-
t = {'test1': 1, 'test2': 2, 'test3': 3, 'test5': 5}
t2 = {'test1': 2, 'test3': 4, 'test2': 3, 'test4': 4}
#t2.update(dict(map(lambda x: (x, t[x] + t2[x]) if x in t2 else (x, t[x]), t)))
#print sorted(t2.items(), reverse=True)
def merge_dict(d1, d2, merge=lambda x, y: y):
... |
24a38fa1f44c1de091ecfc3f8ba6cc7bbb0f8185 | robertomf/python-afi | /ejercicio_dias.py | 508 | 3.84375 | 4 | # -*- coding: utf-8 -*-
diasmes = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
anho = input('Introduce un año: ')
if (anho <= 0):
print ' ** El anho es incorrecto **'
mes = input('Introduce un mes: ')
if (mes < 0 or mes > 12):
print ' ** El mes es incorrecto ** '
dia = input('Introduce un dia: ')
if (dia < 0 ... |
3904bc365341e27ac83a9294b628732804c4d6e7 | harsitbaral/Natural-Selection-2.0 | /main.py | 6,200 | 3.734375 | 4 | import random
import draw
import time
import graphs
import csv
"""
PEP8:
module_name, package_name, ClassName, method_name, ExceptionName, function_name, GLOBAL_CONSTANT_NAME,
global_var_name, instance_var_name, function_parameter_name, local_var_name
"""
class Apple:
def __init__(self, x, y, col... |
fb2bb11296e80a2e4dd6a27e090ca643491f32c7 | pally2409/Hackerrank | /Python/sherlock-and-anagrams.py | 1,087 | 3.546875 | 4 | #!/bin/python3
import math
import os
import random
import re
import sys
# Complete the sherlockAndAnagrams function below.
def sherlockAndAnagrams(s):
signatures = {}
result = 0
for i in range(len(s)):
wor = ''
for j in range(i, len(s), 1):
signature = [0]*26
wor = ... |
372f35c380bb21d3045fbbf1142a91bca3cd8a48 | CarolinaRodrigues/atividades_teste | /atividade_teste/conversor_base_2_10_16.py | 3,271 | 3.71875 | 4 | #Conversão de Bases
#CONVERSÃO DE BASE 2 PARA BASE 10
def base_2_para_base_10(valor_para_converter):
tamanho_valor = len(valor_para_converter)
valor_convertido = 0
i = 0
while tamanho_valor > 0:
numero_posicao_atual = valor_para_converter[tamanho_valor - 1]
tamanho_valor = taman... |
1d2d32d5a3f924b6eec38908efc0fcd56d877bca | MrHamdulay/csc3-capstone | /examples/data/Assignment_6/sldcar001/question3.py | 604 | 3.84375 | 4 | def vote():
print("Independent Electoral Commission")
print("--------------------------------")
print("Enter the names of parties (terminated by DONE):")
print()
line=[]
voters=[]
ip=input()
while ip!="DONE":
line.append(ip)
a=line.count(ip)
if a==1:
... |
3b408351330907caf98c21176121bc08835f0bec | HKervadec/Project-Euler | /Problem 042/problem42.py | 1,491 | 3.828125 | 4 | # The nth term of the sequence of triangle numbers is given by, tn = 1/2*n(n+1); so the first ten
# triangle numbers are:
# 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, ...
# By converting each letter in a word to a number corresponding to its alphabetical position
# and adding these values we form a word value. For exampl... |
6f8282cd4b630f329d878d69a146ef1d610bfa15 | JosephLevinthal/Research-projects | /5 - Notebooks e Data/1 - Análises numéricas/Arquivos David/Atualizados/logDicas-master/data/2019-1/224/users/4353/codes/1613_1804.py | 197 | 4.0625 | 4 | from math import*
XA=float(input("digite XA: "))
YA=float(input("digite YA: "))
XB=float(input("digite XB: "))
YB=float(input("digite YB: "))
DAB=sqrt((XB-XA)**2+(YB-YA)**2)
print(round(DAB,3)) |
c7ae2d1dcd9215b392be4503faea0c759c5d0fcc | advra/OpenTester | /Question.py | 2,686 | 3.71875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Mon May 14 12:20:07 2018
@author: 1172334950C
"""
class Question(object):
"""
This is used as the structure to format questions and retrieve those properties for our tests
number : string
Display element number within the Test Container
questi... |
fd1204c8ce2f93dbc9c8350e816804c0ef569cb5 | natsmith9/mustached-wookie | /magic8Ball.py | 1,549 | 3.640625 | 4 | __author__ = 'Nathan A. Smith'
import random
import time
myMagic8Ball = {1: "Yes",
2: "No",
3: "Maybe",
4: "Reconsider",
5: "Are You Dumb?",
6: "Sure, if that's what you want to do",
7: "Send in the clowns",
... |
dab768a398322ac40f69ba4ebbf2b21f722f97fc | Eclipsess/LintCode | /BinaryTree/480. Binary Tree Paths.py | 1,300 | 4.15625 | 4 | # Given a binary tree, return all root-to-leaf paths.
#
# Example
# Example 1:
#
# Input:{1,2,3,#,5}
# Output:["1->2->5","1->3"]
# Explanation:
# 1
# / \
# 2 3
# \
# 5
# Example 2:
#
# Input:{1,2}
# Output:["1->2"]
# Explanation:
# 1
# /
# 2
"""
Definition of TreeNode:
class TreeNode:
def __init__... |
906bc5212bd3552e2e6ea7c94f5fd7d317bb878b | alexro/pypypy | /olymp/graph/basic/bfs.py | 1,004 | 3.546875 | 4 | from collections import deque
from graph.basic.init import *
def bfs(g, v, process_vertex, process_edge):
discovered = [False] * len(g)
processed = [False] * len(g)
parents = [0] * len(g)
queue = deque()
queue.append(v)
discovered[v] = True
while queue:
v = queue.popleft()
... |
12e302202fb304246a63bc821f3412bc426bd621 | YordanPetrovDS/Python_Fundamentals | /_13_FUNCTIONS/_2_Calculations.py | 357 | 3.828125 | 4 | operator = input()
first_number = int(input())
second_number = int(input())
def solve(action, a, b):
if action == "multiply":
return a * b
elif action == "divide":
return a // b
elif action == "add":
return a + b
elif action == "subtract":
return a - b
print(solve(ope... |
b8b37c9adab443bf04d28e0a8fe34d8712130a72 | Jordan-Camilletti/Project-Euler-Problems | /python/40. Champernowne's constant.py | 560 | 3.9375 | 4 | """An irrational decimal fraction is created by concatenating the positive integers:
0.123456789101112131415161718192021...
It can be seen that the 12th digit of the fractional part is 1.
If dn represents the nth digit of the fractional part, find the value of the following expression.
d1 × d10 × d100 × d1000 × d10... |
1637d23ce185c4cb5131a40908b453c6bcb40bb3 | uyupun-archive/prockxy | /musics.py | 1,427 | 3.765625 | 4 | import sqlite3
class Musics:
def __init__(self):
self.conn = sqlite3.connect('database.sqlite')
self.cur = self.conn.cursor()
def create_table(self):
self.cur.execute('CREATE TABLE IF NOT EXISTS musics(id INTEGER PRIMARY KEY AUTOINCREMENT, song_name STRING, artist STRING, cd_jacket STR... |
20c378a273307b566a4c079e7ba413aca3c94c64 | carlos-baraldi/python | /EstruturaSequencial/exercício5.py | 264 | 4.125 | 4 | #Faça um Programa que converta metros para centímetros.
val_metro = float(input('digite um valor em metros para saber o valor correspondente em centímetros '))
val_cent = val_metro * 100
print(f'{val_metro} metros equivale a {val_cent} centímetros')
|
370b0a6692bf09b4ceea4e61a39c1e92d4143fb9 | bel4212a/Curso-ciencia-de-datos | /Semana-2/carro.py | 1,773 | 4.1875 | 4 | class Carro:
"""Representacion basica de un carro"""
def __init__(self, marca, modelo, anio):
"""Atributos del carro"""
self.marca = marca
self.modelo = modelo
self.anio = anio
self.kilometraje = 0 # Se define un atributo por defecto
def descripcion(self):
... |
dea7f4eacfd08e42c8b59bf95990ce912afee35f | senatn/learning-python | /draw_a_square.py | 361 | 4.125 | 4 | square_length = int(input("Length of the square: "))
stars = square_length
spaces = (square_length-2)
lines = square_length-3
for i in range(stars):
print("*", end="")
print()
for i in range(lines):
print("*", end="")
for i in range(spaces):
print(" ", end="")
print("*")
for i in range(stars):
... |
90a637d0ddacfa2055fc08287d17a31f506c0ea7 | bwh1te/Bulls-and-Cows | /bullsncows.py | 980 | 3.734375 | 4 | import random
import re
print """
BULLS & COWS
Guess a four-digit number with unique digits.
If you guessed right digit and it's position - it's a bull.
If you guessed right digit but it's standing on a incorrect position - it's a cow.
Good luck!
"""
number = "".join(map(str, random.sample([1, 2, 3, 4, 5, 6, 7, 8... |
379e4ac9e3721730ea276507fc26a2fdda456d23 | xuefengZhan/python | /_03_高级特性/_02_迭代.py | 1,587 | 3.6875 | 4 | #todo 迭代
# 迭代是一种遍历方式:用for in这种方式遍历我们称为迭代(Iteration)。
#todo 可迭代对象
# 可迭代对象指的就是可以用for in 来迭代遍历的对象
# list,tuple,dict,str 都是可迭代对象 可迭代对象不要求有索引
#todo 3. dict的迭代
# dict的存储不是按照list的方式顺序排列,所以,迭代出的结果顺序很可能不一样。
#todo 3.1迭代key
d = {'a': 1, 'b': 2, 'c': 3}
for key in d:
print('%s : %i' % (key,d[key]))
#todo 3.2迭代value
for v... |
fef54a4e85bf06a4ad20ffd4fe4a784d10ea6c5b | tashseeto/python | /exercises/variables-and-user-input-exercises.py | 1,578 | 4.25 | 4 | # Question 1
num1A = input("Please type 3 ")
num1B = input("Please type 9 ")
num1A = int(num1A)
num1B = int(num1B)
product = num1A + num1B
print(f"{num1A} + {num1B} = {product}")
num1C = input ("Please type -3 ")
num1B = input("Please type 9 ")
num1C = int(num1C)
num1B = int(num1B)
product = num1C + num1B
print(... |
3276c9164d506fbf1a053a9f61c7b7dba267122c | terylll/LeetCode | /Array/11_maxArea.py | 653 | 3.5 | 4 | """
Link: https://leetcode.com/problems/container-with-most-water/description/
"""
"""
@Tag: ["DP", "Array"]
"""
import math
class Solution(object):
def maxArea(self, height):
"""
:type height: List[int]
:rtype: int
"""
left = 0
right = len(height - 1)
... |
e0dc271c5dfff698b82ff08c81f8db232c6d85c6 | 962245899/trabajo-5 | /boleta 2.py | 810 | 3.984375 | 4 | #INPUT
print("ASERRADERO TU BUENA TABLA")
cliente=input("Ingrese el nombre del cliente:")
vendedor=input("ingrese el nombre del vendedor:")
nº_de_tablas=int(input("Ingrese Nº de tablas:"))
precio_unitario=float(input("Ingrese precio unitario:"))
# PROCESSING
total = (precio_unitario * nº_de_tablas)
#verific... |
2b62924140798b7ce6b8cc3ec7ce3462a6537dde | Tolkosino/UniventionApplication | /Univention_Application.py | 684 | 4.03125 | 4 | import random # import random functionality
rndInt = random.randrange(100) # Generate random number between 0 and 100
guess = 101 # placeholder for guess of user
print("I'd like to play a game, bet you can't guess the number im thinking of? Aight, try your luck!")
while rndInt != guess... |
7d9f0dc68e579994aa49e6ef44c73272a239f2ad | XIAOQUANHE/pythontest | /yu_c/Chapter1-6/get_digits.py | 475 | 3.859375 | 4 | # 1. 写一个函数get_digits(n),将参数n分解出每个位的数字并按顺序存放到列表中。举例:get_digits(12345) ==> [1, 2, 3, 4, 5]
# insert() 方法语法:L.insert(index,obj)
result = []
def get_digits(n):
if n > 0:
result.insert(0,n%10) # Python 列表 insert() 方法将指定对象插入到列表中的指定位置。 求个位数
# print(n%10) # 5,4,3,2,1
get_digits(n//10)
... |
13ad273a8efb3e46f5262b0a131508e8ad11c558 | jannik-sa/jansa | /python/primenzahlen.py | 331 | 3.609375 | 4 |
x=2
y=3
for i in range(100000):
n=y/x
if int(n)==n:
y=y+1
x=2
elif int(n)!=n:
x=x+1
if x==y:
print(y)
#while x <= y or int(n)==n:
# n=y/x
#
# if int(n)==n:
# print("Ist keine Primenzahl")
# elif int(n)!=n:
# x=x+1
#if x==y:
# print(y... |
a1189380279c9f5abdafa63ffb9a24bd20406f5e | kellysteele168/Optimization-Algorithms | /Project 1/Project1_A.py | 3,911 | 3.6875 | 4 | """
This program uses the timeit module to calculate the runtime for two dynamic programming models to determine the optimal model. DPKP utilizes a matrix filled with zeros to begin, while DPKP1 does not.
"""
def DynamicProgrammingtest(n, Vmax, Smax, alpha, x):
from random import randint
import timeit
... |
8f90c13d758f89244629c66389a1d5d8d9b7c4bb | srankur/DataStructure_Algorithms | /6.006_MIT/Sortings/mergeSort.py | 1,393 | 4.1875 | 4 |
def mergeArr(arr,leftArr,rightArr):
print("Pre Merge Array::", arr)
print("Pre Merge Left Arr:", leftArr)
print("Pre Merge Right Arr:", rightArr)
i=0
j=0
k=0
while(i < len(leftArr) and j < len(rightArr)):
if(leftArr[i] < rightArr[j]):
arr[k] = leftArr[i]
i... |
4c0b8ca1e8d86ab11360e29e5cdf704ea170cd79 | jonathan-murmu/ds | /data_structure/leetcode/easy/53 - Maximum Subarray/max_subarray.py | 1,476 | 4.09375 | 4 | '''
https://leetcode.com/problems/maximum-subarray/
Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum.
A subarray is a contiguous part of an array.
Example 1:
Input: nums = [-2,1,-3,4,-1,2,1,-5,4]
Output: 6
Explanation: [4,-1,2,1] h... |
be7cfbeedb0c2a6df04bb57e4bf7539fe0438ce0 | ligb1023561601/CodeOfLigb | /OOP.py | 3,875 | 4.1875 | 4 | # Author:Ligb
# 1.定义一个类,规定类名的首字母大写,括号是空的,所以是从空白创建了这个类
# _init_()方法在创建类的新实例的时候就会自动运行,两个下划线是用来与普通方法进行区分
# self是一个自动传递的形参,指向实例本身的引用,在调用方法时,不必去给它传递实参
# 以self作前缀的变量称之为属性
# 命名规则
# object() 共有方法 public
# __object()__ 系统方法,用户不这样定义
# __object() 全私有,全保护方法 private protected,无法继承调用
# _object() private 常用这个来定义私有方法,不能通过import导入,可被继承... |
f57cc1db869309669cde38bb40f79bdfae652520 | GuillermoLopezJr/CodeAbbey | /Abbey006/main.py | 244 | 3.71875 | 4 | print("Enter number of test Cases followed by data: ")
SIZE = int(input())
answers = []
for i in range(SIZE):
a, b = map(int, input().split())
answers.append(round(a/b))
print("\nanswer: ")
for ans in answers:
print(ans, end=" ")
|
3dc210b79af27322ab20ca72a69987cac83e3fa8 | clarencenhuang/programming-challenges | /canonical_problems/longest_palindrome_subseq.py | 279 | 3.515625 | 4 |
def longest_palindrome_subseq(s):
def dp(i, j):
ends_eq = s[i] == s[j]
if i == j or ends_eq and j == i + 1:
return j - i + 1
if ends_eq:
return 2 + dp(i+1, j-1)
else:
return max(dp(i+1, j), dp(i, j-1))
|
3d048d6c09248864a097be59370af09aca7a0ed7 | jongbeom11/16PFB-jongbeom | /ex06/ex06.py | 395 | 3.578125 | 4 |
x = "there ard %d types of people." # 10
binary = "binary"
do_not = "don't "
y= "Those who know %s and those who %s." % (binary, do_not)
print x
print y
print "I said: %r." % x
print "T also said: '%s'." % y
hilarious = False
joke_evalution = "Isn't that joke so fuunt?! %r"
print joke_evalution % hilarious
w = "... |
73d11a708b3e91f0cb3f1b9a0636cf7861f8f25f | wenjiazhangvincent/leetcode | /1119-112/504.py | 627 | 3.59375 | 4 | class Solution(object):
def __init__(self):
self.res = []
def loop(self, num):
if num < 7:
self.res.append(str(num))
return
else:
self.res.append(str(num % 7))
self.loop(num / 7)
def convertToBase7(self, num):
... |
9c6a1e1a90a5761987990076b07bf88bf111f99a | Dawn-Test/Python | /Basics/03-分支语句.py | 820 | 3.921875 | 4 | # if elif else
# 运算符:
# == 是否相等 !=是否不等于 >是否大于 <是否小于 >=是否大于等于 <= 是否小于等于
# 如果成立返回true 不成立返回false
# 练习:登录页面
input_username = input('请输入您的用户名:')
input_password = input('请输入您的密码:')
correct_urername = 'admin'
correct_password = '123456'
# 首先判断用户名是否正确
if input_username == correct_urername:
# 如果用户名正确... |
ac192a5826a18ffd43f4c9efce302d01a46c894f | fepettersen/inf3331 | /uke2/averagerandom.py | 1,089 | 3.6875 | 4 | import sys
import random
from numpy import zeros,linspace
if len(sys.argv) == 2:
n = int(sys.argv[1]) #read a number from the commandline
else:
#prvide an error message which makes sense if the above fails
print 'You provided the wrong ammount of commandline arguments \n please specify the number of times to draw a... |
aa905bd42ecc6699010e394b8cc1a87a0777d66d | Randle9000/pythonCheatSheet | /pythonCourseEu/1Basics/32MetaClassesIntro/Ex2.py | 1,291 | 4.09375 | 4 | #We can improve our approach in Ex1.py
# by defining a manager function and avoiding redundant code this way.
# The manager function will be used to augment the classes conditionally.
# the following variable would be set as the result of a runtime calculation:
x = input("Do you need the answer? (y/n): ")
if x =... |
9dbd332942d80c92fa00242dbd510af75115d3ce | tisnik/python-programming-courses | /Python1/examples/list_sort.py | 181 | 3.640625 | 4 | seznam = [5, 4, 1, 3, 4, 100, -1]
print(seznam)
seznam.sort()
print(seznam)
seznam = [5, 4, 1, 3, 4, 100, -1]
print(seznam)
seznam2 = sorted(seznam)
print(seznam)
print(seznam2)
|
61128c97bcd49dcc175cc1b6976b6c22b4f39360 | A432-git/Leetcode_in_python3 | /67_Add Binary.py | 1,356 | 3.5625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sun Sep 1 12:53:44 2019
@author: leiya
"""
#1.str,int类型
#2.变量的声明
#3.while循环里变量每次循环的更新
class Solution:
def addBinary(self, a: str, b: str) -> str:
carry = 0
i = len(a) - 1
j = len(b) - 1
res = ''
while i >= 0 or j >= 0 or carry:
... |
e7f6131cca21132561df5fb2bde280f8b133ae2e | GeorgiyDemo/FA | /Course_I/Алгоритмы Python/Part2/семинары/pract5/task2.py | 820 | 4.4375 | 4 | """
Задача 2:
В массиве найти максимальный элемент с четным индексом.
Другая формулировка задачи: среди элементов массива с четными индексами, найти тот,
который имеет максимальное значение.
"""
import array as ar
from random import randint
main_arr = ar.array("i", [randint(-100, 100) for _ in range(50)])
print("И... |
0dbacd0cc3e3b98d35613f5b7c4937d9994ef5e0 | silvercobraa/competitive-programming | /6. String Processing/Ad Hoc String Processing Problems/Regular Expression/00494.py | 187 | 3.53125 | 4 | import sys
for line in sys.stdin:
words = 0
prev = ' '
for c in line:
if c.isalpha() and not prev.isalpha():
words += 1
prev = c
print(words)
|
1df3a46b9dde63024901708aa54087657c2b6b8d | sm11/CodeJousts | /merge.py | 882 | 3.890625 | 4 | def merge(arr1, arr2):
arr3 = []
c1 = 0
c2 = 0
while c1 < len(arr1) and c2 < len(arr2):
if arr1[c1] < arr2[c2]:
arr3.append(arr1[c1])
c1 += 1
else:
arr3.append(arr2[c2])
c2 += 1
if c1 < len(arr1):
arr3.extend(arr1[c1:]... |
36c55fc15441acb81dbb3c4558942ca1749133c7 | ruidazeng/online-judge | /Kattis/mjehuric.py | 411 | 3.9375 | 4 | def bubblesort(vals):
changed = True
while changed:
changed = False
for i in range(len(vals) - 1):
if vals[i] > vals[i + 1]:
changed = True
vals[i], vals[i + 1] = vals[i + 1], vals[i]
# Yield gives the "state"
yield vals... |
8ad41702b99b7af93f899f19322bbd4c296671c6 | echosand/comp9021 | /ass1-2.py | 1,250 | 3.78125 | 4 | import sys
import math
try:
name=input('Which data file do you want to use?')
with open(name,'r') as f:
data=f.readlines()
matrix=[]
for line in data:
matrix.append(list(map(int,line.split())))
f.close()
except IOError:
print('Sorry, there is no such file.')
sys.exit()
f.close
#print (matrix)
#二分法算法
def div... |
da088bcfcf444bd513ece26748b39806925b0a2f | ROBIN6666/Purchase-Analytics | /Self_challenge/Combine.py | 2,735 | 3.609375 | 4 | import csv
import os
final_order=[]
with open('order.csv', 'r') as csvfile:
rw=csv.reader(csvfile,dialect='excel')
for row in rw:
final_order.append(row)
for a in range(len(final_order)):
final_order[a].pop(0)
for a in range(len(final_order)):
final_order[a]... |
a650d617838f8d5a85ec1004659de8dd7613c99d | angelkin1050/python | /list 개념.py | 1,495 | 4.03125 | 4 | """
여러개의 값을 하나의 변수에 담을 수 있다.
하나의 list변수에 다양한 자료형을 담을 수 있다.
음수 인덱스가 가능하다.(문자열도)하지만 사용을 지양해야 함.
인덱싱 추출값: 데이터만
슬라이싱 추출값: 리스트
"""
season =["봄","여름","가을","겨울"]
grade = [1,2,3]
print(season[0])
print(season[2])
print(season[0] + season[2])
print(grade[1] + grade[2])
hello = "안녕하세요"
print(hello[0:3])
#리스트 인... |
77dcc81ec23e65d4e54e3ed1303fdc29907667a0 | geetheshbhat/Flask-CRUD-sqlite3 | /app.py | 2,782 | 3.5625 | 4 | import sqlite3
from flask import Flask, request
from flask_restful import Resource, reqparse
app=Flask(__name__)
@app.route('/create', methods=['GET'])
def create_table():
connection=sqlite3.connect('data.db')
cursor=connection.cursor()
query="CREATE TABLE IF NOT EXISTS movies (id INTEGER PRIMARY ... |
8617d5c494f1788fc9feacbd51b719a5b984928f | its-Kumar/Python.py | /8_ObjectOrientedProgramming/BankAccount.py | 1,563 | 4.1875 | 4 | """Bank Account Class"""
class Account:
"""Class to represent a Bank Account"""
def __init__(self, owner: str, balance=0):
assert isinstance(owner, str), "owner name should be string"
assert not isinstance(balance, str), "balance should be int or float"
if balance < 0:
... |
f4e760857c37441136baffb980ccac2872cd00c3 | sandeshjoy/python-scripts | /dict.py | 213 | 3.65625 | 4 | def add_items(some_dict):
# Add new items to dict
some_dict.update({'k': 3, 'l': 4})
return some_dict
if __name__ == __main__:
some_dict = {'a': 1, 'b': 2}
new_dict = add_items()
print(new_dict)
|
1ac61293da313a3e6b2771f2c8a9265007c5e343 | ttp55/LearnPy | /CodeWars/23.py | 486 | 3.6875 | 4 | # @Time : 2019/8/23 8:42
# @Author : WZG
# --coding:utf-8--
def count_smileys(arr):
x = 0
print(arr)
for i in arr:
if (';' and 'D' in i) or (':' and 'D' in i) or (';' and ')' in i) or (':' and ')' in i):
if i.count('o') == 0:
l = list(i)
if (l[0] == ';')... |
fb30f8d4922cf5613862eb7a668a8c41d206ab70 | CarloAviles/PythonTesting | /pythonSelenium/explicitWaitDemo.py | 1,727 | 3.75 | 4 | # Using explicit wait
# A diferencia del modo implicito, esta forma se debe especificar el elemento poel que se va
# a esperar que aparezca, siendo este más eficiente que el Implicito que es global."
import time
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.... |
6b97834e3013ff12e4c59d5bde5d6b371731e8d2 | Woobs8/data_structures_and_algorithms | /Python/DataStructures/Queues/de_queue.py | 3,396 | 4.1875 | 4 | import argparse
import random
import math
class DEQueue():
"""
A class encapsulating a double-ended queue data structure
Attributes
----------
queue (list)
The list representing the ordered double-ended queue
len (int)
The current length of the queue
max_len (int)
... |
c0295c476cb83437e2e0836a931c975e7108714e | Skati/boring_stuff | /04_commacode.py | 144 | 3.6875 | 4 | spam = ['apples', 'bananas', 'tofu', 'cats']
def convert(spam):
a=','.join(spam[:len(spam)-1])+' and '+spam[-1]
print(a)
convert(spam)
|
f6f6d76d65cab93ceeb3a4c74a962f10f6ed21ea | ahmedelsers/Exercises_for_Programmers_57_Challenges | /03_printing_quotes.py | 292 | 4.125 | 4 | #!/usr/bin/env python3
quote = input("What is the quote? ")
who_said_it = input("Who said it? ")
print(who_said_it + " says, " + quote)
# Challenge
quotes = {"Obi-Wan Kenobi": "These aren't the droids you're looking for."}
for who, quote in quotes.items():
print(who + " says, " + quote) |
38c1ded804454b86f9ff79f9c82460195c4e53f5 | AnamIslam/PatternRecognitionLab | /Lab 1/PatternExp.py | 271 | 3.6875 | 4 | print("Enter Number of Train Data : ")
inpt = input()
n = int(inpt)
weight = []
height = []
label = []
print("Enter Train Data : \n")
#for i in range(n):
w,h,l = input().split()
m=w+h
print(m)
print(l)
#weight=int(w)
#height=int(h)
#label=l;
|
4d2e546234c723805125a157d98b586cec83027f | HEERAMANI26/python-programming | /for_loop.py | 3,763 | 4.25 | 4 | # for loop
'''n1 =int(input("Enter 1st number:"))
n2 =int(input("Enter 2nd number:"))
for i in range(n1,n2+1):
print(i)'''
# prime number
'''n1 =int(input("Enter 1st number:"))
count =0
for i in range(1,n1+1):
if (n1 % i == 0):
count = count+1
i = i-1
if count ==2:
print(n1)
else... |
c3bd244b9acf0986f6cfd8f58d28dc12011ca25b | byAbaddon/Essentials-Course-with----JavaScript___and___Python | /Python Essentials/3.0 Conditional Statements/07. Area of Figures.py | 411 | 3.890625 | 4 | def area_of_figures(figure):
num_a = float(input())
num_b = 0
if figure == 'rectangle' or figure == 'triangle':
num_b = float(input())
switch = {
'square': num_a * num_a,
'rectangle': num_a * num_b,
'circle': num_a * num_a * 3.14159,
'triangle': num_a * num_b / ... |
ee82adcd9ad22e464c6bcdc70ac1ba72df08bd19 | jgabdiaz/mycode | /testmod | 100 | 3.625 | 4 | #!/usr/bin/env python3
def Mult_3(x):
if x % 3 = 0:
return True
x=9
print(Mult_3(x))
|
9baa1b24e50bf3e268a89f0b65b902e38dda3f2a | anushreedas/Classification | /a1.py | 7,503 | 4.15625 | 4 | import numpy as np
import matplotlib.pyplot as plt
import math
"""
a1.py
This program implements least-squares linear classifier and k-nearest neighbor classifier
and plots 1) the training samples 2) the decision boundary separating class 0 and 1,
and 3) the classification regions.
@author: Anushree Das (ad1707)
"... |
7fb6457b668ad3f28fa62cca7e48d42a2a916cd3 | joao29a/traveling-salesman | /graph_gen.py | 610 | 3.703125 | 4 | #!/usr/bin/python
from sys import argv
from random import random
#generate a complete graph
def main():
if len(argv) > 3:
f = open(argv[1], 'w')
for i in range(1, int(argv[2]) + 1):
pos_x = random()*int(argv[3]) + 1
pos_y = random()*int(argv[3]) + 1
if (.01 > ra... |
82e97fb389912265ddaf83c38dd860110ab8105f | Jorewang/LeetCode_Solutions | /657. Robot Return to Origin.py | 496 | 3.625 | 4 | class Solution(object):
def judgeCircle(self, moves):
"""
:type moves: str
:rtype: bool
"""
right = left = up = down = 0
for m in moves:
if m == 'R':
right += 1
if m == 'L':
left += 1
if m == 'U':
... |
8f1555b7466734a20a715da46be61f59780311c5 | haveano/codeacademy-python_v1 | /05_Lists and Dictionaries/01_Python Lists and Dictionaries/09_More with for.py | 809 | 4.6875 | 5 | """
More with 'for'
If your list is a jumbled mess, you may need to sort() it.
animals = ["cat", "ant", "bat"]
animals.sort()
for animal in animals:
print animal
First, we create a list called animals with three strings. The strings are not in alphabetical order.
Then, we sort animals into alphabetical order. Not... |
65ee3829f70b1b116d1fde5731cd83ee424699ad | TzStrikerYT/holbertonschool-web_back_end | /0x03-caching/100-lfu_cache.py | 1,749 | 3.75 | 4 | #!/usr/bin/python3
""" BasicCaching module
"""
from base_caching import BaseCaching
class LFUCache(BaseCaching):
"""LIFO Cache"""
def __init__(self):
"""Init the instance"""
super().__init__()
self.stack = []
self.stack_count = {}
def put(self, key, item):
"""Assi... |
492f7b200620f4bb54e80c58bb03adca6f5e10f0 | jColeChanged/MIT | /Computer Science 6.00 SC/test.py | 4,673 | 3.703125 | 4 | from random import *
class Card(object):
RANKS = ["A","2","3","4","5","6","7","8","9","10","J","Q","K"]
SUITS = ["C","D","H","S"]
def __init__(self, rank, suit):
self.rank = rank
self.suit = suit
def __str__(self):
rep = self.rank + self.suit
return... |
a9a5c6845049c8bf840c30b84d00b95b425b46ff | newwhy/python-ch2.8 | /paint.py | 593 | 3.734375 | 4 | #바로 Point를 이 안에서 정의
from point import Point
def test_bound_instance_method():
p = Point()
p.set_x(10)
p.set_y(20)
#print(p.get_x(), p.get_y())
p.show()
print(p.count_of_instance)
def test_unbound_class_method():
p = Point()
Point.set_x(p, 10)
Point.set_y(p, 20)
print(Point.ge... |
b49c2ba966e37c93f70b5497d46b568b487bdf26 | m-mcneive/McNeive_ENVS | /src/co2Emmisions.py | 1,198 | 3.875 | 4 | import pandas as pd
import matplotlib.pyplot as plt
from scipy.stats import linregress
"""
This source had measurements of the carbon emissions of various countries. It also has measurements
of the continents as a whole. These are the measurements that I used because once visualized this will
be easier to read. The pr... |
9afe02d9df0261e24cfb45ee7b17b6c2ee4194ce | Do-code-ing/Python_Built-ins | /Methods_Set/difference_update.py | 256 | 3.5625 | 4 | # set_a.difference_update(set_b)
# 집합 a와 집합 b의 차집합을 집합 a에 갱신한다.
a = {1,2,3,4}
b = {3,4,5,6}
a.difference_update(b)
print(a)
# {1, 2}
# 다음과 같이 표현할 수도 있다.
a = {1,2,3,4}
b = {3,4,5,6}
a -= b
print(a) |
c66b9cd5379353ac41204979a9170b576948113d | vaibhavranjith/Heraizen_Training | /Assignment2/Asmt2Q4.py | 557 | 3.75 | 4 | def binarySearch(data,p):
c=0
for i in range(0,len(data)):
pattern=True
if(i+len(p)<len(data)+1):
for j in range(0,len(p)):
if(data[i+j]!=p[j]):
pattern=False
if pattern and i+len(p)<len(data)+1 :
c+=1
print(c)
... |
65551a51fbb5efbdfd18af4ac7dfd92a8f524352 | Yogesh-Singh-Gadwal/YSG_Python | /Core_Python/Day-12/42.py | 173 | 3.796875 | 4 | # String
# join
l1 = ['Y','o','g','e','s','h']
print(''.join(l1))
print()
print(' '.join(l1))
print()
print(' - '.join(l1))
print()
print('_'.join(l1))
|
e6e9185bf761fa2d93d92c236a0957092e0a07a9 | deeksha-malhotra/Coding-Interview-Preparation | /Python_/LinkedList/single_linked_list/merge_to_list.py | 899 | 4.125 | 4 | from linked_list import LinkedList
list1 = LinkedList()
list1.append("1")
list1.append("5")
list1.append("7")
list1.append("9")
list1.append("10")
list2 = LinkedList()
list2.append("2")
list2.append("3")
list2.append("4")
list2.append("6")
list2.append("8")
def merge_to_list(list1, list2):
P = list1.head
Q... |
e86ebe9d6e4d0635625900d148ba7d9f1bc2e5b7 | havenshi/leetcode | /206. Reverse Linked List.py | 737 | 3.859375 | 4 | # Definition for singly-linked list.
# class ListNode(object):
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution(object):
def reverseList(self, head):
"""
:type head: ListNode
:rtype: ListNode
"""
# iteration
dummy = ListNo... |
4629789848d5f08b5e2d1fea2ce34207303c2c72 | shukriev/sad-python-life | /simpleDS/vowels_dict.py | 900 | 3.96875 | 4 | vowels = ['h', 'i', 't', 'c', 'h', 's', 'i', 'k', 'e', 'r', 'a', 'h']
word = input("Provide a word to search for vowels: ")
found = {}
print("Print Vowels First")
print(vowels)
print()
print("Print Found Second")
print(found)
print("------------------------------------")
for letter in word:
if letter in vowels:... |
f6c42704b454d2f4319cdf83fba20b82f2f8ee81 | chinrw/WeatherBot | /GetWeather_Data.py | 970 | 3.609375 | 4 | #!/usr/bin/env python
import json
import urllib
import urllib2
from pprint import pprint
def get_weather_data(api_key, request_type, location):
# return a dict data that coutains required information
url = 'http://api.wunderground.com/api/%s/%s/%s.json'\
% (api_key, request_type,location)
... |
3849baa2222e81274417969e93cc746d4784e381 | gioiab/py-collection | /challenges/chat/chat_server.py | 7,438 | 3.828125 | 4 | """
Created on 23/11/2015
@author: gioia
This script runs a simple ChatServer built with sockets.
The code is organized as follows:
- the ChatServer class defines the behaviour of the server;
- the main module function simply executes the server.
The programming language used is Python 2.7 and it is assumed you hav... |
d0e803738e681ddc50692eac607e46a78a47d823 | BennyJane/python-demo | /设计模式/1.0抽象工厂.py | 1,128 | 4 | 4 | # -*- coding: utf-8 -*-
# @Time : 2020/11/2
# @Author : Benny Jane
# @Email : 暂无
# @File : 抽象工厂.py
# @Project : Python-Exercise
class PetShop:
def __init__(self, animal_factory=None):
"""PetShop 本身就是一个抽象工厂"""
self.pet_factory = animal_factory
def show_pet(self):
"""animal_factory 需要实... |
ba46ac180da4ad1b26648367f7055c7578dc30d6 | gr8rithic/Simple_Codes_Python | /largest of three.py | 197 | 4.0625 | 4 |
a=input("Enter a,b and c \n")
b=input()
c=input()
if a>b and a>c:
print(a," is the largest")
elif b>c and b>a:
print(b," is the largest")
else :
print(c," is the largest")
|
d24853429cf59f596718ecc9589f049c893680cb | magshi/hackbright | /Whiteboarding/Puzzles/task8.py | 533 | 4.40625 | 4 | #!/bin/env python
"""
Given two dictionaries, d1 and d2, update the contents of d1 with the contents of d2, overwriting any existing keys
eg:
d1 = {"a":1, "b":2}
d2 = {"a":3, "c":4}
becomes
d1 = {"a":3, "b":2, "c":4}
"""
d1 = {"a": 5, "c": 7, "d": 9, "q": 15}
d2 = {"a": 6, "e": 13, "g": 6, "q": 1}
d... |
48bbd73294c631013d4fc618b84d32dedba74189 | ramjal/python-sandbox | /think_python/chapter_10/exercise10.8.py | 589 | 3.59375 | 4 | import random
def has_duplicates(my_list):
lcopy = my_list[:]
lcopy.sort()
for i in range(len(lcopy)-1):
if lcopy[i] == lcopy[i+1]:
return True
return False
def birthday_paradox():
students = []
for i in range(23):
students.append(random.randint(15, 99))
# prin... |
977b325748fc907d7b13a1976b5b39e59fb9c9c3 | eugeniocarvalho/CursoEmVideoPython | /Python Exercicios/Mundo 1: Fundamentos/4. Condições em Python (if..else)/ex034.py | 371 | 3.796875 | 4 | '''
Escreva um programa que pergunte o salario de um funcionario e calcule o valor de seu aumento
Para salários superiores as 1.250, calule um aumento de 10%,
Para os inferiores ou iguais, o aumento é de 15%
'''
n = float(input('Salario: '))
if n > 1250:
print('Novo salario: R$ {:.2f}'.format(n * 1.1))
else:
pr... |
96a4d966350db9b0f44f05a69de682cdae65c5db | kongziqing/Python-2lever | /实战篇/第15章-并发编程/15.6多协程编程/使用gevent模块自动切换.py | 1,539 | 3.5625 | 4 | """
虽然greenlet组件可以实现多协程开发,但是需要由开发者明确地获取指定的切换对象后才可以进行处理,
这样的操作会比较麻烦,而在第三方Python模块中还提供了一个gevent模块,利用此模块还可以实现自动切换处理
本程序利用gevent分别设置了两个协程管理对象,只需要使用sleep()方法就可以自动实现不同协程的操作
"""
import gevent # pip install gevent
info = None # 保存数据
def producer_handle(): # 协程处理函数
global info # 使用全局变量
for item in range(... |
87a0d57d9b17fc0c4c4cd445dd931467fbe81791 | joeylmaalouf/gravity-ball | /gravity_ball.py | 2,923 | 3.890625 | 4 | # JLM - Python Gravity Ball
# Copyright (c) 2014 Joey Luke Maalouf
# import pygame for init, font, display, Rect, event, QUIT, draw
import pygame
#import sys for exit
import sys
#import time for sleep
import time
# -- initialization ------------------------------------------------------------
# Start up pygame with i... |
b9d8321147ad2043a93087c2ecc065b1a67820e4 | gHuwk/python_MEPhI | /lab_02/lab_02.py | 1,831 | 3.75 | 4 | # Решение влоб
from random import randint
from math import sin, log, factorial
def main():
print("Введите int k > 0:")
k = int(input())
if k > 0:
x = x_from(k)
print("X = ", x)
ret_z = z(x, k)
print("№{} из последовательности: {}".format(k, ret_z))
print(... |
c8300d2da7059f2cca63417e200e7cc4bbc06183 | RahatIbnRafiq/leetcodeProblems | /Tree/501. Find Mode in Binary Search Tree.py | 632 | 3.5625 | 4 | # Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution(object):
d = None
def dfs(self,node):
if node:
self.d[node.val] = self.d.get(node.val,0)+1
sel... |
1eaac96dba5db66597e43c0450324abf22740476 | chenya1123236324/python-examples | /function_module/file_operation_example/pandas_write_example.py | 632 | 3.59375 | 4 | # -*- coding:utf-8 -*-
import pandas as pd
__author__ = 'Evan'
def write_excel(file_name, sheets, data):
"""
使用pandas,写入多页工作表到Excel
:param file_name: 需要生成的Excel表格名
:param sheets: 需要写入的工作表名
:param data: 需要写入的数据
:return:
"""
writer = pd.ExcelWriter(file_name)
for sheet in sheets:
... |
203791c77d8a985625e359a97670ff89634ba403 | codingpen-io/codeup | /1930.py | 403 | 3.5 | 4 | memo = {}
def super_sum(k, n):
# print('k', k, 'n', n)
if k == 0:
return n
sum = 0
for i in range(1, n+1):
key = str(k-1)+str(i)
if not key in memo:
memo[key] = super_sum(k-1, i)
sum += memo[key]
return sum
while True:
try:
k, n = map(int, i... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.