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
d800d63f49158fcbb0f2af79a9d315061e028fdb
jorzel/codefights
/arcade/intro/biuldPalindrome.py
575
4.25
4
""" Given a string, find the shortest possible string which can be achieved by adding characters to the end of initial string to make it a palindrome. Example For st = "abcdc", the output should be buildPalindrome(st) = "abcdcba". """ def isPalindrome(st): for i in range(len(st) / 2): if st[i] != st[-1 -...
0725fe8ef04175b03de2315a61be93a6bbf4aa2e
jorzel/codefights
/arcade/intro/firstDigit.py
414
4.28125
4
""" Find the leftmost digit that occurs in a given string. Example For inputString = "var_1__Int", the output should be firstDigit(inputString) = '1'; For inputString = "q2q-q", the output should be firstDigit(inputString) = '2'; For inputString = "0ss", the output should be firstDigit(inputString) = '0'. """ def fi...
48b634c329bd738bac5b9109f8b14278c1b9bb07
jorzel/codefights
/arcade/core/rectangleRotation.py
944
4.09375
4
""" A rectangle with sides equal to even integers a and b is drawn on the Cartesian plane. Its center (the intersection point of its diagonals) coincides with the point (0, 0), but the sides of the rectangle are not parallel to the axes; instead, they are forming 45 degree angles with the axes. How many points with in...
5ba2945537ef7e2f1045ee494c090d68b5fbb149
jorzel/codefights
/arcade/python/crackingPassword.py
1,370
4.0625
4
""" Easy Recovery 100 Implement the missing code, denoted by ellipses. You may not modify the pre-existing code. You've been trying to crack the password from your friend's laptop (just to prank him, malicious intent!), but with no luck. However, looks like you're finally up to something: you checked the keyboard wi...
610b9390cab19274ecf4c9cad6d42bb8e29905d9
jorzel/codefights
/bots/godaddybot/domainForwarding.py
2,860
3.984375
4
""" Domain name forwarding lets GoDaddy domain owners automatically redirect their site visitors to a different site URL. Sometimes the visitors have to go through multiple redirects before ending up on the correct site. Using the DNS Manager, GoDaddy customers can view redirects in a simple visual format. One handy f...
e520b1fc70883eacd427dc2b6ffe006d2f75d926
jorzel/codefights
/interview_practice/dynamic_programming_basic/climbingStairs.py
688
4.1875
4
""" Easy Codewriting 1500 You are climbing a staircase that has n steps. You can take the steps either 1 or 2 at a time. Calculate how many distinct ways you can climb to the top of the staircase. Example For n = 1, the output should be climbingStairs(n) = 1; For n = 2, the output should be climbingStairs(n) = 2....
7872f5adf499f79df9cec821fb8020c8f3bbadbb
jorzel/codefights
/arcade/core/fileNames.py
856
4.15625
4
""" 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 used yet. Return an array of names that will...
67e5a175e8e6067ffa3986f0418157a05e2059e6
jorzel/codefights
/arcade/core/maximumSum.py
1,259
4.09375
4
""" Medium Codewriting 300 You are given an array of integers a. A range sum query is defined by a pair of non-negative integers l and r (l <= r). The output to a range sum query on the given array a is the sum of all the elements of a that have indices from l to r, inclusive. You have the array a and a list of ran...
0e560565ad7817f019f80acef62f43e8f8e82ba4
jorzel/codefights
/bots/autodeskasia/licenceCheck.py
2,598
3.984375
4
""" You are given two tables products and users in a MySQL database. The products table has columns product_name and product_licenses (valid licenses for this product, separated by commas). The users table has columns user_name and product_licenses (licenses that this user has, separated by commas). Your task is to fe...
79907a750c9bffa2f140a3f1be68acf207da1f59
jorzel/codefights
/interview_practice/common_techinques_basic/containsDuplicates.py
640
4.15625
4
""" Given an array of integers, write a function that determines whether the array contains any duplicates. Your function should return true if any element appears at least twice in the array, and it should return false if every element is distinct. Example For a = [1, 2, 3, 1], the output should be containsDuplicate...
3e87f968e223e5f9eab7db6f3422b2fc2b5ddce6
jorzel/codefights
/bots/dattobot/incrementacBackups.py
1,701
3.921875
4
""" One of the easiest ways to back up files is with an incremental backup. This method only backs up files that have changed since the last backup. You are given a list of changes that were made to the files in your database, where for each valid i, changes[i][0] is the timestamp of the time the change was made, and ...
388748ed56911db4eefc35817dee3e0bafe07404
jorzel/codefights
/challange/maxPoints.py
1,212
4.15625
4
""" World Cup is going on! One of the most fascinating parts of it is the group stage that has recently ended. A lot of great teams face each other to reach the playoff stage. In the group stage, each pair of teams plays exactly one game and each team receives 3 points for a win, 1 point for a draw and 0 points for a l...
445dedbd9f368696693c8f12aacc3e8cc8424885
xiaomurong/bootcamp_cli
/index.py
1,816
3.734375
4
import click import requests # The entry point of the app @click.command() def cli(): # Show the user the intro message get_intro() # Prompt the user to enter a news source news_source = click.prompt("Please select a news source by entering its number or press enter for BBC", default=1) # Dictio...
91ffbd9dfa2c2a7eaf0ad033a46af0246291bb56
yishine18/net_safe
/mysocket/socket_client.py
2,150
3.640625
4
# import socket # s2 = socket.socket() # s2.connect(("127.0.0.1",2345)) # data = s2.recv(1024) # s2.close() # print ("receive data",repr(data)) # import socket # #in python3.7 # #if in python2.X ,input() will can't work! # def conn_socket(): # client = socket.socket() # ip_port=('127.0.0.1',2466) # clie...
35be2605ba1f7fa18c02c08783e8623701e51896
JSKing92/PYTHON
/mientras.py
357
3.640625
4
cadena = 'El pato hace quack' cadena = cadena.lower() print(cadena) print(len(cadena)) vocales = 0 posicion = 0 while posicion < 18: if(cadena[posicion]=='a' or cadena[posicion]=='e' or cadena[posicion]=='i' or cadena[posicion]=='o' or cadena[posicion]=='u' ): vocales = vocales+1 posicion=posicion+1 p...
a1b3512c0b2492e83f0dbaefe5aeb422da3325c2
dtzxyangq/learnGit
/pythonTrain/looptrain.py
229
3.828125
4
#!/usr/bin/env python3 sum = 0 for x in range(2,11,2): sum = sum + x print (sum) sum = 0 x = 2 while x < 11: sum = sum + x x = x + 2 print (sum) L = ['Bart', 'Lisa', 'Adam'] for name in L: print ('Hello, %s!' % name )
8f41b042e884a2721df346890d37f7938e56a023
ramsesh2/Coco
/MaxRev.py
3,137
4.0625
4
''' To select the companies to sell to in order to achieve maximum revenue Assumptions made: 1) Orders can only be completed in full. If a company requests 5 items at a price, then you can only sell them exactly 5. 2) The price given is the price the company is willing to pay for the total quantity given, NOT the...
620d5d8f93e089e965f118bbd770f1e6bb31e6f7
Nirzak/Security-Lab-Tasks
/Caesar Solver.py
1,861
4.0625
4
#!/usr/bin/python3 def caesar(string, shift): return "".join(chr(((ord(char) - 97 + shift)%26) + 97) if not char.isspace() else " " for char in string) def frequencyAnalysis(string): # Normalised frequency analysis freq = [0]*26 for c in string: if(c.isalpha()): freq[ord(c)-ord('a')]+...
408180cc6280c275126914eea6e8d2a93f69e454
vaultli/my-algorithm-learning
/Review/InsertionSort.py
666
3.78125
4
def insertionSort(arr, n): for i in range(n): j = i while j > 0 and arr[j - 1] > arr[j]: arr[j - 1], arr[j] = arr[j], arr[j - 1] j -= 1 return arr def insertionSortModified(arr, n): for i in range(n): e = arr[i] j = i while j > 0 and arr[j - 1] > e: arr[j] = arr[j - 1] j -= 1 arr[j] = e ...
83d79c134eca48718194223aeeabd90aee653f20
austinphilp/Pydoku
/pydoku/grid.py
6,329
3.96875
4
from square import Square class SquareCollection(object): """ A one dimmensional collection of square objects """ def __init__(self, squares): self._squares = squares @property def is_valid(self): """ Determine whether this collection is "valid" which is to say that no...
f17ba2ede15984ac894cb066f3605989d0116441
NikitaPlesovskix/Susu-101
/ex 18
977
4.1875
4
# Имеются две ёмкости: кубическая с ребром A, цилиндрическая с высотой H и радиусом основания R. # Определить, можно ли заполнить жидкостью объёма M первую ёмкость, вторую, обе. import math A = int(input("Ребро кубической ёмкости ")) R = int(input("Радиус основания цилиндрической ёмкости ")) H = int(input("Высота цилин...
2e8420dbdc995ecd6dca5813cb7ac280c87900ac
aimeecodes/adventofcode2020
/day9/encodingpart2.py
1,140
4
4
inputfile = './input.txt' with open(inputfile) as f: numbers = [line.rstrip('\n') for line in f] # cast all members of numbers as integers numbers = [int(x) for x in numbers] # initialize special number variable which holds the # number which is the sum of a contiguous set of at least # 2 numbers from input # note...
5ed98b3a4769abad7dd2251bee09c48ef22c19c4
aimeecodes/adventofcode2020
/day2/passwordpart1.py
1,586
3.9375
4
inputfile = './input.txt' with open(inputfile) as f: lines = [line.rstrip('\n') for line in f] # function that returns the number of specified # characters in a given string def NumberOfLetters(character, password): # create variable to hold number of times # character is found in password count = 0 # create ar...
67824e6082ab31fe72e716a85a950b106f066072
zhyordanova/Python-Fundamentals
/Exam-Preparation/Mid Exam/mu_online.py
900
3.625
4
health = 100 bitcoins = 0 dungeons_rooms = input().split("|") for i in range(len(dungeons_rooms)): room = dungeons_rooms[i] args = room.split() command = args[0] number = int(args[1]) if command == "potion": current_health = health health += number healed = number ...
d10c55d267ba3962b2310461dfb5156f4b912dd9
zhyordanova/Python-Fundamentals
/09-Regular-Expressions/LAB/01_match_full_name.py
118
3.8125
4
import re line = input() pattern = r"\b[A-Z][a-z]+\s[A-Z][a-z]+\b" names = re.findall(pattern, line) print(*names)
c4fa448d1dcf57c6450378a81f8f465ff4bca213
zhyordanova/Python-Fundamentals
/04-Functions/Exercise/09_factorial_division.py
294
4.15625
4
def calc_factorial(n): result = 1 for num in range(2, n + 1): result *= num return result number_1 = int(input()) number_2 = int(input()) factorial_1 = calc_factorial(number_1) factorial_2 = calc_factorial(number_2) res = factorial_1 / factorial_2 print(f"{res:.2f}")
233d9f88ed8ef39b128418bc43b416174833e807
zhyordanova/Python-Fundamentals
/09-Regular-Expressions/Exercise/03_find_occurrences_of_word_in_sentence.py
156
3.796875
4
import re text = input() word = input() pattern = r"\b" + re.escape(word) + r"\b" matches = len(re.findall(patter, text, re.IGNORECASE)) print(matches)
03774d711b764b0726293c4bec93c07a818932ee
zhyordanova/Python-Fundamentals
/Exam/Final-Exam/1.py
1,936
3.75
4
def replace(raw_message, current, new): raw_message = raw_message.replace(current, new) print(raw_message) return raw_message def cut(raw_message, start, end): if start > 0 or end < len(raw_message): print("Invalid indices!") else: if len(raw_message) > 0: raw_message =...
335c7a0b2aefbd394629c0c6713a4432aba0cb7b
zhyordanova/Python-Fundamentals
/Exam-Preparation/Mid Exam/the_final_quest.py
1,379
3.921875
4
words = input().split() def delete_word(index): if index + 1 in range(len(words)): words.remove(words[index + 1]) return words def swap_word(word_1, word_2): if word_1 in words and word_2 in words: index1 = words.index(word_1) index2 = words.index(word_2) words[index1], w...
60012890271e528050764fd122bb0e1175c3a1e8
zhyordanova/Python-Fundamentals
/08-Text-Processing/Exercise/04_ceasar_clipher.py
80
3.78125
4
text = input() result = [chr(ord(x) + 3) for x in text] print(''.join(result))
87cca2c560526d4ad4c0cf387625906672735b7f
zhyordanova/Python-Fundamentals
/01-Basic-Syntax-Conditional-Statements-and-Loop/Exercise/05_can`t_sleep_count_sheep.py
96
3.703125
4
number = int(input()) for count in range(1, number + 1): print(f'{count} sheep...', end='')
59b508a4d8cd26b98fd0329a0353dd80c4e5336d
lottege/heuristieken_smartgrid
/hillclimber.py
2,228
3.65625
4
''' / Makes a cable between a house and a battery in 2 ways: / 1: making new cables all alongside each other / 2: connecting cables all together / plot met mat plot lib ''' import experimentimportTXT # import visualisation as vis import classes import random # from buitennaarbinnen import cost_bb cable_list = [] ne...
17cc925e50bccf532a88a84ef484758af6a0f117
ramlaxman/wdc-2021-jan-intro-python
/WDC — 2021 Feb 18.py
4,811
4.3125
4
#!/usr/bin/env python # coding: utf-8 # # Agenda # # 1. virtualenv # 2. Objects! # # In[1]: s = 'abcd' type(s) # In[2]: n = 123 type(n) # In[3]: d = {'a':1, 'b':2, 'c':3} type(d) # # What is an object? # # 1. `id` -- unique ID numbers # 2. `type` -- every object has a class/type # 3. attributes # In[4...
4ee3cc4557b7a98e89a5f973ff55e757caba3c6d
ramlaxman/wdc-2021-jan-intro-python
/wdc/address.py
2,815
3.828125
4
people = [] filename = 'people.data' while True: print(people) user_choice = input('Enter command: ').strip() if user_choice == 'q': break elif user_choice == 'a': # first_name = input('Enter first name: ').strip() # last_name = input('Enter last name: ').strip() # pho...
55784d86de19f169a697f0fd3d905e3be1f177b4
Trsak/ISJ
/isj_proj07_xsopfp00.py
2,734
3.59375
4
#!/usr/bin/env python3 class TooManyCallsError(Exception): """ Custom error message """ pass class Log: """ Class used for logging """ def __init__(self, file): """ Opens log file for reading. :param file: log file path """ self.file = open(file...
bd492e30f12f071799e6b2a39978ec0aaa68f4ad
ElliotFriend/pythonchallenge.com
/exercises/06.py
676
3.640625
4
# This URL: http://www.pythonchallenge.com/pc/def/channel.html # Next URL: http://www.pythonchallenge.com/pc/def/oxygen.html import zipfile zfile = zipfile.ZipFile(open('../data/06.zip', 'r')) next_nothing = "Next nothing is " nothing = "90052" suffix = ".txt" answer = [] for name in zfile.namelist(): data = zf...
3c776c5c6acd091656e2b87ae1149b640f36ce34
ckdgml1031/Practice_py
/Python_prac_01.py
346
3.65625
4
#useageof python #if01 a=15 if a>5: a=a-10 print(a) #if02 a,b = 10,20 if a>b: cha = a-b print(cha) else: cha = b-a print(cha) #if03 a,b = 21,10 if a%2==0: if b%2==0: print("둘다짝") else : print("a짝,b홀") else : if b%2==0: print("a홀,b짝") else : print("...
2670bca2f4d4feb0eaf6c33df97a51c438380b21
uskovboris/coursera_bioinformatics
/neighbors_tests.py
1,444
3.53125
4
import unittest from neighbors import * class NeighboursTest(unittest.TestCase): def test_neighbours_d_equals_0(self): """d=0 test""" self.assertSetEqual(neighbors('ACG', 0), {"ACG"}) def test_neighbours_len_equals_1(self): """1 nucleotide len DNA test""" self.ass...
55a66104724e4ca6a2d624122ef0b89fd099c53b
pascal758/hyperskill-hangman
/hangman.py
1,444
3.96875
4
import random print('H A N G M A N') while True: choose = input('Type "play" to play the game, "exit" to quit:') if choose == 'play': list_words = ['python', 'java', 'kotlin', 'javascript'] random_word = random.choice(list_words) word_list = list('-' * len(random_word)) attem...
d04238b5570c6dbb4a1a7932974c61e560c530a1
arkss/MathAndComputer
/python/Miller_Rabin.py
543
3.71875
4
import random def Miller_Rabin(n): m = 0 k = 0 p = n - 1 while 1: if p % 2 == 0: k += 1 p = p / 2 else: m = p break a = random.randint(2,n-2) T = pow(a,int(m),n) if (T == 1) and (T == n-1): return "prime" for i...
fdacaba08025f49fefb82588cd9712a3a9e42381
vgilev/MyPythonCourse
/Max_Figure.py
293
3.75
4
number_in = int(input("Введите число больше 10 >>>")) while True: if number_in < 10: number_in = int(input("Введите число больше 10 >>>")) else: number_list = list(str(number_in)) print(max(number_list)) break
be4235811659b59029faf55207ecf3413c00f851
MulderPu/legendary-octo-guacamole
/codewars/first_non_repeated_letter.py
532
3.75
4
def first_none_repeated_letter(string): list = [] if string == "": return '' new_string = string.lower() for i in new_string: if not i in list: list.append(i) for i in list: if new_string.count(i) ==1: letter = i pos = [pos for pos,char in ...
ea6d0db5f16517eb8db4a3ade372cbe50b9b49a0
MulderPu/legendary-octo-guacamole
/python_calendar_part2.py
5,672
3.953125
4
import sys from calendar import weekday import calendar import datetime from dateutil.relativedelta import relativedelta def print_selection(): print('[C] Show new calendar after n years (user input)') print('[D] Show new date based on user input') print('[T] Show new time based on user input') def addSec...
8f4fb641afb383be3f5870418eb9b26f74ed1321
MulderPu/legendary-octo-guacamole
/codewars/multiple_3_and_5.py
321
3.5
4
def solution(number): list = [] lists = ['3','5'] for i in range(1,12): for j in range(len(lists)): result = int(lists[j]) * i if(int(result) < number): list.append(int(result)) else: break return sum(list) print(solution(10))...
ca8dd729003dd665c4e3fba57289fc4b315128ec
MulderPu/legendary-octo-guacamole
/pythonTuple_part1.py
767
4.15625
4
''' Write a Python program to accept values (separate with comma) and store in tuple. Print the values stored in tuple, sum up the values in tuple and display it. Print the maximum and minimum value in tuple. ''' user_input = input("Enter values (separate with comma):") tuple = tuple(map(int, user_input.split(','))) ...
71c4d79d3e982de8875def381e621b8a8dd46247
MulderPu/legendary-octo-guacamole
/guess_the_number.py
801
4.25
4
import random print('~~Number Guessing Game~~') try: range = int(input('Enter a range of number for generate random number to start the game:')) rand = random.randint(1,range) guess = int(input('Enter a number from 1 to %i:'%(range))) i=1 while (i): print() if guess == 0 or gue...
b13afc0735388f752477451a724d17c960fe47a2
MulderPu/legendary-octo-guacamole
/word_reverse.py
339
3.71875
4
def spin_words(sentences): lists = sentences.split(' ') print(lists) for i in range(len(lists)): if len(lists[i]) >= 5: new_words = lists[i][::-1] lists[i] = new_words new_sentence = ' '.join(lists) return new_sentence sentences = input('Enter sentences:') print(spin...
daa7208cdb4a9a3b3612bb25e1472ed4c4a16b61
MulderPu/legendary-octo-guacamole
/smart_looping_system.py
1,178
4.09375
4
''' Write a python program for the following output. Accept 3 values: Initial value, Ending value and Counter value for while loop. The program be able to determine it is either an Increase loop or a Decrease loop from the values input and display the values after the process.  If the value entered for Counter value to...
ba5929ff73e5e1f65f9bf83c674b714a09e291d6
hossainarif726/HackerRank_problems_solved_by_me
/Solevd_Problems/Triangle Quest.py
123
3.640625
4
#!/usr/bin/env python # coding: utf-8 # In[2]: for i in range(1,int(input())): print((10**(i)//9)*i) # In[ ]:
3dfd321e995b43748a7f9db4e5efed152747ff5b
hossainarif726/HackerRank_problems_solved_by_me
/Solevd_Problems/Validating phone numbers.py
228
3.53125
4
#!/usr/bin/env python # coding: utf-8 # In[2]: import re N = int(input()) for _ in range(N): st = input() s = re.findall('^[789]\d{9}$',st) if s: print('YES') else: print('NO') # In[ ]:
75fa5bd73f67fcf6cb9ef4dee956bd9a1b5f8547
mohanrajendran/Advent-of-Code
/2016-Python/day20/cidr.py
1,117
3.546875
4
def allowed(intervals, ip): for start, end in intervals: if ip >= start and ip <= end: return False return True def part1(): with open('input') as f: intervals = [] for line in f.readlines(): start, end = [int(i) for i in line.strip().split('-')] ...
adc2a2f586d4900023e263a7fb96c49767983a9a
mohanrajendran/Advent-of-Code
/2015-Python/Day 12/accounting.py
309
3.609375
4
import json def parse(obj): if type(obj) is list: return sum(map(parse, obj)) if type(obj) is int: return obj if type(obj) is dict: keys = obj.keys() return sum(parse(obj[k]) for k in keys) return 0 f = open('input.txt', 'r') j = json.load(f) print parse(j)
a0be4b8fb5ce033fee5f2a4c6cef30261342646c
HyowonKim1116/Sudoku
/sudoku-grade.py
2,030
3.75
4
# 1. 채점 함수 정의 def horizontal(board): #가로줄 채점 함수 for i in range(9): s = set(board[i]) #가로줄 리스트를 집합으로 변환 if len(s) < 9: #집합 s에 중복값이 있을 경우 return False #False 반환 return True #모든 가로줄에 중복이 없다면 True 반환 def vertical(board): #세로줄 채점 함수 for i in range(9): s = set() ...
eed8131880194e5329fe3413e8b3c99f24faa54b
TophTab/Learning_python_firsttime
/basic_knowledge/8_3_4.py
501
4.09375
4
def build_full_name(first_name,last_name,middle_name=''): if middle_name: full_name=first_name+' '+middle_name+' '+last_name else: full_name=first_name+' '+last_name return full_name.title() while True: print('\ntell me ur name:') print('(enter "q" to exit)') f_name=input('first...
f0dda5c52d598325631b123f2c5f8aeeec028456
TophTab/Learning_python_firsttime
/basic_knowledge/5_2_4.py
158
4.1875
4
ages=[18,15,2,66] for age in ages: if age>=18: print("adult") elif age<18 and age>12: print("teenager") else: print('kid')
c1e285dbe8da19ee27fc589d294f1d582fddf041
chepel-vn/homework_iterators
/GeneratotMD5.py
983
3.96875
4
import hashlib # Function read text file and get hash function md5 from next string of file def get_next_hash_string_from_file(filename): """ (string) -> hash object or None Function get iterable information from text file """ try: with open(filename, encoding="utf8") as file: ...
0a7d823632f8425923c0343f9b52a4e19da7f567
Aashish647/GUVI_submissions
/repeated_nums.py
367
3.671875
4
def counter(num): d = {} for i in num: if num.count(i)>1: d[i] = num.count(i) res="" for i in d: if d[i]>1: res.append(i) print int(res) num = (raw_input().strip()) res="" try: num = int(num) except: print "input should be a string" exit(0)...
eeada3386755f9c44edc4b0d7231ef2260c6c47f
mkessy/umnopendata
/opendataapi/umnopendata/utils.py
2,220
3.5625
4
import re def parse_class_description(desc): """ Parse a course description returning the following class parameters in dictionary format: start_time end_time days sectionnumber credits type (LEC, DIS, IND, etc.) """ class_time_re = re.compile( r'(?P<times>0([1-9...
8cebfa5a38b110b09b2acdc6bd927ab1a22e52ba
gaotiecheng1982/pythonSample
/dataStructure/bubbleSort/bubbleSort.py
589
3.9375
4
#!/usr/bin/python3 # 冒泡排序 二层循环格式 def bubblesort(lst): n = len(lst) for i in range(n,1,-1): # i = n, n-1, n-2, ..., 2 print("") for j in range(n): print(str(lst[j]), " ", end="") print(" ") # 截取 A 的前i个元素进行冒泡 for j in range(i-1): if lst[j] < lst[j+1]...
520cb94d14660c93b05511d36a91bc3f8d0ea3b6
imhyo/codejam
/kruskal.py
499
3.53125
4
from graph import Graph from union_find import UnionFind # Kruskal's minimum spanning tree algorithm def kruskal(graph): ret = 0 result = [] edges = [] for u in graph: for v, c in graph[u]: edges.append((u, v, c)) edges.sort(key=lambda x: x[2]) uf = UnionFind(len(graph.V)) ...
d3289468d50958d92c5b9278d28a90f537418e36
PDXCodeGuildJan/AndreaCGPDX
/pythongames/helloworld copy.py
80
3.90625
4
saying = "hello world" name = input("What is your name? ") print(saying, name)
21fa7894c4e15ac9b3a4e065a581233f2d29309c
PDXCodeGuildJan/AndreaCGPDX
/pythongames/phonebook.py
3,051
4.34375
4
"""Implements a very simple phonebook using a Dictionary""" __author__ = "Andrea L. Flack" import re # Initialize our dictionary, which will store our phone number phonebook = {} def main(): """the main driver function of our Phonebook""" # load existing data in to phonebook load_phonebook() print("phonebook aft...
35c48ed308a44a6dd4c4f2941cc0405ef609edad
kikihiter/PythonLearning
/sortingAlgorithmPython/heapSort.py
2,764
4.125
4
#!user/bin/env python #python heapSort.py #kiki 18/04/27 #保证根节点为最大的 def maxChange(heap,size,i): #分别有三个参数,heap为传入的列表,size为列表长度,i为当前根节点索引号 root = i left = i*2+1 #左子节点 right = i*2+2 #右子节点 """ if left<size and heap[root]<heap[left]: heap[root],heap[left] = heap[left],heap[root] left,roo...
de6de075709d7aa7e3ba41364a17d50c439673c8
OualhaSlim/Algorithmic-Toolbox
/algorithmic_warmup/2_last_digit_of_fibonacci_number.py
268
4.0625
4
def fibonacci_digits(n): if n <= 1: return n f0 = 0 f1 = 1 i = 2 while(i<=n): f0,f2 = f1,(f0+f1) % 10 f1 = f2 i += 1 return f2 if __name__ =='__main__': n = int(input()) print(fibonacci_digits(n))
bc310f2136318bb449a0d7fbe27a8b66a4252948
saurabh3796/practice
/CycleLinkList.py
264
3.796875
4
def has_cycle(head): if head is None: return 0 temp = head temp1 = head while temp and temp1 and temp1.next: temp = temp.next temp1 = temp1.next.next if temp == temp1: return 1 print(0) return 0
aaecd5dcfef773a53a501f34ff60447a2e5b97e0
jmlatham/My-Tests
/classes/LeapYear.py
537
3.6875
4
class LeapYear: def __init__(self): pass def determineYearStatus(self, year): # if not isinstance(year, int): # return "invalid data" try: yearInt = int(year) if yearInt < 1582: return "Not within the Gregorian calendar period!" elif yearInt % 4 != 0: ret...
06a9916f27c1cf28de8c033298f7ef40edaa1075
the-pandey-ji/Numpy
/numpy1/numpy1.py
257
3.75
4
# Create numpy array import numpy as np arr=np.array([[1,2,3,4,5,6],[1,2,3,4,5,6]]) print(arr) print(type(arr)) # no. of dimention in np array print(arr.ndim) # no. of element in array print(arr.size) # shape of array print(arr.shape) print(arr.dtype)
0f5d92f6644ea9f149b8e4c274332b76654ca6c6
mohdsameer7408/gui_in_python
/message.py
354
3.625
4
from tkinter import * from tkinter import messagebox root = Tk() root.title("Static") root.iconbitmap('images/logos/my-ic.ico') def popup(): # created a message box... response = messagebox.askyesno("This is my popup", 'Hello World!!!') Label(root, text=response).pack() Button(root, text='Popup', comma...
fa9f458246e4025303276cb0d78125fe1b1a05f7
RafaelAraujoCv/Jogo_python
/adivinhacao_for.py
3,922
3.984375
4
import random #adiciona biblioteca(modulo) do random, para numero aleatorio def jogar(): #codigo abaixo vira uma função criada pelo "def" >>>> função jogar(): print("********************") print("Bem vindo ao jogo de adivinhação !") print("********************") numero_secreto = random.randra...
6619d2d052cbcd8a901edec4e23e8c398e7f8002
PaytonCrawford1/astr-119-hw-2
/Payton/variables_and_loops.py
232
3.59375
4
import numpy as np def main(): i=0 n=10 x=119.0 y=np.zeros(n,dtype=float) for i in range(n): y[i]=2.0*float(i) + 1 for y_element in y: print(y_element) if __name__== "__main__": main()
b365cef1164f57fd8e3fe27c470a639f6abade96
avs-abhishek123/DSA-Projects
/HW2/DSA HW2 Ruiyu Zhang/Q1/2.1.py
1,877
3.65625
4
# -*- coding: utf-8 -*- """ Created on Mon Feb 12 14:13:23 2018 @author: Ruiyu Zhang rz213 """ #HOMEWORK 2 QUESTION 1 import random import time #define functions def my_insertsort(a): swap,comp=0,0 t1=time.clock() for i in range(1,len(a)): for j in range(i,0,-1): comp+=1 i...
c090cb814632d258ee1f2eabd1c348a275c02f6a
Username-self/Scrabble
/board.py
2,865
3.90625
4
from math import floor class Board: WIDTH = 15 def __init__(self): self.board = [[None for _ in range(Board.WIDTH)] for _ in range(Board.WIDTH)] def __str__(self): column_labels = ' |' + '|'.join(map(Board.label_to_string, range(Board.WIDTH))) return column_labels + '\n' + '\n...
618b75b4d5f2ec2b4dc3829f4c0b7f4ede5ccc2a
Beard12/algorithms
/selectionsort.py
324
3.59375
4
import random def selectionSort(arr): for j in xrange(len(arr)): minu = arr[j] idx = j for x in xrange(j,len(arr)): if arr[x] < minu: minu= arr[x] idx = x arr[idx] = arr[j] arr[j]=minu arr = [] for x in range(0,100): arr.append(random.randint(0,10000)) print arr selectionSort(arr) print arr ...
31740915c45ca11fceaab6ede2e4a84679cbfacc
rayhan50001/Additional_Codes
/Python/Quadratic Equations.py
1,186
4.09375
4
#pyramid n=int(input("Enter Size to Print Pyramid: ")) nn=n print(1) for i in range(n+1): for j in range(i): print("*",end=" ") print("\r") for i in range(n-1,0,-1): for j in range(i): print("*",end=" ") n=n-1 print("\r") print(2) for i in range(nn+1): len=nn-i+1 for j in ra...
e6d095a87b13f20b968ae4a22a8775af0a99f995
arvindr21/python-ml
/examples/3-supervised-learning/decision-tree.py
1,117
3.609375
4
# Video: https://www.youtube.com/watch?v=84gqSbLcBFE&list=PLOU2XLYxmsIIuiBfYad6rFYQU_jL2ryal&index=4 # import Iris dataset from sklearn import datasets iris = datasets.load_iris() # Features X = iris.data # Labels y = iris.target # A classifier is an equation # f(X) = y # f(X) => Features # y => Labels # Partition ...
da282d56b68a77f4709c5b3ab11a580d35bd346b
ChuyueL/COMS20011_2020
/labs/lab_1/product.py
448
4.09375
4
from __future__ import print_function import sys def product(numbers): """Function to return the product of two numbers Params: numbers: List of two numbers to be multiplied Returns: product of two numbers """ #Write your solution here prod = int(numbers[0]) * int(numbers[1]) ...
0b75b4e4818d473ec5311918804a89518e999ac4
GiftofHermes/4op
/4op_Random.py
601
3.84375
4
import random big_numbers = (100,75,50,25) small_numbers = (1,2,3,4,5,6,7,8,9,10) def generate_goal(): return random.randrange(100,1000) def generate_littles(): littles = [0,0,0,0,0,0] for i in range(6): littles[i] = random.randrange(1,11) while littles.count(littles[i]) > 2: ...
de771923dfa085d0d2a624f9406f329fcc301020
zjacokes/ucsd_python
/zacharyjacokes_a6.py
2,278
3.90625
4
import random pokemon_type = ['fire', 'electric', 'grass'] pokemon_char = ['cute', 'cool', 'scary'] pokemon = ['Charmander', 'Rapidash', 'Moltres', 'Pikachu', 'Electabuzz', 'Zapdos', 'Bulbasaur', 'Exeggutor', 'Victreebel'] print("\n -- Welcome to the beginning of your new Pokemon adventure! Let\'s find out ...
583995f58ed96cc5cd333220b9ba8404043f0c5d
MissObange/Andela_Boot_Camp_day3
/word_count_solution.py
296
3.59375
4
def words(word): string_dict = {} list_of_words = word.split() for word in list_of_words: if word.isdigit(): word = int(word) if word in string_dict: string_dict[word] += 1 else: string_dict[word] = 1 return string_dict
2dba639bceecadab2416ce182a200ddd9d3a7f87
DirceuMaraschin/PPGC-FIA
/estados.py
3,732
3.5
4
#!/usr/bin/env python # -*- coding: utf-8 -*- from regras import * class Estados: estados = [] pai_estados = None movimento = [] def __init__(self, estados, referencia): self.estados = estados[:] self.pai_estados = referencia #referencia ao pai def gera_filhos(self, turno): ...
ce71585126ae1e765a99600203ba6e2585860f60
ProNilabh/Class12PythonProject
/Q11_RandomGeneratorDICE.py
307
4.28125
4
#Write a Random Number Generator that Generates Random Numbers between 1 and 6 (Simulates a Dice) import random def roll(): s=random.randint(1,6) return s xD= str(input("Enter R to Roll the Dice!-")) if xD=="r": print(roll()) else: print("Thanks for Using the Program!")
815e512a8e83f37f30d940aa0c61114ce4d02eea
kurdam/BTS_sio
/Thomas/Python/DS1/statchains.py
574
3.578125
4
chaine = input("entrez la chaine à analyser :\n") maxi = len(chaine) car_count = 0 voy_count = 0 voy_range = "aeiouy" cons_count = 0 cons_range = "zrtpqsdfghjklmwxcvbn" ponc_count = 0 for i in range (0, maxi, 1): if (chaine[i] in (voy_range)): voy_count += 1 car_count += 1 elif (chaine[i] in (cons_range)): cons...
d5cad84f5d1ef6ded1f09766dc229a431bf67f4e
redachour/project-3
/work_log.py
8,175
3.9375
4
import csv import datetime import os import re import sys # Helper to clean the screen def clear(): os.system('cls' if os.name == 'nt' else 'clear') # main menu with 3 options def main_menu(): clear() print('''\n\n\t\tMAIN MENU:\n\n 1 - Add new entry 2 - Search for existing entry ...
35ad063cb1c4f96549ed52ce46ce415bff73a0ea
sd18fall/music_visualizer
/audio_visualizer.py
5,150
3.984375
4
"""We are creating an Interactive Music Visualizer users input an MP3 file into the program which generates a movie with data extracted from the music file. This program will run prior to playing the movie and music at the same time, and will preprocess the audio data to generate the Computational Art equations that wi...
014674cad94445da44a1c2f258777d6529687270
Raghavi94/Best-Enlist-Python-Internship
/Tasks/Day 8/Day 8.py
2,983
4.21875
4
#TASK 8: #1)List down all the error types and check all the errors using a python program for all errors #Index error #Name error #zerodivision error a=[0,1,2,3] try: print(a[1]) print(a[4],a[1]//0) except(IndexError,ZeroDivisionError): print('Index error and zero division error occured') ...
00a3102ec9b0721494842761f50234280ea1b356
fernando2xV/easy21
/environment.py
2,001
3.609375
4
#Fernando Victoria easy21 #Description of easy21: # Infinite deck of cards (cards with replacement) # Cards are in range [1,10], P[red] = 1/3, P[black] = 2/3 # No aces/picture cards # At the start --> dealer and player draw 1 black card each (fully observed) # Each turn the player can a) stick b) hit # a) Don'...
4236a0f51e09c3ab4d5140325de3a2a2aacb4f38
moniquedesalvo/HB_Intro_to_Programming
/exercise5.py
1,072
4.0625
4
# Problem 4 #1) Broken code: fix the syntax and other errors in this code, #2) comment on what each line of code is doing #please assign values to the variables' my_name = "Monique" my_height = 63 pet_age = 10 pet_eyes = "green" pet_hair = "multi-colored" pet_name = "Charlene" pet_weight = 7 def string_formatting():...
12a4e3efe3bab1a24c84ad07bb61e227dec54643
CheeryW/Work-Reminder
/scripts/my_script.py
2,075
3.828125
4
"""Script to run some part of my project.""" # This adds the directory above to our Python path # This is so that we can add import our custom python module code into this script import sys sys.path.append('../') # Imports import datetime as dt from my_module.functions import send_email, send_timed_email ### ### se...
4a8e19ee33db599334253c6b64d878e281293757
nsragow/SeleniumCodeExample
/Example.py
1,126
3.546875
4
#Imports from selenium import webdriver from selenium.webdriver.common.keys import Keys import time def wait_until_user_exits(): should_exit = False while not should_exit: try: time.sleep(10) should_exit = driver.window_handles.__len__() == 0 except Exception as e: ...
00b75b92ccda9b8cd04760da415f1aebb5bc0e03
nikhl/Miscellaneous
/src/multiplication_table.py
490
4.28125
4
# Take as input a number and print all the multiplications from 1 upto that number def print_multiplication_table(n): i = 1 while i<=n: j = 1 while j<=n: print '%d * %d = %d' % (i,j,(i*j)) j = j+1 i = i+1 # test cases print_multiplication_table(2) #>>> 1 * 1 = 1 #>>> 1 * 2 = 2 #>>> 2 * 1 = 2 #>>> 2 * 2 ...
95a001a14ced2f66cfce94ea2f862378fd5b90b4
Vigneshthanga/hadoop3a-2
/mapper.py
875
3.578125
4
#!/usr/bin/env python """mapper.py""" import sys rc =0 val=0 cc = 0 # input comes from STDIN (standard input) for line in sys.stdin: # remove leading and trailing whitespace line = line.strip() if (rc == 0): rc+=1 continue # split the line into words cc = 0 words = line.split('...
10137ea7013a16bef47a8ccb6b3dcfa521872b9d
harleencore/godeep
/weekly_rating.py
1,275
3.890625
4
hours = 0 intensity = 0 breakthroughs = 0 goals = 0 committed_changes = 0 print("\n") print("NUMBER OF HOURS") num_hours = float(input("How many hours did you clock in this week? ")) hours = num_hours/25 print("hours:", hours, "\n") print("INTENSITY") print("How would you rate the effectiveness of your deep work ses...
fb83ff996efaafe5a6b1b92f740dace592feef60
brettaphillips/LPTHW
/ex2.py
395
3.578125
4
# LCTHW - Exercise 2: Comments and Pound Characters # By: Brett A Phillips # Date: February 3, 2013 # A comment, this is so you can read your program later. # Anything after the # sign is ignored by python. print "I could have oe like this." # and the comment after it is ignored. # You can also use a comment to "dis...
f9ab385a9b1e9eaa15aaa5bfe09bb23bf5b93bb2
alejandromarinculcha/MisionTIC_Ciclo1
/RETOS/utilidades.py
1,110
3.734375
4
def clases(cadena): lista = [] for i in range(0, len(cadena)-1): if (cadena[i] in cadena) and (cadena[i] not in lista): lista.append(cadena[i]) return lista def faltan(lista1, lista2, clase): posicion = [] for i in range(0, len(lista2)): if clase == lista2[i]...
3b2a290a63decca873f65e72baa3c3c8616f529e
alejandromarinculcha/MisionTIC_Ciclo1
/Tablas_Multiplicar.py
203
3.734375
4
# Tablas de multiplicar del 1 al 9 def tablas(n): for i in range(1, 11): Resultado = n*i print(n, "X", i, "=", Resultado) for j in range(1, 10): tablas(j) print()
821bf8bee67c6319a4b071b43fe51f0334f34b5f
alejandromarinculcha/MisionTIC_Ciclo1
/Listado_1_al_100.py
586
3.953125
4
# Imprimir un listado con los números del 1 al 100 cada uno con su respectivo cuadrado. x = 1 while (x <= 100): print(x, (x**2)) x += 1 # Imprimir un listado con los números del 100 al 1 cada uno con su respectivo cuadrado. x = 100 while (x >= 1): print(x, (x**2)) x -= 1 # Imprimir...
bc64467b3fb3c141484f3c9323000490ecdbf3c4
alejandromarinculcha/MisionTIC_Ciclo1
/Cuadrado_Matriz.py
246
3.71875
4
def cuadrados_matriz(X): Y = [] for i in range(len(X)): fila = [] for j in range(len(X[i])): fila.append(X[i][j]*X[i][j]) Y.append(fila) return Y print(cuadrados_matriz([[1, -3, 2], [4, 11, -1]]))
dabe424a11f936578836d0cbcd0cd751365a028d
nicogra98/whattsapp_bot
/whatsapp_bot.py
1,190
3.734375
4
from selenium import webdriver import os import sys """ @Author Nicolas Granados A bot made for whattsappweb to annoy your friends ex: python whattsapp_bot name_of_file name_of_chat """ class WhattsappBot(): """ We define a whattsappbot object """ def __init__(self,file_name,chat): self.driver = webdri...
14381d1a3b700634dd761ebcd69785425370b0ba
tosteve189/SeleniumPythonDemo
/Demo/UnitTestExamples3.py
832
3.640625
4
import unittest from Examples import Example class MyTestCase(unittest.TestCase): @classmethod def setUpClass(Example): print("setUpClass executed") def setUp(self) -> None: print("setUp executed") def test_add(self): self.assertEqual(Example.add(self, 10, 20), 30) sel...
0697fc177dcd58970ce3e224dea1f55c953a1a06
ardenchaing/Chess_Openings
/code/ml.py
7,831
3.703125
4
""" Constructs and trains a machine learning model on the featured data. """ import pandas as pd from sklearn.tree import DecisionTreeClassifier from sklearn.model_selection import train_test_split from sklearn.metrics import accuracy_score def opening_model(cleaned): """ Returns the trained Decis...