text
stringlengths
0
1.05M
meta
dict
# 1.1 p = (4, 5) x, y = p print(x) print(y) data = [ 'ACME', 50, 91.1, (2012, 12, 21) ] name, shares, price, date = data print(name) print(date) name, shares, price, (year, mon, day) = data print(name) print(year) print(mon) print(day) s = 'Hello' a, b, c, d, e = s print(a) print(b) print(e) data = [ 'ACME', 50, 9...
{ "repo_name": "cragwen/hello-world", "path": "py/cookbook/p1.py", "copies": "1", "size": "3296", "license": "unlicense", "hash": -1141708750737350800, "line_mean": 18.619047619, "line_max": 69, "alpha_frac": 0.5998179612, "autogenerated": false, "ratio": 2.547140649149923, "config_test": false,...
#1 1pt) What is the symbol "=" used for? # = is called assignment operator, it is used to put a value into a variable. # For example, if you put Myname = Daniel Kwon. Myname will be the variable # and the value will be Daniel Kwon. #(1) #2 3pts) Write a technical definition for 'function' # A fuction is a named seque...
{ "repo_name": "daniel2504-cmis/daniel2504-cmis-cs2", "path": "cs2quiz1.py", "copies": "1", "size": "3131", "license": "cc0-1.0", "hash": 1421084007931847700, "line_mean": 28.819047619, "line_max": 173, "alpha_frac": 0.664324497, "autogenerated": false, "ratio": 2.8258122743682312, "config_test"...
# 1.1 Tennis # Programmed by Rachel J Morris import pygame, sys, math from pygame.locals import * pygame.init() fpsClock = pygame.time.Clock() window = pygame.display.set_mode( ( 1024, 768 ) ) pygame.display.set_caption( "Tennis" ) bgColor = pygame.Color( 135, 215, 105 ) txtColor = pygame.Color( 0, 0, 0 ) fontObj =...
{ "repo_name": "Rachels-Courses/CS210-Discrete-Structures", "path": "Resources/Program Illustrations/1.1/1.1 Tennis/main.py", "copies": "1", "size": "5879", "license": "mit", "hash": -7675673751382739000, "line_mean": 28.103960396, "line_max": 145, "alpha_frac": 0.5441401599, "autogenerated": false,...
## 1.1 Types from deap import base, creator creator.create("FitnessMin", base.Fitness, weights=(-1.0,)) creator.create("Individual", list, fitness=creator.FitnessMin) ## 1.2 Initialization import random from deap import tools IND_SIZE = 10 toolbox = base.Toolbox() toolbox.register("attribute", random.random) toolbo...
{ "repo_name": "DailyActie/Surrogate-Model", "path": "docs/code/tutorials/part_1/1_where_to_start.py", "copies": "2", "size": "2146", "license": "mit", "hash": -5856502628096785000, "line_mean": 28.8055555556, "line_max": 74, "alpha_frac": 0.6547064306, "autogenerated": false, "ratio": 3.564784053...
# 12/01/2003 - Jeff Grimmett (grimmtooth@softhome.net) # # o Updated for wx namespace. Not tested though. # # 12/17/2003 - Jeff Grimmett (grimmtooth@softhome.net) # # o Removed wx prefix from class name, # updated reverse renamer # """ sorry no documentation... Christopher J. Fama """ import wx ...
{ "repo_name": "ktan2020/legacy-automation", "path": "win/Lib/site-packages/wx-3.0-msw/wx/lib/ClickableHtmlWindow.py", "copies": "1", "size": "1895", "license": "mit", "hash": 2924706960970223600, "line_mean": 31.2456140351, "line_max": 80, "alpha_frac": 0.5287598945, "autogenerated": false, "rati...
# 120206_Demonstration.py # In class exercises for Feb 6th # Chad Hobbs # ------------- Slicing Strings ------------------- # name = "Chad Hobbs" # this is a string # print(name[0]) # putting brackets and a valid number gets a piece of the string out # print(name[1]) # the string slice starts at 0 and goe...
{ "repo_name": "itsallvoodoo/csci-school", "path": "CSCI220/Week 05/120206_Demonstration.py", "copies": "1", "size": "1411", "license": "apache-2.0", "hash": 5265542333350671000, "line_mean": 27.3958333333, "line_max": 137, "alpha_frac": 0.6109142452, "autogenerated": false, "ratio": 3.28139534883...
# 120208_Demonstration.py # In class exercises for Feb 8th # Chad Hobbs from graphics import * import random, time # -----------printing with lists--------------- ##n = eval(input("n: ")) ## ##win = GraphWin("Example",300,300) ## ##ball_list = [] ##for i in range(n): ## x = random.randint(0,299) ...
{ "repo_name": "itsallvoodoo/csci-school", "path": "CSCI220/Week 05/120208_Demonstration.py", "copies": "1", "size": "1807", "license": "apache-2.0", "hash": -2311275641276566500, "line_mean": 20.8734177215, "line_max": 90, "alpha_frac": 0.5406751522, "autogenerated": false, "ratio": 2.59626436781...
# 12/02/2003 - Jeff Grimmett (grimmtooth@softhome.net) # # o Updated for 2.5 compatability. # """ FancyText -- methods for rendering XML specified text This module exports four main methods:: def GetExtent(str, dc=None, enclose=True) def GetFullExtent(str, dc=None, enclose=True) def RenderToB...
{ "repo_name": "ktan2020/legacy-automation", "path": "win/Lib/site-packages/wx-3.0-msw/wx/lib/fancytext.py", "copies": "1", "size": "16689", "license": "mit", "hash": 1510189997676168700, "line_mean": 34.1233766234, "line_max": 151, "alpha_frac": 0.6023728204, "autogenerated": false, "ratio": 3.51...
# 120222_Demonstration.py # In class exercise creating a tic tac toe board # <Chad Hobbs> #Global Commands from graphics import * #Functions def create_board(): # Opens a new window and draws our board bboard = [['','',''],['','',''],['','','']] wwin = GraphWin("Tic-Tac-Toe",600,600) wwin.setCo...
{ "repo_name": "itsallvoodoo/csci-school", "path": "CSCI220/Week 07 - FEB27-02/120222_Demonstration.py", "copies": "1", "size": "1091", "license": "apache-2.0", "hash": 8189549489425517000, "line_mean": 25.275, "line_max": 69, "alpha_frac": 0.583868011, "autogenerated": false, "ratio": 2.948648648...
# 120229_Demonstration.py # In class demonstration of Tic Tac Toe # <Chad Hobbs> from graphics import * def create_board(): board = [['','',''],['','',''],['','','']] wwin = GraphWin("Tic Tac Toe",300,300) wwin.setCoords(30,30,0,0) Line(Point(10,0),Point(10,30)).draw(wwin) Line(Point(...
{ "repo_name": "itsallvoodoo/csci-school", "path": "CSCI220/Week 08 - MAR05-09/120229_Demonstration.py", "copies": "1", "size": "2177", "license": "apache-2.0", "hash": 8388968225780661000, "line_mean": 20.6770833333, "line_max": 82, "alpha_frac": 0.4735875057, "autogenerated": false, "ratio": 2.9...
# 12/03/2017 from string import ascii_lowercase, ascii_uppercase def make_table(mirrors): table = [[]]*15 table[0] = ' ' + ascii_lowercase[0:13] + ' ' table[14] = ' ' + ascii_uppercase[13:] + ' ' for i in range(1, 14): table[i] = ascii_uppercase[i-1] + mirrors[i-1] + ascii_lowercase[12+i] r...
{ "repo_name": "tlseabra/dailyprogrammer", "path": "Python/intermediate/i269.py", "copies": "2", "size": "2005", "license": "mit", "hash": 3245000988777836500, "line_mean": 34.1754385965, "line_max": 101, "alpha_frac": 0.4119700748, "autogenerated": false, "ratio": 3.57397504456328, "config_test...
# 120328_Demonstration.py # In class demonstrations # <Chad Hobbs> import sys # ---------------------------Sorts -------------------------- # ----- Bubble Sort ------ def bubbleSort(array): times = 0 swapHappend = True while swapHappend: for i in range(len(array)-1,0,-1): ...
{ "repo_name": "itsallvoodoo/csci-school", "path": "CSCI220/Week 11 - MAR26-30/120328_Demonstration.py", "copies": "1", "size": "2284", "license": "apache-2.0", "hash": 894293942618564700, "line_mean": 15.303030303, "line_max": 68, "alpha_frac": 0.4343257443, "autogenerated": false, "ratio": 3.329...
# 12/07/2003 - Jeff Grimmett (grimmtooth@softhome.net) # # o 2.5 Compatability changes # import wx from wx.lib.evtmgr import eventManager class FoldOutWindow(wx.PopupWindow): def __init__(self,parent,style=0): wx.PopupWindow.__init__(self,parent,style) self.SetAutoLayout(True) ...
{ "repo_name": "ktan2020/legacy-automation", "path": "win/Lib/site-packages/wx-3.0-msw/wx/lib/foldmenu.py", "copies": "1", "size": "2615", "license": "mit", "hash": -611627684909905700, "line_mean": 27.3820224719, "line_max": 78, "alpha_frac": 0.5797323136, "autogenerated": false, "ratio": 3.57240...
# 12/09/2003 - Jeff Grimmett (grimmtooth@softhome.net) # # o 2.5 compatability update. # o I'm a little nervous about some of it though. # # 12/20/2003 - Jeff Grimmett (grimmtooth@softhome.net) # # o wxTreeModel -> TreeModel # o wxMVCTree -> MVCTree # o wxMVCTreeEvent -> MVCTreeEvent # o wxMVCTreeNotifyEvent ...
{ "repo_name": "ktan2020/legacy-automation", "path": "win/Lib/site-packages/wx-3.0-msw/wx/lib/mvctree.py", "copies": "1", "size": "41690", "license": "mit", "hash": -7215666787507909000, "line_mean": 34.252173913, "line_max": 125, "alpha_frac": 0.5684576637, "autogenerated": false, "ratio": 3.8537...
# 12/09/2003 - Jeff Grimmett (grimmtooth@softhome.net) # # o Updated for wx namespace # # 12/18/2003 - Jeff Grimmett (grimmtooth@softhome.net) # # o wxScrolledMessageDialog -> ScrolledMessageDialog # import re import wx class Layoutf(wx.LayoutConstraints): """ The class Layoutf(wxLayoutConst...
{ "repo_name": "ktan2020/legacy-automation", "path": "win/Lib/site-packages/wx-3.0-msw/wx/lib/layoutf.py", "copies": "1", "size": "9885", "license": "mit", "hash": 4953203760174129000, "line_mean": 34.6111111111, "line_max": 136, "alpha_frac": 0.5193727871, "autogenerated": false, "ratio": 3.25271...
# 12/14/2003 - Jeff Grimmett (grimmtooth@softhome.net) # # o 2.5 compatability update. # def RestOfLine(sx, width, data, bool): if len(data) == 0 and sx == 0: return [('', bool)] if sx >= len(data): return [] return [(data[sx:sx+width], bool)] def Selection(SelectBegin,SelectEn...
{ "repo_name": "ktan2020/legacy-automation", "path": "win/Lib/site-packages/wx-3.0-msw/wx/lib/editor/selection.py", "copies": "1", "size": "1351", "license": "mit", "hash": -8716312372957072000, "line_mean": 28.7045454545, "line_max": 60, "alpha_frac": 0.5388601036, "autogenerated": false, "ratio"...
"""121. Best Time to Buy and Sell Stock https://leetcode.com/problems/best-time-to-buy-and-sell-stock/ Say you have an array for which the i^th element is the price of a given stock on day i. If you were only permitted to complete at most one transaction (i.e., buy one and sell one share of the stock), design an algo...
{ "repo_name": "isudox/leetcode-solution", "path": "python-algorithm/leetcode/best_time_to_buy_and_sell_stock.py", "copies": "1", "size": "1144", "license": "mit", "hash": 7348793416793554000, "line_mean": 25, "line_max": 77, "alpha_frac": 0.6145104895, "autogenerated": false, "ratio": 3.134246575...
# # 12 .1 Create Rectangle and Square classes with a method called # # calculate_perimeter that calculates the perimeter of the shapes they # # represent. Create Rectangle and Square objects and call the method # # on both of them. # # # class Shape(): # def __init__(self, l, w): # self._length = l # ...
{ "repo_name": "Frikeer/LearnPython", "path": "exc12/exc12.py", "copies": "1", "size": "3102", "license": "unlicense", "hash": 5269613313305685000, "line_mean": 24.85, "line_max": 83, "alpha_frac": 0.5918762089, "autogenerated": false, "ratio": 2.9154135338345863, "config_test": false, "has_no...
# 1.2.1 Write a Point2D client that takes an integer value N from the # command line, generates N random points in the unit square, and computes # the distance separating the closest pair of points. from math import hypot, atan2, fabs from random import random import sys def main(argv=None): ''' Function ca...
{ "repo_name": "timgasser/algorithms_4ed", "path": "ch1_fundamentals/ex1.2.2.py", "copies": "1", "size": "3633", "license": "mit", "hash": 2161476008267052800, "line_mean": 29.5378151261, "line_max": 105, "alpha_frac": 0.5953757225, "autogenerated": false, "ratio": 3.8121720881427072, "config_te...
# 12/20/2003 - Jeff Grimmett (grimmtooth@softhome.net) # # o wxPyInformationalMessagesFrame -> PyInformationalMessagesFrame # o dummy_wxPyInformationalMessagesFrame -> dummy_PyInformationalMessagesFrame # """ infoframe.py Released under wxWindows license etc. This is a fairly rudimentary, but slightly fanci...
{ "repo_name": "ktan2020/legacy-automation", "path": "win/Lib/site-packages/wx-3.0-msw/wx/lib/infoframe.py", "copies": "1", "size": "19730", "license": "mit", "hash": 1134730862160436700, "line_mean": 38.1016260163, "line_max": 110, "alpha_frac": 0.558337557, "autogenerated": false, "ratio": 4.325...
# 122. Best Time to Buy and Sell Stock II - LeetCode # https://leetcode.com/problems/best-time-to-buy-and-sell-stock-ii/description/ class Solution(object): def maxProfit(self, prices): """ :type prices: List[int] :rtype: int """ total_profit = 0 if len(prices) == 0:...
{ "repo_name": "heyf/cloaked-octo-adventure", "path": "leetcode/122_best-time-to-buy-and-sell-stock-ii.py", "copies": "1", "size": "1024", "license": "mit", "hash": 2951638824239572500, "line_mean": 33.1666666667, "line_max": 79, "alpha_frac": 0.5166015625, "autogenerated": false, "ratio": 3.25079...
# 122. Best Time to Buy and Sell Stock II # # Say you have an array for which the i-th element is the price of a # stock on day i. # # Design an algorithm to find the maximum profit. You may complete as # many buys and sells as you like, but you must hold at most one share # at a time. # It seems like this has to be...
{ "repo_name": "afbarnard/glowing-broccoli", "path": "lc/000122.py", "copies": "1", "size": "8280", "license": "mit", "hash": 3307837099479888400, "line_mean": 35.8, "line_max": 74, "alpha_frac": 0.5350241546, "autogenerated": false, "ratio": 3.420074349442379, "config_test": false, "has_no_ke...
# [1, 2, 3] => [1, 4, 9] # 배열로 받는거 제곱 def get_square_list(number_list): square_list = [] for i in number_list: square_list.append( i ** 2) return square_list get_square_list([1, 2, 3]) # 받는 모든 수 제곱 def get_square_list(*args): square_list = [] for i in args: squa...
{ "repo_name": "LeoHeo/FastCampus-Python-Django", "path": "Week-2/06_lambda_map_reduce.py", "copies": "1", "size": "2472", "license": "mit", "hash": 6694271618836870000, "line_mean": 17.3898305085, "line_max": 79, "alpha_frac": 0.5640552995, "autogenerated": false, "ratio": 1.8281381634372367, "...
# |1|2|3|4|5|6|7|8| # 1|a| | | | | | | | | # 2|b| | | | | | | | | # 3|c| | | | | | | | | # 4|d| | | | | | | | | # 5|e| | | | | | | | | # 6|f| | | | | | | | | # 7|g| | | | | | | | | # 8|h| | | | | | | | | # 9|i| | | | | | | | | import logging import logging.handlers import traceback from helpMenu import parser from...
{ "repo_name": "Mimieam/CS540_AI", "path": "project1/AnimalChecker.py", "copies": "1", "size": "23177", "license": "mit", "hash": 2082468114857117700, "line_mean": 36.1426282051, "line_max": 172, "alpha_frac": 0.4978211158, "autogenerated": false, "ratio": 3.7000319284802043, "config_test": fals...
"""123 Revision ID: d5480b6ea221 Revises: None Create Date: 2016-05-09 13:31:11.192108 """ # revision identifiers, used by Alembic. revision = 'd5480b6ea221' down_revision = None from alembic import op import sqlalchemy as sa def upgrade(): ### commands auto generated by Alembic - please adjust! ### op.cr...
{ "repo_name": "Millyn/Flask_blog", "path": "migrations/versions/d5480b6ea221_123.py", "copies": "1", "size": "1192", "license": "apache-2.0", "hash": 5905180780422510000, "line_mean": 27.380952381, "line_max": 65, "alpha_frac": 0.6619127517, "autogenerated": false, "ratio": 3.4853801169590644, ...
# 125. Valid Palindrome # # Given a string, determine if it is a palindrome, # considering only alphanumeric characters and ignoring cases. # # For example, # "A man, a plan, a canal: Panama" is a palindrome. # "race a car" is not a palindrome. # # Note: # Have you consider that the string might be empty? # This is a g...
{ "repo_name": "gengwg/leetcode", "path": "125_valid_palindrome.py", "copies": "1", "size": "1541", "license": "apache-2.0", "hash": -9198968882678752000, "line_mean": 27.0181818182, "line_max": 78, "alpha_frac": 0.5691109669, "autogenerated": false, "ratio": 3.2373949579831933, "config_test": f...
"""128. Longest Consecutive Sequence https://leetcode.com/problems/longest-consecutive-sequence/ Given an unsorted array of integers, find the length of the longest consecutive elements sequence. Your algorithm should run in O(n) complexity. Example: Input: [100, 4, 200, 1, 3, 2] Output: 4 Explanation: The longest...
{ "repo_name": "isudox/leetcode-solution", "path": "python-algorithm/leetcode/longest_consecutive_sequence.py", "copies": "1", "size": "2182", "license": "mit", "hash": -4404200000999182300, "line_mean": 27.6973684211, "line_max": 78, "alpha_frac": 0.5061898212, "autogenerated": false, "ratio": 3....
# 12/9/16, made this AMR specific, eliminating the need to parse srl vectors. # # DaisyLu Vectors 10/8/2015 # # Read in the original conll format files and the list of items represented by each feature. # Create MySQLite database with everything necessary to generate vectors for specific models, # in Lua, including: #...
{ "repo_name": "BillFoland/daisyluAMR", "path": "system/daisylu_vectors.py", "copies": "1", "size": "74777", "license": "mit", "hash": -4332465398764724700, "line_mean": 46.088790932, "line_max": 198, "alpha_frac": 0.5389625152, "autogenerated": false, "ratio": 3.42056630529253, "config_test": t...
''' 12-extract_magnitude_long_periods.py =============================================== AIM: Prepare cumulative plots (THIS SCRIPT IS with STRAY LIGHT) INPUT: files: - <orbit_id>_misc/orbits.dat - <orbit_id>_flux/flux_*.dat variables: see section PARAMETERS (below) OUTPUT: in <orbit_id>_misc/ : complicated name ...
{ "repo_name": "kuntzer/SALSA-public", "path": "12_extract_magnitude_long_periods.py", "copies": "1", "size": "9561", "license": "bsd-3-clause", "hash": -8532696114189522000, "line_mean": 28.878125, "line_max": 117, "alpha_frac": 0.6631105533, "autogenerated": false, "ratio": 2.9158279963403477, ...
# 12:{'name':'m3','self_servant':2,'self_blood':0,'enermy_servant':0,'enermy_blood':0,'time':2,'img':'m3.jpg','show_img':'m3.jpg','card_type':1} import pygame import threading import time import sys reload(sys) sys.setdefaultencoding('utf-8') class MagicCard: def __init__(self,dict): self.self_serv...
{ "repo_name": "diyalujiaf/yewan-s-", "path": "cardgame/magic_card.py", "copies": "1", "size": "2494", "license": "mit", "hash": 1923527192178204200, "line_mean": 38.2258064516, "line_max": 144, "alpha_frac": 0.5753809142, "autogenerated": false, "ratio": 3.2097812097812097, "config_test": false...
# 1305, 9 Jan 2018 (NZDT) # # Nevil Brownlee, U Auckland # From a simple original version by Joe Hildebrand # ElementTree doesn't have nsmap try: import xml.etree.cElementTree as ET except ImportError: import xml.etree.ElementTree as ET #from lxml import etree as ET import getopt, sys, re import word_prop...
{ "repo_name": "nevil-brownlee/check_svg", "path": "check-svg.py", "copies": "1", "size": "10646", "license": "mit", "hash": -1276686827572183000, "line_mean": 35.3344709898, "line_max": 104, "alpha_frac": 0.5166259628, "autogenerated": false, "ratio": 3.232918311569997, "config_test": false, ...
# 133. Single Number # # Given a non-empty array of integers, every element appears twice # except for one. Find that single one. # # Note: Your algorithm should have a linear runtime complexity. Could # you implement it without using extra memory? [No, not that I can # figure out.] def multiscan(nums): # Idea...
{ "repo_name": "afbarnard/glowing-broccoli", "path": "lc/000136.py", "copies": "1", "size": "2033", "license": "mit", "hash": 8331102719575565000, "line_mean": 27.6338028169, "line_max": 80, "alpha_frac": 0.5159862273, "autogenerated": false, "ratio": 3.716636197440585, "config_test": false, "...
# 13.5 pts of 15 for terminology # 23 pts of 25 for programming #Part 1: Terminology (15 points) #1 1pt) What is the symbol "=" used for? # assigning values, function calls to a variable # 1 pt right answer # #2 3pts) Write a technical definition for 'function' # A function is a named sequence of statements that perfor...
{ "repo_name": "walter2645-cmis/walter2645-cmis-cs2", "path": "cs2quiz1.py", "copies": "1", "size": "3328", "license": "cc0-1.0", "hash": 2672031770761448000, "line_mean": 33.6666666667, "line_max": 126, "alpha_frac": 0.7142427885, "autogenerated": false, "ratio": 3.389002036659878, "config_test...
# 137. Single Number II # # Given an array of integers, every element appears three times except for one, # which appears exactly once. Find that single one. # # Note: # Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory? class Solution(object): def singleNum...
{ "repo_name": "gengwg/leetcode", "path": "137_single_number_ii.py", "copies": "1", "size": "1181", "license": "apache-2.0", "hash": -2004322425491656000, "line_mean": 25.2444444444, "line_max": 108, "alpha_frac": 0.5156646909, "autogenerated": false, "ratio": 4.232974910394265, "config_test": f...
# 138. Copy List with Random Pointer # # A linked list is given such that each node contains an additional random pointer # which could point to any node in the list or null. # # Return a deep copy of the list. # Definition for singly-linked list with a random pointer. class RandomListNode(object): def __init__(s...
{ "repo_name": "gengwg/leetcode", "path": "138_copy_list_with_random_pointer.py", "copies": "1", "size": "2060", "license": "apache-2.0", "hash": -9079333589129421000, "line_mean": 25.625, "line_max": 82, "alpha_frac": 0.5874413146, "autogenerated": false, "ratio": 2.4377682403433476, "config_te...
# 1396. Design Underground System - LeetCode # https://leetcode.com/problems/design-underground-system/ class UndergroundSystem: def __init__(self): self.time_sheet = dict() # key=(startStation, endStation), value=(count, total) self.checkin_cache = dict() # key=id def checkIn(self, id: int, ...
{ "repo_name": "heyf/cloaked-octo-adventure", "path": "leetcode/1396_design-underground-system.py", "copies": "1", "size": "1558", "license": "mit", "hash": 5499505929967784000, "line_mean": 36.0952380952, "line_max": 94, "alpha_frac": 0.648267009, "autogenerated": false, "ratio": 3.30084745762711...
"""139. Word Break https://leetcode.com/problems/word-break/description/ Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, determine if s can be segmented into a space-separated sequence of one or more dictionary words. Note: The same word in the dictionary may be reused mul...
{ "repo_name": "isudox/leetcode-solution", "path": "python-algorithm/leetcode/word_break.py", "copies": "1", "size": "2055", "license": "mit", "hash": -1025950237266193500, "line_mean": 25.0126582278, "line_max": 75, "alpha_frac": 0.5907542579, "autogenerated": false, "ratio": 3.914285714285714, ...
# 139. Word Break # # Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, # determine if s can be segmented into a space-separated sequence of one or more dictionary words. # You may assume the dictionary does not contain duplicate words. # # For example, given # s = "leetcode", #...
{ "repo_name": "gengwg/leetcode", "path": "139_word_break.py", "copies": "1", "size": "1201", "license": "apache-2.0", "hash": 45148379034663280, "line_mean": 32.3611111111, "line_max": 98, "alpha_frac": 0.5795170691, "autogenerated": false, "ratio": 3.3361111111111112, "config_test": false, "...
"""13C(methyl) - H to C CPMG Measures methyl carbon chemical exchange recorded on site-specifically 13CH3-labeled proteins in a highly deuterated background. Magnetization is initally anti-phase and is read out as in-phase. Because of the P-element only even ncyc should be recorded. The calculation uses a 12x12 basis ...
{ "repo_name": "gbouvignies/chemex", "path": "chemex/experiments/cpmg/ch3_h2c.py", "copies": "1", "size": "3248", "license": "bsd-3-clause", "hash": 6305267732005172000, "line_mean": 32.8333333333, "line_max": 88, "alpha_frac": 0.5969827586, "autogenerated": false, "ratio": 3.041198501872659, "c...
"""13CO - Pure Anti-phase Carbonyl 13C CPMG Analyzes carbonyl chemical exchange that is maintained as anti-phase magnetization throughout the CPMG block. This results in lower intrinsic relaxation rates and therefore better sensitivity. The calculations use a 12x12, 2-spin exchange matrix: [ COx(a), COy(a), COz(a), 2...
{ "repo_name": "gbouvignies/chemex", "path": "chemex/experiments/cpmg/co_ap.py", "copies": "1", "size": "3724", "license": "bsd-3-clause", "hash": 3661196107404293000, "line_mean": 31.6666666667, "line_max": 88, "alpha_frac": 0.608216971, "autogenerated": false, "ratio": 3.1479289940828403, "con...
# 1-3: Given two strings, write a method to decide if one is a permutation # of the other # Permutation: an ordered set that uses the same elements as another # Example: cat act # Brute force: for each letter in word1, see if that letter exists in word2 # If yes, remove that letter from the word2. If you get to ...
{ "repo_name": "dmart914/CTCI", "path": "01-arrays-and-strings/permutation.py", "copies": "1", "size": "2235", "license": "apache-2.0", "hash": 8652293307203110000, "line_mean": 29.2027027027, "line_max": 79, "alpha_frac": 0.5494407159, "autogenerated": false, "ratio": 3.9557522123893807, "confi...
# 13 octobre 2017 # astro_v3.py from pylab import * import os def B3V_eq(x): """ :param x: abcsisse du point de la ligne B3V dont on veut obtenir l'ordonnee :return: ordonnee du point de la ligne B3V correspondant a l'abscisse x (dans un graphique u-g vs g-r) """ return 0.9909 * x - 0.8901 def...
{ "repo_name": "anthonygi13/Recherche_etoiles_chaudes", "path": "astro_v3.py", "copies": "1", "size": "16991", "license": "apache-2.0", "hash": -5304523769552843000, "line_mean": 37.4321266968, "line_max": 267, "alpha_frac": 0.5871548831, "autogenerated": false, "ratio": 3.0751267197682837, "con...
''' 13-plot_long_periods.py =============================================== AIM: Prepare cumulative plots (THIS SCRIPT IS with STRAY LIGHT) INPUT: files: - <orbit_id>_misc/ : files from 12-<...>.py or 11-<...>.py variables: see section PARAMETERS (below) OUTPUT: in <orbit_id>_figures/ : <height>_<threshold_obs_time...
{ "repo_name": "kuntzer/SALSA-public", "path": "13_plot_long_periods.py", "copies": "1", "size": "6716", "license": "bsd-3-clause", "hash": -8277964516791386000, "line_mean": 28.0735930736, "line_max": 120, "alpha_frac": 0.6360929124, "autogenerated": false, "ratio": 2.600077429345722, "config_t...
# 14.02.2007 # last revision: 20.03.2008 #! #! Poisson Equation #! ================ #$ \centerline{Example input file, \today} #! Mesh #! ---- filename_mesh = 'database/simple.mesh' #! Materials #! --------- #$ Here we define just a constant coefficient $c$ of the Poisson equation. #$ The 'here' mode says that. Other...
{ "repo_name": "certik/sfepy", "path": "input/poisson.py", "copies": "1", "size": "4538", "license": "bsd-3-clause", "hash": 624042417552123000, "line_mean": 25.0804597701, "line_max": 79, "alpha_frac": 0.572939621, "autogenerated": false, "ratio": 2.875792141951838, "config_test": false, "has...
# 1418. Display Table of Food Orders in a Restaurant - LeetCode # https://leetcode.com/problems/display-table-of-food-orders-in-a-restaurant/ from typing import List class Solution: def displayTable(self, orders: List[List[str]]) -> List[List[str]]: order_set = set() tables = {} # id: { "order": c...
{ "repo_name": "heyf/cloaked-octo-adventure", "path": "leetcode/1418_display-table-of-food-orders-in-a-restaurant.py", "copies": "1", "size": "1351", "license": "mit", "hash": -1901851463914809900, "line_mean": 37.6, "line_max": 164, "alpha_frac": 0.5632864545, "autogenerated": false, "ratio": 3.5...
#14.1 Add a square_list # class Shape(): # def __init__(self, l, w): # self._length = l # self._width = w # # def calculate_perimeter(self): # return (self._length + self._width)*2 # # class Square(Shape): # square_list = [] # # def __init__(self, l): # self._length = l ...
{ "repo_name": "Frikeer/LearnPython", "path": "exc14/exc14.py", "copies": "1", "size": "1099", "license": "unlicense", "hash": 6761107140029584000, "line_mean": 17.9482758621, "line_max": 60, "alpha_frac": 0.5432211101, "autogenerated": false, "ratio": 2.8694516971279374, "config_test": false, ...
# 141. Linked List Cycle - LeetCode # https://leetcode.com/problems/linked-list-cycle/description/ # Definition for singly-linked list. class ListNode(object): def __init__(self, x): self.val = x self.next = None # TLE: # class Solution(object): # def hasCycle(self, head): # """ # ...
{ "repo_name": "heyf/cloaked-octo-adventure", "path": "leetcode/141_linked-list-cycle.py", "copies": "1", "size": "1611", "license": "mit", "hash": 3138583598956296000, "line_mean": 25, "line_max": 80, "alpha_frac": 0.5009310987, "autogenerated": false, "ratio": 3.5098039215686274, "config_test"...
"""141. Linked List Cycle https://leetcode.com/problems/linked-list-cycle/ Given a linked list, determine if it has a cycle in it. To represent a cycle in the given linked list, we use an integer pos which represents the position (0-indexed) in the linked list where tail connects to. If pos is -1, then there is no cy...
{ "repo_name": "isudox/leetcode-solution", "path": "python-algorithm/leetcode/linked_list_cycle.py", "copies": "1", "size": "1260", "license": "mit", "hash": 7742093496961098000, "line_mean": 21.1052631579, "line_max": 78, "alpha_frac": 0.6285714286, "autogenerated": false, "ratio": 3.452054794520...
# 141. Linked List Cycle # # Given a singly-linked list, determine if it has a cycle. # Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None def has_cycle_set(head): seen = set() node = head while node is not None: if...
{ "repo_name": "afbarnard/glowing-broccoli", "path": "lc/000141.py", "copies": "1", "size": "1621", "license": "mit", "hash": -5942605714990883000, "line_mean": 23.1940298507, "line_max": 69, "alpha_frac": 0.5712523134, "autogenerated": false, "ratio": 3.531590413943355, "config_test": false, ...
"""142. Linked List Cycle II https://leetcode.com/problems/linked-list-cycle-ii/ Given a linked list, return the node where the cycle begins. If there is no cycle, return null. To represent a cycle in the given linked list, we use an integer pos which represents the position (0-indexed) in the linked list where tail ...
{ "repo_name": "isudox/leetcode-solution", "path": "python-algorithm/leetcode/linked_list_cycle_ii.py", "copies": "1", "size": "2923", "license": "mit", "hash": -1472553331056441000, "line_mean": 23.3583333333, "line_max": 78, "alpha_frac": 0.5237769415, "autogenerated": false, "ratio": 3.92348993...
# 1439. Find the Kth Smallest Sum of a Matrix With Sorted Rows # Maintain the first 200 smallest sums and merge the rows one by one. # O(40 * 200 * log(200)) from heapq import heappush, heappop from collections import defaultdict class Solution: def kthSmallest(self, mat: List[List[int]], k: int) -> int: ...
{ "repo_name": "digiter/Arena", "path": "1439-find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows.py", "copies": "1", "size": "1254", "license": "mit", "hash": -2489632573334207500, "line_mean": 32.8918918919, "line_max": 70, "alpha_frac": 0.4704944179, "autogenerated": false, "ratio": 3.361930...
# 146 - LRU Cache (Medium) # https://leetcode.com/problems/lru-cache/ # Implement a LRU (Least Recently Used) cache. It has an initialization (with as # capacity) and two operations, get and set. Any time an element is retrieved, # set or updated, it has become the most recently used. If there's a lot of elements # ex...
{ "repo_name": "zubie7a/Algorithms", "path": "LeetCode/02_Medium/lc_146.py", "copies": "1", "size": "2603", "license": "mit", "hash": 5871490891473516000, "line_mean": 25.8453608247, "line_max": 85, "alpha_frac": 0.5255474453, "autogenerated": false, "ratio": 4.0482115085536545, "config_test": f...
"""146. LRU Cache https://leetcode.com/problems/lru-cache/ Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and put. get(key) - Get the value (will always be positive) of the key if the key exists in the cache, otherwise return -1. put(key, val...
{ "repo_name": "isudox/leetcode-solution", "path": "python-algorithm/leetcode/lru_cache.py", "copies": "1", "size": "3938", "license": "mit", "hash": -1133091344744559500, "line_mean": 26.9290780142, "line_max": 76, "alpha_frac": 0.5510411376, "autogenerated": false, "ratio": 3.488042515500443, ...
# 146. LRU Cache # # Design and implement a data structure for Least Recently Used (LRU) cache. # It should support the following operations: get and put. # # get(key) - Get the value (will always be positive) of the key if the key exists in the cache, # otherwise return -1. # put(key, value) - Set or insert the value ...
{ "repo_name": "gengwg/leetcode", "path": "146_lru_cache.py", "copies": "1", "size": "3358", "license": "apache-2.0", "hash": -3790482572943026700, "line_mean": 26.9833333333, "line_max": 95, "alpha_frac": 0.5413936867, "autogenerated": false, "ratio": 3.527310924369748, "config_test": false, ...
# 1473. Paint House III # O(m * n * target * n) class Solution: def minCost( self, houses: List[int], cost: List[List[int]], m: int, n: int, target: int ) -> int: INF = 10 ** 4 * 100 + 5 isPainted = lambda x: houses[x] != 0 @cache def solve(x, groupCnt, color): ...
{ "repo_name": "digiter/Arena", "path": "1473-paint-house-iii.py", "copies": "1", "size": "1184", "license": "mit", "hash": 4871736994581748000, "line_mean": 31.8888888889, "line_max": 83, "alpha_frac": 0.4527027027, "autogenerated": false, "ratio": 3.4121037463976944, "config_test": false, "h...
"""148. Sort List https://leetcode.com/problems/sort-list/ Sort a linked list in O(n log n) time using constant space complexity. Example 1: Input: 4->2->1->3 Output: 1->2->3->4 Example 2: Input: -1->5->3->4->0 Output: -1->0->3->4->5 """ from common.list_node import ListNode # Definition for a list node. # cl...
{ "repo_name": "isudox/leetcode-solution", "path": "python-algorithm/leetcode/sort_list.py", "copies": "1", "size": "1827", "license": "mit", "hash": 4130150800186769000, "line_mean": 24.375, "line_max": 70, "alpha_frac": 0.5073891626, "autogenerated": false, "ratio": 3.554474708171206, "config_...
# 148. Sort List # # Sort a linked list in O(n log n) time using constant space complexity. # http://bookshadow.com/weblog/2014/11/21/leetcode-sort-list/ # Definition for singly-linked list. class ListNode(object): def __init__(self, x): self.val = x self.next = None class Solution(object): d...
{ "repo_name": "gengwg/leetcode", "path": "148_sort_list.py", "copies": "1", "size": "1543", "license": "apache-2.0", "hash": 3449421644226414600, "line_mean": 26.5535714286, "line_max": 72, "alpha_frac": 0.5547634478, "autogenerated": false, "ratio": 3.9564102564102566, "config_test": false, ...
#14 - Inflight Entertainment.py # https://www.interviewcake.com/question/python/inflight-entertainment #Users on longer flights like to start a second movie right when their first one ends, #but they complain that the plane usually lands before they can see the ending. #So you're building a feature for choosing two mo...
{ "repo_name": "bruno615/one-off-analysis", "path": "Python/Inteview Cake/14 - Inflight Entertainment.py", "copies": "1", "size": "1639", "license": "mit", "hash": -5125389999771418000, "line_mean": 41.0256410256, "line_max": 113, "alpha_frac": 0.7504575961, "autogenerated": false, "ratio": 3.5942...
# 14. print_log('\n14. Issuer (Trust Anchor) is creating a Credential Offer for Prover\n') schema_json = json.dumps(schema) cred_offer_json = await anoncreds.issuer_create_credential_offer(wallet_handle, cred_def_id) print_log('Credential Offer: ') pprint.pprint(json.load...
{ "repo_name": "anastasia-tarasova/indy-sdk", "path": "docs/how-tos/issue-credential/python/step4.py", "copies": "2", "size": "2162", "license": "apache-2.0", "hash": 7309655443027840000, "line_mean": 49.2790697674, "line_max": 178, "alpha_frac": 0.6503237743, "autogenerated": false, "ratio": 3.44...
''' 14-plot_target-list.py =============================================== AIM: Given a catalogue of objects, plots when the targets are visible according to their magnitude for a given period of time. INPUT: files: - <orbit_id>_misc/orbits.dat - <orbit_id>_flux/flux_*.dat variables: see section PARAMETERS (below)...
{ "repo_name": "kuntzer/SALSA-public", "path": "14_plot_target-list.py", "copies": "1", "size": "11435", "license": "bsd-3-clause", "hash": -7994642935063516000, "line_mean": 28.8563968668, "line_max": 224, "alpha_frac": 0.6625273284, "autogenerated": false, "ratio": 2.880352644836272, "config_t...
#1-50. Разработайте собственную стратегию ходов компьютера для игры "Крестики-нолики" (Задача 12). #Перепишите функцию computer_move() в соответствии с этой стратегией. # Митин Д.С., 01.06.2016, 22:50 X="X" O="O" EMPTY=" " TIE="Ничья" NUM_SQUARES=9 def display_instruct(): print(''' Привет, студент! Давай поиграем в...
{ "repo_name": "Mariaanisimova/pythonintask", "path": "INBa/2015/Mitin_D_S/task_13_15.py", "copies": "1", "size": "3835", "license": "apache-2.0", "hash": -1901769136229669000, "line_mean": 23.0563380282, "line_max": 124, "alpha_frac": 0.6333821376, "autogenerated": false, "ratio": 2.1600253004427...
# 151 currencies, 22650 currency pairs, 364 days (period 1) 134 days (period 2) => 3,035,100(20,100/from_c) - 8,221,950 entries(8361.157) #####IMPORT PACKAGES print('importing packages') import time import sqlite3 import json import requests import datetime import pytz from datetime import date from multiprocessing.p...
{ "repo_name": "HartBlanc/Mastercard_Exchange_Rates", "path": "rate__retriever_multi_oct_14.py", "copies": "1", "size": "6885", "license": "mit", "hash": -947402704726338300, "line_mean": 33.425, "line_max": 169, "alpha_frac": 0.5443718228, "autogenerated": false, "ratio": 3.7055974165769645, "c...
# 151 currencies, 22650 currency pairs, 364 days (period 1) 134 days (period 2) => 3,035,100(20,100/from_c) - 8,221,950 entries(8361.157) print('importing packages') import time import sqlite3 import json import requests import datetime import math import pytz from datetime import date from multiprocessing.pool impor...
{ "repo_name": "HartBlanc/Mastercard_Exchange_Rates", "path": "rate__retriever_multi.py", "copies": "1", "size": "9269", "license": "mit", "hash": 5944809106055677000, "line_mean": 34.1098484848, "line_max": 156, "alpha_frac": 0.5043694034, "autogenerated": false, "ratio": 3.7571949736522092, "c...
# 152. Maximum Product Subarray # # Find the contiguous subarray within an array (containing at least one number) which has the largest product. # # For example, given the array [2,3,-2,4], # the contiguous subarray [2,3] has the largest product = 6. class Solution: def maxProduct(self, A): """ ht...
{ "repo_name": "gengwg/leetcode", "path": "152_maximum_product_subarray.py", "copies": "1", "size": "1725", "license": "apache-2.0", "hash": -5237878554375346000, "line_mean": 29.6981132075, "line_max": 110, "alpha_frac": 0.5175169023, "autogenerated": false, "ratio": 2.926258992805755, "config_...
# 1531. String Compression II # O(kN^2), 1340 ms class Solution: def getLengthOfOptimalCompression(self, s: str, k: int) -> int: INF = 105 def runLen(count): if count <= 1: return count if count <= 9: return 2 if count <= 99: ...
{ "repo_name": "digiter/Arena", "path": "1531-string-compression-ii_2.py", "copies": "1", "size": "1114", "license": "mit", "hash": -2726846771393935000, "line_mean": 24.9069767442, "line_max": 70, "alpha_frac": 0.3859964093, "autogenerated": false, "ratio": 3.950354609929078, "config_test": fal...
# 1531. String Compression II # The dynamic programming states are sparse. # Time: 2944 ms class Solution: def getLengthOfOptimalCompression(self, s: str, k: int) -> int: char, cnt = [], [] x = 0 while x < len(s): y = x + 1 while y < len(s) and s[y] == s[x]: ...
{ "repo_name": "digiter/Arena", "path": "1531-string-compression-ii.py", "copies": "1", "size": "1706", "license": "mit", "hash": -2965531853986724400, "line_mean": 30.0181818182, "line_max": 87, "alpha_frac": 0.429073857, "autogenerated": false, "ratio": 4.023584905660377, "config_test": false,...
# 153. Find Minimum in Rotated Sorted Array # # Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand. # # (i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2). # # Find the minimum element. # # You may assume no duplicate exists in the array. class Solution(object): # http://b...
{ "repo_name": "gengwg/leetcode", "path": "153_find_minimum_in_rotated_sorted_array.py", "copies": "1", "size": "1129", "license": "apache-2.0", "hash": -8695469665433482000, "line_mean": 25.880952381, "line_max": 96, "alpha_frac": 0.4880425155, "autogenerated": false, "ratio": 3.189265536723164, ...
# 155. Min Stack - LeetCode # https://leetcode.com/problems/min-stack/description/ # Design a stack that supports push, pop, top, and retrieving the minimum element in constant time. class MinStack(object): def __init__(self): """ initialize your data structure here. """ self.stac...
{ "repo_name": "heyf/cloaked-octo-adventure", "path": "leetcode/155_min-stack.py", "copies": "1", "size": "1501", "license": "mit", "hash": 3087350743966768600, "line_mean": 22.8412698413, "line_max": 99, "alpha_frac": 0.5163224517, "autogenerated": false, "ratio": 3.4585253456221197, "config_te...
"""155. Min Stack https://leetcode.com/problems/min-stack/ Design a stack that supports push, pop, top, and retrieving the minimum element in constant time. push(x) -- Push element x onto stack. pop() -- Removes the element on top of the stack. top() -- Get the top element. getMin() -- Retrieve the minimum element in...
{ "repo_name": "isudox/leetcode-solution", "path": "python-algorithm/leetcode/min_stack.py", "copies": "1", "size": "1168", "license": "mit", "hash": 3806502000796175400, "line_mean": 21.9019607843, "line_max": 79, "alpha_frac": 0.5924657534, "autogenerated": false, "ratio": 3.3855072463768114, ...
# 155. Min Stack # # Design a stack that supports push, pop, top, # and retrieving the minimum element in constant time. # # push(x) -- Push element x onto stack. # pop() -- Removes the element on top of the stack. # top() -- Get the top element. # getMin() -- Retrieve the minimum element in the stack. # Example: # Mi...
{ "repo_name": "gengwg/leetcode", "path": "155_min_stack.py", "copies": "1", "size": "2488", "license": "apache-2.0", "hash": -2329201528075071000, "line_mean": 23.1553398058, "line_max": 67, "alpha_frac": 0.5438102894, "autogenerated": false, "ratio": 3.3440860215053765, "config_test": false, ...
# 1563. Stone Game V # Dynamic programming from bottom up. # Time complexity: O(N^2), 6380 ms # # Note that we can't assume stoneGameV(A) <= stoneGameV(A + [x]), see # https://leetcode.com/problems/stone-game-v/discuss/889244/Please-do-not-assume-monotonicity-like-stoneGameV(A)-stoneGameV(A%3A-1) class Solution: ...
{ "repo_name": "digiter/Arena", "path": "1563-stone-game-v.py", "copies": "1", "size": "2079", "license": "mit", "hash": -8198490243154992000, "line_mean": 34.8448275862, "line_max": 131, "alpha_frac": 0.4785954786, "autogenerated": false, "ratio": 3.279179810725552, "config_test": false, "has...
# 1563. Stone Game V # Time: O(N^2), 5280 ms # # Another bottom up dynamic programming. # Loops y increasing and x decreasing, in order to enumerate interval [x, y] from small to large. # So that the answer of interval [x, y] can be constructed via its sub-intervals. class Solution: def stoneGameV(self, stoneValu...
{ "repo_name": "digiter/Arena", "path": "1563-stone-game-v_2.py", "copies": "1", "size": "1851", "license": "mit", "hash": -2344841015569233000, "line_mean": 36.02, "line_max": 97, "alpha_frac": 0.4575904916, "autogenerated": false, "ratio": 3.219130434782609, "config_test": false, "has_no_key...
# 156. Binary Tree Upside Down # Given a binary tree where all the right nodes are either leaf nodes with a sibling # (a left node that shares the same parent node) or empty, # flip it upside down and turn it into a tree where the original right nodes turned into left leaf nodes. # Return the new root. # For example:...
{ "repo_name": "gengwg/leetcode", "path": "156_binary_tree_upside_down.py", "copies": "1", "size": "1310", "license": "apache-2.0", "hash": -2283411060256632800, "line_mean": 26.8723404255, "line_max": 109, "alpha_frac": 0.6526717557, "autogenerated": false, "ratio": 3.234567901234568, "config_t...
"""15N CEST with CW decoupling. Analyzes chemical exchange in the presence of 1H CW decoupling during the CEST block. Magnetization evolution is calculated using the 30*30 two-spin matrix: [ I{xyz}, S{xyz}, 2I{xyz}S{xyz} ]{a, b, ...} Notes ----- The calculation is designed specifically to analyze the experiment foun...
{ "repo_name": "gbouvignies/chemex", "path": "chemex/experiments/cest/n_ip_h_cw.py", "copies": "1", "size": "2437", "license": "bsd-3-clause", "hash": 8694834469004552000, "line_mean": 29.0864197531, "line_max": 82, "alpha_frac": 0.5999179319, "autogenerated": false, "ratio": 3.2278145695364238, ...
''' 15-observation_fixed_direction =============================================== AIM: Similar to 14-<...>.py, but for only one traget. INPUT: files: - <orbit_id>_misc/orbits.dat - <orbit_id>_flux/flux_*.dat variables: see section PARAMETERS (below) OUTPUT: in <orbit_id>_figures/ : (see below for file name defin...
{ "repo_name": "kuntzer/SALSA-public", "path": "15_observation_fixed_direction.py", "copies": "1", "size": "10213", "license": "bsd-3-clause", "hash": 1957432752794572000, "line_mean": 26.4543010753, "line_max": 117, "alpha_frac": 0.6433956722, "autogenerated": false, "ratio": 2.8057692307692306, ...
# 15-Puzzle Solver # Yoni Elhanani 2019 from typing import List, Iterator, Tuple from argparse import ArgumentParser from heapq import heappop, heappush from random import randrange # A state is a configuration of stones on the board State = Tuple[int, ...] def showState(state: State) -> str: "Prints the state...
{ "repo_name": "ryanbhayward/games-puzzles-algorithms", "path": "simple/stile/15star.py", "copies": "1", "size": "6039", "license": "mit", "hash": 9147156056561495000, "line_mean": 33.1186440678, "line_max": 97, "alpha_frac": 0.5721145885, "autogenerated": false, "ratio": 3.5481786133960047, "co...
# 15-Puzzle Solver # Yoni Elhanani 2019 # RBH: added node count printing from typing import List, Iterator, Tuple from argparse import ArgumentParser from collections import deque from random import randrange # A state is a configuration of stones on the board State = Tuple[int, ...] def showState(state: State) ...
{ "repo_name": "ryanbhayward/games-puzzles-algorithms", "path": "simple/stile/15puzzle.py", "copies": "1", "size": "6363", "license": "mit", "hash": -4683582141403558000, "line_mean": 36.4294117647, "line_max": 97, "alpha_frac": 0.5599559956, "autogenerated": false, "ratio": 3.629777524244153, "...
"""15th Night Flask App.""" from email_client import send_email, verify_email from flask import ( Flask, render_template, redirect, url_for, request, session, flash ) from flask.ext.login import ( login_user, current_user, login_required, LoginManager ) from twilio_client import send_sms from werkzeug.exceptio...
{ "repo_name": "Hack4Eugene/Hack4Cause2016", "path": "src/bobby-drop-tables/15thnight/app/__init__.py", "copies": "1", "size": "8815", "license": "mit", "hash": -798903816248380500, "line_mean": 31.8917910448, "line_max": 102, "alpha_frac": 0.600226886, "autogenerated": false, "ratio": 3.992300724...
# 1601. Maximum Number of Achievable Transfer Requests # Time: 4572 ms class Solution: def maximumRequests(self, n: int, requests: List[List[int]]) -> int: lenReq = len(requests) def isCircle(subset): inDegree = collections.Counter() outDegree = collections.Counter() ...
{ "repo_name": "digiter/Arena", "path": "1601-maximum-number-of-achievable-transfer-requests.py", "copies": "1", "size": "1302", "license": "mit", "hash": 6513162663974796000, "line_mean": 32.3846153846, "line_max": 77, "alpha_frac": 0.4869431644, "autogenerated": false, "ratio": 4.213592233009709...
# 1601. Maximum Number of Achievable Transfer Requests # Time: O(2^len(requests)), 640 ms class Solution: def maximumRequests(self, n: int, requests: List[List[int]]) -> int: stay = sum(1 if x == y else 0 for x, y in requests) requests = [(x, y) for x, y in requests if x != y] lenReq = len...
{ "repo_name": "digiter/Arena", "path": "1601-maximum-number-of-achievable-transfer-requests_3.py", "copies": "1", "size": "1205", "license": "mit", "hash": 403998231328250750, "line_mean": 27.6904761905, "line_max": 72, "alpha_frac": 0.4406639004, "autogenerated": false, "ratio": 3.86217948717948...
# 16/02/2018 import sys def ffd(s, b): """First Fit Decreasing algorithm 1.Sort the items to be inserted in decreasing order by size 2.Go through the items in sorted order 1.Try to place the item in the first bin that will accommodate it 2.If no bin is found, start a new bin """ #sh...
{ "repo_name": "tlseabra/dailyprogrammer", "path": "Python/easy/e350.py", "copies": "2", "size": "1313", "license": "mit", "hash": -6985693161280268000, "line_mean": 33.5526315789, "line_max": 112, "alpha_frac": 0.5582635187, "autogenerated": false, "ratio": 3.298994974874372, "config_test": fal...
# 160. Intersection of Two Linked Lists - LeetCode # https://leetcode.com/problems/intersection-of-two-linked-lists/description/ # Your code should preferably run in O(n) time and use only O(1) memory. # Definition for singly-linked list. class ListNode(object): def __init__(self, x): self.val = x ...
{ "repo_name": "heyf/cloaked-octo-adventure", "path": "leetcode/160_intersection-of-two-linked-lists.py", "copies": "1", "size": "1591", "license": "mit", "hash": 8724546032823632000, "line_mean": 23.4923076923, "line_max": 77, "alpha_frac": 0.5028284098, "autogenerated": false, "ratio": 3.3636363...
# 160. Intersection of Two Linked Lists # # Write a program to find the node at which the intersection # of two singly linked lists begins. # # # For example, the following two linked lists: # # A: a1 - a2 # \ # c1 - c2 - c3 # / # B: b1 - b2 - b3 ...
{ "repo_name": "gengwg/leetcode", "path": "160_intersection_two_linked_lists.py", "copies": "1", "size": "3199", "license": "apache-2.0", "hash": -8922265284723552000, "line_mean": 25.0081300813, "line_max": 83, "alpha_frac": 0.5323538606, "autogenerated": false, "ratio": 3.7591069330199764, "co...
# 163 Missing Ranges # Given a sorted integer array where the range of elements are [lower, upper] inclusive, # return its missing ranges. # # For example, given [0, 1, 3, 50, 75], lower = 0 and upper = 99, # return ["2", "4->49", "51->74", "76->99"]. # class Solution(object): def findMissingRanges(self, nums, ...
{ "repo_name": "gengwg/leetcode", "path": "163_missing_range.py", "copies": "1", "size": "1202", "license": "apache-2.0", "hash": -5720606794152456000, "line_mean": 26.976744186, "line_max": 88, "alpha_frac": 0.496672213, "autogenerated": false, "ratio": 3.840255591054313, "config_test": false, ...
# 1655. Distribute Repeating Integers # Enumerates a subset of quantity to fill the ith freq. # Dynamic programming, number of states: len(freq) * 2^len(quantity). # Time complexity: O(3^len(quantity)), see https://cp-algorithms.com/algebra/all-submasks.html class Solution: def canDistribute(self, nums: List[int]...
{ "repo_name": "digiter/Arena", "path": "1655-distribute-repeating-integers.py", "copies": "1", "size": "1140", "license": "mit", "hash": -6979880613950458000, "line_mean": 33.5454545455, "line_max": 94, "alpha_frac": 0.5175438596, "autogenerated": false, "ratio": 3.877551020408163, "config_test...
# 1659. Maximize Grid Happiness # # Time complexity of this dynamic programming: # Number of states: 5^2 * 6 * 6 * 3^5 # Number of transitions: 3 * 5 # So 3*10^6 in total. # # It takes 228 ms to calculate the input of (5, 5, 5, 5). class Solution: def getMaxGridHappiness( self, m: int, n: int, introve...
{ "repo_name": "digiter/Arena", "path": "1659-maximize-grid-happiness_2.py", "copies": "1", "size": "1887", "license": "mit", "hash": -7347570347155684000, "line_mean": 30.45, "line_max": 78, "alpha_frac": 0.4483306836, "autogenerated": false, "ratio": 3.774, "config_test": false, "has_no_keyw...
# 1659. Maximize Grid Happiness # This solution got TLE for input (5, 5, 5, 5): it takes 3380 ms to run. # Time complexity (roughtly): # Number of states: 5 * 6 * 6 * 3^5 # Number of transitions: 3^5 * 5 # So 5*10^7 in total. class Solution: def getMaxGridHappiness( self, m: int, n: int, introvertsCoun...
{ "repo_name": "digiter/Arena", "path": "1659-maximize-grid-happiness_TLE.py", "copies": "1", "size": "2814", "license": "mit", "hash": -646941700635765400, "line_mean": 36.0263157895, "line_max": 78, "alpha_frac": 0.4004975124, "autogenerated": false, "ratio": 4.289634146341464, "config_test": ...
# 165. Compare Version Numbers # # Compare two version numbers version1 and version2. # If version1 > version2 return 1, if version1 < version2 return -1, otherwise return 0. # # You may assume that the version strings are non-empty and contain only digits and the . character. # The . character does not represent a dec...
{ "repo_name": "gengwg/leetcode", "path": "165_compare_version_numbers.py", "copies": "1", "size": "2196", "license": "apache-2.0", "hash": -4598336444710715000, "line_mean": 29.9295774648, "line_max": 100, "alpha_frac": 0.5564663024, "autogenerated": false, "ratio": 3.425897035881435, "config_t...
# 16695334890 import math import euler s = 0 for a in xrange(1, 999/17): aa = euler.digit_usage(a * 17, 3) for b in xrange(1, 999/13): if (a * 17) / 10 != (b * 13) % 100: continue for c in xrange(1, 999/11): if (b * 13) / 10 != (c * 11) % 100: continue ...
{ "repo_name": "higgsd/euler", "path": "py/43.py", "copies": "1", "size": "1463", "license": "bsd-2-clause", "hash": 1447385772348309800, "line_mean": 37.5, "line_max": 81, "alpha_frac": 0.3075871497, "autogenerated": false, "ratio": 3.8806366047745358, "config_test": false, "has_no_keywords":...
# 167. Two Sum II - Input array is sorted # # Given an array of integers that is already sorted in ascending order, # find two numbers such that they add up to a specific target number. # # The function twoSum should return indices of the two numbers such that # they add up to the target, where index1 must be less than...
{ "repo_name": "gengwg/leetcode", "path": "167_two_sum_input_array_sorted.py", "copies": "1", "size": "1494", "license": "apache-2.0", "hash": -7301708719713219000, "line_mean": 32.9545454545, "line_max": 108, "alpha_frac": 0.5702811245, "autogenerated": false, "ratio": 3.830769230769231, "confi...
# 1681. Minimum Incompatibility # O(C(N, SIZE-1)*N + C(N-SIZE, SIZE-1)*(N-SIZE) + C(N-SIZE*2, SIZE-1)*(N-SIZE*2) + ...) # About O(10^5) class Solution: def minimumIncompatibility(self, nums: List[int], k: int) -> int: nums.sort() N = len(nums) SIZE = N // k INF = nums[-1] * N + 5 ...
{ "repo_name": "digiter/Arena", "path": "1681-minimum-incompatibility.py", "copies": "1", "size": "1210", "license": "mit", "hash": -8493537203627276000, "line_mean": 30.0256410256, "line_max": 87, "alpha_frac": 0.4338842975, "autogenerated": false, "ratio": 3.723076923076923, "config_test": fal...
# 1687. Delivering Boxes from Storage to Ports # Inspired from https://leetcode.com/problems/delivering-boxes-from-storage-to-ports/discuss/969560/Python-O(n).-DP-%2B-Monotonic-Queue-(Sliding-Window)-with-Full-Explanation class Solution: def boxDelivering( self, boxes: List[List[int]], portsCount: int, ma...
{ "repo_name": "digiter/Arena", "path": "1687-delivering-boxes-from-storage-to-ports.py", "copies": "1", "size": "1812", "license": "mit", "hash": 8724266326574729000, "line_mean": 38.3913043478, "line_max": 174, "alpha_frac": 0.5469094923, "autogenerated": false, "ratio": 3.425330812854442, "co...
__author__ = 'Libao Jin' __date__ = 'December 14, 2015' class Solution(object): def convertToTitle(self, n): """ :type n: int :rtype: str """ alphabets = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' remainders = [] r = n % 26 if r == 0: r = 26 ...
{ "repo_name": "jinlibao/LeetCode-Solutions", "path": "solutions/168_Excel_Sheet_Column_TItle.py", "copies": "2", "size": "1099", "license": "mit", "hash": 675759214301460400, "line_mean": 21.4285714286, "line_max": 48, "alpha_frac": 0.4895359418, "autogenerated": false, "ratio": 3.663333333333333...
# 1697. Checking Existence of Edge Length Limited Paths # Should be medium difficulty. class Solution: def distanceLimitedPathsExist( self, n: int, edgeList: List[List[int]], queries: List[List[int]] ) -> List[bool]: # Adds index to each query. for i in range(len(queries)): ...
{ "repo_name": "digiter/Arena", "path": "1697-checking-existence-of-edge-length-limited-paths.py", "copies": "1", "size": "1276", "license": "mit", "hash": -6153467610366099000, "line_mean": 30.1219512195, "line_max": 73, "alpha_frac": 0.5039184953, "autogenerated": false, "ratio": 3.5444444444444...
#16 - cake thief.py import pdb # weighs 7 kilograms and has a value of 160 pounds (7, 160) # weighs 3 kilograms and has a value of 90 pounds (3, 90) cake_tuples = [(7, 160), (3, 90), (2, 15)] capacity = 20 def max_duffel_bag_value(cake_tuples, capacity): # pdb.set_trace() # rank by value/weight cake_tupl...
{ "repo_name": "bruno615/one-off-analysis", "path": "Python/Inteview Cake/16 - cake thief.py", "copies": "1", "size": "1164", "license": "mit", "hash": 2834756345059349500, "line_mean": 25.4545454545, "line_max": 77, "alpha_frac": 0.6589347079, "autogenerated": false, "ratio": 2.5866666666666664, ...
''' 16-compute-ephemerids.py ========================= AIM: Computes the ephermerids for all the cells that constitute the sky grids. The cell must be visible for at least (period)-(max_interruptions)+t_acquisition To be used by the three next scripts (17, 18, 19) to treat and plot. INPUT: files: - <orbit_id>_misc/...
{ "repo_name": "kuntzer/SALSA-public", "path": "16_compute_ephermerids.py", "copies": "1", "size": "10591", "license": "bsd-3-clause", "hash": -4849171423493973000, "line_mean": 30.15, "line_max": 167, "alpha_frac": 0.6587668775, "autogenerated": false, "ratio": 2.889768076398363, "config_test":...
# 16 GPIO of ESP board # Pin objects are stored here once they have been initialized pins = [None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None] def pwmStart(arg): pwmNb = arg[0] frequence = arg[1] print("pwmStart", pwmNb, frequence) def pwmSet(arg): pwmNb = arg[0] dut...
{ "repo_name": "nodesign/micropython-electrolink", "path": "firmware/modules/electroGpioDebug.py", "copies": "1", "size": "1598", "license": "apache-2.0", "hash": -5583718346052110000, "line_mean": 37.0714285714, "line_max": 159, "alpha_frac": 0.6157697121, "autogenerated": false, "ratio": 3.20240...
''' Created on Mar 13, 2016 @author: Dead Robot Society ''' from wallaby import ao from wallaby import digital from wallaby import analog from wallaby import seconds from wallaby import a_button_clicked from wallaby import b_button_clicked import constants as c # reads the right button def getRB...
{ "repo_name": "gras/16-TaterBot", "path": "src/sensors.py", "copies": "1", "size": "2682", "license": "mit", "hash": -292232812248376400, "line_mean": 22.1621621622, "line_max": 71, "alpha_frac": 0.6118568233, "autogenerated": false, "ratio": 3.6489795918367345, "config_test": false, "has_no_...
''' Created on Mar 13, 2016 @author: Dead Robot Society ''' import constants as c from sensors import onBlack from sensors import atArmLength from sensors import getET from wallaby import motor from wallaby import msleep from wallaby import seconds # tests motors def testMotors(): drive(10...
{ "repo_name": "gras/16-TaterBot", "path": "src/drive.py", "copies": "1", "size": "4870", "license": "mit", "hash": 790785920122633600, "line_mean": 22.1138613861, "line_max": 72, "alpha_frac": 0.5435318275, "autogenerated": false, "ratio": 3.4785714285714286, "config_test": false, "has_no_key...
''' Created on Mar 13, 2016 @author: Dead Robot Society ''' import constants as c from wallaby import set_servo_position from wallaby import msleep from wallaby import enable_servos from wallaby import get_servo_position from wallaby import ao # tests servos def testServos(): print "Testing serv...
{ "repo_name": "gras/16-TaterBot", "path": "src/servos.py", "copies": "1", "size": "1902", "license": "mit", "hash": 287913699535163460, "line_mean": 22.4615384615, "line_max": 52, "alpha_frac": 0.6366982124, "autogenerated": false, "ratio": 2.8905775075987843, "config_test": false, "has_no_ke...