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
d29dade29735f037b8e9e7858389a9068a3ccf50
akimi-yano/algorithm-practice
/lc/review2_5.LongestPalindromicSubstring.py
968
3.796875
4
# 5. Longest Palindromic Substring # Medium # 18296 # 1084 # Add to List # Share # Given a string s, return the longest palindromic substring in s. # Example 1: # Input: s = "babad" # Output: "bab" # Explanation: "aba" is also a valid answer. # Example 2: # Input: s = "cbbd" # Output: "bb" # Constraints: ...
8879cb3d49db25ece9e53a19d686c43cd186cec3
akimi-yano/algorithm-practice
/lc/1738.FindKthLargestXORCoordinate.py
3,304
3.75
4
# 1738. Find Kth Largest XOR Coordinate Value # Medium # 62 # 10 # Add to List # Share # You are given a 2D matrix of size m x n, consisting of non-negative integers. You are also given an integer k. # The value of coordinate (a, b) of the matrix is the XOR of all matrix[i][j] where 0 <= i <= a < m and 0 <= j <= b...
5b096ae02de83a983ce31a25bf932cb78a33d856
akimi-yano/algorithm-practice
/lc/review_695.MaxAreaOfIsland.py
1,576
3.625
4
# 695. Max Area of Island # Medium # 3437 # 111 # Add to List # Share # You are given an m x n binary matrix grid. An island is a group of 1's (representing land) connected 4-directionally (horizontal or vertical.) You may assume all four edges of the grid are surrounded by water. # The area of an island is the nu...
6d835fbceb009717acdd5a784ac539dd464e0418
akimi-yano/algorithm-practice
/lc/572.SubtreeOfAnotherTree.py
1,751
4.09375
4
# 572. Subtree of Another Tree # Easy # 3216 # 160 # Add to List # Share # Given two non-empty binary trees s and t, check whether tree t has exactly the same structure and node values with a subtree of s. A subtree of s is a tree consists of a node in s and all of this node's descendants. The tree s could also be ...
6391a7a5cc9287ce0a46f34128b68bf2f408f8a5
akimi-yano/algorithm-practice
/lc/1697.CheckingExistenceOfEdgeLength.py
3,895
3.6875
4
# 1697. Checking Existence of Edge Length Limited Paths # Hard # 49 # 3 # Add to List # Share # An undirected graph of n nodes is defined by edgeList, where edgeList[i] = [ui, vi, disi] denotes an edge between nodes ui and vi with distance disi. Note that there may be multiple edges between two nodes. # Given an a...
c197d5eec878514d151d4596f5f35f3e32590227
akimi-yano/algorithm-practice
/lc/448.FindAllNumbersDisappearedInA.py
876
3.8125
4
# 448. Find All Numbers Disappeared in an Array # Easy # 5149 # 338 # Add to List # Share # Given an array nums of n integers where nums[i] is in the range [1, n], return an array of all the integers in the range [1, n] that do not appear in nums. # Example 1: # Input: nums = [4,3,2,7,8,2,3,1] # Output: [5,6] ...
caaeb39a359f4374f3e5ac0a42ea82c4f8e264dc
akimi-yano/algorithm-practice
/lc/120.Triangle.py
1,852
3.8125
4
# 120. Triangle # Medium # 2812 # 311 # Add to List # Share # Given a triangle array, return the minimum path sum from top to bottom. # For each step, you may move to an adjacent number of the row below. More formally, if you are on index i on the current row, you may move to either index i or index i + 1 on the n...
5492929768a222cdce9fd74bee508dd53bdbb45f
akimi-yano/algorithm-practice
/lc/WordSearchII.py
5,926
3.75
4
# Word Search II class Solution: # TLE!!! dont use this # def findWords(self, board: List[List[str]], words: List[str]) -> List[str]: # Input: # board = [ # ['o','a','a','n'], # ['e','t','a','e'], # ['i','h','k','r'], # ['i','f','l','v'] # ] # ...
7b73c85ef25724d457d80c55efbb0698f2c49fa8
akimi-yano/algorithm-practice
/lc/1716.CalculateMoneyInLeetcodeBank.py
1,761
3.609375
4
# 1716. Calculate Money in Leetcode Bank # Easy # 29 # 0 # Add to List # Share # Hercy wants to save money for his first car. He puts money in the Leetcode bank every day. # He starts by putting in $1 on Monday, the first day. Every day from Tuesday to Sunday, he will put in $1 more than the day before. On every s...
7a1e8dfd5c13bad4a6ea5fb00b17bee606b7510f
akimi-yano/algorithm-practice
/lc/review_1332.RemovePalindromicSubsequences.py
1,553
4.0625
4
# 1332. Remove Palindromic Subsequences # Easy # 617 # 765 # Add to List # Share # You are given a string s consisting only of letters 'a' and 'b'. In a single step you can remove one palindromic subsequence from s. # Return the minimum number of steps to make the given string empty. # A string is a subsequence o...
ad9fbd248bf7b1b325ba6fb1671ae651fd57e235
akimi-yano/algorithm-practice
/lc/127.WordLadder.py
3,976
3.796875
4
# 127. Word Ladder # Given two words (beginWord and endWord), and a dictionary's word list, find the length of shortest transformation sequence from beginWord to endWord, such that: # Only one letter can be changed at a time. # Each transformed word must exist in the word list. # Note: # Return 0 if there is no such...
c101d600f039374d01d948ee1518b54f61cbe986
akimi-yano/algorithm-practice
/lc/1808.MaximizeNumberOfNiceDivisors.py
1,838
4.03125
4
# 1808. Maximize Number of Nice Divisors # Hard # 73 # 90 # Add to List # Share # You are given a positive integer primeFactors. You are asked to construct a positive integer n that satisfies the following conditions: # The number of prime factors of n (not necessarily distinct) is at most primeFactors. # The numb...
9638d7c0f387506216a3ffce18ccbe121682cddc
akimi-yano/algorithm-practice
/lc/1718.ConstructTheLexicographically.py
2,365
3.953125
4
# 1718. Construct the Lexicographically Largest Valid Sequence # Medium # 61 # 5 # Add to List # Share # Given an integer n, find a sequence that satisfies all of the following: # The integer 1 occurs once in the sequence. # Each integer between 2 and n occurs twice in the sequence. # For every integer i between 2...
2ec7bcb7d3343d94de742dd8528ccaa0eb3481e4
akimi-yano/algorithm-practice
/lc/1313.DecompressRun-LengthEncodedLi.py
1,243
3.671875
4
# 1313. Decompress Run-Length Encoded List # Easy # 293 # 636 # Add to List # Share # We are given a list nums of integers representing a list compressed with run-length encoding. # Consider each adjacent pair of elements [freq, val] = [nums[2*i], nums[2*i+1]] (with i >= 0). For each such pair, there are freq ele...
aba38a79ae828aa68980a60ea6425723f68d1cff
akimi-yano/algorithm-practice
/tutoring/mockP/mockInterview12.py
1,809
3.5625
4
# Given an array of meeting time intervals consisting of start and # end times [[s1,e1],[s2,e2],...] (si < ei), find the minimum number # of conference rooms required. # Example 1: # Input: [[0, 30],[5, 10],[15, 20]] # Output: 2 # 0 30 -> 1 # 5 10 15 20 -> 1 # ...
03acc8aca6ea3e7410fc8bb08f72549740b7d5bf
akimi-yano/algorithm-practice
/lc/236.LowestCommonAncestorOfBinar.py
2,077
3.921875
4
# 236. Lowest Common Ancestor of a Binary Tree # Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree. # According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined between two nodes p and q as the lowest node in T that has both p and q as descendants (...
e4a7d1f310d338e5e64b1ad14ae740f5456c61bf
akimi-yano/algorithm-practice
/lc/review_376.WiggleSubsequence.py
2,079
3.796875
4
# 376. Wiggle Subsequence # Medium # 1550 # 75 # Add to List # Share # Given an integer array nums, return the length of the longest wiggle sequence. # A wiggle sequence is a sequence where the differences between successive numbers strictly alternate between positive and negative. The first difference (if one exi...
f2ec83131298fd44f3966e637b944e3667885a12
akimi-yano/algorithm-practice
/lc/review_629.KInversePairsArray.py
1,635
3.640625
4
# 629. K Inverse Pairs Array # Hard # 1131 # 136 # Add to List # Share # For an integer array nums, an inverse pair is a pair of integers [i, j] where 0 <= i < j < nums.length and nums[i] > nums[j]. # Given two integers n and k, return the number of different arrays consist of numbers from 1 to n such that there a...
571b56701fd3fcc74c28f9a04bf4dcac07c62aa2
akimi-yano/algorithm-practice
/lc/63.UniquePathsII.py
1,726
4
4
# 63. Unique Paths II # Medium # 2754 # 295 # Add to List # Share # A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). # The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corner of the grid (marked 'Finish'...
323585745e2d7f83533a0c8b7273619c21b8ff2b
akimi-yano/algorithm-practice
/lc/1936.AddMinimumNumberOfRungs.py
2,606
4.28125
4
# 1936. Add Minimum Number of Rungs # Medium # 123 # 9 # Add to List # Share # You are given a strictly increasing integer array rungs that represents the height of rungs on a ladder. You are currently on the floor at height 0, and you want to reach the last rung. # You are also given an integer dist. You can only...
9d57660c7872dedcd0afd609e759830402546fd3
akimi-yano/algorithm-practice
/lc/980.UniquePathsIII.py
5,221
3.546875
4
# 980. Unique Paths III # Hard # 887 # 75 # Add to List # Share # On a 2-dimensional grid, there are 4 types of squares: # 1 represents the starting square. There is exactly one starting square. # 2 represents the ending square. There is exactly one ending square. # 0 represents empty squares we can walk over. #...
f1f10367df1a478a0f6338cdb9f9acabe2ad85df
akimi-yano/algorithm-practice
/lc/1567.MaximumLengthOfSubarrayWith.py
2,898
4.09375
4
# 1567. Maximum Length of Subarray With Positive Product # Given an array of integers nums, find the maximum length of a subarray where the product of all its elements is positive. # A subarray of an array is a consecutive sequence of zero or more values taken out of that array. # Return the maximum length of a suba...
b1cc4d292c14b35f3cbc92cee94099862d582d5b
akimi-yano/algorithm-practice
/lc/1631.PathWithMinimumEffort.py
5,657
4.15625
4
# 1631. Path With Minimum Effort # Medium # 88 # 4 # Add to List # Share # You are a hiker preparing for an upcoming hike. You are given heights, a 2D array of size rows x columns, where heights[row][col] represents the height of cell (row, col). You are situated in the top-left cell, (0, 0), and you hope to travel...
a29385f47b9ef6da4bc12989c9fb546666ceeece
akimi-yano/algorithm-practice
/lc/782.TransformToChessboard.py
3,626
4.125
4
# 782. Transform to Chessboard # Hard # 243 # 261 # Add to List # Share # You are given an n x n binary grid board. In each move, you can swap any two rows with each other, or any two columns with each other. # Return the minimum number of moves to transform the board into a chessboard board. If the task is imposs...
4a0d635cdc528e8a01db872dcdc2be6a02fbc0b7
akimi-yano/algorithm-practice
/lc/140.WordBreakII.py
3,801
3.875
4
# Word Break II # Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, add spaces in s to construct a sentence where each word is a valid dictionary word. Return all such possible sentences. # Note: # The same word in the dictionary may be reused multiple times in the segmentatio...
7c9d8921e1b99f857b02d48735c29112dec60e5d
alexanderGGreenberg/Spring_2018_WICC_OSC
/src/python.py
323
3.84375
4
# Your friend has become a firm python fanatic, # to the point where he will only speak in sentences # that contain all of the letters in the word python # Your objective is, given a string, return true if # it contains all the letters p, y, t, h, o, n, and return # false otherwise def python(sentence): p...
510dce9ef0110dee3280924427c9c952da0c255f
diadzine/buckets
/buckets.py
1,707
3.90625
4
""" buckets.py Bucket game in Python (2/3). How to play? >>> from buckets import * >>> m = Manager() >>> p = BucketPlayer(m) >>> p.playGame(3, 5, 4) # Bucket A=3L, B=5L, Want=4L Solution is [0, 0] [0, 5] [3, 2] [0, 2] [2, 0] [2, 5] [3, 4] >>> """ class Manager: """ Manage game queue. Keep track of states a...
e637715b1411f9bacf1c1c3d00b225c265915e35
zhan01/guess-numbers
/guess_number.py
426
3.9375
4
number = 77 guess = input("\nGuess: ") guess = int(guess) counter = 1 while guess != number : if guess > number : print("Guess lower!") else: print("Guess higher!") print("-------------") guess = input("\nTry again: ") guess = int(guess) ...
b9861a7e891faecd6338172c428d790c732922b1
varora24/Find-My-Game
/binary_search.py
1,753
3.75
4
#!/usr/bin/env python3 #Creates a list for all of the values of a specific category def make_list(arr, category, val): #Checks for special players instance of call if(category == "Maxplayers"): return make_list_players(arr, category, val) position = binary_search(arr, category, 0, len(arr), val) #Che...
87e05c7adbfef0eb974c5c6b9055b2ef569e801d
raypretam/Project_Euler
/problem32.py
477
3.765625
4
import time pandigital = set() def is_pandigital(a, b): if len(str(a) + str(b) + str(a*b)) == 9 and set(str(a) + str(b) + str(a*b)) == set('123456789'): pandigital.add(a*b) else: return for i in range(1, 10): for j in range(1000, 10000): is_pandigital(i, j) for i in range(10, 10...
c9bee664342285e2a945702ee279f3b42d538472
abhira15/CP2
/Unit 10/test.py
959
3.625
4
two_vertex = [[2, 1], [2, 2], [3, 4], [3, 1], [2, 4]] # counterList = [] # for smallerList in two_vertex: # for index, number in enumerate(smallerList): # if number in counterList: # smallerList[index] = smallerList[index]-1 # else: # smallerList[index] = smallerList[index]-...
9e702d979ad735d8ec63853afc57fc2ade9ffed7
abhira15/CP2
/Unit 7/euclid problem.py
287
3.5625
4
def extended_gcd(a,b): x,y = 0,1 lx,ly = 1,0 while b: q = a//b a,b = b,a%b x,lx = lx - q*x, x y,ly = ly - q*y, y return a,lx,ly while True: a,b = map(int,input().split()) gcd, x, y = extended_gcd(a,b) print(x,y,gcd)
af9272a3f51f95c9007ff0f900a0d7ed654d7c18
sameerjha18/RandomPasswordGenerator
/main.py
1,166
3.609375
4
from tkinter import * from random import randint root = Tk() root.title('Strong Password Generator') root.iconbitmap('') root.geometry("600x400") def new_rand(): pw_entry.delete(0, END) pw_length = int(my_entry.get()) my_password = '' for x in range(pw_length): my_password += chr(randint(33...
25d49f5c5c9b58191aa63a3d4d8c446938ede9a3
vlad0-0/lab12
/task1.py
123
3.984375
4
def PowerA3(a, b): b = a*a*a return b for i in range(5): a = float(input()) b = 0 print(PowerA3(a, b))
e1efa7df2b4bebbfd3dfafdfc016f454bec28894
matchaTiff/FireMaze
/script.py
27,676
3.6875
4
import matplotlib.pyplot as plt from matplotlib.collections import EventCollection import numpy as np import random import sys import time import collections from heapq import heappop, heappush dim = 500 if sys.version_info[0] < 3: raise Exception("Python 3 is required for this program.") def get_maze(p): "...
6c9e8e1de82c46c38cb8d3fefee89bfa74f0350f
surya-parthipan/Practice
/find_the_access_code.py
831
3.640625
4
_DEPTH = 2 def _count(x, i, depth, indices, highest_value): """Count the sets of divisible numbers of a specific depth.""" out = 0 for m in xrange(1, int(highest_value / x) + 1): if x * m in indices: for j in indices[x * m]: if i < j: if de...
6c11ac6d7d5daaddd9b53ccc4fc8f1b70517c7d9
surya-parthipan/Practice
/binary_tree.py
990
3.890625
4
class Tree(object): def __init__(self, data, left=None, right=None): self.data = data self.left = left self.right = right def __repr__(self): left = None if self.left is None else self.left.data right = None if self.right is None else self.right.data ret...
bb693490f449cb2943d52cb35cdbed3c08b208d9
neutrons/GUI_Tools
/PropertiesGetterSetter/example2.py
681
3.796875
4
class GetterSetterClass(): __age = -1 def __init__(cls, age): cls.__age = age # x is a private variable def getAge(self): return self.__age def setAge(cls, age): if age < 0: age = 0 cls.__age = age if __name__ == "...
017cf3f3eb4794a4455d700113b4190c93d13244
Handagege/serverMonitor
/timeManager.py
912
3.6875
4
#!/usr/bin/python import time class timeManager(): def __init__(self): self.Period = 0 self.endPoint = 0 def __init__(self,period,tempTime): self.period = period self.endPoint = tempTime-tempTime%(self.period)+self.period def setEndPoint(self,tempTime): self.endPoint = tempTime-tempTime%(self.period)+s...
eab05bb2df84c96bbd978cc1d10470631747bdb8
mayankmahavar111/Text-Classification
/test4.py
791
3.53125
4
import nltk from nltk.corpus import stopwords from nltk.tokenize import word_tokenize from nltk.stem import PorterStemmer ,WordNetLemmatizer #nltk.download('stopwords') example_sent = "This is a sample sentence, showing off the stop words filtration. my name is mayank." stop_words = set(stopwords.words('english')) ...
944fa5b9b972a819a69f66b1a01c55cf7b2e6cfd
bossperry08/FirstPython-Perry
/Perry4-050821.py
1,666
3.546875
4
# -*- coding: utf-8 -*- #Phần import module import decimal import fractions #load module fractions import math #Phần khai báo biến a = decimal.Decimal(10) / decimal.Decimal(3) b = decimal.Decimal(100) / decimal.Decimal(3) m = fractions.Fraction('1.67') n = fractions.Fraction(5) o = fractions.Fraction(1,3) ...
ae1c8c6090c6c09ab545caaa95086418521656f2
ppanagiotaros/diceduels
/mod.py
1,021
3.890625
4
from random import randrange p1 = 0 p2 = 0 while p1 == p2: dice1a = randrange(1,7) dice2a = randrange(1,7) dice1b = randrange(1,5) dice2b = randrange(1,5) dice1c = randrange(1,13) dice2c = randrange(1,13) dice1d = randrange(1,21) dice2d = randrange(1,21) userinput = raw_input("Lets Play Dice! Grab a pa...
d845f3b13e5c23b615bd18653757361839161410
cristianA06/ProgCompEAFIT.github.io
/20171/presentaciones/Ordenamiento/sol.py
682
3.78125
4
import random def insertionSort(): tam = 100 lista = random.sample(range(0,tam+1),tam) #print lista for index in range(1,len(lista)): actual = lista[index] pos = index while pos>0 and lista[pos-1]>actual: lista[pos]=lista[pos-1] pos = pos-1 l...
55931f090ea97f6b398fe7991296ad62051718ad
identor/code
/python/deck.py
18,814
4.03125
4
# This class creates a single card of a deck. For simplicity, assume that Ace has a value of 1 # and has the lowest value. King has a value of 13 and has the highest value. # Order of suits are clubs, spades, hearts and diamonds in ascending order class Card: # spade ("\u2660") # diamond ("\u2666") # ...
741a10a3abbd1254b71b13dea9d69d4bba60dae1
identor/code
/python/palindrome.py
491
4.0625
4
def ispalindrome(string): last = len(string)-1 # The last index of string for i in range(len(string)): if string[i] != string[last]: return False last -= 1 if last == i: break return True def main(): s = input("Enter a palindrom...
897f450c70b4f0a748ba2424b417fbdcef933f1e
identor/code
/python/hexadecimal.py
590
4.0625
4
def hex_digit(decimal): if decimal < 10: return chr(decimal + ord('0')) else: return chr((decimal-10) + ord('A')) def convert(decimal): if (decimal < 16): return hex_digit(decimal) else: quotient = decimal // 16 remainder = decimal % 16 ...
af7f9899b143667fd41a9ebb3a1f0e1aef5b9bfc
identor/code
/python/desert_food.py
1,125
3.796875
4
import math class Food: def __init__(self, name, weight, volume, cal): self.name = name self.weight = weight self.volume = volume self.cal = cal def __str__(self): return self.name def tom(): TOM_MAX = 15.0 tiny = 0.77 small = 1.10 ...
4fed98db300a53e4ea5cad1714ae7c416eaecb5b
leisure007/xlPandas
/pandas_merge.py
2,015
4.09375
4
# View more python tutorials on my Youtube and Youku channel!!! # Youtube video tutorial: https://www.youtube.com/channel/UCdyjiB5H8Pu7aDTNVXTTpcg # Youku video tutorial: http://i.youku.com/pythontutorial """ Please note, this code is only for python 3+. If you are using python 2+, please modify the code accord...
5f48e1be8ebfa43331c7e9ad4b3cc232e8ca2a3c
vithal-4u/OneStopPySpark
/src/com/pyspark/poc/functions/windowsFun.py
15,536
3.6875
4
''' Created on 27-Jun-2020 Window Functions or Windowed Aggregates: Window (also, windowing or windowed) functions perform a calculation over a set of rows. It is an important tool to do statistics. Most Databases support Window functions. Spark from version 1.4 start supporting Window functions. Spark Window ...
25935546f461556a1a7cb0864868e0cee3593ad5
meankitsingh/tp-test
/primenumber.py
1,006
4.03125
4
import pprint import random # Function to obtain first 1000 Prime numbers def obtain_primenumbers(): prime_list = [] for Number in range (1, 1001): count = 0 for i in range(2, (Number//2 + 1)): if(Number % i == 0): count = count + 1 break...
d2457c4fb92451e14096e57ed7c65531eaaa4cc6
the-espee/document_tagger
/part1/script1.py
1,377
3.640625
4
import re from pg_sample_texts import DIV_COMM, MAG_CART documents = [DIV_COMM, MAG_CART] #?P<title> creates a named capturing group -- What are named groups? # Why the [] expression? # Why is (.*) in parenthesis? When do we use parenthesis and brackets? # Why does my code work without the parenthesis in the ...
f1c3a9bf81ecfb1c1a60691fe617d8d434abb5d4
hoangdo9698/Python
/US_States_Quiz/score.py
547
3.578125
4
from turtle import Turtle ALIGN = "Center" FONT = ("Courier", 18, "bold") class Score(Turtle): def __init__(self): super().__init__() self.hideturtle() self.speed(0) self.penup() self.color("black") def update(self, score): self.goto(300, 300) ...
a316b2d14a524e00985fd59c54d58595f3c2c4a7
ARWA-ALraddadi/python-tutorial-for-beginners
/02-How to Use Pre-defined Functions Demos/2-random_numbers.py
1,626
4.53125
5
#--------------------------------------------------------------------- # Demonstration - Random Numbers # # The trivial demonstrations in this file show how the # functions from the "random" module may produce a different # result each time they're called # Normally when we call a function with the same parameters # ...
15e88757e99a4285445e4641ff9e86df0c9ff134
ARWA-ALraddadi/python-tutorial-for-beginners
/03-Workshop/Workshop-Solutions/fun_with_flags.py
1,564
4.28125
4
#-------------------------------------------------------------------- # # Fun With Flags # # In the lecture demonstration program "stars and stripes" we saw # how function definitions allowed us to reuse code that drew a # star and a rectangle (stripe) multiple times to create a copy of # the United States flag. # # As...
de5d83e72f9e97e33665e635fd5099dcfb4bec07
ARWA-ALraddadi/python-tutorial-for-beginners
/06-How to Create User Interfaces Demos/02-frustrating_button.py
1,076
4.40625
4
#---------------------------------------------------------------- # # Frustrating button # # A very simple demonstration of a Graphical User Interface # created using Tkinter. It creates a window with a label # and a frustrating button that does nothing. # # Import the Tkinter functions from tkinter import * # Creat...
d49423bc7fc93a65763555efc2a9e6aec0ccf1a1
ARWA-ALraddadi/python-tutorial-for-beginners
/10-How to Stop Programs Crashing Demos/0-mars_lander_V5.py
2,361
4.46875
4
#--------------------------------------------------------------------# # # Mars lander example - Exception handling # # This simple program allows us to experiment with defensive # programming, assertions and exception handling. It is based on # a real-life example in which a software failure caused # a Mars lander to ...
15eaf7c1be83f2636e171211a049ceda21eb2fe5
ARWA-ALraddadi/python-tutorial-for-beginners
/03-Workshop/Workshop-Solutions/olympic_rings.py
2,327
4.5625
5
#------------------------------------------------------------------------- # # Olympic Rings # # In this folder you will find a file "olympic_rings.pdf" which shows # the flag used for the Olympics since 1920. Notice that this flag # consists of five rings that differ only in their position and colour. # If we wa...
43aaf6575d5a423e006fbe4360972d2868e7a8ff
ARWA-ALraddadi/python-tutorial-for-beginners
/08-How to Find Things Demos/08-replacing_patterns.py
2,598
4.3125
4
## Replacing patterns ## ## The small examples in this demonstration show how regular ## expressions with backreferences can be used to perform ## automatic modifications of text. from re import sub ## This example shows how to "normalise" a data representation. ## A common problem at QUT is that student numbe...
d69866a1cf193e6eed2cc8abfad5b9a5c6653777
ARWA-ALraddadi/python-tutorial-for-beginners
/01-Workshop/Workshop-Solutions/cylinder_volume.py
939
4.4375
4
# Volume of a cylinder # # THE PROBLEM # # Assume the following values have already been entered into the # Python interpreter, denoting the measurements of a cylindrical # tank: radius = 4 # metres height = 10 # metres # Also assume that we have imported the existential constant "pi" # from the "math" library module...
4a1039d67f5927daf41b2aa86fde4cf9d7ead6a8
ARWA-ALraddadi/python-tutorial-for-beginners
/10-How to Stop Programs Crashing Demos/0-mars_lander_V0.py
2,269
4.34375
4
#--------------------------------------------------------------------# # # Mars lander example - No error handling # # This simple program allows us to experiment with defensive # programming, assertions and exception handling. It is based on # a real-life example in which a software failure caused # a Mars lander to c...
70d2912f7acbaa964fa09f0d17f11f96a5e3fb26
ARWA-ALraddadi/python-tutorial-for-beginners
/05-How to Repeat Actions demos/09-uniqueness.py
1,090
4.46875
4
#--------------------------------------------------------------------# # # Uniqueness test # # As an example of exiting a loop early, here we develop a small # program to determine whether or not all letters in some text # are unique. It does so by keeping track of each letter seen and # stopping as soon as it sees a l...
0f868fcf7aa226a4a68bce5d8d9417f953da291a
ARWA-ALraddadi/python-tutorial-for-beginners
/02-How to Use Pre-defined Functions Demos/9-shooting_gallery.py
3,636
4.59375
5
#--------------------------------------------------------------------- # Target shooting game - Demonstration of some Turtle graphics # and list features # # This program shows how to use a few Turtle graphics features # to simulate a target shooting game. It draws a multi-coloured # target and fires several random "s...
101c4d993889264c4e592564584242cb96e85754
ARWA-ALraddadi/python-tutorial-for-beginners
/12-How to do more than one thing Demos/B_scribbly_turtles.py
1,501
4.71875
5
#--------------------------------------------------------------------# # # Scribbly turtles # # As a simple example showing that we can create two independent # Turtle objects, each with their own distinct state, here # we create two cursors (turtles) that draw squiggly lines on the # canvas separately. # # To develop ...
2feadbab0771b4ec3050e8144f2dc91fe7a0e619
ARWA-ALraddadi/python-tutorial-for-beginners
/06-Workshop/Workshop-Solutions/passcode.py
5,099
4.25
4
#---------------------------------------------------------------- # # PASSCODE # # In this challenging exercise you will will develop a GUI # program using tkinter that comprises: # # 1) a ten digit keypad; # 2) an 'OK' button; and # 3) a text field. # # The program should allow numerical passcodes to be entered # afte...
0598e5896c2b92261ac342485f300d5b0af7c907
ARWA-ALraddadi/python-tutorial-for-beginners
/09-Workshop/print_elements.py
2,663
4.84375
5
#--------------------------------------------------------- # # Print a table of the elements # # In this exercise you will develop a Python program that # accesses an SQLite database. We assume that you have # already created a version of the Elements database using # the a graphical user interface. You can do so by ...
189cbe4c2f6cb9b263e5c6f7fba1571040478428
ARWA-ALraddadi/python-tutorial-for-beginners
/08-How to Find Things Demos/01-wheres_Superman.py
1,804
4.65625
5
#--------------------------------------------------------------------- # # Where's Superman? # # To illustrate how we can find simple patterns in a text file using # Python's built-in "find" method, this demonstration searches for # some patterns in an HTML file. # # Read the contents of the file as a single string te...
197e956b3a503d5d19c4b6648dc7657ced169c43
ARWA-ALraddadi/python-tutorial-for-beginners
/11-Workshop/staff_directory.py
3,238
3.71875
4
#--------------------------------------------------------------------# # # Staff Directory Front-End # # This is the front-end of the staff directory application. It # creates a Graphical User Interface which can be used with any # of the back-end functions. # # Import the Tkinter functions from tkinter import * # Im...
3fa93d909be221ada55da37d6f3b5b6407ea3317
ARWA-ALraddadi/python-tutorial-for-beginners
/04-How to Make Decisions Demos/13-print_largest.py
4,059
4.5625
5
#--------------------------------------------------------------------- # # Demonstration - Comprehending conditional statements # # The following example programs and questions are designed to # show how different outcomes can be produced by similar-looking # conditional statements, # # This is an exercise in code comp...
5c6f7af9847b7112297337f1dd5199f9ba6bb97e
ARWA-ALraddadi/python-tutorial-for-beginners
/04-How to Make Decisions Demos/15-un-nesting.py
1,389
4.40625
4
#--------------------------------------------------------------------- # # "Un-nesting" some conditional statements # # There are usually multiple ways to express the # same thing in program code. As an instructive # exercise in using conditional statements, consider # the code below which decides whether or not # an ...
3a2ad3460b8151fc7df5ae3232b315b6c5dc9cab
ARWA-ALraddadi/python-tutorial-for-beginners
/03-How to Create Reusable Code Demos/07-ref_transparency.py
1,735
4.21875
4
#--------------------------------------------------------------------- # # Demonstration - Referential transparency # # The small examples in this file illustrate the meaning of # "referentially transparent" function definitions. A # function that is referentially transparent always does this # same thing when given t...
bb3592ff1e10509815948ece4afeefd9f53c565f
ARWA-ALraddadi/python-tutorial-for-beginners
/Assignment/button_title_changer.py
4,516
4.375
4
#---------------------------------------------------------------- # # 1 label, 8 buttons (as per diagram) # Initially, the title is empty. # When the user hits one of the buttons, the title is changed (as per diagrams): # When the user hits one of the Buttons, the title display changes depending on the Button: # Monty...
7eb74aa30753e86d540dc2d988b90c53e57c2927
ARWA-ALraddadi/python-tutorial-for-beginners
/04-Workshop/Workshop-Solutions/hungry_ant.py
5,483
4.375
4
################################################################### # # Hungry Ant # # As a graphics program that involves making decisions, this # program aims to simulate the behaviour of a foraging ant. The # ant meanders about the screen at random until either it is # exhausted or until it finds a tasty meal. A d...
d8d0afeca8c35fdfa370f32af41f0ce66e670e58
ARWA-ALraddadi/python-tutorial-for-beginners
/01-Workshop/Workshop-Questions/01_repair_cost.py
854
4.21875
4
# Total repair cost # # THE PROBLEM # # Assume the following values have already been entered into the # Python interpreter, representing the vehicle repair costs in dollars # from several suppliers following a motor accident, and the deposit # paid for the work: panel_beating = 1500 mechanics = 895 spray_painting = 5...
04be86086a5eefb53ec2239718915ceddf7cc72e
ARWA-ALraddadi/python-tutorial-for-beginners
/02-Workshop/Workshop-Solutions/pollock.py
2,768
4.09375
4
## Jackson Pollock's Final Masterpiece ## ## 20th century "artists" such as Jackson Pollock achieved fame ## by stumbling drunkenly around a canvas on the floor ## dribbling paint out of tins. (We're not being rude - he openly ## admitted to being drunk when creating his paintings.) However, ## today we can...
072d4198ea1dea7962646af90a14f36fc72bbf81
ARWA-ALraddadi/python-tutorial-for-beginners
/10-How to Stop Programs Crashing Demos/0-mars_lander_V1.py
2,045
4.65625
5
#--------------------------------------------------------------------# # # Mars lander example - Checking input validity # # This simple program allows us to experiment with defensive # programming, assertions and exception handling. It is based on # a real-life example in which a software failure caused # a Mars lande...
a4c7f758a648367ca431a4aed08c7d6d0497edd8
Furkshn/Transforming_CSV_to_Excel
/Transforming CSV to Excel.py
661
3.84375
4
############################################################ # Converting CSV to Excel ############################################################ import pandas as pd def converting_func(file_name): # Only file name, not adding file format type df_reading_file = pd.read_csv(fi...
d4e19d058a7a7ea4f0d66467c19c15cfd3d510d9
DiogoBispo/python
/funcao_duplicados.py
1,575
4.28125
4
""" -> é uma lista de listas de numeros inteiros -> as listas internas tem o tamanho de 10 elementos -> as listas internas contem numeros entre 1 a 10 e eles podem ser duplicados Exercicio -> Crie uma função que controla o primeiro duplicado considerando o segundo numero como a duplicação: requisitos: ...
e3ca22e7b3a105df20b93aae56b3e783ca704392
cuiqxiaobai/python_cq
/temp.py
1,020
3.75
4
""" __mtime__ = '2017/6/26' """ class Role(object): sex = 'male' def __init__(self,name,weapon,life_value = 100,money = 15000): self.name = name self.weapon = weapon self.life_value = life_value self.Money = money self.__high = 175 #定义一个私有属性 def shot(self): ...
f278e0cb5838c6bd80d57bc5e4ccc90c46fb4d28
erikblanchard/tictac_py
/old files/tictactoe_040621.py
4,282
3.515625
4
# -*- coding: utf-8 -*- """ Created on Sun Apr 4 23:16:23 2021 @author: ErikB """ # board_size = 5 def board_columns(): temp_column = [] for column in range(board_size): list_temp=[] for i, num in enumerate(range(1, board_size_sq+1, board_size)): list_temp.append(game_dict[num+co...
af3ea970dec4f9921baae333f31f53a69e8c70d7
jytrowbridge/FixedWidthFileParser
/lib/parse_fw_file.py
1,608
3.609375
4
# need to add error handling: # widths don't match up with file # file is single line, but multi-line parser was run # add some try/except blocks # need to open the file def parse_fw_file(in_file, out_file, widths): ''' Returns tuple [result, message] where: Result is booelan value representing success or...
54c8ea5a00668a857155537863741783c1b58e3e
Noeuclides/Hitch_Tech_Interview
/fixIT.py
2,345
3.6875
4
""" First Part: Fix it. The next class is filled with failing or bad implemented methods. Fix them according to what the documentation expects them to do. Some errors can also be when calling the methods. """ class failingClass(): def __init__(self): self.aList = [1, 2, 3...
e58af182d2969af6fb05cfce55370a6f21a0b37d
Leviosar/ine5416
/atividades/2/1024.py
536
3.625
4
# https://www.urionlinejudge.com.br/judge/en/problems/view/1024 n = int(input()) for i in range(n): text: str = input() text_list = list(text) # Shift right 3 for index, char in enumerate(text_list): if char.isalpha(): text_list[index] = chr(ord(char) + 3) # Reverse t...
ed5903f9477c672f436b271894e54f507f3420d2
Souuul/python
/Algorithm/14 큐.py
796
3.9375
4
## 함수 선언부 def isQueueFull() : if (rear == SIZE -1) : return True else : return False def isQueueEmpty() : if (rear == front) : return True else : return False def enQueue(data) : global SIZE, queue, front, rear if (isQueueFull()) : print('꽉참') ...
61a3c277fb0149a80952fb0654daf0af587e7f38
Souuul/python
/Python_basic/09_python_exception.py
1,065
3.59375
4
''' exception Error - compile time error : 문법오류 runtime error : 실행시 발생하는 오류 어떤 runtime error 들은 비정상 종료되지 않고 프로그램을 지속적으로 수행시킬수 있는 방법이 있어요! exception 처리는 하나의 구문 밖에 없어요!! try~ except else finally ''' def my_func(my_list): total_sum = 0 # list안의 숫자들을 누적해요! try: total_sum = my_list[0] + my_...
a9caebabdf171d0f736e2d36d431084f893a43ac
Souuul/python
/Python_basic/07_python_decorator.py
4,072
3.515625
4
''' decorator decorator의 사전적 의미는 장식가, 도배업자 python에서 Decorator는 기존의 코드에 여러가지 기능을 추가하는 python구문이라고 이해하면 편해요! Closure first class에 대해서 알아보았어요 first class function(일급함수) : 파이썬은 일급함수를 지원하는 언어 1. 파이썬의 함수는 변수에 저장할 수 있어요! 2. 함수의 인자로 함수를 이용할 수 있어요! > decorator / 프로그램의 확정성 생산성을 높이기 위함 3. 함수의 결과값(리턴값)으로 함수를 이용할 수 있어요! > closure...
e39c10147ccbcb588b4caba74c4e8f71ef0e5c64
samkeet/Python
/pascal.py
357
3.640625
4
import sys def getRow(n): print(n) if n == 1: print([1]) elif n == 2: print([1,2,1]) else: prev = [1,2,1] next = [] for i in range(n-2): for j in range(len(prev)-1): next.append(prev[i]+prev[i+1]) prev = [1]+next+[1] print(prev) next = [] print(prev) if __name__ == '_...
9a3859cc4e29efbb213a25de2e981a7e12aef339
samkeet/Python
/ip-factorialrecursion.py
121
3.734375
4
def factorialRecursion(n): if n == 1: return 1 else: return n*factorialRecursion(n-1) print factorialRecursion(5)
c147feedb5dcb70a3df4ef279310549e099f1080
samkeet/Python
/pyds-binarytree.py
985
3.796875
4
class BinaryTree(object): def __init__(self, data = ''): self.data = data self.leftChild = None self.rightChild = None def setRight(self, data): self.rightChild = BinaryTree(data) def setLeft(self, data): self.leftChild = BinaryTree(data) def getRight(self): return self.leftChild def getLeft(self)...
5c6f57c3bd0029e561cdb3585942544ac09978f4
reynoldscem/eulerpy
/0002/1.py
548
3.5
4
from functools import reduce from itertools import count from functools import lru_cache @lru_cache(maxsize=None) def fib(n): if n < 2: return 1 else: return fib(n - 1) + fib(n - 2) def number_generator(max_num): for i in count(0): fib_val = fib(i) if fib_val >= max_num: ...
e73ff277b95e7b91c5f44fdbd7cee6f574554b85
junwei0812/Faster-RCNN
/utils/mergeSort.py
601
3.921875
4
def merge(arr,lo,mid,hi): aux = arr.copy() i = lo j = mid+1 for k in range(lo,hi+1): if i > mid: arr[k] = aux[j] j += 1 elif j > hi: arr[k] = aux[i] i += 1 elif aux[i] < aux[j]: arr[k] = aux[i] i+= 1 ...
b8d235b943b1c8d2953e379ac4fc2c79bc2b91ba
celord/PythonGreencore
/ExamenFinal/ej1.py
509
4.03125
4
""" Realiza una función llamada relacion(a, b)que a partir de dos números cumpla lo siguiente: Si el primer número es mayor que el segundo, debe devolver 1. Si el primer número es menor que el segundo, debe devolver -1. Si ambos números son iguales, debe devolver un 0. Comprueba la relación entre los nú...
fccac4793fc74dc71fd0134a6127cf314e3a44ab
celord/PythonGreencore
/calcProducto.py
371
3.5
4
IVA = 0.13 producto = input("Ingrese el Prodcuto: ") cantidad = int(input("Ingrese la cantidad de producto: ")) precio_unitario = int(input("Ingrese el precio unitario: ")) subTotal = cantidad * precio_unitario impuesto = subTotal * IVA Total = subTotal + impuesto print("Subtotal: %s" % str(subTotal)) print("Imp: %s"...
015526d3f4b70a5bd26b02bb93b935db6d855dbb
celord/PythonGreencore
/whileLista.py
185
3.59375
4
mylist = ['a','b','c','d','e'] freno = 0 #while len(mylist) < 7: # mylist.append('a') #print(mylist) while freno < 2 : mylist.append('a') freno = freno + 1 print(mylist)
a8db2aca7619d67380c8c082df0cf501bc598a09
usd-cs/comp110-fa20-lab03
/volume_increaser.py
679
3.921875
4
""" Module: comp110_lab03 Practice code for working with sounds in Python. """ import sound love_sound = sound.load_sound("love.wav") love_sound.play() sound.wait_until_played() # waits until love_sound is done playing filtered_sound = sound.copy(love_sound) # change the volume of the love sound for sample_number...
8ec625f3b054605450ffa79fae827d1e4d29e51d
vicious987/old_uni_assignments
/python_basic/l5/zad1/zad1.py
662
3.640625
4
def median(l): l.sort() #sorted(l) index = (len(l)- 1) // 2 if (len(l) % 2): return l[index] else: return (l[index] + l[index + 1]) / 2.0 def f(n): if n % 2 == 0: return n / 2 else: return 3 * n + 1 def energy(n): energy_counter = 0 while not n == 1: ...
398c5d3a967a18fd606298f02c255b09e595460a
vicious987/old_uni_assignments
/python_basic/l11/zad2/zad2.py
819
3.59375
4
def cesar(word, key): word = list(word) alphabet = "aąbcćdeęfghijklłmnńoóprsśtuwyzźż" if key > len(alphabet): key = key % len(alphabet) ciphered_alphabet = alphabet[key:] + alphabet[:key] cipher = dict(zip(alphabet, ciphered_alphabet)) for index,letter in enumerate(word): word[in...
d3c04ad0b10271ad19026b2c62c740ce47c57e89
vicious987/old_uni_assignments
/python_basic/2015/my/djikstra.py
1,282
4.03125
4
graph = input("gib graph\n") #[(edge_name1,edge_name2, edge_value)] starting_node_name = input("gib start name\n") finish_node_name = input("gib finish name\n") import math def get_neighbour_list(node_name, graph): neighbour_list = [] for x in graph: if x[0] == node_name: neighbour_list.app...
721332e351f309126197ce0096451e74faaecf0a
vicious987/old_uni_assignments
/python_basic/l12/zad2/zad2.py
320
3.5
4
w = "wolf" g = "goat" c = "cabbage" h = "human" L = [w,g,c,h] R = [] move_history = [] def legal(S): if "human" in S: return True else: if "wolf" in S and "goat" in S: return False if "goat" in S and "cabbage" in S: return False return True def move(
739e8928ec01a851caee0a62d8238d7289be250e
vicious987/old_uni_assignments
/anl/anl/bla.py
186
3.765625
4
import math def derp(n): return pow(2,n+1)/math.factorial(n+1) def derp2(n): return pow(7,n)*(n+1) a = pow(10, 10) for x in range(30): print(x, derp2(x), a < derp2(x), a)
3b219cf192a3f0533e7f71a3b2bf5e661430665b
vicious987/old_uni_assignments
/python_basic/l12/wpr.py
931
3.71875
4
def visited_dict(Tree): visited = {} for x in range(len(Tree)): visited[x] = False return visited def ifroot(v, Tree, visited, skierowany = True): visited[v] = True for x in Tree[v]: if not visited[x]: ifroot(x, Tree, visited, skierowany) else: retu...