blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
545k
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
545k
dddebbbe43ea8eb3bad43061496a23f73426a2c9
tsakallioglu/Random-Python-Challenges
/number_of_clans.py
645
3.640625
4
#Let's call two integers A and B friends if each integer from the array divisors is a divisor of both A and B or neither A nor B. #If two integers are friends, they are said to be in the same clan. How many clans are the integers from 1 to k, inclusive, broken into? def numberOfClans(divisors, k): def div(n): ...
f8c33c98dc671fd597a5b40848d72e42f504fbc5
tsakallioglu/Random-Python-Challenges
/Weak_numbers.py
1,324
4.25
4
#We define the weakness of number x as the number of positive integers smaller than x that have more divisors than x. #It follows that the weaker the number, the greater overall weakness it has. For the given integer n, you need to answer two questions: #what is the weakness of the weakest numbers in the range [1, n]? ...
d1a9b20d306aeebe37903a9affe746d78a516923
tsakallioglu/Random-Python-Challenges
/swap_adj_bits.py
698
3.859375
4
#You're given an arbitrary 32-bit integer n. #Swap each pair of adjacent bits in its binary representation and return the result as a decimal number. def swapAdjacentBits(n): return int(''.join([(bin(n)[2:].zfill((len(bin(n)[2:])/2)*2 + (len(bin(n)[2:])%2)*2))[i+1]+(bin(n)[2:].zfill((len(bin(n)[2:])/2)*2 + (len(bi...
36d32046cb6a50e8c9b25379cbf7bae627991a2f
selthebell/CodingDojoAssignments_Sel
/Python/tuple.py
95
3.640625
4
num = (1, 5, 7, 3, 8) for index, item in enumerate(num): print(str(index)+" = "+str(item))
7ea637affb0ded0bda1f1e66903a9a2c797c400e
SQasimHamdani/Intro-To-Data-Science-coursera
/week2/assignment2.py
7,289
4.4375
4
#!/usr/bin/env python # coding: utf-8 # # Assignment 2 # For this assignment you'll be looking at 2017 data on immunizations from the CDC. Your datafile for this assignment is in [assets/NISPUF17.csv](assets/NISPUF17.csv). A data users guide for this, which you'll need to map the variables in the data to the questions...
3679e9df1a83add848694b6c607f93818337f12c
budvinchathura/nn-basics
/1-numpy/numpy1.py
721
3.640625
4
import numpy as np arr1 = [1,2,3,4] print("arr1 : ") print(arr1) narr1 = np.array(arr1) #normal array to numpy array print() print("type of narr1 : "+ str(type(narr1))) print() print("narr1:") print(narr1) print("narr1.shape:") print(narr1.shape) #dimension of the numpy array as a tuple print(...
02e1808c0f5b46fce1b3b657baf458bfb1314536
nataschkarodina/IB
/control_work_2_Rodina.py
3,125
3.703125
4
import numpy as np import matplotlib.pyplot as plt import random2 #function that finds the index of the current_point in the matrix def find_index (matrix, n, m, point): for i in range (n): for j in range (m): if np.any (matrix[i,j] == point): index = i, j return (index) #...
3e59fdcaf40e067d7eae9c394f287b1e4405a06d
FedotovArtemii/random_python_stuff
/square_spiral.py
215
3.8125
4
import turtle def main(): my_turtle = turtle.Turtle() i = 0 while True: i += 1 my_turtle.left(90) my_turtle.forward(5 * i) if __name__ == '__main__': main()
12ac0b09a1c0e7f0e84c0ebcfd1b2d928c9d8a48
abhash3141/netsec
/insertionsort.py
527
3.703125
4
import random as rd def insertion_sort(array): last_index = len(array)-1 def recursion_sort(array,last_index): if(last_index==0): return recursion_sort(array,last_index-1) value = last_index while value>0 and array[value]<array[value-1]: array[value],arra...
4be8e138cbcce2d16f5dba61c7f58959fca479ce
cybertaxi/Foo-bar-challenge
/foo bar challenge/level 1/level_1_num_station_code_msg.py
6,012
3.546875
4
# Numbers Station Coded Messages # ============================== # When you went undercover in Commander Lambda's organization, you set up a coded messaging system with Bunny Headquarters to allow them to send you important mission updates. Now that you're here and promoted to Henchman, you need to make sure you can ...
6a2f4ecc973b48dc679b852b2ff64ba861636d29
ryang1337/Tetris-AI
/Game.py
23,443
3.703125
4
import pygame import random import Piece import Grid import copy import time class Game: pygame.font.init() SCREEN_WIDTH = 800 SCREEN_HEIGHT = 700 PLAY_WIDTH = 300 PLAY_HEIGHT = 600 BLOCK_SIZE = 30 TOP_LEFT_X = (SCREEN_WIDTH - PLAY_WIDTH) // 2 TOP_LEFT_Y = SCREEN_HEIGHT - PLAY_HEIGHT...
79b4810bdad51a3358a81d4641208028182133f6
Ethan-Arrowood/python-coding-challenges
/challenges/1.3.Input/lesson_tests.py
371
3.671875
4
import unittest import lesson_code class InputTests(unittest.TestCase): def test_main(self): name = lesson_code.Name age = lesson_code.Age self.assertIsInstance(name, str) self.assertIsInstance(age, str) # To run the tests from the console: # Make sure that you are in the '1.3.Addi...
42e988923e5cf8bbe7ce412033ee06adf1d00520
shenlinli3/python_learn
/second_stage/day_02/demo_05_基础数据类型-列表.py
2,564
3.96875
4
# -*- coding: utf-8 -*- """ @Time : 2021/5/11 14:13 @Author : zero """ # 列表 list # # 列表的初始化 # # 1.初始化一个列表并放入对象 # list01 = [1, 9.9, True, "abc"] # print(type(list01)) # print(list01) # # 2.初始化一个空列表 # list02 = [] # print(list02) # # 3.初始化一个空列表 # list03 = list() # print(list03) # # 4.打散一个字符串并放入一...
5752916b9ee0cd014f80595cf9dca503c75c48c7
shenlinli3/python_learn
/second_stage/day_01/work_01.py
3,702
3.953125
4
# -*- coding: utf-8 -*- """ @Time : 2021/5/10 17:07 @Author : zero """ # 1.用户输入任意两个数,比如10 95或95 10,计算它们(都包含)之间所有数的和 # num1 = int(input("请输入第一个数:")) # num2 = int(input("请输入第二个数:")) # if num1 > num2: # # 交换两个变量 # num3 = num1 # num1 = num2 # num2 = num3 # sums = 0 # while num1 <= num2...
3edca50ac0faee8c95d27f19232bd03202ab814c
shenlinli3/python_learn
/second_stage/day_11/demo_05_面向对象-多态和鸭子类型.py
1,449
4.40625
4
# -*- coding: utf-8 -*- """ @Time : 2021/5/22 16:08 @Author : zero """ # 多态:在面向对象中,一个类的实例可以是多种形态(向上转型) # 鸭子类型:在python中,只要一个对象长的像鸭子,走路和鸭子差不多,我就认为它是一只鸭子 class Person: # 会默认继承自object类 def eat(self): print("eat eat eat") class Student(Person): pass class LowLevelStudent(Student): ...
24ac42452a2c8d4a84d52447187451ea079d4b1d
shenlinli3/python_learn
/second_stage/day_03/demo_03_for循环.py
1,090
4.125
4
# -*- coding: utf-8 -*- """ @Time : 2021/5/12 16:06 @Author : zero """ # for循环 """ for 变量名 in 可迭代对象: print(变量名) ... """ # 遍历字符串 # str01 = "hello world!" # 12 # for i in str01: # print(i) # 遍历列表 # list01 = [1, 2, 3, 4, 5] # for j in list01: # print(j) # 遍历元组 # tuple01...
aba31558c232c3fc9d24211b6f93a4327713a3cb
shenlinli3/python_learn
/second_stage/day_06/demo_01_函数.py
1,292
3.671875
4
# -*- coding: utf-8 -*- """ @Time : 2021/5/16 09:14 @Author : zero """ # 函数 function method # 把代码封装起来,便于重复使用,优化代码的逻辑 # 定义一个函数 def # 函数的命名规则同变量 def my_func_01(): print("函数内部步骤1") print("函数内部步骤2") print("函数内部步骤3") # 执行(调用)一个函数:函数名+括号 # my_func_01() # my_func_01() # my_func_01() ...
ecebd711a7527c8f85e219ed1544bfdac1a0b2c1
shenlinli3/python_learn
/second_stage/day_01/demo_02_注释.py
264
3.65625
4
"""""" # 单行注释 # 注释:解释你写的代码是什么意思 # print("你好") # 代码被注释后不会被执行 """多行注释 print("你好") print("你好")""" # 快捷键 ctrl + / print("你好") print("你好") print("你好")
20fb5f0e199a4728b38dc9d6c5d07f639c89ac13
JgallegosS/Codigo_clases
/Clase1.py
2,707
3.875
4
# Numericos edad, _peso = 50, 70.5 #String nombres = " Josue Gallegos" dirDomiciliaria = "Av. Amazonas" tipo_sexo="M" #Boolean civil = True #Colecciones usuario=("JgallegosS","1234", "Jgallegoss@unemi.edu.ec") materias= ["programacion web", "PHP", "POO"] docente = {"nombre":"Josue", "edad":20, "fac":"f...
7af6a875e8789ca9846521d0df9be2bd5eb2fa22
KhushiRana2003/Hacktoberfest2021-1
/Python/bubble_sort.py
319
4.21875
4
def bubbleSort(array): for i in range(len(array)): for j in range(len(array) - i - 1): if array[j] > array[j + 1]: swap(j, j + 1, array) return array def swap(i, j, array): array[i], array[j] = array[j], array[i] # Time Complexity: O(n^2) # Space Complexity: O(1)
3671b88600bd56068d0fac343aa748e34511336e
martiaos/exercises
/Python/polynomial.py
1,001
3.796875
4
import matplotlib.pyplot as plt import numpy as np class Polynomial(): def __init__(self, coeffs): self.coeffs = coeffs def __call__(self, x): sum = 0 for key in self.coeffs: sum += (x**key)*self.coeffs[key] return sum def __str__(self): poly_list = '' ...
71417cb49cb8704d54aa0f6f923e92bd37da5bd9
Niteshyadav0331/Zip-File-Extractor
/main.py
248
4.15625
4
from zipfile import ZipFile file_name = input("Enter the name of file you want to file in .zip: ") with ZipFile(file_name, 'r') as zip: zip.printdir() print('Extracting all the files...') zip.extractall() print("Done!")
6b2a7b5c39942b11093974da8c635d3a6e94f8f2
BeastModeLT/teachable
/test.py
71
3.5
4
def add(x, y): return (x + y) x = 5 y = 7 print(add(x,y))
ee8a059fe31e4c7cc38c193318e8cef57c84312d
TamirEckstein/mat0
/add.py
75
3.71875
4
n1 = int(input('insert num:')) n2 = int(input('insert num:')) print(n1+n2)
d1929893d83acf3c1df2858a5e3c29a9d24f00c5
zmijek1995/Python-lekcja-2
/zad4/Untitled-1.py
110
3.578125
4
liczba = int(input("Podaj jakas liczbe: ")) if liczba < 0 : print(liczba * (-1)) else: print (liczba)
3c6cdf9a2e2a38723902b41af79315c9a46b3481
JordanRosas/Revisiting-Python
/Hello.py
420
3.96875
4
print("Hello World") name = "Jordan" print("Hello! my name is " + name) age = int(input("Enter Your age ")) name = input("Enter Your name ") print("Your name is " + name + " you are " + str(age) + " years old") Fizz Buzz challenge in python! for i in range (101): if (i % 3 == 0 & i % 5 == 0): print("Fizz Buzz...
6981ba46cf418be6111a8eb7a9e92c68233d8f74
J-Grizz/Algorithms
/CodeWars-py/sudoku-solution-checker.py
1,279
3.890625
4
# Write a function done_or_not/DoneOrNot passing a board (list[list_lines]) as parameter. If the board is valid return 'Finished!', otherwise return 'Try again!' # Sudoku rules: # Complete the Sudoku puzzle so that each and every row, column, and region contains the numbers one through nine only once. def done_or_no...
74d174d8878c2604daf720d755e6b156a6ec4881
netor27/codefights-solutions
/arcade/python/arcade-theCore/07_BookMarket/053_IsTandemRepeat.py
643
4.3125
4
def isTandemRepeat(inputString): ''' Determine whether the given string can be obtained by one concatenation of some string to itself. Example For inputString = "tandemtandem", the output should be isTandemRepeat(inputString) = true; For inputString = "qqq", the output should b...
e082ba713c0a0001a3c47dfb5b1e31719534600d
netor27/codefights-solutions
/arcade/python/arcade-theCore/07_BookMarket/054_IsCaseInsensitivePalindrome.py
339
4.1875
4
def isCaseInsensitivePalindrome(inputString): ''' Given a string, check if it can become a palindrome through a case change of some (possibly, none) letters. ''' lowerCase = inputString.lower() return lowerCase == lowerCase[::-1] print(isCaseInsensitivePalindrome("AaBaa")) print(isCaseInsensitiveP...
ccf05528888e455e586090cb12192844fd6e0560
netor27/codefights-solutions
/interviewPractice/python/02_linkedLists/02_isListPalindrome.py
1,694
4.03125
4
'''' Note: Try to solve this task in O(n) time using O(1) additional space, where n is the number of elements in l, since this is what you'll be asked to do during an interview. Given a singly linked list of integers, determine whether or not it's a palindrome. Example For l = [0, 1, 0], the output should be isListP...
1e7cf789ed5052659cf1e83cd6a551ec85eea981
netor27/codefights-solutions
/arcade/python/arcade-intro/12_Land of Logic/060_sudoku.py
1,555
3.90625
4
def sudoku(grid): # check columns for col in range(9): if not validColumn(grid, col): print("Failed in column ", col) return False # check rows for row in range(9): if not validRow(grid, row): print("Failed in row ", row) re...
7409adc90575be9de7e4c4eca98226c65b657a8f
netor27/codefights-solutions
/interviewPractice/python/01_arrays/04_sudoku2.py
2,781
3.984375
4
'''' Sudoku is a number-placement puzzle. The objective is to fill a 9 × 9 grid with numbers in such a way that each column, each row, and each of the nine 3 × 3 sub-grids that compose the grid all contain all of the numbers from 1 to 9 one time. Implement an algorithm that will check whether the given grid of numbers...
c32f3501b32a4141e575abe2f57b9b8eb712b6e1
netor27/codefights-solutions
/arcade/python/arcade-intro/02_Edge of the Ocean/004_adjacentElementsProduct.py
522
4.15625
4
def adjacentElementsProduct(inputArray): '''Given an array of integers, find the pair of adjacent elements that has the largest product and return that product. ''' n = len(inputArray) if n < 2: raise "inputArray must have at least 2 elements" maxValue = inputArray[0] * inputArray[1] ...
fbd2d8ce142d278ff559583b05a894cd698a2f19
netor27/codefights-solutions
/arcade/python/arcade-theCore/10_LabOfTransformations/085_HigherVersion.py
830
3.671875
4
''' Given two version strings composed of several non-negative decimal fields separated by periods ("."), both strings contain equal number of numeric fields. Return true if the first version is higher than the second version and false otherwise. The syntax follows the regular semver ordering rules: 1.0.5 < 1.1.0 < 1...
cf8cb966cad6c708b65ccd814069c65e821f3eb3
netor27/codefights-solutions
/arcade/python/arcade-theCore/05_ListForestEdge/038_ConcatenateArrays.py
180
3.875
4
def concatenateArrays(a, b): ''' Given two arrays of integers a and b, obtain the array formed by the elements of a followed by the elements of b. ''' return a + b
805220b5acecb5a06ddffd9dd6df42c7d26495b3
netor27/codefights-solutions
/arcade/python/arcade-theCore/13_WaterfallOfIntegration/113_Correct Nonogram.py
3,916
3.84375
4
''' A nonogram is also known as Paint by Numbers and Japanese Crossword. The aim in this puzzle is to color the grid into black and white squares. At the top of each column, and at the side of each row, there are sets of one or more numbers which describe the runs of black squares in that row/column in exact order. For...
502df68c302d78fe692c224f2807b299c268d630
netor27/codefights-solutions
/arcade/python/arcade-intro/05_Island of Knowledge/020_arrayMaximalAdjacentDifference.py
552
3.921875
4
def arrayMaximalAdjacentDifference(inputArray): ''' Given an array of integers, find the maximal absolute difference between any two of its adjacent elements. ''' if len(inputArray) < 2: raise "The inputArray must contain at least 2 elements" maxDiff = abs(inputArray[0] - input...
5a8a41955bdce06df8978d83873cf92ae97c4d24
netor27/codefights-solutions
/arcade/python/arcade-theCore/01_IntroGates/001_AddTwoDigits.py
160
4.09375
4
def addTwoDigits(n): ''' You are given a two-digit integer n. Return the sum of its digits. ''' return n % 10 + n // 10 print(addTwoDigits(29))
a69a5d08faefda2da918974047118fcd34067bfb
netor27/codefights-solutions
/arcade/python/arcade-intro/12_Land of Logic/057_fileNaming.py
1,464
4.09375
4
def fileNaming(names): ''' You are given an array of desired filenames in the order of their creation. Since two files cannot have equal names, the one which comes later will have an addition to its name in a form of (k), where k is the smallest positive integer such that the obtained name is not...
7bedb82fc09842d8412b9b2180e235347c11cab0
netor27/codefights-solutions
/arcade/python/arcade-theCore/14_SortingOutpost/119_RowsRearranging.py
978
3.984375
4
''' Given a rectangular matrix of integers, check if it is possible to rearrange its rows in such a way that all its columns become strictly increasing sequences (read from top to bottom). Example For matrix = [[2, 7, 1], [0, 2, 0], [1, 3, 1]] the output should be rowsRearranging(matrix) = fals...
62bbb74e43256f78b67050821d847af478d4669c
netor27/codefights-solutions
/arcade/python/arcade-intro/12_Land of Logic/052_longestWord.py
637
4.21875
4
def longestWord(text): ''' Define a word as a sequence of consecutive English letters. Find the longest word from the given string. ''' maxLen, maxStart, currStart, currLen = 0, 0, 0, 0 for i in range(len(text)): if text[i].isalpha(): if currLen == 0: currSta...
bab94cc2b2d9dc68b48a7371eebfafb7c41db9b2
netor27/codefights-solutions
/arcade/python/arcade-theCore/16_TimeRiver/133_CuriousClock.py
375
3.546875
4
from datetime import datetime def curiousClock(someTime, leavingTime): timeFormat = "%Y-%m-%d %H:%M" s = datetime.strptime(someTime, timeFormat ) l = datetime.strptime(leavingTime, timeFormat) diff = l - s res = s - diff print("fail at", s) print("leaving at", l) print("diff", diff) ...
a88abb9e2c271a3f2805a3b72bd84f289c91031b
netor27/codefights-solutions
/arcade/python/arcade-intro/06_Rains of Reason/027_variableName.py
455
3.53125
4
import re def variableName(name): ''' Correct variable names consist only of Latin letters, digits and underscores and they can't start with a digit. Check if the given string is a correct variable name. ''' p = re.compile("^[a-zA-Z_$][a-zA-Z_$0-9]*$") return p.match(name) is not None pri...
5bf736aa8224408f3032fca540fe75c38994529e
netor27/codefights-solutions
/arcade/python/arcade-theCore/06_LabyrinthOfNestedLoops/050_CrosswordFormation.py
1,698
3.625
4
import itertools def crosswordFormation(words): ''' You're a crossword fanatic, and have finally decided to try and create your own. However, you also love symmetry and good design, so you come up with a set of rules they should follow: the crossword must contain exactly four words; ...
6cc342813a5cf0ab9e54f0ebb7bf05911b66e9b0
netor27/codefights-solutions
/arcade/python/arcade-theCore/05_ListForestEdge/040_IsSmooth.py
996
4.125
4
def isSmooth(arr): ''' We define the middle of the array arr as follows: if arr contains an odd number of elements, its middle is the element whose index number is the same when counting from the beginning of the array and from its end; if arr contains an even number of elements, its midd...
33d3a5098ed1a1b1428e1ee445e1f05879346f6a
netor27/codefights-solutions
/arcade/python/arcade-intro/12_Land of Logic/058_messageFromBinaryCode.py
686
4.03125
4
def messageFromBinaryCode(code): ''' You are taking part in an Escape Room challenge designed specifically for programmers. In your efforts to find a clue, you've found a binary code written on the wall behind a vase, and realized that it must be an encrypted message. After some thought, your first ...
df112813c067411853941f8455d31fed51a2c1fa
netor27/codefights-solutions
/arcade/python/arcade-theCore/01_IntroGates/005_MaxMultiple.py
349
4.21875
4
def maxMultiple(divisor, bound): ''' Given a divisor and a bound, find the largest integer N such that: N is divisible by divisor. N is less than or equal to bound. N is greater than 0. It is guaranteed that such a number exists. ''' num = bound - (bound % divisor) return max(0, nu...
db274210d2f9ee82cdb1629dde9a54f1610e254d
netor27/codefights-solutions
/arcade/python/arcade-intro/10_Eruption of Light/044_FindEmailDomain.py
613
3.859375
4
def findEmailDomain(address): ''' An email address such as "John.Smith@example.com" is made up of a local part ("John.Smith"), an "@" symbol, then a domain part ("example.com"). The domain name part of an email address may only consist of letters, digits, hyphens and dots. The local part...
4360bfb5399e8fc6a7d7453b8582063d04704139
netor27/codefights-solutions
/arcade/python/arcade-intro/02_Edge of the Ocean/008_matrixElementsSum.py
1,100
4.1875
4
def matrixElementsSum(matrix): ''' After they became famous, the CodeBots all decided to move to a new building and live together. The building is represented by a rectangular matrix of rooms. Each cell in the matrix contains an integer that represents the price of the room. Some rooms are free (...
9ab6e5d04bdd7d278e9f6c1188160ff8ae892e14
netor27/codefights-solutions
/arcade/python/arcade-theCore/04_LoopTunnel/029_AdditionWithoutCarrying.py
763
4.375
4
def additionWithoutCarrying(param1, param2): ''' A little boy is studying arithmetics. He has just learned how to add two integers, written one below another, column by column. But he always forgets about the important part - carrying. Given two integers, find the result which the little boy ...
cbd3430850fe3a73dccc68751baea91685736114
netor27/codefights-solutions
/arcade/python/arcade-intro/03_Smooth Sailing/009_allLongestStrings.py
596
3.859375
4
def allLongestStrings(inputArray): ''' Given an array of strings, return another array containing all of its longest strings. ''' resultArray = [] currentMax = len(inputArray[0]) for i in range(len(inputArray) ): currentLen = len(inputArray[i]) if currentLen...
cb03a35c7e74fc7ca73545dadc59c16bce5c6f7a
netor27/codefights-solutions
/arcade/python/arcade-theCore/08_MirrorLake/059_StringsConstruction.py
634
4.1875
4
def stringsConstruction(a, b): ''' How many strings equal to a can be constructed using letters from the string b? Each letter can be used only once and in one string only. Example For a = "abc" and b = "abccba", the output should be stringsConstruction(a, b) = 2. We can construct 2 strings a with letters fr...
14e8d9416e1b3bfeb8e46b9eb7eee156cd067f76
TD87/Super-Mario-Python
/person.py
881
3.921875
4
"""This module creates the person base class""" class Person: """Basic person class from which enemy and mario inherit from""" def __init__(self, x, y, xdisp, ydisp): self.x_coord = x self.y_coord = y self.xdisp = xdisp self.ydisp = ydisp def move_left(self): ...
0aa2a90bb7526db4328a656696e4ab10f47e8154
Wooyongjeong/python-algorithm-interview
/17 정렬/60 삽입 정렬 리스트.py
1,019
3.90625
4
from ListNode import ListNode from typing import Optional, List # 풀이 1. 삽입 정렬 class Solution1: def insertionSortList(self, head: Optional[ListNode]) -> Optional[ListNode]: cur = parent = ListNode(None) while head: while cur.next and cur.next.val < head.val: cur = cur.ne...
a00302effc5d807769a773c2f52900d2a9dacc82
Wooyongjeong/python-algorithm-interview
/부록 B 2018 카카오 공채/B3 캐시.py
1,202
3.640625
4
import collections # deque를 이용한 LRU 구현 def solution(cacheSize, cities): elapsed = 0 cache = collections.deque(maxlen=cacheSize) for city in cities: city = city.lower() if city in cache: # cache hit cache.remove(city) cache.append(city) elapsed += 1 ...
34a1816e8e30392f201f7602c70316d2c11f2fab
Wooyongjeong/python-algorithm-interview
/17 정렬/61.py
474
3.640625
4
from typing import List class Solution: @staticmethod def to_swap(n1: int, n2: int) -> bool: return f"{n1}{n2}" < f"{n2}{n1}" def largestNumber(self, nums: List[int]) -> str: i = 1 while i < len(nums): j = i while j > 0 and self.to_swap(nums[j - 1], nums[j]...
e602bd4a5b5205c05b10dd4a4c2fe13ea754e643
mlo2014/Project101
/pythonScripting/oddnum.py
126
4.0625
4
#!/usr/bin/python #range function a=2 b=int(sys.argv[1]) if(b%2==0) print 'b is even number' print 'b is an odd number'
030ccb847159cfd0282749f86be2eb9836d1bedb
jimmyzhaoj/python_tutorial
/dictionary.py
706
3.8125
4
student = { "name": "John", "age": 25, "course": ["Math", "compSci"], "cell": "616-111-88888", } print(student) print(student["name"]) print(student["course"]) print(student.get("cell")) print(student.get("phone", "_Not Found_")) student["phone"] = "555-5555" print(student.get("phone", "_Not Found_")) p...
6243c4439b79c3dd80fac6d9bbdd4a84e13aa451
jaabberwocky/code_in_community
/project2.py
2,017
4.03125
4
class WordList: words = set() used = set() last_word = None def __init__(self, path='word_list.txt'): ''' Initialises WordList. Params: path - path to word list Returns: None ''' with open(path) as...
308c787c385f524d6ce2404d9844f0698d35b3e3
maxmarzolf/100-days-of-code
/days 16-18/day17.py
560
3.953125
4
import random names = ['arnold schwarzenegger', 'alec baldwin', 'bob belderbos', 'julian sequeira', 'sandra bullock', 'keanu reeves', 'julbob pybites', 'bob belderbos', 'julian sequeira', 'al pacino', 'brad pitt', 'matt damon', 'brad pitt'] capitalized_names = [name.title() for name in name...
771f4455330cd99b11d8fa52a85de529319dafe1
IntSPstudio/vslst-python
/sta/980004015.py
1,026
3.5625
4
#|==============================================================|# # Made by IntSPstudio # Project Visual Street # ID: 980004015 # Twitter: @IntSPstudio #|==============================================================|# #IMPORT import it8c #AVARAGE CALCULATOR def calculateAvarage(listContent): listLength = len(listCo...
1c7d4d59319cbdcc5142e7a08a44f4802ddfd838
sharedordaz/cse210-tc06
/game/player.py
729
3.5625
4
class Player: """Guess the numbers that you need to guess""" def __init__(self, name, number=0, guess=[0,0,0,0], info="****"): self.name = name self.number = number self.guess = guess self.info = info self.win = False def ask_number(self, user): guess = int(i...
72577880577c2ef5c1a4373ace36a79cdbace24e
sheabunge/kit103-labs
/prac04/q3.py
763
3.5625
4
from prac03.lab3 import words """ 3. implementing own ∃ and ∀ """ def for_all(collection, predicate): for item in collection: if not predicate(item): return False return True def for_all_simple(collection, predicate): return all(predicate(item) for item in collection) def exists(collection, predicate):...
7edc318da89e2b400803bf7d01e99b01c33eef6d
sheabunge/kit103-labs
/prac08/hash.py
1,428
3.96875
4
""" For KIT103/KMA115 Practical 8: Euclidean Algorithm and applications Revised: 2016-09-08 Author: James Montgomery (james.montgomery@utas.edu.au) An implementation of Java's string hash function (both the original and a version that wraps to a certain number of buckets) and a wrapper for Python's hash() function can...
5cf96612d1c9bdb7f2fd851e8a00b424c2da2b6f
mixelpixel/CS1-Code-Challenges
/cc69strings/strings.py
2,486
4.28125
4
# cc69 strings # https://repl.it/student/submissions/1855286 # https://developers.google.com/edu/python/ # http://pythoncentral.io/cutting-and-slicing-strings-in-python/ ''' For this challenge, you'll be writing some basic string functions. Simply follow along with each exercise's prompt. You may find the following a...
553812b0d7e48c85a24f20a4f0f8365afdb97710
Msiavashi/Veronica-Auction-Website
/project/websocket/Timer.py
1,205
3.53125
4
from datetime import datetime import time class CountDownTimer: # temporary functions just for test, a utility class should handle these functions def dateDiffInSeconds(self, date1, date2): timedelta = date2 - date1 return timedelta.days * 24 * 3600 + timedelta.seconds # tempora...
ddc9948a5368871b1ee18df9679800de936a0330
EvanMata/Mini-Projects
/Chaos_Project.py
15,207
3.5
4
import numpy as np import matplotlib.pyplot as plt import math import random import time from mpl_toolkits.mplot3d import Axes3D ''' Chaos and Nonlinear Dynamics project to do a basic simulation of chaotic mixing on the surface of a sphere due to two vortices that alternate being on and off. Two main func...
e0e97cf8142cbe7e2c469a0989c1caf45d18ac3b
kazaia/AlgoExpert_Solutions
/Binary Tree/branch_sums.py
668
3.96875
4
# Branch sums: # Time complexity: O(n) # Space complexity: O(n) # This is the class of the input root. Do not edit it. class BinaryTree: def __init__(self, value): self.value = value self.left = None self.right = None def branchSums(root): sums = [] computeBranchSums(root, 0, s...
88e73d734efbf30379883fbd3834805473fba60f
kazaia/AlgoExpert_Solutions
/Searching/shifted_binary_search.py
971
3.921875
4
# Shifted binary search #Time complexity: O(log(n)) #Space complexity: O(log(n)) (Due to recursion) def shiftedBinarySearch(array, target): return shiftedBinarySearchHelper(array, target, 0, len(array) -1) def shiftedBinarySearchHelper(array, target, left, right): # base case: if left > right: ret...
1daba81ce284d205f731e6685660327b92dfaa68
imxana/show-me-the-code
/code/0012.py
735
3.75
4
#!/usr/bin/env python3 # -*-coding:utf-8-*- ''' 0011 题: 敏感词文本文件 filtered_words.txt,里面的内容为以下内容, 当用户输入敏感词语时,则打印出 Freedom,否则打印出 Human Rights''' output = ('Freedom', 'Human Rights') def sensetive(): sens = [] lines = open('assets/filtered_words.txt').readlines() for line in lines: sens.append(line.st...
f9f66392607577475b29ce253a985d5d538b5304
huytrinh93/HadoopPracticeProblem
/code/friends_mapper.py~
350
3.875
4
#!/usr/bin/python import sys #read data input line by line for line in sys.stdin: data = line.strip().split(",") if len(data)<3: continue print "{0},{1},{2}".format(data[0],data[0],data[1]) for n in range(2,len(data)): #if data[0]=="Alivia": print "{0},{1},{2}".format(data[n],data[0],data[1]) #print "{0}...
339e9320b1e776c622f1c8b344a2079747089114
alu0100759785/grupo1I
/src/src/python/factorial.py
222
3.828125
4
#!/usr/bin/python from math import * i=float(raw_input("Escriba el numero del cual quiere su factorial: ")) def fac(i): if i == 0: return 1 else: return i * fac(i-1) if __name__ == '__main__': print fac(i)
b5013dd6a8d95c2f0a5d2d51e227129ca819ee39
MeatballNissan/py
/untitled/day01/strTest.py
1,216
3.609375
4
name = "bxd" fort = "hello {name} ,age {age}" print(name.capitalize()) print(name.count("x")) print(name.casefold()) print(name.center(40, "-")) print(name.endswith("d")) print(fort.format(name="bxd", age= 22)) print(name.isalnum()) #英文字符 + 0-9 print(name.isalpha()) #纯英文字符(含大小写) print("12".isdecimal()) #是否为十进制 print(...
2b884b71a5b262a717e2b6ec024fd464a810552a
MeatballNissan/py
/untitled/day06/polymorphisn.py
490
3.75
4
class Animal(object): def __init__(self, name): self.name = name def talk(self): return "" @staticmethod def animal_talk(obj: object) -> object: obj.talk() class Dog(Animal): def talk(self): print("wang wang") class Cat(Animal): def talk(self): print("mia...
89e83db44d869f3bd60691571a0f25af71931c0f
MeatballNissan/py
/untitled/day04/test.py
721
3.859375
4
# print(range(10)) for i in range(10): print(i) def func(i): print(i*100) # 列表生成式 [func(i) for i in range(10)] [print(i*2) for i in range(10)] print([i * 2 for i in range(10)]) a = [i * 2 for i in range(1)] print(len(a)) # 生成器 列表生成式会把所有数据准备好,生成器只有在用到的时候才生成,省内存 #生成的列表可以支持切片 生成器不行 (i * 2 for i in range(1...
4a5be9b71fe0de462e633d4d73bcc3de59eb9140
venu823/Python_Assignments
/chapter 3/3.14.py
1,045
3.578125
4
""" Problem 14: Create a new virtualenv and install BeautifulSoup. BeautifulSoup is very good library for parsing HTML. Try using it to extract all HTML links from a webpage. """ from bs4 import BeautifulSoup from urllib.request import urlopen as urls import html5lib from html import parser import requests url="ht...
6f23d04ff32bf2297a79bfd9fe8965aff05eb20b
venu823/Python_Assignments
/chapter 2/2.31.py
230
3.578125
4
""" Problem 31: Generalize the above implementation of csv parser to support any delimiter and comments. """ def filename(filename): print([i.split('!') for i in open(filename).readlines() if i[0]!='#']) filename("new1.txt")
3505ec06158b6cf4dc7820aeba1a451e634a883e
venu823/Python_Assignments
/python_assignments/Lab Assignments/python_libraries.py
2,997
3.90625
4
""" (numpy,pandas,matplotlib,scipy) 1. Complete following program import pandas as pd mymoviedata=pd.read_table("http://bit.ly/movieusers",sep="|",header=None) print(mymoviedata.head()) # add headings to the column- col1,col2,col3,col4,col5 #display only column col3 #add col6 concatenate values of col2 and col3 and s...
066744603e0150a3d86d3b170367c16cd7e3894c
venu823/Python_Assignments
/chapter 3/3.2.py
488
3.953125
4
""" Problem 2: Write a program extcount.py to count number of files for each extension in the given directory. The program should take a directory name as argument and print count and extension for each available file extension. """ from collections import Counter import os def direct(dir): f=os.listdir(dir) l...
414e1516fe9f0139060294d83e2dc1c7095e8168
venu823/Python_Assignments
/python_assignments/Lab Assignments/operator_overloading.py
1,449
3.6875
4
""" Object oriented programming Write a class MyClass it contains 2 members One number and one string Write default constructor, parametrized constructor Overload +,*,- operator + - will do the addition of the number and ascii of 1 st character of the string ‘- - it will chk if num>ascii of 1 st character of the strin...
3d380ed198d249a751f02f0b91790c3ee73a2e96
venu823/Python_Assignments
/chapter 2/2.9.py
294
4.03125
4
""" Problem 2.9: Write a function cumulative_product to compute cumulative product of a list of numbers. """ ##---method 1--- import numpy as np print(np.cumprod([1,2,3,4])) ##---method 2--- def prod(lis): x=1 for i in lis: x*=i yield x print(list(prod([1,2,3,4])))
ccf2b3faf9f9d3ff3411798fe7034b2593b709d7
venu823/Python_Assignments
/chapter 6/6.9.py
228
4.0625
4
""" Problem 9: Write a function permute to compute all possible permutations of elements of a given list. """ import itertools def permute(new_list): xx=itertools.permutations(new_list) print(list(xx)) permute([1,2,3])
2c5bc89ac0b37b59c5cb9b64e82109a2a9f40ab8
venu823/Python_Assignments
/chapter 2/2.24.py
446
4.09375
4
""" Problem 24: Provide an implementation for zip function using list comprehensions. """ """---1st-method---""" def str(*list): return range(len(sorted(list,key=len)[0])) alpha=['a','b','c'] nos=[1,2,3] g=((nos[i],alpha[i])for i in str(nos,alpha)) for item in g: print(item) """--2nd-method---""" def str...
2b6df6a088d464685167bf22cc6033aaf083c5d9
FOUZANKHAN/PythonBootcamp
/check_pylint.py
179
3.640625
4
'''This program just checks for errors in the functions''' def func(): '''function for numbers''' first = 3 second = 5 print(first) print(second) func()
a989104d7790bbd62b71e893637bfd8e6a1bf0ab
MonicaCat/Cat-Food
/22.py
688
3.65625
4
import math a = 12+13 print(a) b = 78-66 print(b) c = 11*22 print(c) d = 52/2 print(d) e = 6**2 print(e) a = 5 b = 2 c = a*b print("面积为:", c) a = 12*5 print(a) b = "有没有人告诉你." print(b) a = input() b = input() if float(a) == 0.0: print("0") else: print("结果为:", float(b) / float(a)) a = float(input(1)) b = float...
2e5cafae1ef0893ec812f6e3a753b8e850c89bb6
anilcs13m/Data-Structure-and-algorithms-
/KthSmallest.py
762
3.6875
4
def kthlargest(arr1, arr2, k): if len(arr1) == 0: return arr2[k] elif len(arr2) == 0: return arr1[k] mida1 = len(arr1)/2 mida2 = len(arr2)/2 if mida1+mida2<k: if arr1[mida1]>arr2[mida2]: return kthlargest(arr1, arr2[mida2+1:], k-mida2-1) #we can ignore the first ...
6a90be2120058693cdb8c6d0cfd283f07321e826
rbnphlp/Dissertation
/Dissertation/MNIST Dataset scripts/Model1.py
5,556
3.546875
4
''' Creata a single layer NN using tensorflow , report its accuracy for a 1K iterations -- labelled as Model 1 in Report ----------------'' 100 images at a time - batch - 10 digits : MNIST dataset ''' 'Output : Accuracy after 10K iteration:test or train accuracy :,60K images , batch size of 100, 600 iterations t...
4973a604b279d2b150a3732ca888f0a68eb1fcd8
rbnphlp/Dissertation
/Dissertation/MNIST Dataset scripts/Model2.py
6,046
3.78125
4
''' Creata a Five layer NN using tensorflow , report its accuracy for a 2K iterations -using Relu function ''' '100 images at a time - batch - 10 digits : MNIST dataset ''' 'Output : Accuracy after 200 0 iterations: ' "Accuracy for training data set : 95.22%" "accuracy for test dataset : 92.0%" import tensorfl...
335445bea593a01b34faa6c4758765241304920e
ssavann/PY-strings
/scinder_joindre.py
440
3.6875
4
''' Méthode: split() scinder, espace si pas délimiteur join() joindre des caractères ''' prenoms = " Luc Paul Lana Loic Aurelie" lst_prenom = prenoms.split(",") #avec délimiteur print(lst_prenom) lst_prenom = prenoms.split() #sans délimiteur print(lst_prenom) chaine = " ".join(lst_prenom) print(chaine) c...
7587d88c578e5e7fbe6c896bff1ce248634aa31b
GatitoLunar/Ejercicios-de-python
/Ejercicio 10.py
143
3.828125
4
def procedimiento(numeros): simbolo = "*" for value in numeros: print(simbolo * value) procedimiento([1,2,3,4,9,8,7,4,5,6,7,3,2,1,0])
8640be6c8147846923b72154d0c0d3ec1048bafb
thinkreed/pyf
/lpthw/ex18.py
349
3.59375
4
def print_two(*args): arg1, arg2 = args print(f"arg1: {arg1}, arg2: {arg2}") def print_two_again(arg1, arg2): print(f"arg1: {arg1}, arg2: {arg2}") def print_one(arg1): print(f"arg1: {arg1}") def print_none(): print("I got nothing !") print_none() print_two("hha", "heh") print_two_again("thin...
bea5e6113d2122229d80dcb6e924c76fc326f762
thinkreed/pyf
/cs101/unit27/27_2.py
150
3.703125
4
def triangular(n): if n == 1: return 1 return n + triangular(n - 1) print(triangular(1)) print(triangular(3)) print(triangular(10))
38999bddc94388fd7d68816ccfbf5bb7277d3f7f
thinkreed/pyf
/cs101/unit20/20_2.py
258
3.71875
4
def shift_n_letters(letter, n): shift_value = (ord(letter) - ord('a') + (n % 26)) % 26 return chr(ord('a') + shift_value) print(shift_n_letters('s', 1)) print(shift_n_letters('s', 2)) print(shift_n_letters('s', 10)) print(shift_n_letters('s', -10))
91307bf31ee3e0512a0b6544c77bb6bb3479d523
thinkreed/pyf
/cs101/unit27/27_7.py
463
3.890625
4
def is_list(p): return isinstance(p, list) def deep_reverse(input_list): result_list = [] i = len(input_list) - 1 while i >= 0: if is_list(input_list[i]): result_list.append(deep_reverse(input_list[i])) else: result_list.append(input_list[i]) i -= 1 ...
7c6f44681fbf79de9d886882f13d8734e2743e4b
hillarychang/Poker
/main.py
8,493
3.921875
4
import random print('''Welcome to the Game.''') class Card: SUIT = ['♥', '♦', '♣', '♠'] RANK = ['A', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K'] def __init__(self, rank, suit): self.rank = rank self.suit = suit # Returns a numerical value for cards 1-13 dependistack_of_cards t...
00ee3b447230863898e5f9578bd9fa7e86cb4bcb
asqMyrrh/homework
/homework/work.py
1,689
3.65625
4
import random import string from random import choice import string num=int(input()) def create (num): result = '' for i in range (num): result += choice(string.ascii_letters) return result #print (create(num)) def count_up_and_low(k): u = [x for x in create(num) if x.isupper()] l = [x for...
3c5428b904e9765b71d52ad1f4127e40c0361e28
garymorrissey/Project2018
/project.py
3,867
3.765625
4
# Gary Morrissey, 20-April-2018 # Analysis of the Iris Flower Data Set # Adapted from http://archive.ics.uci.edu/ml/machine-learning-databases/iris/ print("Petal Length", "Petal Width", "Sepal Length", "Sepal Width") # Column headings with open ("Data/iris.csv") as f: # Link the csv file for line in f: ...
af735cafed55e50a6c9644415882223e8feec189
javanmattos/Othello-AI
/b78.py
41,802
3.96875
4
import random, sys, time, math, itertools from tables import * from opening_book import * from patterns_loader import * """ Throughout the code, you will see lots of magic hex numbers and bitwise operations. The top reversi programs have enormous portions of their codebase devoted to speeding up the move generation a...
c2bad1043e0499dfcd0fed9d617d9200ebede882
lijerryjr/MONIAC
/textFunctions.py
1,637
4.21875
4
################### # rightJustifyText # This contains the text justifier code from HW3 ################### import string def replaceWhiteSpace(text): #replace white space in text with normal spaces #inspired by recitation 3 video inWhiteSpace=False result='' for c in text: if not inWhiteSp...
9350d256f1005dc024e186d8711fae0191b61c20
alanmaranto/Basico-Algoritmos
/arte10.py
283
3.765625
4
import turtle myTurtle = turtle.Turtle() myWindow = turtle.Screen() def draw(myTurtle, length): if length > 0: myTurtle.forward(length) myTurtle.right(60) myTurtle.left(-60) draw(myTurtle, length-2) draw(myTurtle, 100) myWindow.exitonclick()