blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
3.06M
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
3.06M
2279bc1343d76245ef3ff63bf8dc9fc037119de6
OrdenWills/100daysofpyhton
/trycode5.py
480
3.984375
4
print("mary had a little lamb") print("it's fur was white as {}.".format("snow")) print("and everywhere that mary went. ") print("." * 10) #this looks strange tho end1="c" end2="h" end3="e" end4="e" end5="s" end6="e" end7="b" end8="u" end9="r" end10="g" end11="e" end12="r" #we notice that end= ' ' at the end will remo...
efee696cf56fb7ba8a121eebc59c0daead0a9ea2
Silversmithe/Jukebot_Hero
/research/Algorithm/Leveling.py
17,189
3.78125
4
#!/usr/bin/python """ FILE: Leveling.py DESCRIPTION: Finding the average of a level of a graph while finding out if a point should be incorporated into that level """ """ What is a level? - a level is a group of adjacent equidistant points from the origin - ...
a6c9a1eced3987dc4b38694101caaad44a9fdb5f
VProv/Poem2poem
/models/rhyme_testers.py
8,035
3.546875
4
import rupo.api from enum import Enum from typing import NamedTuple, Optional def get_reversed(line): return ''.join(reversed(line)) class LetterType(Enum): NOT_LETTER = 0 VOWEL = 1 CONSONANT = 2 SIGN = 3 ''' Auxiliary class providing convenient functions for retrieving Russian letter type. '''...
ec0beb1594b2ba3cdfb95a29d342e99c12adcab8
jbeen2/AlgorithmStudy
/programmers/부족한 금액 계산하기.py
197
3.515625
4
# Weekly Challenge 1 def solution(price, money, count): answer = sum([i*price for i in range(count+1)]) - money if answer >= 0 : return answer else : return 0 print(solution(3, 20, 4))
d52e07ac8cecca24517fbf1e8db3ab9331fa5324
james-721/chat_limpet
/common_functions.py
236
3.671875
4
import math def distance_finder(loc1, loc2): inside = ((loc1[0] - (loc2[0])) ** 2) + ((loc1[1] - (loc2[1])) ** 2) + ((loc1[2] - (loc2[2])) ** 2) distance = math.sqrt(inside) distance = round(distance, 2) return distance
6741dfd84673f751765d5b93a377a462b82da315
BatuhanAktan/SchoolWork
/CS121/Assignment 4/sort_sim.py
2,852
4.21875
4
''' Demonstration of time complexities using sorting algorithms. Author: Dr. Burton Ma Edited by: Batuhan Aktan Student Number: 20229360 Date: April 2021 ''' import random import time import a4 def time_to_sort(sorter, t): ''' Returns the times needed to sort lists of sizes sz = [1024, 2048, 4096, 8192] ...
517b2a70822e581424af41bfde09e41eb4ab179f
mukeshphulwani66/Competitive-coding-python
/recursion/combination.py
326
3.71875
4
def combination(mylist,r): if r == 0: return [[]] L = [] for i in range(0,len(mylist)): first = mylist[i] rem = mylist[i+1:] combList = combination(rem,r-1) for x in combList: L.append([first]+x) return L print(combination(["A","B","C","D...
ced4a64606c36371142a4806783d48433e4d6147
mukeshphulwani66/Competitive-coding-python
/dynamic programming/minnimum path sum.py
997
3.859375
4
''' Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right, which minimizes the sum of all numbers along its path. Note: You can only move either down or right at any point in time. Input: grid = [[1,3,1],[1,5,1],[4,2,1]] Output: 7 Explanation: Because the path 1 → 3 → 1 → 1 → 1...
882106286eb7f66079a6fe3b822bb771b5ba13b3
mukeshphulwani66/Competitive-coding-python
/Arithmetic problems/sexyprimes.py
847
3.8125
4
''' Given a range of the form [L, R].The task is to print all the sexy prime pairs in the range. Examples: Input : L = 6, R = 59 Output : (7, 13) (11, 17) (13, 19) (17, 23) (23, 29) (31, 37) (37, 43) (41, 47) (47, 53) (53, 59) Input : L = 1, R = 19 Output : (5, 11) (7, 13) (11, 17) (13, 19) ''' from math import ...
bcdc37c7edad6deddcb5a14d5b23e4c35896ca8f
ngs90/RLBanana
/sumtree.py
3,473
3.515625
4
import numpy as np # SUM Tree functions class Node: # The code is based on: https://adventuresinmachinelearning.com/sumtree-introduction-python/ def __init__(self, left, right, is_leaf: bool=False, idx=None, insertion_time=None): self.left = left self.right = right self.is_leaf = is_le...
c9b3636195f06863bfe65e779b5dcabdeb7313a4
gab706/Hangman
/main.py
2,734
3.65625
4
import time from functions import * from game import * ComplexNames = TextNames clearScreen() clickText(f"Mystery Man > Welcome traveler, you seem lost, allow me to introduce myself, I'm {ComplexNames.NARRATOR_ITSELF}") clearScreen() playerName = getPlayerName() clearScreen() clickText(f"{ComplexNames.NARRATOR} Hi ...
94cc9b875edca75c61ce7921a14a7c0d7e9f3bfc
sammhit/Learning-Coding
/HackerRankSolutions/electronicShop.py
817
4.09375
4
#!/bin/python3 import sys #https://www.hackerrank.com/challenges/electronics-shop/problem def getMoneySpent(keyboards, drives, s): # Complete this function sarr=[] for keyboard in keyboards: for drive in drives: sarr.append(keyboard+drive) sarr.sort(reverse=True) for elem i...
dfba925cf90c84910c32768a9a4f4b95a798006f
sammhit/Learning-Coding
/HackerRankSolutions/bestAndWorst.py
695
3.984375
4
#!/bin/python3 import sys #https://www.hackerrank.com/challenges/breaking-best-and-worst-records/problem def breakingRecords(score): hRecords = 0 lRecords = 0 highest = score[0] lowest = score[0] for each in score: if each>highest: hRecords+=1 highest=eac...
a38ccc08bc8734389f11b1a6a9ac15eca5b7d53a
sammhit/Learning-Coding
/HackerRankSolutions/quickSortPartion.py
521
4.1875
4
#!/bin/python3 import sys #https://www.hackerrank.com/challenges/quicksort1/problem def quickSort(arr): pivot = arr[0] left = [] right = [] for i in arr: if i>pivot: right.append(i) if i<pivot: left.append(i) left.append(pivot) return left+right # Co...
84204405dbc1c4a9e3d62cd6c268ec65e6304cf5
quangvinh86/Python-HackerRank
/Python_domains/3-Strings-Challenges/Codes/Ex3_6.py
550
3.890625
4
#!/usr/bin/env python3 def validate_string(input_string): # alphanumeric print(any([sg_char.isalnum() for sg_char in input_string])) # alphabetical print(any([sg_char.isalpha() for sg_char in input_string])) # Digits print(any([sg_char.isdigit() for sg_char in input_string])) # lowercase ...
d3d50cb016ef1554a59452a806d959796ef53b45
quangvinh86/Python-HackerRank
/Python_domains/2-Basic-Data-Types-Challenges/Code/Ex2_4.py
297
4.21875
4
#!/usr/bin/env python3 def find_second_largest(integer_list): return sorted(list(set(integer_list)))[-2] if __name__ == '__main__': # n = int(input()) # arr = map(int, input().split()) integer_list = map(int, "1 -4 0 -2 -4".split()) print(find_second_largest(integer_list))
9005000d28ac02469091f5f2dbe823715bdd693f
quangvinh86/Python-HackerRank
/Python_domains/1_Introduction_Challenges/Code/Ex1_5_Loops.py
551
3.859375
4
#!/usr/bin/env python3 ''' # [Ex5_Loops](https://www.hackerrank.com/challenges/python-loops/problem) Nhận đầu vào là một số tự nhiên N ( 1<= N <= 20). i là các giá trị thỏa mãn 0 <= i < N. In ra màn hình các số bình phương của i. Mỗi số trên 1 dòng. ''' def solve(input_number): ''' ' params: number ' rtyp...
96aa9d68c07f0e696bd72831b8876e02c24c56da
bswood9321/PHYS-3210
/Exam2/Exam2_Q1_BSW.py
2,757
3.875
4
# -*- coding: utf-8 -*- """ Created on Sun Nov 3 23:54:26 2019 @author: Brandon """ import numpy as np import matplotlib.pyplot as plt x = np.linspace(-10,10,100) y = (5/4)*x -2 plt.plot(x,y) plt.grid() plt.title("A linear equation; Y=5/4X-2") plt.show() y1=x**3-4 plt.plot(x,y1) plt.grid() plt.title("A nonlinea...
78a204b4a7ddcc8d39cab0d2c92430d292ad204a
bswood9321/PHYS-3210
/Week 03/Exercise_06_Q4_BSW.py
1,653
4.34375
4
# -*- coding: utf-8 -*- """ Created on Sat Sep 7 19:50:39 2019 @author: Brandon """ import numpy as np import numpy.random as rand import matplotlib.pyplot as plt def walk(N): rand.seed() x = [0.0] y = [0.0] for n in range(N): x.append(x[-1] + (rand.random() - 0.5)*2.0)...
fc76bed2804c3befa9f3534e79a126cb0a978445
bswood9321/PHYS-3210
/Week 02/Exercise05_BSW.py
1,177
3.6875
4
# -*- coding: utf-8 -*- """ Spyder Editor This is a temporary script file. """ import numpy as np import matplotlib.pyplot as plt N = int(input("Pick a number: ")) n, a, sum1, m, b, sum2 = 1, 0, 0, N, 0, 0 while (n<=N): a = 1/n sum1+=a n = n+1 while (m>=1): b = 1/m sum2+=b m = m-1 ...
ca36e5f0b93e976ee70b0873fecede0cbc5de6d2
C74C3/probabilitysimulation
/probabilitysimulator.py
2,641
3.9375
4
""" Probabilty Simulation by Alex Funnell. Written in Python 3.7.2. ||| DESCRIPTION ||| Probabilty Simulation is a python program to calculate expirmental probability. It can be configured heavily to your needs. You can change the values in the "VARIABLES" section below, but the main calculations are not to...
343553df4497258e168a4ea2d17cf4508820ba0b
marcelogaray/SICARIOS
/src/admin_module/user_module/membership.py
1,386
3.8125
4
__author__ = 'Roy Ortiz' import datetime from datetime import datetime class Membership(object): def __init__(self, type, percent_of_discount, start_date): """ type is a string it stores the membership type percent_of_discount is an int value it will store the percentage of discou...
01c48f4a4eb9bf29fc8d4364dbd2d759ce265b0f
nii5/lesson03
/tast05.py
493
3.609375
4
my_sum = 0 while True: str = input('Введите набор чисел через пробел') my_list = str.split(' ') stop = False for i in my_list: if i.isdigit(): my_sum = my_sum + int(i) else: print(my_sum) stop = True break if stop: ...
fed18b055337f8e88a9ed840e8e26afcdb56a4b6
dunkle/python_Learn
/fanye_readfile.py
589
3.53125
4
#向上翻页 #读的时候,采用截取的方法读 #Page = 1 range[0,5) Page = 2 range[5,10) Page = n range(0,5) # 向下翻页 file = open("gitlab_acess.log","r") lines = file.readlines() num = 1 while True: control = input(">>>") if control == "N": print("++++-第%s页开始+++") start = (num-1)*5 end = num*5 for line in ...
e04ecdf0de9152e925c6dbd00abfc236318a6398
fenscsb08/INF6050GroupProject
/DemoInfo.py
483
3.859375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sun Dec 2 20:50:01 2018 @author: TenleySablatzky """ print("Let's start by getting to know you a little bit.") Gender = input("Please select one: M/F or type N for nonbinary ") str.capitalize("n", "m", "f") Age = input("Enter your age numberically: ") ...
99eb4e757c3f6ebe5f1d77537288eb0623b90fd6
adlerpriit/Codingame
/FantasticBits/FantaticBitsOOP.py
17,421
3.65625
4
import sys import math import random # Grab Snaffles and try to throw them through the opponent's goal! # Move towards a Snaffle and use your team id to determine where you need to throw it. class Point: def __init__(self, x, y): self.x = x self.y = y def distance2(self, p): return (s...
6df2e08197f766370b9ea1a4e9a33f9563d85c50
olaudemy/litsp
/bracket_checker.py
483
3.734375
4
def balance_checker(data): pocket = [] left_br = "{[(" right_br = "}])" for i in data: if i in left_br: pocket.append(right_br[ left_br.index(i) ]) elif i in right_br: if pocket and i == pocket[-1]: pocket.pop(-1) else: ...
bb3f951f4b11b64a18002ffa77bd6880bff60b37
MesutCevik/AlexaSkillsNew
/Miscellaneous/decorators4learning/functions_returning_functions.py
193
4.0625
4
def f(x): """ This function returns the function 'g' which is inside function. """ def g(y): return y + x + 3 return g nf1 = f(1) nf2 = f(3) print(nf1(1)) print(nf2(1))
48062dcd3b54044bc64c0c497a47da3f8640724c
MesutCevik/AlexaSkillsNew
/Miscellaneous/decorators4learning/functions_as_parameters_2.py
247
3.625
4
import math def foo(func): print("The function " + func.__name__ + " was passed to foo.") result = 0 for x in [1, 2, 2.5]: result += func(x) print(result) return result print(foo(math.sin)) print(foo(math.cos))
aed0bc3fcbdc63e47a4cea6d15c0903db82760a8
Ovsjah/gothonweb_py
/gothonweb/parser.py
2,650
3.625
4
class ParserError(Exception): pass class Sentence(object): def __init__(self, subject, verb, obj): self.subject = subject[1] self.verb = verb[1] self.object = obj[1] def edit(self): return "%s %s %s" % (self.subject, self.v...
022095f6b832b23007e8b7c487a06037f849e9d5
DARRIUS-LK/celcius-to-fahrenheit
/temp2.py
123
3.953125
4
celcius = input('please input celcius:' ) celcius = float(celcius) fahrenheit = celcius * 9 / 5 + 32 print(fahrenheit, 'f')
c3833a93466dbc82202bb5fc973e65bd6c552129
DolanDark/Practice-Files
/prog03.py
318
3.84375
4
n = int(input()) if n == 0: print("Time estimate is 0 minutes") elif n in range(1, 2000): print("Time estimate is 25 minutes") elif n in range(2001,4000): print("Time estimate is 35 minutes") elif n in range(4001, 7000): print("Time estimate is 45 minutes") else: print("invalid input")
d61d34b7f14afa23557ae0f777b3307ed3bf56ff
DolanDark/Practice-Files
/hamletprog.py
1,929
3.640625
4
import collections import matplotlib.pyplot as plt hamlet = '''To be, or not to be, that is the question: Whether 'tis nobler in the mind to suffer The slings and arrows of outrageous fortune, Or to take arms against a sea of troubles And by opposing end them. To die—to sleep, No more; and by a sleep to say we...
16d8012778a0a4b005ff28bf8af8b0e669e3eba7
DolanDark/Practice-Files
/prog05.py
732
3.859375
4
interior_wall = int(input()) exterior_wall = int(input()) if interior_wall: #checks for true value in_wall = [] for i in range(interior_wall): in_wall.append(float(input())) if exterior_wall: ex_wall = [] for i in range(exterior_wall): ex_wall.append(float(input())...
24b14caef5e04fe94d320e851c2d22c9e43102e5
DolanDark/Practice-Files
/prog18.py
339
3.875
4
x = int(input()) y = int(input()) smallest = x if x < y else y isCoprime = True for i in range(smallest): if i > 1: if x % i == 0 and y % i == 0: isCoprime = False break print(isCoprime) # from math import gcd # # if gcd(x,y) == 1: # print("True") # else: #...
70fe8fdf2f0d12b61f21f5d9bd825d2f0a0ec93f
LiuJLin/learn_python_basic
/ex32.py
639
4.53125
5
the_count = [1, 2, 3, 4, 5] change = [1, 'pennies', 2, 'dimes', 3, 'quarters'] #this first kind of for-loop goes through a list for number in the_count: print("This is count %d"% number) #also we can go through mixed lists too #notice we have use %r since we don't know what's in it for i in change: print("I g...
552b709ecd6407b5e22fbebcd3315281227ca631
ichlasiana/project-euler
/scripts/p006.py
782
3.59375
4
# Sum square difference # https://projecteuler.net/problem=6 # Problem 6 # The sum of the squares of the first ten natural numbers is, # 1^2 + 2^2 + ... + 10^2 = 385 # The square of the sum of the first ten natural numbers is, # (1 + 2 + ... + 10)^2 = 55^2 = 3025 # Hence the difference between the sum of the squares of...
1d9bdb0de6584f4f7aefd63da7a1638a3954a3c8
nico-olivares22/CompuacionII-Practica
/GuiaPráctica-COMPUTACIONII/ejercicio13.py
818
3.921875
4
"""Ejercicio 13 – Multiprocessing Escribir un programa que genere tres procesos hijos (fork) cuyos nombres serán “Hijo1”, “Hijo2” e “Hijo3”. El proceso padre debe mostrar por pantalla el mensaje “Lanzando hijo NN” en la medida que ejecuta cada uno de los procesos. Cada hijo que se lance mostrará por pantalla su pid, el...
ac4da547e6797940cd9c206f948a4e00454d3af5
youngtux/python
/02_06_while문_list_sort.py
257
3.59375
4
# 5개의 값을 입력받아서 크기순으로 출력 # while문, list사용법 d_list = [] cnt = 1 while cnt<6 : d = input(str(cnt)+"번째 값을 입력하세요.:") d_list.append(d) cnt = cnt + 1 d_list.sort() print(d_list)
9d1cb5e2ec644a4efd28779d7f170161e132fd4b
Phongkaka/python
/TrinhTienPhong_92580_CH04/Exercise/page_114_exercise_03.py
1,076
4.03125
4
""" Author: Trịnh Tiến Phong Date: 20/10/2021 Program: page_114_exercise_03.py Problem: 3. Translate each of the following numbers to binary numbers: a. 47(8) b. 127(8) c. 64(8) * * * * * ============================================================================================= * * * ...
a23918b8be59403c251423abdf493a3f5cd9106f
Phongkaka/python
/TrinhTienPhong_92580_CH03/Exercise/page_92_exercise_01.py
594
3.96875
4
""" Author: Trịnh Tiến Phong Date: 05/10/2021 Program: page_92_exercise_01.py Problem: 1. Translate the following for loops to equivalent while loops: a. for count in range(100): print(count) b. for count in range(1, 101): print(count) c. for count in rang...
8b8945a9936304593b65b5648bcb882365ba5ad3
Phongkaka/python
/TrinhTienPhong_92580_CH05/Exercise/page_145_exercise_06.py
469
4.1875
4
""" Author: Trịnh Tiến Phong Date: 31/10/2021 Program: page_145_exercise_06.py Problem: 6. Write a loop that replaces each number in a list named data with its absolute value * * * * * ============================================================================================= * * * * * Solution: Display resu...
6e37562c7ffed2695bf99118657aabbc986aaa88
Phongkaka/python
/TrinhTienPhong_92580_CH03/Exercise/page_70_exercise_05.py
381
4.03125
4
""" Author: Trịnh Tiến Phong Date: 03/10/2021 Program: page_70_exercise_05.py Problem: 5. Assume that the variable teststring refers to a string. Write a loop that prints each character in this string, followed by its ASCII value. Solution: Display: p = 112; h = 104; o = 111; n = 110; g = 103 "...
8fcae316dc7717b1eeb735f53c49866940c63e27
Phongkaka/python
/TrinhTienPhong_92580_CH02/Exercise/page_46_exercise_01.py
457
3.984375
4
""" Author: Trinh Tien Phong Date: 25/09/2021 Program: page_46_exercise_01.py Problem: 1. Let the variable x be "dog"and the variable y be "cat". Write the values returned by the following operations: a. x +y b. "the " +x +" chases the " +y c. x * 4 Solution: Display: a. ...
e70cff4332c025e17994eee544699d2cfd7f0c53
Phongkaka/python
/TrinhTienPhong_92580_CH04/Exercise/test.py
435
3.890625
4
""" Author: Trịnh Tiến Phong Date: 20/10/2021 Program: page_114_exercise_05.py Problem: 5. Translate each of the following numbers to decimal numbers: a. 47(16) b. 127(16) c. AA(16) * * * * * ============================================================================================= * ...
0de84e9a8943307e88a2ab6d48bb9c5b1b8be86b
larwon/python
/Pandas_pt(2).py
398
3.78125
4
import numpy as np import pandas as pd #여러 개의 값들을 딕셔너리 값으로 넣어보자 a = pd.DataFrame([{'A':2, 'B':4, 'D':3}, {'A':4, 'B':5, 'C':7}]) print(a) #총 칼럼은 A, B, C, D #값이 없는 부분은 NaN으로 처리 (누락값) s = pd.DataFrame(np.random.rand(5, 5), columns=['A', 'B', 'C', 'D', 'E'], index=[1, 2, 3, 4, 5]) pr...
986f69b9c6625f12928e4c213269310528eac0b3
larwon/python
/bool.py
191
3.8125
4
# 101. print(3 == 5) # 102. x = 4 print(1 < x < 5) # 103. print((3 == 3) and (4 != 3)) # 104. if 4 < 3: print("Hello World") else: print("Hi, there.")
a45f4958e8059b9bfef7fefcb123dcd4907c394c
larwon/python
/baekjoon_pt_2.py.py
883
3.8125
4
1. a = int(input("첫번째 숫자를 입력해주세요.")) b = int(input("두번째 숫자를 입력해주세요.")) if a > b: print(">") elif a == b: print("==") else: print("<") 2. a = int(input("시험성적을 입력해주세요 : ")) if 90 <= a <= 100: print("A") elif 80 <= a <= 89: print("B") elif 70 <= a <= 79: print("C") elif 60 <=...
7d0d49210ba96496330d1519b07ef4137c74f09e
mmqfilho/jogo_da_velha
/velha_oo.py
3,903
3.96875
4
""" Jogo da velha campos do tabuleiro 1 | 2 | 3 ----------- 4 | 5 | 6 ----------- 7 | 8 | 9 """ class JogoDaVelha: def __init__(self): # inicializa tabuleiro self._inicializa_tabuleiro() # sequencia de possibilidades para se ganhar o jogo self.possibilidade...
fc399182e128c75611add67a65ddfe18d180dc55
gamershen/everything
/hangman.py
1,151
4.25
4
import random with open(r'C:\Users\User\Desktop\תכנות\python\wordlist.txt', 'r') as wordfile: wordlist = [line[:-1] for line in wordfile] # creates a list of all the words in the file word = random.choice(wordlist) # choose random word from the list letterlist = [letter for letter in word] # the word convert...
44d385d04ffed3c7ced324d1599b83a01cbecce8
tirsott/lc-go
/problems/0206.reverse-linked-list/reverse-linked-list.py
692
3.921875
4
# Definition for singly-linked list. class ListNode: def __init__(self, x, next=None): self.val = x self.next = next class Solution: def reverseList(self, head: ListNode) -> ListNode: if not head or not head.next: return head old_head = head while head.next: ...
f04e141c5c6b2ce197e530bcb1bfd1eeabaf9cfa
tirsott/lc-go
/problems/0127.word-ladder/word-ladder.py
2,856
3.515625
4
from typing import List import time as tt class Solution: def ladderLength(self, beginWord: str, endWord: str, wordList: List[str]) -> int: if endWord not in wordList: return 0 neighbor = [[] for _ in range(len(wordList))] start = [i for i in range(len(wordList)) if self.word_di...
67a7cc30af26b12944b6ca1cd537455c14e6b50a
tirsott/lc-go
/problems/0007.reverse-integer/reverse-integer.py
384
3.65625
4
class Solution: def reverse(self, x: int) -> int: if x < 0: x = - x flag = -1 else: flag = 1 res = 0 while x: res = res * 10 + x % 10 x = x // 10 return res * flag if res * flag in range(-2 ** 31, 2 ** 31 - 1) else 0...
effef5664a2dfb8f36d29722cf74934b58b542fb
tirsott/lc-go
/problems/0244.shortest-word-distance-ii/shortest-word-distance-ii.py
702
3.6875
4
from typing import List class WordDistance: def __init__(self, words: List[str]): self.position = self._get_position(words) def _get_position(self, words): position = {} for i in range(len(words)): if words[i] in position: position[words[i]].append(i) ...
f7d93b0f5a01ee074720d58f497d7ff0e4e1b27c
tirsott/lc-go
/problems/0048.rotate-image/rotate-image.py
631
3.84375
4
from typing import List class Solution: def rotate(self, matrix: List[List[int]]) -> None: """ Do not return anything, modify matrix in-place instead. """ ''' 123 456 789 ''' length = len(matrix[0]) for i in range(length): ...
40c7045b476223a743db0bff8cd7860353b34924
tirsott/lc-go
/problems/0014.longest-common-prefix/longest-common-prefix.py
504
3.8125
4
from typing import List class Solution: def longestCommonPrefix(self, strs: List[str]) -> str: res = '' if not strs: return res shortest_length = min([len(str) for str in strs]) for i in range(shortest_length): for str in strs: if str[i] != st...
719a154003be326e640c0e882cba3c3ca07d5034
tirsott/lc-go
/problems/0153.find-minimum-in-rotated-sorted-array/find-minimum-in-rotated-sorted-array.py
637
3.53125
4
from typing import List class Solution: def findMin(self, nums: List[int]) -> int: if len(nums) == 1: return nums[0] if nums[0] < nums[-1]: return nums[0] mid = (len(nums) + 1) // 2 if nums[mid-1] > nums[mid]: return nums[mid] else: ...
ac356398b8b66a16bc346af15b5671cfe72c0c99
tirsott/lc-go
/problems/0189.rotate-array/rotated-array.py
957
3.671875
4
from typing import List import math class Solution: def rotate(self, nums: List[int], k: int) -> None: """ Do not return anything, modify nums in-place instead. """ nums[:] = self.rotate_nums(nums, k) def rotate_nums(self, nums, k): if k == 0: return nums ...
bae7e2709c16062e4296992c94140dd2a7eb2aed
tirsott/lc-go
/problems/0056.merge-intervals/merge-intervals.py
607
3.609375
4
from typing import List class Solution: def merge(self, intervals: List[List[int]]) -> List[List[int]]: intervals.sort(key=lambda x: x[0]) left = 0 while left < len(intervals): if left == 0: left += 1 continue if intervals[left][0] <= ...
f9903bbf4aef77ba0ab3d933e7fdd6ae6e5b7abf
tirsott/lc-go
/problems/0247.strobogrammatic-number-ii/strobogrammatic-number-ii.py
650
3.59375
4
from typing import List class Solution: def findStrobogrammatic(self, n: int) -> List[str]: mapping = {'1': '1', '6': '9', '8': '8', '9': '6', '0': '0'} dp = [[] for _ in range(max(3, (n+1)))] dp[0] = [] dp[1] = ['1', '8', '0'] if n == 1: return dp[1] dp[...
55eb3b4f08361c1d4ce6b7d79285ee398db50759
tirsott/lc-go
/problems/0087.scramble-string/scramble-string.py
817
3.609375
4
class Solution: def isScramble(self, s1: str, s2: str) -> bool: print(s1, s2) if s1 == s2: return True for i in range(1, len(s1)): if self.str_has_same_char(s1[:i], s2[:i]): if self.isScramble(s1[:i], s2[:i]) and self.isScramble( s1...
88784247731251f6fbfc188c95d1aa879bbff520
tirsott/lc-go
/problems/0284.peeking-iterator/peeking-iterator.py
822
4.09375
4
class PeekingIterator: def __init__(self, iterator): """ Initialize your data structure here. :type iterator: Iterator """ self.iterator = iterator self.temp = [] def peek(self): """ Returns the next element in the iteration without advancing the ...
0ac76313cf2722e7088a118c0956a0c6fa4dfbc5
tirsott/lc-go
/problems/0186.reverse-words-in-a-string-ii/reverse-words-in-a-string-ii.py
741
3.71875
4
from typing import List class Solution: def reverseWords(self, s: List[str]) -> None: """ Do not return anything, modify s in-place instead. """ s.reverse() left, right = 0, 0 while right < len(s): while right < len(s) and s[right] != ' ': ...
cbbabc2107a4db45b6191beb4340ef652811c83e
tirsott/lc-go
/problems/0023.merge-k-sorted-lists/merge-k-sorted-lists.py
1,469
3.859375
4
# Definition for singly-linked list. class ListNode: def __init__(self, x): self.val = x self.next = None from typing import List class Solution: def mergeKLists(self, lists: List[ListNode]) -> ListNode: if not lists: return None if len(lists) == 1: retur...
2cb99b1052bcbd14215b3ddfddd76114a1c30e31
tirsott/lc-go
/problems/0179.largest-number/largest-number.py
514
3.625
4
from typing import List class Solution: def largestNumber(self, nums: List[int]) -> str: nums = [str(num) for num in nums] for i in range(len(nums)): for j in range(i+1, len(nums)): if nums[i] + nums[j] > nums[j] + nums[i]: nums[i], nums[j] = nums[j],...
00257ca64d744f77e19e34b23ecabb362be0052a
tirsott/lc-go
/problems/0229.majority-element-ii/majority-element-ii.py
347
3.859375
4
from typing import List class Solution: def majorityElement(self, nums: List[int]) -> List[int]: return [x for x in set(nums) if nums.count(x) > (len(nums)//3)] # 示例 1: # # 输入:[3,2,3] # 输出:[3] # # 示例 2: # # 输入:nums = [1] # 输出:[1] # # 示例 3: # # 输入:[1,1,1,3,3,2,2,2] # 输出:[1,2]
301af9471ac7bbbe454c0d558d3f796101d8c647
tirsott/lc-go
/problems/0124.binary-tree-maximum-path-sum/binary-tree-maximum-path-sum.py
1,518
3.71875
4
# Definition for a binary tree node. class TreeNode: def __init__(self, x, left=None, right=None): self.val = x self.left = left self.right = right class Solution: def maxPathSum(self, root: TreeNode) -> int: self.max_path(root) return self.max_path_sum(root) def ma...
cb8d2565899a06a9e0af4b79a92364c96eb97df8
ib407ov/Labs---5
/Завдання 2.py
176
3.78125
4
n = int(input('You can find the number of digits in the numer: ')) i = 0 while n != 0: n = n // 10 i += 1 print(n) print('You have {0} numbers'.format(i))
5b419bf68ec5db639c12aaee1b49461eac6fa61a
pankratdodo/dr_quine-42
/python/Colleen.py
352
3.53125
4
# Comment outside def another_func(): str = "# Comment outside{0}{0}def another_func():{0} str = {2}{1}{2}{0} print(str.format(chr(10), str, chr(34))){0}{0}if __name__ == '__main__':{0} # Comment inside{0} another_func()" print(str.format(chr(10), str, chr(34))) if __name__ == '__main__': # Co...
fd722b3d1dedacaab9996e5180e08c2f81491bc3
mateenjameel/Python-Course-Mathematics-Department
/Week 5_GUI Development Tkinter Python/gui_12_FeedBack_FORM.py
2,714
3.53125
4
import tkinter from tkinter import * def save(): text=E1.get()+"\n"+E2.get()+"\n"+E3.get()+"\n"+E4.get()+"\n"+E5.get()+"\n"+E6.get()+"\n"+E7.get()+"\n"+E8.get()+"\n"+E9.get() with open ("text.txt",'w')as f: f.writelines(text) nimrah=tkinter.Tk() nimrah.title("nimrah ansari") nimrah.geometry('6...
270cd8531880d6a2ab9054ac5c1bf70f5abf27aa
mateenjameel/Python-Course-Mathematics-Department
/Week 3_Mastering the Loops Part # 2/nested_loop_one.py
159
4
4
side = int(input("Please Enter the side of the square: ")) for i in range(side): for i in range(side): print('9', end = ' ') print()
3ac625a4ef5169a8583ca33edbd571c90ad6ee9a
mateenjameel/Python-Course-Mathematics-Department
/Object Oriented Programming/class_19.py
456
3.765625
4
class Vehicle: #parent class "Parent Class" def __init__(self, price): self.price = price def display(self): print ('Price = $',self.price) class Category(Vehicle): #derived class "Child/Derived class" def __init__(self, price, name): Vehicle.__init__(self, price) self.name...
a14b405482d5e61cb494517635f43a28cc9e01bc
mateenjameel/Python-Course-Mathematics-Department
/Week 4_Mastering Functions in Python Programming/function_four.py
241
3.75
4
def Arith(a,n,d): first_term = int(a) number = int(n) difference = int(d) Answer = first_term + (number - 1)*difference print("The result of Arithmetic Progression is: ", Answer) return Arith(2,10005,2)
63da190f27e5252b9353562da697106d8e0c63d6
mateenjameel/Python-Course-Mathematics-Department
/Week 3_Mastering the Loops Part # 2/nested_four.py
127
3.640625
4
for i in range(10): for j in range(i):#RANGE_OF_J_LOOP_IS_THE_VALUE_OF_OUTER_I print(i, end=" ") print()
dbc8639bf1702af883eec6a0581dabd0ac0fef65
mateenjameel/Python-Course-Mathematics-Department
/Object Oriented Programming/class_26.py
641
3.546875
4
class Employee: def __init__(self,first,last,pay): self.first = first self.last = last self.email = first + '.' + 'last' +'@gmail.com' self.pay = pay def fullname(self): return '{] {}'.format(self.first, self.last) class Developer(Employee): def __ini...
efead44c4d9c3ea1b6de8a1868cffc3030911343
mateenjameel/Python-Course-Mathematics-Department
/Week 14_Integration with Plotting Responses/integration_six.py
301
3.65625
4
import numpy as np import matplotlib.pyplot as plt x = np.linspace(-1,3,1000) def f(x): return x**2 plt.plot(x,f(x)) plt.axhline(color='red') plt.fill_between(x, f(x), where = [(x>0) and (x<2) for x in x], color='blue', alpha =0.3) # alpha is for transparency plt.show()
92d0db25839f0ff639bf6e782bb8733a2e39ccfb
LoganG-T/SpotifyDataAnalysis
/ArtistGrouping.py
8,744
3.625
4
#Group all artists in a playlist / list of playlists and display the results # import spotipy from spotipy.oauth2 import SpotifyClientCredentials import pandas import matplotlib.pyplot as plt #Spotify developer account details CLIENT_ID = '' CLIENT_SECRET = '' sp = spotipy.Spotify(client_credentials_...
a8a49630d4e3fcf8ec20ae04af47626c282d6c2f
pannachow/cs50
/fibonacci.py
205
4
4
def fibonacci(n): if n==0: return 0 if n==1: return 1 return fibonacci(n-1) + fibonacci(n-2) for i in range(7): # x = fibonacci(i) # print(x) print(fibonacci(i))
caa1be529eed780e4db83da6a6c8a13bc7fcfb61
stainley/python-workshop
/lesson3/helper_currency.py
329
3.515625
4
def convert_currency(amount, rate, margin=0): return amount * rate * (1 + margin) def compute_usd_total(amount_in_aud=0, amount_in_gpb=0): total = 0 total += convert_currency(amount_in_aud, 0.78) total += convert_currency(amount_in_gpb, 1.29, 0.01) return total print(compute_usd_total(amount_in_...
56ef70d8a5a9462ac5144cd5e04f01642d0d51f2
timisaurus/workspace-python-Hello_world
/edx/edx_list_manipulation.py
5,102
3.796875
4
# This program accepts a integer between 1 to 9999 as parameter and returns # the number as a string. input_retry = True n = 0 while input_retry: input_retry = False try: n = int(input('please enter an integer between 1 and 9999: ')) assert n > 0 or n < 10000 == True except (AssertionError...
0ebaf72736ec6b8f1705ecd653a4353d0e2f7ff6
timisaurus/workspace-python-Hello_world
/book/fermats_theorem.py
2,986
3.90625
4
# This program tries to disprove the fermates theorem def it_worked(): print('Holy smokes, Fermat was wrong!') user_input = int(input('type a positive integer again: ')) a = user_input b = user_input c = user_input n = user_input ticker(a, b, c, n) def it_didnt_worke(): print('No, t...
10b0f21e24f0c8b9295234fd7118093c951e3ab7
timisaurus/workspace-python-Hello_world
/edx/edx_functions.py
3,584
4.40625
4
# This program calculates and prints loan information. # This function lets the user input 3 times. def input_user(): x = float(input('principal :')) y = float(input('annual_interest_rate :')) z = int(input('duration :')) loan_information(x, y, z) # This function calculates the main information. def ...
e0d6812a81d0a65fb8998b63ac1af09247fc803e
Nihilnia/June1-June9
/thirdHour.py
1,283
4.21875
4
""" 7- Functions """ def sayHello(): print("Hello") def sayHi(name = "Nihil"): print("Hi", name) sayHello() sayHi() def primeQ(number): if number == 0 or number == 1: print(number, "is not a Primer number.") else: divs = 0 for f in range(2, number): ...
9140dd7db00f4aab06b41ed49069ddd42d596b76
infotraining-team/py-bs-2020-12-07
/bank_account.py
1,558
3.71875
4
class BankAccount: __interest_rate = 0.01 def __init__(self, owner, balance): self.__balance = balance self.__owner = owner def info(self): print("owner:", self.__owner, " - balance:", self.__balance) def withdraw(self, amount): if (self.__balance < amount): ...
00d7e9e92bf0b708a8ba97c369cee34df3912217
infotraining-team/py-bs-2020-12-07
/inheritance.py
451
3.75
4
class Parent: def __init__(self): print("Parent constructor") self.parent_attr = 123 def method(self): print("parent method") class Child(Parent): def __init__(self): super().__init__() print("Child constructor") def method(self): super().method() ...
e77f4ff186007985b1a38c2369f45e2920d98221
tudou-man/Finite_element_method
/Finite_element_method_py/3.py
495
3.625
4
def lengthOfLongestSubstring(s): """ :type s: str :rtype: int """ if s == '': return 0 longest_len = 1 curr = [] for x in s: if x in curr: index = curr.index(x) curr = curr[index + 1:] print (curr) curr.append(x) # pri...
af4c141fc364f89f4d1ad14541b368c164f40b81
stephenfreund/PLDI-2021-Mini-Conf
/scripts/json_to_csv.py
1,116
4.15625
4
# Python program to convert # JSON file to CSV import argparse import csv import json def parse_arguments(): parser = argparse.ArgumentParser(description="MiniConf Portal Command Line") parser.add_argument("input", default="data.json", help="paper file") parser.add_argument("out", default="data.csv", he...
f43c35a61455a975adc8087581a90b2938cbfc1d
LuzinDaniil/lab2
/dict_algs.py
714
3.65625
4
def dict(arr): res = [] for i in arr: for child in i['children']: if child['age'] > 18: res.append(i['name']) return res if __name__ == "__main__": ivan = { "name": "ivan", "age": 34, "children": [{ "name": "vasja"...
aabe0fd787be306682edc976f2eb6fd2e72d347b
J2xMurphy/JointFrame
/lib/c8.py
1,912
4
4
import math #--------------------------------------------------------------------------- # This is used to calculate the angle using atan def calcAngle(pt1,pt2,cstats,v): p1 = cstats[pt1] p2 = cstats[pt2] ## Reminder that P1 and P2 are formatted in Y: X: D: when output if v == 1: print(str(p1)+","+str(p2))...
3c2ed0f17a7e642936cecffe9788c511e16276f1
SathriMamatha123/EDUYEAR-PYTHON---20
/Day2.py
438
3.953125
4
Name='Stella' Marks=90 Balance =30864.89 AccNo =13786431991 print("My name is {}, and I got {} Marks in ComputerScience".format(Name,Marks)) print("My Account Number {}, and my Balance is {}" .format(AccNo,Balance)) print("My name is",Name,"and I got" ,Marks, "Marks in ComputerScience") print("my name is...
ae7922f1cd7be6def39e113f61390b4ceebcb016
gngoncalves/cursoemvideo_python_pt1
/desafio18.py
510
4.1875
4
from math import sin, cos, tan, radians num = int(input('Insira um ângulo: ')) print('Valores em Rad:') print('O seno de {}º é {:.2f}.'.format(num,sin(num))) print('O cosseno de {}º é {:.2f}.'.format(num,cos(num))) print('A tangente de {}º é {:.2f}.\n'.format(num,tan(num))) print('Valores em Deg:') print('O seno de {...
f49b75b94eeceac8906b6f812c706f31439e8240
gngoncalves/cursoemvideo_python_pt1
/desafio09.py
616
4.125
4
num = int(input('Insira um número inteiro: ')) n1 = num*1 n2 = num*2 n3 = num*3 n4 = num*4 n5 = num*5 n6 = num*6 n7 = num*7 n8 = num*8 n9 = num*9 n10 = num*10 print('Tabuada de {0}:'.format(num)) print('-'*12) print('{} x 1 = {:2}'.format(num,n1)) print('{} x 2 = {:2}'.format(num,n2)) print('{} x 3 = {:2}'.format(n...
0a5ebbc78c07295677b0df7239dc5cd1f668e7de
gngoncalves/cursoemvideo_python_pt1
/desafio54.py
499
3.640625
4
from datetime import date atual = date.today().year maior = 0 menor = 0 for i in range (1,8): print('=' * 45) nasc = int(input('Digite o de nascimento [Pessoa {}/7]: '.format(i))) if atual - nasc >= 21: maior += 1 else: menor += 1 print('=' * 45) print('Nos dados informados acima, temos ...
902258a6ec97197a8840559bc4692514b6e4d1f4
gngoncalves/cursoemvideo_python_pt1
/desafio42.py
690
3.921875
4
l1 = float(input('Insira o primeiro lado do triângulo: ')) l2 = float(input('Insira o segundo lado do triângulo: ')) l3 = float(input('Insira o terceiro lado do triângulo: ')) c1 = l1 < (l2 + l3) c2 = l2 < (l1 + l3) c3 = l3 < (l1 + l2) if c1 == True and c2 == True and c3 == True: if l1 == l2 == l3: print('E...
c64c542b57107c06de2ce0751075a81fcb195b61
DmitriiIlin/Merge_Sort
/Merge_Sort.py
1,028
4.25
4
def Merge (left,right,merged): #Ф-ция объединения и сравнения элементов массивов left_cursor,right_cursor=0,0 while left_cursor<len(left) and right_cursor<len(right): if left[left_cursor]<=right[right_cursor]: merged[left_cursor+right_cursor]=left[left_cursor] left_cursor+=1...
d166529ddb87574ad1aac74e599e53f187f82b73
hkilter/bullwhip_effect
/supplier_buyer_graph/diffusion_v0.2.0.py
4,615
3.546875
4
#------------------------------------------------------------------------------- # Name: module1 # Purpose: # # Author: Luke # # Created: 01/06/2013 # Copyright: (c) Luke 2013 # Licence: <your licence> #------------------------------------------------------------------------------- #!/usr/bin/env ...
9a8e8de1b5fd6d2b1acf4596227f60f3b46678ee
HRIDDHIMABANSAL/intro.py
/intro.py
338
4
4
introduction=input("write something about you") characterCount=0 wordCount=1 print(introduction) for i in introduction: characterCount=characterCount+1 if(i==" "): wordCount=wordCount+1 print("no. words in the string") print(wordCount) print("no. of characters in the paragraph") print(chara...
546f13f754d939cdb1bda0f246087118fdc0df92
AmaurX/automated_flappy_bird
/flappy_automation_code/scripts/controller.py
2,452
3.609375
4
#!/usr/bin/env python import math DESIRED_VELOCITY_NORM = 2.1 class Controller(): ''' This controller tracks target velocity values : Vx and Vy They are computed from the current state, from the desired velocity norm, and from the desired direction angle given by the planner The desired velocity no...
0f8a9e2bf060fa284a3d3aee09f87d446d6cf568
betoxedon/CursoPython
/Programação_Funcional/closure.py
302
3.734375
4
#!/usr/bin/python3 def multiplicar(x): def calcular(y): return x*y return calcular if __name__ == '__main__': dobro = multiplicar(2) triple = multiplicar(3) print(triple) print(dobro) print(f'O triplo de 3 é {triple(3)}') print(f'O dobro de 7 é {dobro(7)}')
820ed5f7338202897dc05c8dd3e915214572152e
betoxedon/CursoPython
/Fundamentos/area_circulo_v2.py
154
3.640625
4
#!/usr/local/bin/python3 ''' Cálculo da área de um círculo ''' PI = 3.1415 RAIO = 15.3 AREA = PI * RAIO ** 2 print(f'A Área do círculo é {AREA}')