blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
8c1f633ce11e45fe12052ebc0a2fb86d0b00a47f
Luksos9/LearningThroughDoing
/automateboringstuff/smallGames/RockPaperScissors.py
1,828
4.15625
4
import random #Rock, Paper, Scissors Game tie = 0 win = 0 loose = 0 userMove = "" while userMove != "q": #Main loop, breaks when user chooses quit print("{} wins, {} losses, {} Ties".format(win, loose, tie)) userMove = input("Enter your move:\n" "(r) - rock\n" ...
12d3b6b00ca66ca512adda48993f442b623292ab
bunuli12138/2019_summer_coding
/Programing(Phase 8)/Python/Task4/sort_binary_search.py
2,874
4
4
'''Sort''' # Merge Sort(used recursion) from arrays import Array ## recursion function def mer_fun(lyst, ary, low, high): if low<high: mid = (low+high)//2 mer_fun(lyst, ary, low, mid) mer_fun(lyst, ary, mid+1, high) ## merge small arrays to a large array def mer(lyst, ary, low, mid, high): ...
4baa305c519ec7cc26c4298ba3e798e694a69af2
vupham26/Recursive-Algorithm
/Factorial Fibonacci GCD - Python/gcd.py
326
4.03125
4
def gcd(a,b): if a==0: return b elif b==0: return a if a==b: return a if a>b: return gcd(a-b,b) return gcd(a,b-a) a=int(input("Enter value of a :")) b=int(input("Enter value of b :")) if gcd(a,b): print("GCD of",a,"and",b,"is",gcd(a,b)) else: print("Inva...
1c59806c4215cff02e50b6ffe74248da47429a71
Pradeepsuthar/PythonTkinter
/sample.py
4,253
3.59375
4
from tkinter import * import time class App(Frame): def __init__(self, master=None): 'Start Application' Frame.__init__(self, master) self.pack() self.countdown(120) # Start Timer def countdown(self, remaining = None): 'Countdown Timer' s...
4363b5af0fda94093c45b029480d0a1fe6313bff
moey920/Algorithm-study
/2주차/2020-12-30/강인선/[수학]무어의 법칙.py
229
3.6875
4
#자연수 N입력 N=int(input()) #2^N값 생성 s=2**N #s를 리스트로 변경 list_s=list(str(s)) #문자열을 정수로 바꾸어서 더한값 출력 sum_s=0 r=[] for i in list_s : r.append(int(i)) print(sum(r))
5caad998cfeaf7a4326daf293289ab04a47be939
moey920/Algorithm-study
/3주차/손상준/[문자열] 너가 왜 거기서 나와 - 레벨 2 100.py
168
3.59375
4
N = int(input()) n_str = "" for i in range(1, N+1): #문자열 생성 n_str = n_str + str(i) ans = n_str.find(str(N)) + 1 #문자열 인덱스 생성 print(ans)
0b4a9582f567f9a082b0f2ccb884b3713e85a32a
moey920/Algorithm-study
/2주차/2020-12-30/강인선/[구현]생수통.py
145
3.546875
4
a=[] b=[] for i in range(3): a.append(int(input())) for i in range(2): b.append(int(input())) a.sort() b.sort() print(a[0]+b[0]+10)
a1406576946697e1ac59be5c48173aff8e1ea871
rajishwagh/N_Queens
/One.py
4,420
3.625
4
''' Created on Jul 2, 2017 @author: rjw0028 ''' import random, sys # Following code tries to tackle the N Qeens problem, using backtracking technique... The algo was available online, the code is written by me... global _QUEENS_ _QUEENS_ = [] # Contains [i,j] of all the queens placed... def pop(): ...
1b318cc07e9fb9be036adfe9211dea3ca6a869a8
ralterman/nyc-ds-111819-lectures
/Mod_1/rolling-stones/functions.py
2,902
3.671875
4
def find_by_name(collection, album_name): for item in collection: if item['album'] == album_name: return item return None def find_by_rank(collection, album_rank): for item in collection: if item['number'] == album_rank: return item return None def find_by_y...
de63081b59e74d1229a3b4fa6f603e0144ef832c
The-CJ/oppadc.py
/oppadc/vector.py
645
4.125
4
import math class Vector: """ A 2D vector """ def __init__(self, x:float=0.0, y:float=0.0): self.x:float = x self.y:float = y def __sub__(self, Other:"Vector") -> "Vector": return Vector(self.x-Other.x, self.y-Other.y) def __mul__(self, factor:float) -> "Vector": return Vector(self.x*factor, self.y*fa...
fc3351c74df5333ffeee8c45763475f42284b957
GBru14661/Learn-Python
/L3_PY.py
321
3.84375
4
num1=[12,34,56,78,90,991,191,12] num2=[1,2,3,4,5,6,7,334] str1=["Prachya","Peeranat","Adisak","Kanokon","Suppawit","Pichamon"] print(num1+num2) print(str1*3) print(num1*3) print(num1==num2) print(num1!=num2) print(num1>num2) print(len(num1)) print(len(num2)) num3=[num1,num2] print(num3) print(sum(num1)) print(max(num2)...
83c64bce8146e80fc09e32891ec2ff7c0720c350
sotetsuk/five-programming-problems
/prob1st.py
630
3.625
4
""" [1st problem] https://www.shiftedup.com/2015/05/07/five-programming-problems-every-software-engineer-should-be-able-to-solve-in-less-than-1-hour start 11:28 end 11:35 = 7min """ def sum_for(l): sum = 0 for e in l: sum += e return sum def sum_while(l): sum = 0 i = 0 len_l = len...
bd2eb17e73a584635dab78bf8d60cab29b24e444
99004342-yash/mini-project-python
/src/index.py
680
3.78125
4
""" Program for working with xl sheets. """ from ExcelOperation import ExcelOperation xls = ExcelOperation('input.xlsx') while True: choice = int(input(""" ## MENU ## Select option: 1. Show all PS Numbers 2. Create XL of selected PS Number. """)) if choice == 1: for ps_no_xl i...
6a5fef07f556772ff056adb4eceeaf99c6898df3
MaRTeKs-prog/Self-Taught
/Ch 21/python_exQUEUE.py
509
3.96875
4
# Ex. 295 class Queue: def __init__(self): self.items = [] def is_empty(self): return self.items == [] def enqueue(self, item): self.items.insert(0, item) # Здесь код работает не как в книге def dequeue(self, item): self.items.pop() def size(self): return len(self.items) # Ex. 296-298 a_queue = Qu...
d65b19e005e958ec76bd32db0995858b3644c404
MaRTeKs-prog/Self-Taught
/Ch 12/Chall/chall3.py
186
3.75
4
class Triangle: def __init__(self, h, b): self.height = h self.base = b def area(self): return self.height * self.base triangle = Triangle(3, 5) print(triangle.area())
4dbb6535086786dbeb3ad5a906c226fd0d5e727a
MaRTeKs-prog/Self-Taught
/Ch 13/Chall/chall1.py
710
4.1875
4
from math import pi class Circle: def __init__(self, r): self.radius = r def calculate_perimeter(self): return 2 * pi * self.radius class Square: def __init__(self, s): self.side = s def calculate_perimeter(self): return self.side * 4 circle = Circle(3) print(circle.calculate_perimeter...
266e3195e1c8fcadee45bfe63c2632d23371c833
MaRTeKs-prog/Self-Taught
/Ch 6/chall9.py
86
3.828125
4
str1 = 'три' + 'три' + 'три' print(str1) str2 = 'три' * 3 print(str2)
1a8796ece5793c326e65fa2fef9effa88e21e4f7
MaRTeKs-prog/Self-Taught
/Ch 22/python_ex302.py
122
3.625
4
def palidrom(word): word = word.lower() return word[::-1] == word print(palidrom('Мама')) print(palidrom('Мам'))
9c7f4ea2349c26ac01de6a7b506d91c9a6333ce8
MaRTeKs-prog/Self-Taught
/Ch 6/chall2.py
183
3.828125
4
s1 = input('Type the first string:') s2 = input('Type the second string:') string = 'Вчера я написал {}. Вчера я ходил {}!'.format(s1, s2) print(string)
fb94ab9f709310379c9f6d354ae9f00a340c2846
Templario17/componentes_vector
/componentes_vector.py
404
3.65625
4
#!/usr/bin/env python #-*- coding: utf-8 -*- # componentes para un vector import math dist = 200 grados = 30 def magnitud(dist, grados): g = math.radians(grados) i = dist * math.cos(g) j = dist * math.sin(g) mag = math.sqrt(i ** 2+ j ** 2) print "las componentes del vector ({} i),({} j) ".format(...
0ca0227870609c3db5950b72d845cdeeca9310f2
PaulBrownMagic/Slither
/text_objects.py
1,608
3.609375
4
# Text to Screen functions from constants import * class TextObject: # Class to place text objects on the screen. x_displace = 0 y_displace = 0 size = "small" def __init__(self, text, colour, x_displace=0, y_displace=0, size="small"): # Text Object, defaults to small black centered te...
6e337540caf76f404a97f4899f9b6df5c2a5aec2
sudormrfbin/clid
/clid/commands.py
1,696
3.734375
4
#!/usr/bin/env python3 from . import const class InvalidCommand(Exception): """Error raised when a command string is invalid""" pass class InvalidCommandSyntax(Exception): """Error raised when there is a syntax error in the command string, like unwanted switches, args, misspelled switches, etc ...
fa2ec2538d6ae0ca6ea5e4eaa0d5afad1f70d018
Craig314/Network
/SMTP/SMTPclient.py
2,199
3.5625
4
#CSC 138, M/W/F 11:00-11:50am #Craig Hulsebus, November 13, 2017 #Skeleton Used From Computer Networking: A Top-Down Approach from socket import * message = 'HELLO CRAIG\r\n' # Choose a mail server (e.g. Google mail server) and call it mailserver mailserver = "localhost" serverport = 25 # Create socket ...
02cb6859580aee0dca8ac3b3f0e2f2d31a1f4c03
trananhkma/Project_Euler
/10.py
278
3.84375
4
import math def is_prime(x): count = 1 while count < math.sqrt(x): count += 1 if not x % count: return False return True sum = 2 number = 3 while number < 2000000: if is_prime(number): sum += number number += 2 print sum
eef0986af59252892c0c77aa02fac1cba0009805
trananhkma/Project_Euler
/122.py
1,200
3.9375
4
def is_increasing_num(n): """ Return True if n is increasing number Return None if n is bouncy number """ s = str(n) s = s[0] + s.lstrip(s[0]) if len(s) == 1: return True for i in range(len(s)): if i == 1: if int(s[i]) > temp: increasing_num = ...
ef724944d37604eccaf24d7d6a5601b6021b9857
trananhkma/Project_Euler
/50.py
703
3.59375
4
import math def is_prime(x): num = 1 while num < math.sqrt(x): num += 1 if not x % num: return False return True primes = [2] number = 3 while number < 10000: if is_prime(number): primes.append(number) number += 2 cumulative = {} for i in range(len(primes)): ...
03af48b905fb7b334aad76c2795ce45957150b4a
DucTruongKomit/PythonBeginning
/Exercise/Exercise06.py
200
4.15625
4
s = str(input("Please type: ")) #read frome the end to the start of string sbw = s[::-1] print() if s == sbw: print("This string is a palindrome") else: print("This string isn't a palindrome")
2cca56fbc35f31ef18a9f0480eca2ce9b1a628fd
canyoufeelme/U3-L12
/Magic Eight Ball App/Magic eight ball.py
563
3.859375
4
import time import random print('-'*63) print('Hello queer traveler! I am a Magic Eight Ball!') print() question = input('What is your question? ') time.sleep(0.7) print('Shaking!') time.sleep(0.7) print('...thinking...') time.sleep(0.7) print('...thinking...') time.sleep(0.7) choice = random.randint(1,6) if choice ...
4ebdc984d490a9d2c77aa7942cfe0e0d8ee7ada8
iannolon/Unit-4
/functionDemo.py
695
4.125
4
#IanNolon #3/9/18 #functionDemo.py - how to write our own functions def hw(): print("hello, world") hw() #test of hello world function hw() #another one def double(thingToDouble): print(thingToDouble*2) double(12) #test of double function double('w') #test of double with a string input double(False)...
25883178065bfaaecb92b1e02b5e11ce736929e2
Smalz92/Python
/CadsManager/cads_main.py
661
3.578125
4
import cards_tools while True: #TODO show menu cards_tools.show_menu() action_str = input("please choice do:") print("you choice is [%s]" % action_str) #1,2,3 if action_str in ["1","2","3"]: #pass if action_str == "1": #pass cards_tools.new_card() ...
ff2fd7bfa0bd231ec5e3e95e3d6d7dc77950c951
Ricardo-Sousa-hub/SmintsTheSocialNetwork
/Menus/Menu.py
539
3.6875
4
import os clear = lambda: os.system('cls') def Menu(titulo, opcoes, nop): clear() print() print(titulo) print() for i in range(nop): print(i + 1, "-", opcoes[i]) print("-" * 30) print("0 - Terminar") while True: try: op = int(input("Opcao? ")) e...
352ebab91a223755cfc1bf9ed57f4a6ff9c7ab96
bluejok3/TADEJ_Louis_M1RES
/TD4.py
2,964
3.78125
4
#!/usr/bin/env python # coding: utf-8 # In[10]: # In[ ]: # In[21]: #Exercice 1 question 1 from math import pi; def surf_cercle(r): #variable r pour le rayon return pi(r**2) r = input("saissisez R :") surf_cercle(r) # In[12]: #Exercice 1 question 2 def surf_cercle2(r=1): return pi(r2) # ...
1d7cd82d8eb5481738d754468195d6d74d422503
Mowrey0210/kb
/w3/examples/mystery-word/mystery_word.py
908
4.21875
4
word_to_guess = "racecar" letters_guessed = [] def word_guessed(word_to_guess, letters_guessed): """ Given a word to guess and a list of the letters currently guessed, return True if all the letters in the word have been guessed already. """ for letter in word_to_guess: if letter not in le...
68324e46181ee5b3f69addf9e8279926f3b948ab
gituser2234/game2
/rooms.py
2,802
3.6875
4
# -*- coding: utf-8 -*- """ """ import pygame from walls import Wall import constants as con class Room(object): """ Base class for all rooms. """ # Each room has a list of walls, and of enemy sprites. wall_list = None enemy_sprites = None def __init__(self): """ Constructor, create ou...
4227af780aa15637836f5fee2c1c6a28c79d6544
dev-voxel/hangman
/text/string_formatter_mb.py
197
3.5
4
def format_string(string): line_replace = ['~', '`', '>', '#', '+', '-', '=', '|', '.', '!'] for line in line_replace: string = string.replace(line, f'\\{line}') return string
77f668cc4c71a49cbee05a3e39c09784e459f5b4
Sharp-Mind/Console-Loto-game
/loto.py
4,779
3.703125
4
from random import random, shuffle rolled = [] number_of_kegs = 90 class Gamer: def __init__(self): self.nums_per_line = 5 self.player_card = [['----------Gamer-----------'], [' ', ' ', ' ', ' '], [' ', ' ', ' ', ' '], [' ', ' ', ' ', ' '], ['------...
8e29658e9452e5b802a80312d6584544ea85f931
richardsj/dotfiles
/bin/genpw
819
3.703125
4
#!/usr/bin/env python """Module to generate a random string Attributes: LENGTH (int): Defaults to a length of 16 """ import sys import logging import optparse try: import OpenSSL except ImportError: logging.error('Missing PyOpenSSL.') logging.debug('Try `pip install pyopenssl`') sys.exit(1) impo...
ecd4c5e1bc797ca57ad0859c00f1b1829356dc42
yanzongzhen/python_base
/4、字典集合运算符/07集合和字典.py
2,568
3.734375
4
#python基础 #集合 就和数学里面的集合一个意思 set se = {1,2,2,'a','c'} #{'a', 1, 2} #无序 不重复 set('abc') ##set(['a','b',[1,2],[1,2,3]]) 嵌套的列表不行 可能会出现重复,违反唯一性原则 set(['a','b',(1,2)]) #元组不可变所以可以 sa = {1,2,'a','b'} se & sa # & 交集 集合相同的部分 se | sa #| 并集 两个集合合起来组成一个集合 se - sa #- 差集 前面这个集合去掉后面这个集合重复的部分 保留不同的部分 se.add('f') #add一次只能添加一...
dfe6291a468eaaed2ae3a8fc40a94c33affcc641
yanzongzhen/python_base
/5、控制流程/python控制流程.py
2,080
4.15625
4
#python 控制流程 a = 3 b = 2 #if a == b: # print('a和b相等') #else: # print('a和b不相等') ''' if a > b: #if可以单独出现 print('a大') elif a < b: print('b大') #elif a == b: else: pass #要不起 print('a和b 不相等') ''' #让程序随生成 import random n = random.randint(1,10) #print(n) ''' a = input("请输入一个不大于十的数:") #input返回为字符串 if...
a5f66a7ac5e5000b2c504ed7314106c593fbe766
yanzongzhen/python_base
/8、面向对象(1)/面向对象.py
1,831
4.1875
4
#python基础 面向对象 ''' 1、概念 2、类的定义 3、类的实例化 4、类和实例的属性 ''' #概念 a = 1 type(a) ''' 把有相同特征的东西抽象出来,取个名字例如A,若下次有个东西也有这个特征 的时候,我们就称之属于A这个类,归并为A类 ''' #定义类 class Animal: #驼峰命名法 #3中默认继承OBJECT类 2中必须写object ''' 这是一个动物类 ''' eye = 2 #共有属性 def __init__(self,name,food,color = 'yellow',leg = 4): #init 类的实例化初始函数 se...
d7e78eedda30cd43c873944309b7b4b6a6cb2b2c
yanzongzhen/python_base
/3、字符串格式化复制/作业讲解.py
622
3.640625
4
#作业讲解 ''' 格式化 % 拼接 + join format ''' #1.a = '苦短' b = 'Python' 用字符串拼接的方法输出'人生苦短,我用Python' a = '苦短' b = 'Python' '人生' + a + ',' + '我用' + b '人生%s,我用%s'%(a,b) ''.join(['人生',a,',','我用',b]) '人生{},我用{}'.format(a,b) #2.列表li = ['I','like','python'],将里面的单个单词拼成一句话 li = ['I','like','python'] ' '.join(li) '%s %s %s'%(li[0],l...
614983fc1f04d5965f71e4e7b703fd0aa9a11c9a
Banehowl/FebruaryDailyCode2021
/DailyCode02062021.py
815
4.21875
4
# -------------------------------------------------------------- # Daily Code 02/06/2021 # "Find the Perimeter of a Rectangle" Lesson from edabit.com # Coded by: Banehowl # -------------------------------------------------------------- # A vehicle needs 10 times the amount of fuel than the distance it travel...
2745edfa625777502f53357e19b5d86742d72aa0
Banehowl/FebruaryDailyCode2021
/DailyCode20192021.py
711
3.96875
4
# ---------------------------------------------- # # Daily Code 02/19/2021 # "Basketball Points" Lesson from edabit.com # Coded by: Banehowl # ---------------------------------------------- # You are counting points for a basketball game, given the amount of 3-pointers scored and 2-pointers scored, # find t...
8eb8ec36a184713d2fe1e59e0b253719dfb0aaa5
Banehowl/FebruaryDailyCode2021
/DailyCode02012021.py
541
4.0625
4
# ------------------------------------------------------- # Daily Code 02/01/2021 # "Convert Hours into Seconds" Lesson from edabit.com # Coded by: Banehowl # ------------------------------------------------------- # Write a fuction that converts hours into seconds # how_many_seconds(2) -> 7200 # how_many_...
2ea760a656327421149c48a900e7814255fd90aa
zachlemberg/python-science-functions
/main
6,670
3.65625
4
#!/usr/bin/env python #-*- coding: utf-8 -*- def quad(a,b,c): """runs the quadradic formula faster than a snail\n the a,b,c come from 0 = ax^2 + bx + c""" x1 = (-b + ((b**2) - (4 * a * c))**.5)/(2 * a) x2 = (-b - ((b**2) - (4 * a * c))**.5)/(2 * a) print "your solutions are " + str(x1) + " and " + str(x2) def dot...
5cb7dc6ded519ff7ea79c3d7a9443b1d32b80ce7
ronniezhr/BeleTears
/main.py
6,676
3.640625
4
import pickle import re import getpass from ucb import main from student import * from course import * from error import * def welcome(): WELCOME_MESSAGE = """ ------------------------------------------------------------------------------- WELCOME TO BELETEARS ------------------------...
027c3f489885781dc2199cfb697822dc851107d3
CassyAnderson/ATM
/ATM2.py
1,479
4.25
4
import sys #account balance account_balance = float(500.25) #This is the print balance account function def print_balance(balance): print('Your current balance is:') print(balance) #This is the account deposit function with input(parameters) def deposit(balance): deposit_amount = float(input("How much would y...
b2b0c493ca0b3b908716b3dc975d765e2ec44b3e
svetoslavastoyanova/Python_Advanced
/Functions_Exercises/04.Negative vs Positive.py
491
3.953125
4
def negative_num(nums): return filter(lambda x: x < 0, nums) def positive_num(nums): return filter(lambda x: x > 0, nums) numbers = list(map(int, input().split())) positive_numbers = sum(positive_num(numbers)) negative_numbers = sum(negative_num(numbers)) print(negative_numbers, positive_numbers, sep="\n") ...
966d01706209a54fd957f04d15ee8215a0e53f97
svetoslavastoyanova/Python_Advanced
/Exercises/Fruit_Market.py
486
3.734375
4
strawberries_price = float(input()) bananas_weight = float(input()) oranges_weight = float(input()) raspberries_weight = float(input()) strawberries_weight = float(input()) raspberries_price = 1/2*strawberries_price oranges_price = 0.6*raspberries_price bananas_price = 0.2*raspberries_price total_price = (strawber...
dafe1a2c2227927a51d167d0a90353bb3f43f81b
svetoslavastoyanova/Python_Advanced
/Exam_14_April/Problem_three.py
611
3.546875
4
def flights(*args): info = {} for i in range(0, len(args), 2): key = str(args[i]) if key == "Finish": break else: value = int(args[i + 1]) if key not in info: info[key] = value else: info[key] += value re...
9e2455c235a51988782e01a6ff5bdc17e134f5f8
svetoslavastoyanova/Python_Advanced
/Exercises/Grade.py
65
3.5
4
grade = float(input()) if grade >= 5.50: print(" Excellent!")
04d9ef58b1dcefa2536ac00ed4b85c854cad6b5c
svetoslavastoyanova/Python_Advanced
/Comprehension_Exercises/02.Words_lengths.py
200
3.625
4
data = input().split(", ") filtered_data = {x: len(x) for x in data} final_list = [] for key, value in filtered_data.items(): final_list.append(f"{key} -> {value}") print(', '.join(final_list))
3665721d832ed91563724f12849ffd65f4dee0f3
FarzanaHaque/CS440
/HW3/data_parsing.py
1,132
3.53125
4
""" This module handles parsing in test data. """ GET_IMAGE = 0 GET_ANSWER = 1 def create_data(filename): """ Generates a list of training data in a list of tuples [(data in a 2d list, true result), ...] :param filename: name of file to input :return: data in a list of tuples [(data in a 2d list of ints, true re...
be54057485e18389a355f403d1ba6be0c86cee3a
SHANA2029/PROGRAMMING-LAB_PYTHON
/CO1_ 4.py
212
3.71875
4
s=input("enter a sentence:") word=input("enter word to be counted:") a=[] count=0 a=s.split(" ") for i in range(0,len(a)): if(word==a[i]): count=count+1 print("count:",count)
58d522a29ecdbc28f0608b648c854e2707f37aab
SHANA2029/PROGRAMMING-LAB_PYTHON
/CO2_3.py
130
3.6875
4
total = 0 l1=[20,15,32,21,14] for elements in range(0,len(l1)): total=total+l1[elements] print("sum : ",total)
5e96bce948e41833863a15e8404ce6d6d8c2fdd9
ronaldoapsilva/Beatiful_Soup
/bs_2 Kinds of objects.py
4,972
4.03125
4
def titulo(msg): cores = {'verde':'\033[32m', 'amarelo':'\033[33m', 'vermelho':'\033[31m', 'limpa':'\033[m'} print(f'{cores["vermelho"]}{msg}{cores["limpa"]}') def exemplo(msg2): print('{:=^50}'.format(msg2)) from bs4 import BeautifulSoup soup = BeautifulSoup...
0616f015cd68cff416b97b9d05b07bcc2f5ee356
Greenun/algorithmPractice
/baekjoon/climb_stairs.py
700
3.546875
4
import sys def climb_stairs(l:list): dp = [0]*(len(l)+1) dp[1] = l[0] dp[2] = l[0] + l[1] # skipped = False # or skipped for i in range(3, len(l)+1): dp[i] = max(dp[i-3] + l[i-1] + l[i-2], dp[i-2] + l[i-1]) # if i == len(l): # dp[i] = max(dp[i-3]+l[i-1]+l[i-2], dp[i-2]+l[i-1]) # skipped = False # els...
046fbf75af7de8a5d09657d438c7228ab5571884
Greenun/algorithmPractice
/coalgo/tri_snail.py
1,086
3.59375
4
def solution(n): # 으아 너무 구리다... matrix = [[] for _ in range(n)] whole = (n*(n+1))//2 start = 1 cycle = 0 temp = n while whole >= start: if whole == start: matrix[2*cycle].insert(cycle, start) break # temp # print(start, matrix, "--1") f...
219b7cb8516be2ee9a332945400221853dcbfb0d
Greenun/algorithmPractice
/programmers/n_queen.py
1,756
3.53125
4
# non-recursive --> 시간 초과 # check 수정하여 시간 맞춤 def solution(n): count = 0 row = 0 col = 0 temp = list() while 1: if row == 0 and col == n: break while col < n: if check(temp, row, col): temp.append(col) row += 1 co...
13f3127f3b92818c5efc328b4358bafbeea4a351
Greenun/algorithmPractice
/programmers/programmers_dfs_bfs.py
1,000
3.578125
4
def solution(n, computers): answer = 0 from collections import defaultdict nodes = defaultdict(set) for i in range(n): for j in range(n): if i <= j: continue if computers[i][j] == 1: nodes[i].add(j) nodes[j].add(i) node_set = set(range(...
2ca189ebc99c8f7ad653d9155a5e30461bd71293
aidyp/Alvaro-Germans
/anagrams/logic-snippets/check_anagram.py
2,308
3.9375
4
import json # primify global # primify = {'a':2,'b':3,'c':5,'d':7,'e':11,'f':13,'g':17,'h':19,'i':23,'j':29,'k':31,'l':37,'m':41,'n':43,'o':47, 'p':53,'q':59,'r':61,'s':67,'t':71,'u':73,'v':79,'w':83,'x':89,'y':97,'z':101} def numberfy(word): out = 1 for letter in word: out *= primify[letter] return out def loa...
4a8f1cca8490931c36ba1f72e39f93edea9fd93c
jronquillog2/Ejercicios-de-practica-Estructura-de-datos-
/ejercicio22.py
373
3.8125
4
print("""********************* Suma de numeros pares ***********************""") suma=0 n = int (input ("Ingresa el valor de n: ")) for i in range (1, n + 1): print ('Numero',i) un_numero = int (input ('Ingresa el valor de un numero: ')) if un_numero%2==0: suma=suma+un_numero print () ...
a87f4702ff14ecfb408cd1a4b26fc0c363d7b235
jronquillog2/Ejercicios-de-practica-Estructura-de-datos-
/ejercicio36.py
164
3.625
4
print("""***************************** Mayor y suma de una Lista **************************""") conjunto=set() conjunto={} conjunto.add(3) print(conjunto)
58d818875291b787c93c1196fa849499d3643ad1
riadghorra/ml-tools
/Feature_engineering/feature_selection.py
5,460
3.609375
4
import pandas as pd import numpy as np import matplotlib.pyplot as plt import seaborn as sns def plot_continuous_column_against_target(data, column_name, target, limit=None): x = data[column_name] y = data[target] if limit: r = data[data[column_name] < limit] x = r[column_name] y =...
8a27406181135c53569f5e4d5ffc9b4e630296cb
markravarra/Python-Projects
/F_ELECQ_4CSA_ACTIVITY1_RAVARRA.py
180
3.90625
4
def mult(): print("Multiplication Table upto 5") n=5 for i in range(1,n+1): for j in range(1,n+1): print(i*j, end="\t") print() mult()
8e8214c0eeabdee58629424d20de352f35eed6c2
GabrielJardimPP/Sideprojects
/shortpath.py
1,686
3.9375
4
'''Implementation of Dijkstra's algorithm By Gabriel Jardim Pereira Pinto O(n^2) solution of Coursera's Algorithms course , programming question 5''' def txt2graph(file): # opens file converting to graph in dictionary structure fil = open(file, 'r') graph = {} for line in fil: data...
59504f51e8ba7a234be1cc6568501344ae1472c0
njerivera/vera-python
/assignment3.py
1,386
3.921875
4
Python 3.7.2 (tags/v3.7.2:9a3ffc0492, Dec 23 2018, 22:20:52) [MSC v.1916 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license()" for more information. >>> x=range(30) >>> for n in x : if n % 3==0 and n % 5==0: print(" {} fizzbuzz.".format(n)) elif n % 3 ==0: print(" {} fizz .".format(n)...
4558d1bae079178f3049e73698dd0fd148b99ea3
ck-fm0211/notes_desigh_pattern
/13_Visitor/src/sample1.py
2,086
3.75
4
# -*- coding:utf-8 -*- from abc import ABCMeta, abstractmethod # 先生クラス class Teacher(metaclass=ABCMeta): def __init__(self, students): self._students = students @abstractmethod def visit(self, student_home): getattr(self, 'visit_' + student_home.__class__.__name__.lower())(student_home) ...
4f99e7793054686390486a66554df7d84250b27a
ck-fm0211/notes_desigh_pattern
/21_Proxy/src/sample1.py
1,409
3.8125
4
# -*- coding:utf-8 -*- from abc import ABCMeta, abstractmethod class Sales(metaclass=ABCMeta): """営業interface""" def __init__(self): pass @staticmethod @abstractmethod def question1(): pass @staticmethod @abstractmethod def question2(): pass @staticmetho...
0f79895bfafbd1da2e38f15a3bf7a8535409fa9e
ck-fm0211/notes_desigh_pattern
/11_Composite/src/sample2.py
1,364
3.734375
4
# -*- coding:utf-8 -*- from abc import ABCMeta, abstractmethod class DirectoryEntry(metaclass=ABCMeta): @abstractmethod def remove(self): pass class File(DirectoryEntry): def __init__(self, name): self._name = name def remove(self): print("{}を削除しました".format(self._name)) cl...
8eaee7094cfceb673da683e3c0870b49f965ab51
weipeng-1996/algorithm-and-data-structure
/algorithm/leetcode/数组问题/搜索旋转排序数组.py
869
3.578125
4
# https://leetcode-cn.com/problems/search-in-rotated-sorted-array/ # 二分法 def search(nums, target): l = len(nums) if l == 0: return -1 left = 0 right = l - 1 while left < right: mid = left + (right-left) // 2 if nums[mid] == target: return mid # 判断左区是否有序 ...
2dabc2802ad829f182ce16feadd3af55e2d1a8fe
weipeng-1996/algorithm-and-data-structure
/algorithm/leetcode/最长公共前缀.py
741
3.640625
4
def longestCommonPrefix(strs): if strs == []: return '' for i in range(len(strs)): if not strs[i]: return '' s1 = strs[0] for i in range(1, len(strs)): j = 0 l1 = len(strs[i]) l2 = len(s1) while (j < l1 and j < l2 and s1[j] == strs[i][j]): ...
a40436f2759a0042a85ffc5e84f7dd0befccb27e
weipeng-1996/algorithm-and-data-structure
/algorithm/leetcode/数组问题/多数元素.py
656
3.609375
4
# 169 # 哈希表 O(n) O(n) def majorityElement(nums): record = {} for num in nums: record[num] = 0 for num in nums: record[num] += 1 m = max(record.values()) for k, v in record.items(): if v == m: return k # 排序 O(nlogn) O(1) def majorityElement1(nums): nums.so...
4a332fb700fcb26c39db6503581b4ddaf391f67b
weipeng-1996/algorithm-and-data-structure
/algorithm/leetcode/2的幂.py
488
3.828125
4
# 231 # O(logn) def isPowerOfTwo(n): if n == 0: return False while n % 2 == 0: n /= 2 return n == 1 # 位运算 # 若 n = 2 ^ x # 且 x 为自然数(即 n 为 2 的幂),则一定满足以下条件: # 恒有 n & (n - 1) == 0,这是因为: # n 二进制最高位为 1,其余所有位为 0; # n−1 二进制最高位为 0,其余所有位为 1; # 一定满足 n > 0。 # O(1) def isPowerOfTwo(n): return...
9f72142adacce4a098b7c7ffe4f0a432e83af5e0
khallon/PROJECT4
/testgame.py
2,054
3.640625
4
import pygame pygame.init() from pygame.locals import Rect, DOUBLEBUF, QUIT, K_ESCAPE, KEYDOWN, K_DOWN, \ K_LEFT, K_UP, K_RIGHT, KEYUP, K_LCTRL, K_RETURN, FULLSCREEN white = (255,255,255) black = (0,0,0) red = (255, 0, 0) green = (0, 255, 0) blue = (0, 0, 255) display_width = 800 display_height = 600 #Setting th...
91126d5dc283486809c07d57b697c91f1629ebd0
gaohuiru/jair_anomaly_detection
/time_series/time_series_helpers.py
478
3.65625
4
import pandas as pd def create_df(values): # given a list create a df with some arbitrarily chosen dates rng = pd.date_range('2000-01-01', periods=len(values), freq='T') df = pd.DataFrame({ 'timestamp': rng, 'value': values}) return df def rename_df(df, timestamp_string, value_string): # given a ...
eba87235e6d69fdf095e79aa864f8e23a6ea7880
hinsonan/ThinkPython
/ThinkPython/Chap16/16.1.py
1,384
4.25
4
# -*- coding: utf-8 -*- """ Created on Thu Jul 5 08:36:47 2018 @author: hinson Write a function called mul_time that takes a Time object and a number and returns a new Time object that contains the product of the original Time and the number. Then use mul_time to write a function that takes a Time object tha...
4f6d06c5959a434db7cb4cf326d57fd94d49d394
hinsonan/ThinkPython
/ThinkPython/Chap10/10.4.py
362
3.703125
4
# -*- coding: utf-8 -*- """ Created on Mon Jul 2 10:57:03 2018 @author: hinson Write a function called chop that takes a list, modifies it by removing the first and last elements, and returns None. """ numbers = [1,2,3,4,5,6,7,8,9] def chop(listOfInts): del listOfInts[0] del listOfInts[len(li...
b3483454df3d83baedf5b5d8e3a6fdd949221df6
hinsonan/ThinkPython
/ThinkPython/Chap5/5.6.py
1,555
4.5625
5
# -*- coding: utf-8 -*- """ Created on Tue Jun 19 15:29:17 2018 @author: hinson """ """ The Koch curve is a fractal that looks something like Figure 5.2. To draw a Koch curve with length x, all you have to do is: 1. Draw a Koch curve with length x/3. 2. Turn left 60 degrees. 3. Draw a Koch curve with len...
244bc384e05bbd5c48756e32ca8a7f001eb9e50c
hinsonan/ThinkPython
/ThinkPython/Chap10/10.1.py
464
4.0625
4
# -*- coding: utf-8 -*- """ Created on Mon Jul 2 10:13:14 2018 @author: hinson Write a function called nested_sum that takes a list of lists of integers and adds up the elements from all of the nested lists """ numbers = [[1, 2], [3], [4, 5, 6]] def nested_sum(listOfInts) -> int: total = 0 for i...
d6b56b97eb4128bcd0c671e5654df3c259eec696
hinsonan/ThinkPython
/ThinkPython/Chap11/11.3.py
490
3.65625
4
# -*- coding: utf-8 -*- """ Created on Mon Jul 2 15:28:57 2018 @author: hinson Memoize the Ackermann function from Exercise 6.2 and see if memoization makes it possible to evaluate the function with bigger arguments. """ known_m = {} known_n = {} def ack(m,n): if m in known_m and n in known_n: ...
19fd4ee1699d22e26f01da1fe78103d78fbc31c6
hinsonan/ThinkPython
/ThinkPython/Chap6/6.4.py
519
4.34375
4
# -*- coding: utf-8 -*- """ Created on Wed Jun 20 16:03:25 2018 @author: hinson A number, a, is a power of b if it is divisible by b and a/b is a power of b. Write a function called is_power that takes parameters a and b and returns True if a is a power of b. Note: you will have to think about the base case ...
425da2264e7cc1f23edb31f65c1564249d3321c4
nmk07/python-simple-linear-regression
/lm_model.py
653
3.5
4
from sklearn import linear_model from pandas import DataFrame import pandas as pd import pandas import matplotlib.pyplot as plt input_data = pandas.read_table("height.csv", sep=",", header=0, names=("weight","height")) plt.scatter(input_data["weight"],input_data["height"]) plt.show() predictor=pd.DataFrame(input_dat...
bb2940fa20b2e2257a6b874d4a20ff7123627784
adang1345/Project_Euler
/87 Prime Power Triples.py
1,197
3.921875
4
"""The smallest number expressible as the sum of a prime square, prime cube, and prime fourth power is 28. In fact, there are exactly four numbers below fifty that can be expressed in such a way: 28 = 2^2 + 2^3 + 2^4 33 = 3^2 + 2^3 + 2^4 49 = 5^2 + 2^3 + 2^4 47 = 2^2 + 3^3 + 2^4 How many numbers below fifty million c...
9385a6a9f8d3365b764377212c1695c6c98469ec
adang1345/Project_Euler
/21 Amicable Numbers.py
1,233
3.703125
4
"""Calculate sum of all amicable numbers less than 10000""" def proper_factors(n): """return list containing all proper factors of n""" factor_set = set() for a in range(1, int(n**0.5)+1): if n % a == 0: factor_set.add(a) factor_set.add(n // a) factor_list = list(factor...
e9ab2608f38abbbfe8c8a8197b3c50163774bc6e
adang1345/Project_Euler
/58 Spiral Primes.py
1,926
4.3125
4
"""Starting with 1 and spiralling anticlockwise in the following way, a square spiral with side length 7 is formed. 37 36 35 34 33 32 31 38 17 16 15 14 13 30 39 18 5 4 3 12 29 40 19 6 1 2 11 28 41 20 7 8 9 10 27 42 21 22 23 24 25 26 43 44 45 46 47 48 49 It is interesting to note that the odd squares lie alon...
b46565e3a23fb201755e02a707567a05335e220a
adang1345/Project_Euler
/36 Double-Base Palindromes.py
443
3.78125
4
"""The decimal number, 585 = 10010010012 (binary), is palindromic in both bases. Find the sum of all numbers, less than one million, which are palindromic in base 10 and base 2. (Please note that the palindromic number, in either base, may not include leading zeros.)""" total = 0 for x in range(1, 1000000): x_s...
79d9ac041f0f29879c7ac107d093580be315bb5c
adang1345/Project_Euler
/16 Power Digit Sum.py
198
3.890625
4
"""Find the sum of the digits of 2^1000""" def sum_digits(n): """return sum of digits of int n""" c = 0 for a in str(n): c += int(a) return c print(sum_digits(2 ** 1000))
36a97e1877e0131de16f825279069ddbcecf1b3e
adang1345/Project_Euler
/102 Triangle Containment.py
1,639
4.21875
4
"""Three distinct points are plotted at random on a Cartesian plane, for which -1000 ≤ x, y ≤ 1000, such that a triangle is formed. Consider the following two triangles: A(-340,495), B(-153,-910), C(835,-947) X(-175,41), Y(-421,-714), Z(574,-645) It can be verified that triangle ABC contains the origin, whereas tri...
9eef84c8f8fa2818852674f43a4ff6d836db2d27
adang1345/Project_Euler
/188 Hyperexponentation of a Number.py
580
3.640625
4
"""The hyperexponentiation or tetration of a number a by a positive integer b, denoted by a↑↑b, is recursively defined by: a↑↑1 = a, a↑↑(k+1) = a(a↑↑k). Thus we have e.g. 3↑↑2 = 3^3 = 27, hence 3↑↑3 = 3^27 = 7625597484987 and 3↑↑4 is roughly 10^(3.6383346400240996*10^12). Find the last 8 digits of 1777↑↑1855.""" d...
92fba165971fa52b8d4d78ee278b8372d007d030
adang1345/Project_Euler
/127 abc-hits.py
1,398
3.828125
4
"""The radical of n, rad(n), is the product of distinct prime factors of n. For example, 504 = 23 × 32 × 7, so rad(504) = 2 × 3 × 7 = 42. We shall define the triplet of positive integers (a, b, c) to be an abc-hit if: GCD(a, b) = GCD(a, c) = GCD(b, c) = 1 a < b a + b = c rad(abc) < c For example, (5, 27, 32) is an a...
f9be2521f2582184d32b528b3eba80d5af3378c9
adang1345/Project_Euler
/112 Bouncy Numbers.py
1,822
4.3125
4
"""Working from left-to-right if no digit is exceeded by the digit to its left it is called an increasing number; for example, 134468. Similarly if no digit is exceeded by the digit to its right it is called a decreasing number; for example, 66420. We shall call a positive integer that is neither increasing nor decreas...
b24acc81770640dce76964cebf58e08a89abf8dd
adang1345/Project_Euler
/104 Pandigital Fibonacci Ends.py
1,044
4.03125
4
"""The Fibonacci sequence is defined by the recurrence relation: F(n) = F(n−1) + F(n−2), where F(1) = 1 and F(2) = 1. It turns out that F(541), which contains 113 digits, is the first Fibonacci number for which the last nine digits are 1-9 pandigital (contain all the digits 1 to 9, but not necessarily in order). And ...
031f2413646ee9af9b44ac7c1366cfdb52eac86b
adang1345/Project_Euler
/45 Triangular, Pentagonal, and Hexagonal.py
971
4.03125
4
"""Triangle, pentagonal, and hexagonal numbers are generated by the following formulae: Triangle Tn=n(n+1)/2 1, 3, 6, 10, 15, ... Pentagonal Pn=n(3n?1)/2 1, 5, 12, 22, 35, ... Hexagonal Hn=n(2n?1) 1, 6, 15, 28, 45, ... It can be verified that T285 = P165 = H143 = 40755. Find the next triangle number that is...
77f41c292a2a0c6eedb3e09ee06406fd8b5a613b
adang1345/Project_Euler
/10 Summation of Primes.py
604
4.1875
4
"""Computes the sum of all primes below 2 million""" def isprime(num): """Determine whether num is prime. If any integer from 2 to the square root of num divides evenly into num, then num is composite. Otherwise, num is prime. Assume that num is an int greater than or equal to 2.""" for x in range(2,...
e88a25037e3841f89e345c82d1bae8d2cd2f062b
adang1345/Project_Euler
/25 1000-Digit Fibonacci Number.py
445
3.9375
4
"""Find the sequence index of the first Fibonacci number with 1000 digits""" # start with list containing first 2 Fibonacci numbers from math import log10 def num_digits(n): """returns number of digits in int n""" return int(log10(n)) + 1 # list out Fibonacci numbers until reaching one with 1000 digits fib...
f78399deaaa9c13e599700b25524d6e366dfbd10
adang1345/Project_Euler
/79 Keylog.py
1,227
4.25
4
"""A common security method used for online banking is to ask the user for three random characters from a passcode. For example, if the passcode was 531278, they may ask for the 2nd, 3rd, and 5th characters; the expected reply would be: 317. The text file, keylog.txt, contains fifty successful login attempts. Given t...
381b876dae98d7006177143c13472da20587c743
divyansh000915/django-airline-0
/flights/models.py
2,684
3.65625
4
from django.db import models #Django designed with wanting to interact with databases in mind # Create your models here. Here we will define classes that are going to define the types of datawe will be able to store inside the database for this app #very similar to SQLAlchemy class Airport(models.Model): #class flight...
4138a0df5f0c8c40910132ef8218cda752d5499e
OcanoMark/CodingBat
/Python/List-1/12_has23.py
137
3.796875
4
# Given an int array length 2, return True if it contains a 2 or a 3. def has23(nums): return (nums.count(2) > 0 or nums.count(3) > 0)
8c4faa9eba14c8d5fadff320a0a34c684eb29172
OcanoMark/CodingBat
/Python/String-2/02_count_hi.py
146
4.03125
4
# Return the number of times that the string "hi" # appears anywhere in the given string. def count_hi(str): count = 0 return str.count('hi')