text
stringlengths
0
1.05M
meta
dict
'32x32x32 Enzynet architecture with adapted weights' # Authors: Afshine Amidi <lastname@mit.edu> # Shervine Amidi <firstname@stanford.edu> # MIT License import numpy as np import os.path from enzynet.keras_utils import MetricsHistory, Voting from enzynet.tools import read_dict, get_class_weights from enzy...
{ "repo_name": "shervinea/enzynet", "path": "scripts/architecture/enzynet_adapted.py", "copies": "1", "size": "6707", "license": "mit", "hash": -2624966482491894300, "line_mean": 30.0509259259, "line_max": 93, "alpha_frac": 0.5692560012, "autogenerated": false, "ratio": 3.9360328638497655, "conf...
'32x32x32 Enzynet architecture with uniform weights' # Authors: Afshine Amidi <lastname@mit.edu> # Shervine Amidi <firstname@stanford.edu> # MIT License import numpy as np import os.path from enzynet.keras_utils import MetricsHistory, Voting from enzynet.tools import read_dict, get_class_weights from enzy...
{ "repo_name": "shervinea/enzynet", "path": "scripts/architecture/enzynet_uniform.py", "copies": "1", "size": "6709", "license": "mit", "hash": 6131769097190653000, "line_mean": 30.0601851852, "line_max": 93, "alpha_frac": 0.569384409, "autogenerated": false, "ratio": 3.9348973607038125, "config...
# 330-patching-array.py class Solution(object): def minPatches_wa(self, nums, n): # Wrong answer. not this method. """ :type nums: List[int] :type n: int :rtype: int """ # Example: # nums = [1, 2, 4, 9] # rbound = 1 + 2 + 4 = 7 count ...
{ "repo_name": "daicang/Leetcode-solutions", "path": "330-patching-array.py", "copies": "1", "size": "1730", "license": "mit", "hash": 7442747472148930000, "line_mean": 23.3661971831, "line_max": 70, "alpha_frac": 0.4040462428, "autogenerated": false, "ratio": 3.949771689497717, "config_test": f...
# 331. Verify Preorder Serialization of a Binary Tree # One way to serialize a binary tree is to use pre-order traversal. # When we encounter a non-null node, we record the node's value. # If it is a null node, we record using a sentinel value such as #. # # _9_ # / \ # 3 2 # / \ / \ # 4 1 # ...
{ "repo_name": "gengwg/leetcode", "path": "331_verify_preorder_serialization_of_a_binary_tree.py", "copies": "1", "size": "2336", "license": "apache-2.0", "hash": -6263315650736752000, "line_mean": 34.3939393939, "line_max": 166, "alpha_frac": 0.6125856164, "autogenerated": false, "ratio": 3.47102...
# 331-verify-preorder-serialization-of-binary-tree.py class Solution(object): def isValidSerialization_TLE(self, preorder): """ :type preorder: str :rtype: bool """ def loop(l): length = len(l) if length < 3: if length == 1 and l[0] ==...
{ "repo_name": "daicang/Leetcode-solutions", "path": "331-verify-preorder-serialization-of-binary-tree.py", "copies": "1", "size": "1138", "license": "mit", "hash": 3027573136362382000, "line_mean": 31.5142857143, "line_max": 174, "alpha_frac": 0.4551845343, "autogenerated": false, "ratio": 3.1523...
# 332-reconstruct-itinerary.py class Solution(object): def findItinerary(self, tickets): """ :type tickets: List[List[str]] :rtype: List[str] """ # Wrong # ret = ["JFK"] # flag = 0 # while flag == 0: # tmp = "ZZZ" # found = 0 #...
{ "repo_name": "daicang/Leetcode-solutions", "path": "332-reconstruct-itinerary.py", "copies": "1", "size": "1542", "license": "mit", "hash": -6769834705727384000, "line_mean": 25.5862068966, "line_max": 58, "alpha_frac": 0.4007782101, "autogenerated": false, "ratio": 3.645390070921986, "config_...
'''[3,3,5,5,6,7] Given an array nums, there is a sliding window of size k which is moving from the very left of the array to the very right. You can only see the k numbers in the window. Each time the sliding window moves right by one position. For example, Given nums = [1,3,-1,-3,5,3,6,7], and k = 3. Window position...
{ "repo_name": "liuyonggg/learning_python", "path": "leetcode/maxSlidingWindow.py", "copies": "1", "size": "1040", "license": "mit", "hash": 3996515629385024000, "line_mean": 31.5, "line_max": 227, "alpha_frac": 0.5451923077, "autogenerated": false, "ratio": 2.613065326633166, "config_test": fal...
# 335-self-crossing.py class Solution(object): def isSelfCrossing(self, x): """ :type x: List[int] :rtype: bool """ l = len(x) if (l < 4): return False flag = 0 # Is square decreasing hasBound = 0 # Has previous edge, cannot cross this bo...
{ "repo_name": "daicang/Leetcode-solutions", "path": "335-self-crossing.py", "copies": "1", "size": "1258", "license": "mit", "hash": -619774399808925200, "line_mean": 27.5909090909, "line_max": 70, "alpha_frac": 0.3728139905, "autogenerated": false, "ratio": 4.460992907801418, "config_test": fa...
"""336. Palindrome Pairs Hard URL: https://leetcode.com/problems/palindrome-pairs/ Given a list of unique words, find all pairs of distinct indices (i, j) in the given list, so that the concatenation of the two words, i.e. words[i] + words[j] is a palindrome. Example 1: Input: ["abcd","dcba","lls","s","sssll"] Outpu...
{ "repo_name": "bowen0701/algorithms_data_structures", "path": "lc0336_palindrome_pairs.py", "copies": "1", "size": "2698", "license": "bsd-2-clause", "hash": 8212894213480702000, "line_mean": 31.9024390244, "line_max": 88, "alpha_frac": 0.5681986657, "autogenerated": false, "ratio": 3.42385786802...
# 336-palindrome-pairs.py class Solution(object): """ :type words: List[str] :rtype: List[List[int]] """ # Brute force # def palindromePairs(self, words): # def isPalindrome(w): # return w == w[::-1] # ret = [] # for i in range(len(words)): # for ...
{ "repo_name": "daicang/Leetcode-solutions", "path": "336-palindrome-pairs.py", "copies": "1", "size": "1681", "license": "mit", "hash": -6214470868893065000, "line_mean": 31.3269230769, "line_max": 79, "alpha_frac": 0.4396192742, "autogenerated": false, "ratio": 3.5614406779661016, "config_test...
# 339 - Nested List Weight Sum (Easy) # https://leetcode.com/problems/nested-list-weight-sum/ # """ # This is the interface that allows for creating nested lists. # You should not implement it, or speculate about its implementation # """ #class NestedInteger(object): # def isInteger(self): # """ # @re...
{ "repo_name": "zubie7a/Algorithms", "path": "LeetCode/01_Easy/lc_339.py", "copies": "1", "size": "1512", "license": "mit", "hash": -3572588796100940000, "line_mean": 29.8775510204, "line_max": 95, "alpha_frac": 0.583994709, "autogenerated": false, "ratio": 3.9069767441860463, "config_test": fal...
#[3|3] def Tile(top, bottom): return {"top": top, "bottom": bottom} def placeDominioTile(tileArray, newTile): if (newTile["bottom"] == tileArray[0]["top"]): tileArray.insert(0, newTile) return tileArray if (newTile["top"] == tileArray[len(tileArray)-1]["bottom"]): tileA...
{ "repo_name": "adrianbeloqui/Python", "path": "domino_tiles.py", "copies": "1", "size": "1295", "license": "mit", "hash": -1866446247554270200, "line_mean": 32.0789473684, "line_max": 105, "alpha_frac": 0.6023166023, "autogenerated": false, "ratio": 2.9770114942528734, "config_test": false, "...
# 341-flatten-nested-list-iterator.py # """ # This is the interface that allows for creating nested lists. # You should not implement it, or speculate about its implementation # """ #class NestedInteger(object): # def isInteger(self): # """ # @return True if this NestedInteger holds a single integer, ...
{ "repo_name": "daicang/Leetcode-solutions", "path": "341-flatten-nested-list-iterator.py", "copies": "1", "size": "1763", "license": "mit", "hash": 1987393945112994600, "line_mean": 26.546875, "line_max": 95, "alpha_frac": 0.5706182643, "autogenerated": false, "ratio": 3.997732426303855, "confi...
# 342. Power of Four # Given an integer (signed 32 bits), write a function to check whether it is a power of 4. # Example: # Given num = 16, return true. Given num = 5, return false. # Follow up: Could you solve it without loops/recursion? # O(1) / O(1) # No recursion or loops, but using count() class Solution(obj...
{ "repo_name": "aenon/OnlineJudge", "path": "leetcode/5.BitManipulation/342.PowerofFour.py", "copies": "1", "size": "1283", "license": "mit", "hash": 63444615020309800, "line_mean": 28.8604651163, "line_max": 105, "alpha_frac": 0.570537802, "autogenerated": false, "ratio": 3.4582210242587603, "c...
# 345. Reverse Vowels of a String - LeetCode # https://leetcode.com/problems/reverse-vowels-of-a-string/description/ class Solution(object): def reverseVowels(self, s): """ :type s: str :rtype: str """ vowels = { "a": True, "e": True, "i":...
{ "repo_name": "heyf/cloaked-octo-adventure", "path": "leetcode/345_reverse-vowels-of-a-string.py", "copies": "1", "size": "1246", "license": "mit", "hash": -4454468884765435400, "line_mean": 24.4489795918, "line_max": 73, "alpha_frac": 0.4060995185, "autogenerated": false, "ratio": 3.376693766937...
# 345. Reverse Vowels of a String # Write a function that takes a string as input and reverse only the vowels of a string. # Example 1: # Given s = "hello", return "holle". # Example 2: # Given s = "leetcode", return "leotcede". # Note: # The vowels does not include the letter "y". class Solution(object): def...
{ "repo_name": "gengwg/leetcode", "path": "345_reverse_vowels_of_string.py", "copies": "1", "size": "1165", "license": "apache-2.0", "hash": 6087780729574406000, "line_mean": 25.4772727273, "line_max": 88, "alpha_frac": 0.4815450644, "autogenerated": false, "ratio": 3.082010582010582, "config_te...
# 3 4 5 triangle inscribed in a square. # j k # ._______.______. # | s /-_ | # | p / 3-_ s| m # | / -_| # | /4 -| # | / 5 _-` | # | / _-` | n # | / _-` | # |/_-___________| # l # # find p # # # Rational Trig view, quadrance, which is like distances squar...
{ "repo_name": "donbright/piliko", "path": "sympy/345chinscr.py", "copies": "1", "size": "1525", "license": "bsd-3-clause", "hash": 7202730081252031000, "line_mean": 15.7582417582, "line_max": 64, "alpha_frac": 0.4963934426, "autogenerated": false, "ratio": 1.9830949284785435, "config_test": fal...
# 346 - Moving Average From Data Stream (Easy) # https://leetcode.com/problems/moving-average-from-data-stream/ from collections import deque class MovingAverage(object): def __init__(self, size): """ Initialize your data structure here. :type size: int """ # Max amount of v...
{ "repo_name": "zubie7a/Algorithms", "path": "LeetCode/01_Easy/lc_346.py", "copies": "1", "size": "1478", "license": "mit", "hash": 6694097618496270000, "line_mean": 35.0731707317, "line_max": 68, "alpha_frac": 0.6062246279, "autogenerated": false, "ratio": 4.016304347826087, "config_test": fals...
# 346. Moving Average from Data Stream # Given a stream of integers and a window size, calculate the moving average of all integers in the sliding window. # For example, # MovingAverage m = new MovingAverage(3); # m.next(1) = 1 # m.next(10) = (1 + 10) / 2 # m.next(3) = (1 + 10 + 3) / 3 # m.next(5) = (10 + 3 + 5)...
{ "repo_name": "gengwg/leetcode", "path": "346_moving_average_from_data_stream.py", "copies": "1", "size": "1427", "license": "apache-2.0", "hash": 1825533509060422400, "line_mean": 27, "line_max": 115, "alpha_frac": 0.5423966363, "autogenerated": false, "ratio": 3.129385964912281, "config_test"...
# 351. Android Unlock Patterns # Given an Android 3x3 key lock screen and two integers m and n, where 1 ≤ m ≤ n ≤ 9, # count the total number of unlock patterns of the Android lock screen, # which consist of minimum of m keys and maximum n keys. # Rules for a valid pattern: # Each pattern must connect at least...
{ "repo_name": "gengwg/leetcode", "path": "351_android_unlock_patterns.py", "copies": "1", "size": "3611", "license": "apache-2.0", "hash": 6489504121559216000, "line_mean": 32.3409090909, "line_max": 136, "alpha_frac": 0.5871121718, "autogenerated": false, "ratio": 2.16138540899042, "config_tes...
# 353. Design Snake Game # Design a Snake game that is played on a device with screen size = width x height. Play the game online if you are not familiar with the game. # # The snake is initially positioned at the top left corner (0,0) with length = 1 unit. # # You are given a list of food's positions in row-column or...
{ "repo_name": "gengwg/leetcode", "path": "353_design_snake_game.py", "copies": "1", "size": "3311", "license": "apache-2.0", "hash": -4158074529336397000, "line_mean": 28.8288288288, "line_max": 143, "alpha_frac": 0.5644820296, "autogenerated": false, "ratio": 3.171455938697318, "config_test": ...
# 356 Line Reflection # Given n points on a 2D plane, find if there is such a line parallel to y-axis that reflect the given set of points. # # Example 1: # # Given points = [[1,1],[-1,1]], return true. # # Example 2: # # Given points = [[1,1],[-1,-1]], return false. # # Follow up: # Could you do better than O(n2)? # #...
{ "repo_name": "gengwg/leetcode", "path": "356_line_reflection.py", "copies": "1", "size": "1144", "license": "apache-2.0", "hash": 7141838148508542000, "line_mean": 25, "line_max": 117, "alpha_frac": 0.5550699301, "autogenerated": false, "ratio": 3.259259259259259, "config_test": false, "has_...
#359e800000-359e98a000 r-xp 00000000 fd:00 15176 /lib64/libc-2.12.so #Size: 1576 kB #Rss: 384 kB #Pss: 18 kB #Shared_Clean: 384 kB #Shared_Dirty: 0 kB #Private_Clean: 0 kB #Private_Dirty: 0 kB #Referenced: 3...
{ "repo_name": "RichardBarrell/snippets", "path": "smap.py", "copies": "1", "size": "1152", "license": "isc", "hash": -7055641152097075000, "line_mean": 27.8, "line_max": 93, "alpha_frac": 0.4539930556, "autogenerated": false, "ratio": 3.4698795180722892, "config_test": false, "has_no_keywords...
# 359 - Logger Rate Limiter (Easy) # https://leetcode.com/problems/logger-rate-limiter/ from collections import defaultdict class Logger(object): def __init__(self): """ Initialize your data structure here. """ # From timestamp to log messages. self.logs = defaultdict(lambd...
{ "repo_name": "zubie7a/Algorithms", "path": "LeetCode/01_Easy/lc_359.py", "copies": "1", "size": "1037", "license": "mit", "hash": -3480856575939477000, "line_mean": 32.4838709677, "line_max": 102, "alpha_frac": 0.6200578592, "autogenerated": false, "ratio": 4.489177489177489, "config_test": fa...
#359. Logger Rate Limiter # Design a logger system that receive stream of messages along with its timestamps, # each message should be printed if and only if it is not printed in the last 10 seconds. # Given a message and a timestamp (in seconds granularity), return true if the message should be printed in the given t...
{ "repo_name": "gengwg/leetcode", "path": "359_logger_rate_limiter.py", "copies": "1", "size": "2234", "license": "apache-2.0", "hash": 3276446825199665700, "line_mean": 30.9142857143, "line_max": 153, "alpha_frac": 0.6902417189, "autogenerated": false, "ratio": 4.017985611510792, "config_test":...
# 3-5. Changing Guest List: You just heard that one of your guests can’t make the dinner, so you need to send # out a new set of invitations. You’ll have to think of someone else to invite. # • Start with your program from Exercise 3-4. Add a print statement at the end of your program stating # the name of the guest w...
{ "repo_name": "AnhellO/DAS_Sistemas", "path": "Ago-Dic-2019/DanielM/PracticaUno/3.5_ChangingGuestList.py", "copies": "1", "size": "1790", "license": "mit", "hash": 9125151369563692000, "line_mean": 45.7631578947, "line_max": 120, "alpha_frac": 0.6497747748, "autogenerated": false, "ratio": 3.2828...
"""3-5. Changing Guest List: You just heard that one of your guests can’t make the dinner, so you need to send out a new set of invitations. You’ll have to think of someone else to invite. • Start with your program from Exercise 3-4. Add a print statement at the end of your program stating the name of the guest who can...
{ "repo_name": "AnhellO/DAS_Sistemas", "path": "Ago-Dic-2019/NoemiEstherFloresPardo/Practica1/ChangingGuestList.py", "copies": "1", "size": "1336", "license": "mit", "hash": -4735657929448656000, "line_mean": 34.7567567568, "line_max": 82, "alpha_frac": 0.7140695915, "autogenerated": false, "ratio...
# 361 Bomb Enemy # Given a 2D grid, each cell is either a wall 'W', an enemy 'E' or empty '0' (the number zero), # return the maximum enemies you can kill using one bomb. # The bomb kills all the enemies in the same row and column from the planted point # until it hits the wall since the wall is too strong to be des...
{ "repo_name": "gengwg/leetcode", "path": "361_bomb_enemy.py", "copies": "1", "size": "2113", "license": "apache-2.0", "hash": 1183746947073019400, "line_mean": 34.2166666667, "line_max": 96, "alpha_frac": 0.4803596782, "autogenerated": false, "ratio": 3.317111459968603, "config_test": false, ...
# 364 - Nested List Weight Sum II (Medium) # https://leetcode.com/problems/nested-list-weight-sum-ii/ # """ # This is the interface that allows for creating nested lists. # You should not implement it, or speculate about its implementation # """ #class NestedInteger(object): # # def isInteger(self): # """ # ...
{ "repo_name": "zubie7a/Algorithms", "path": "LeetCode/02_Medium/lc_364.py", "copies": "1", "size": "2123", "license": "mit", "hash": -4652715492030583000, "line_mean": 32.7142857143, "line_max": 95, "alpha_frac": 0.5916156382, "autogenerated": false, "ratio": 3.9169741697416973, "config_test": ...
# 364 Nested List Weight Sum II # # Given a nested list of integers, return the sum of all integers in the list weighted by their depth. # # Each element is either an integer, or a list — whose elements may also be integers or other lists. # # Different from the previous question where weight is increasing from root to...
{ "repo_name": "gengwg/leetcode", "path": "364_nested_list_weight_sum_ii.py", "copies": "1", "size": "2925", "license": "apache-2.0", "hash": 4598221910275419000, "line_mean": 33.3647058824, "line_max": 124, "alpha_frac": 0.5997945909, "autogenerated": false, "ratio": 3.788586251621271, "config_...
# 366. Find Leaves of Binary Tree # Given a binary tree, collect a tree's nodes as if you were doing this: # Collect and remove all leaves, repeat until the tree is empty. # Example: # Given binary tree # 1 # / \ # 2 3 # / \ # 4 5 # Returns [4, 5, 3], [2], [1]. # Explanati...
{ "repo_name": "gengwg/leetcode", "path": "366_find_leaves_of_binary_tree.py", "copies": "1", "size": "2045", "license": "apache-2.0", "hash": 2246785332537145300, "line_mean": 28.2222222222, "line_max": 82, "alpha_frac": 0.5795763172, "autogenerated": false, "ratio": 2.867601246105919, "config_...
# 368. Largest Divisible Subset # Given a set of distinct positive integers, # find the largest subset such that every pair (Si, Sj) of elements in this subset satisfies: # # Si % Sj = 0 or Sj % Si = 0. # # If there are multiple solutions, return any subset is fine. # # Example 1: # # Input: [1,2,3] # Output: [1,2] (o...
{ "repo_name": "gengwg/leetcode", "path": "368_largest_divisible_subset.py", "copies": "1", "size": "3072", "license": "apache-2.0", "hash": 8124748314830622000, "line_mean": 31, "line_max": 131, "alpha_frac": 0.5325520833, "autogenerated": false, "ratio": 3.282051282051282, "config_test": false...
# 369. Plus One Linked List # Given a non-negative number represented as a singly linked list of digits, # plus one to the number. # The digits are stored such that the most significant digit is at the head of the list. # Example: # Input: # 1->2->3 # Output: # 1->2->4 class Solution: # https://closewen.word...
{ "repo_name": "gengwg/leetcode", "path": "369_plus_one_linked_list.py", "copies": "1", "size": "1557", "license": "apache-2.0", "hash": -315217181579346200, "line_mean": 21.66, "line_max": 88, "alpha_frac": 0.5772285966, "autogenerated": false, "ratio": 1.894648829431438, "config_test": false, ...
# 3-6. More Guests: You just found a bigger dinner table, so now more space is available. # Think of three more guests to invite to dinner. # • Start with your program from Exercise 3-4 or Exercise 3-5. Add a print statement to the end of your # program informing people that you found a bigger dinner table. # • Use i...
{ "repo_name": "AnhellO/DAS_Sistemas", "path": "Ago-Dic-2019/DanielM/PracticaUno/3.6_MoreGuests.py", "copies": "1", "size": "2809", "license": "mit", "hash": -5012520389493567000, "line_mean": 39.5797101449, "line_max": 120, "alpha_frac": 0.6427295463, "autogenerated": false, "ratio": 3.1204013377...
"""3-6. More Guests: You just found a bigger dinner table, so now more space is available. Think of three more guests to invite to dinner. • Start with your program from Exercise 3-4 or Exercise 3-5. Add a print statement to the end of your program informing people that you found a bigger dinner table. • Use insert() t...
{ "repo_name": "AnhellO/DAS_Sistemas", "path": "Ago-Dic-2019/NoemiEstherFloresPardo/Practica1/MoreGuests.py", "copies": "1", "size": "2045", "license": "mit", "hash": 6377739203077795000, "line_mean": 32.3606557377, "line_max": 79, "alpha_frac": 0.7079646018, "autogenerated": false, "ratio": 2.797...
## 3.6 Using the Toolbox from deap import base from deap import tools toolbox = base.Toolbox() def evaluateInd(individual): # Do some computation result = sum(individual) return result, toolbox.register("mate", tools.cxTwoPoint) toolbox.register("mutate", tools.mutGaussian, mu=0, sigma=1, indpb=0.2) to...
{ "repo_name": "DailyActie/Surrogate-Model", "path": "01-codes/deap-master/doc/code/tutorials/part_3/3_6_using_the_toolbox.py", "copies": "2", "size": "1912", "license": "mit", "hash": 7571456689247565000, "line_mean": 31.406779661, "line_max": 92, "alpha_frac": 0.7076359833, "autogenerated": false,...
# 370. Range Addition # Assume you have an array of length n initialized with all 0's and are given k update operations. # Each operation is represented as a triplet: [startIndex, endIndex, inc] # which increments each element of subarray A[startIndex ... endIndex] # (startIndex and endIndex inclusive) with inc. # # ...
{ "repo_name": "gengwg/leetcode", "path": "370_range_addition.py", "copies": "1", "size": "1800", "license": "apache-2.0", "hash": -7705054047055545000, "line_mean": 22.2571428571, "line_max": 98, "alpha_frac": 0.5681818182, "autogenerated": false, "ratio": 2.437125748502994, "config_test": fals...
#3.7.2 про шифрование # put your python code heres=st ''' В какой-то момент в Институте перестали понимать, что говорят информатики: они говорили каким-то странным набором звуков. В какой-то момент один из биологов раскрыл секрет информатиков: они использовали при общении подстановочный шифр, т.е. заменяли каждый ...
{ "repo_name": "RootTeam/pytaskscollect", "path": "other/task_002.py", "copies": "1", "size": "3494", "license": "mit", "hash": -644684157415359500, "line_mean": 16.7013888889, "line_max": 72, "alpha_frac": 0.6331894861, "autogenerated": false, "ratio": 1.5881619937694704, "config_test": false, ...
# 373. Find K Pairs with Smallest Sums # # You are given two integer arrays nums1 and nums2 sorted in ascending order and an integer k. # # Define a pair (u,v) which consists of one element from the first array and one element from the second array. # # Find the k pairs (u1,v1),(u2,v2) ...(uk,vk) with the smallest sums...
{ "repo_name": "gengwg/leetcode", "path": "373_find_k_pairs_with_smallest_sums.py", "copies": "1", "size": "2372", "license": "apache-2.0", "hash": -4368668682840415700, "line_mean": 31.9444444444, "line_max": 138, "alpha_frac": 0.6037099494, "autogenerated": false, "ratio": 2.817102137767221, "...
# 374. Guess Number Higher or Lower # We are playing the Guess Game. The game is as follows: # I pick a number from 1 to n. You have to guess which number I picked. # # Every time you guess wrong, I'll tell you whether the number is higher or lower. # # You call a pre-defined API guess(int num) which returns 3 possib...
{ "repo_name": "gengwg/leetcode", "path": "374_guess_number_higher_or_lower.py", "copies": "1", "size": "1065", "license": "apache-2.0", "hash": 1035923450720145800, "line_mean": 23.2045454545, "line_max": 91, "alpha_frac": 0.5417840376, "autogenerated": false, "ratio": 3.4466019417475726, "conf...
# 375. Guess Number Higher or Lower II # We are playing the Guess Game. The game is as follows: # # I pick a number from 1 to n. You have to guess which number I picked. # # Every time you guess wrong, I'll tell you whether the number I picked is higher or lower. # # However, when you guess a particular number x, and ...
{ "repo_name": "gengwg/leetcode", "path": "375_guess_number_higher_or_lower_ii.py", "copies": "1", "size": "1781", "license": "apache-2.0", "hash": 2624261675573934600, "line_mean": 31.9444444444, "line_max": 134, "alpha_frac": 0.5913434514, "autogenerated": false, "ratio": 2.965, "config_test":...
# 376 c2v = dict([(str(i), i) for i in range(2, 10)]) c2v['T'] = 10 c2v['J'] = 11 c2v['Q'] = 12 c2v['K'] = 13 c2v['A'] = 14 def flush(cards): if all(map(lambda c: c[1] == cards[0][1], cards)): return cards[-1][0] return False def straight(cards): m = [(cards[i][0], i + cards[0][0]) for i in range(...
{ "repo_name": "higgsd/euler", "path": "py/54.py", "copies": "1", "size": "1749", "license": "bsd-2-clause", "hash": -4433786102486995000, "line_mean": 21.4230769231, "line_max": 66, "alpha_frac": 0.413950829, "autogenerated": false, "ratio": 2.432545201668985, "config_test": false, "has_no_ke...
# 377 Combination Sum IV # Given an integer array with all positive numbers and no duplicates, # find the number of possible combinations that add up to a positive integer target. # # Example: # # nums = [1, 2, 3] # target = 4 # # The possible combination ways are: # (1, 1, 1, 1) # (1, 1, 2) # (1, 2, 1) # (1, 3) # (2,...
{ "repo_name": "gengwg/leetcode", "path": "377_combination_sum_iv.py", "copies": "1", "size": "1495", "license": "apache-2.0", "hash": -7992855310839750000, "line_mean": 23.9166666667, "line_max": 84, "alpha_frac": 0.5357859532, "autogenerated": false, "ratio": 3.3823529411764706, "config_test":...
# 378. Kth Smallest Element in a Sorted Matrix # # Given a n x n matrix where each of the rows and columns are sorted in ascending order, find the kth smallest element in the matrix. # # Note that it is the kth smallest element in the sorted order, not the kth distinct element. # # Example: # # matrix = [ # [ 1, 5,...
{ "repo_name": "gengwg/leetcode", "path": "378_kth_smallest_element_in_a_sorted_matrix.py", "copies": "1", "size": "2958", "license": "apache-2.0", "hash": 6311400746413210000, "line_mean": 30.8064516129, "line_max": 133, "alpha_frac": 0.57775524, "autogenerated": false, "ratio": 3.415704387990762...
# 379 Design Phone Directory # Design a Phone Directory which supports the following operations: # # get: Provide a number which is not assigned to anyone. # check: Check if a number is available or not. # release: Recycle or release a number. # # Example: # # // Init a phone directory containing a total o...
{ "repo_name": "gengwg/leetcode", "path": "379_design_phone_directory.py", "copies": "1", "size": "2009", "license": "apache-2.0", "hash": -9117401121379560000, "line_mean": 25.4342105263, "line_max": 90, "alpha_frac": 0.6296665007, "autogenerated": false, "ratio": 3.8339694656488548, "config_te...
# 3-7. Shrinking Guest List: You just found out that your new dinner table won’t arrive in time for the dinner, # and you have space for only two guests. # • Start with your program from Exercise 3-6. Add a new line that prints a message saying that you # can invite only two people for dinner. # • Use pop() to remove...
{ "repo_name": "AnhellO/DAS_Sistemas", "path": "Ago-Dic-2019/DanielM/PracticaUno/3.7_ShrinkingGuestList.py", "copies": "1", "size": "3910", "license": "mit", "hash": -4885624744334136000, "line_mean": 39.5729166667, "line_max": 120, "alpha_frac": 0.6497175141, "autogenerated": false, "ratio": 3.13...
"""3-7. Shrinking Guest List: You just found out that your new dinner table won’t arrive in time for the dinner, and you have space for only two guests. • Start with your program from Exercise 3-6. Add a new line that prints a message saying that you can invite only two people for dinner. • Use pop() to remove guests f...
{ "repo_name": "AnhellO/DAS_Sistemas", "path": "Ago-Dic-2019/NoemiEstherFloresPardo/Practica1/ShrinkingGuestList.py", "copies": "1", "size": "3008", "license": "mit", "hash": 304869354658099900, "line_mean": 30.829787234, "line_max": 81, "alpha_frac": 0.7081243731, "autogenerated": false, "ratio":...
## 3.7 Variations import random from deap import base from deap import creator from deap import tools ## Data structure and initializer creation creator.create("FitnessMax", base.Fitness, weights=(1.0,)) creator.create("Individual", list, fitness=creator.FitnessMax) toolbox = base.Toolbox() toolbox.register("attr_f...
{ "repo_name": "DailyActie/Surrogate-Model", "path": "docs/code/tutorials/part_3/3_8_algorithms.py", "copies": "2", "size": "1053", "license": "mit", "hash": 1591633770448304400, "line_mean": 27.4594594595, "line_max": 92, "alpha_frac": 0.7597340931, "autogenerated": false, "ratio": 3.034582132564...
# 382. Linked List Random Node # Given a singly linked list, return a random node's value from the linked list. # Each node must have the same probability of being chosen. # # Follow up: # What if the linked list is extremely large and its length is unknown to you? # Could you solve this efficiently without using extr...
{ "repo_name": "gengwg/leetcode", "path": "382_linked_list_random_node.py", "copies": "1", "size": "2606", "license": "apache-2.0", "hash": 31297536371148350, "line_mean": 24.2470588235, "line_max": 90, "alpha_frac": 0.6178937558, "autogenerated": false, "ratio": 2.15678391959799, "config_test":...
# 388 - Longest Absolute File Path (Medium) # https://leetcode.com/problems/longest-absolute-file-path/ class Solution(object): def lengthLongestPath(self, input): """ :type input: str :rtype: int """ # A file system: has either files or more fs/folders. class FileTr...
{ "repo_name": "zubie7a/Algorithms", "path": "LeetCode/02_Medium/lc_388.py", "copies": "1", "size": "2113", "license": "mit", "hash": 5201699824389490000, "line_mean": 36.7321428571, "line_max": 78, "alpha_frac": 0.5097018457, "autogenerated": false, "ratio": 4.392931392931393, "config_test": fa...
# 388. Longest Absolute File Path # Suppose we abstract our file system by a string in the following manner: # The string "dir\n\tsubdir1\n\tsubdir2\n\t\tfile.ext" represents: # dir # subdir1 # subdir2 # file.ext # The directory dir contains an empty sub-directory subdir1 and a sub-directory subdir2...
{ "repo_name": "gengwg/leetcode", "path": "388_longest_absolute_file_path.py", "copies": "1", "size": "2624", "license": "apache-2.0", "hash": 5182817440833726000, "line_mean": 38.7727272727, "line_max": 164, "alpha_frac": 0.652820122, "autogenerated": false, "ratio": 3.4122236671001303, "config...
# 389. Find the Difference # Given two strings s and t which consist of only lowercase letters. # # String t is generated by random shuffling string s and then add one more letter at a random position. # # Find the letter that was added in t. # # Example: # # Input: # s = "abcd" # t = "abcde" # # Output: # e # # Expla...
{ "repo_name": "gengwg/leetcode", "path": "389_find_difference.py", "copies": "1", "size": "1060", "license": "apache-2.0", "hash": -2741178108361048000, "line_mean": 22.0434782609, "line_max": 126, "alpha_frac": 0.5660377358, "autogenerated": false, "ratio": 3.3974358974358974, "config_test": f...
# 38. Count and Say - LeetCode # https://leetcode.com/problems/count-and-say/description/ # Example 1: # Input: 1 # Output: "1" # Example 2: # Input: 4 # Output: "1211" class Solution(object): def countAndSay(self, n): """ :type n: int :rtype: str """ res = "1" ...
{ "repo_name": "heyf/cloaked-octo-adventure", "path": "leetcode/038_count-and-say.py", "copies": "1", "size": "1167", "license": "mit", "hash": 31960755531041550, "line_mean": 21.9019607843, "line_max": 61, "alpha_frac": 0.3633247644, "autogenerated": false, "ratio": 3.412280701754386, "config_t...
"""38. Count and Say https://leetcode.com/problems/count-and-say/description/ The count-and-say sequence is the sequence of integers with the first five terms as following: 1. 1 2. 11 3. 21 4. 1211 5. 111221 1 is read off as "one 1" or 11. 11 is read off as "two 1s" or 21. 21 is read off as "on...
{ "repo_name": "isudox/leetcode-solution", "path": "python-algorithm/leetcode/count_and_say.py", "copies": "1", "size": "1328", "license": "mit", "hash": -5497671432386917000, "line_mean": 18.4558823529, "line_max": 74, "alpha_frac": 0.5238095238, "autogenerated": false, "ratio": 3.266666666666666...
# 3.8/pinmux.py # Part of PyBBIO # github.com/graycatlabs/PyBBIO # MIT License # # Beaglebone pinmux driver # For Beaglebones with 3.8 kernel from config import OCP_PATH, GPIO, GPIO_FILE_BASE, EXPORT_FILE, UNEXPORT_FILE,\ SLOTS_FILE from bbio.common import addToCleanup import glob, os, cape_manage...
{ "repo_name": "leftbrainstrain/PyBBIO", "path": "bbio/platform/beaglebone/pinmux.py", "copies": "3", "size": "3928", "license": "mit", "hash": 7142873911039920000, "line_mean": 34.0714285714, "line_max": 80, "alpha_frac": 0.6685336049, "autogenerated": false, "ratio": 3.2223133716160786, "confi...
# 393. UTF-8 Validation # A character in UTF8 can be from 1 to 4 bytes long, subjected to the following rules: # For 1-byte character, the first bit is a 0, followed by its unicode code. # For n-bytes character, the first n-bits are all one's, the n+1 bit is 0, followed by n-1 bytes with most significant 2 b...
{ "repo_name": "aenon/OnlineJudge", "path": "leetcode/5.BitManipulation/393.UTF-8_Validation.py", "copies": "1", "size": "3183", "license": "mit", "hash": -2760603859693652000, "line_mean": 33.989010989, "line_max": 169, "alpha_frac": 0.520263902, "autogenerated": false, "ratio": 3.944237918215613...
# 393 UTF-8 Validation # A character in UTF8 can be from 1 to 4 bytes long, subjected to the following rules: # For 1-byte character, the first bit is a 0, followed by its unicode code. # For n-bytes character, the first n-bits are all one's, the n+1 bit is 0, # followed by n-1 bytes with most sign...
{ "repo_name": "gengwg/leetcode", "path": "393_utf8_validation.py", "copies": "1", "size": "2321", "license": "apache-2.0", "hash": -4463177007631892000, "line_mean": 34.1818181818, "line_max": 96, "alpha_frac": 0.6074967686, "autogenerated": false, "ratio": 3.428360413589365, "config_test": fal...
# 394. Decode String # Given an encoded string, return it's decoded string. # The encoding rule is: k[encoded_string], # where the encoded_string inside the square brackets is being repeated exactly k times. # Note that k is guaranteed to be a positive integer. # You may assume that the input string is always vali...
{ "repo_name": "gengwg/leetcode", "path": "394_decode_string.py", "copies": "1", "size": "1893", "license": "apache-2.0", "hash": -4221064492542397400, "line_mean": 29.5483870968, "line_max": 89, "alpha_frac": 0.5266772319, "autogenerated": false, "ratio": 3.7263779527559056, "config_test": fals...
# 397. Integer Replacement # Given a positive integer n and you can do operations as follow: # # If n is even, replace n with n/2. # If n is odd, you can replace n with either n + 1 or n - 1. # # What is the minimum number of replacements needed for n to become 1? # # Example 1: # # Input: # 8 # # Output: # 3 ...
{ "repo_name": "gengwg/leetcode", "path": "397_integer_replacement.py", "copies": "1", "size": "1214", "license": "apache-2.0", "hash": -7105124984226726000, "line_mean": 19.1403508772, "line_max": 100, "alpha_frac": 0.5461672474, "autogenerated": false, "ratio": 2.6270022883295194, "config_test...
"""3 add plot Revision ID: ab7e839f2b2d Revises: 299ddbcceeae Create Date: 2017-03-30 19:57:12.409636 """ from alembic import op import sqlalchemy as sa # revision identifiers, used by Alembic. revision = 'ab7e839f2b2d' down_revision = '299ddbcceeae' branch_labels = None depends_on = None def upgrade(): op.e...
{ "repo_name": "atlefren/pitilt-api", "path": "db/alembic/versions/ab7e839f2b2d_3_add_plot.py", "copies": "1", "size": "1529", "license": "mit", "hash": 5759882726647263000, "line_mean": 25.8245614035, "line_max": 148, "alpha_frac": 0.6206671027, "autogenerated": false, "ratio": 4.099195710455764,...
# 3a def lookup(d, k): return [v for l, v in d if l == k] d = [("a", 10), ("b", 20), ("c", 30), ("a", 40)] assert(lookup(d, "a") == [10, 40]) assert(lookup(d, "b") == [20]) assert(lookup(d, "c") == [30]) assert(lookup(d, "d") == []) # 3b def cond(b, t, f): if b: return t else: return f de...
{ "repo_name": "metakirby5/cse130-exams", "path": "finals/fa13.py", "copies": "1", "size": "2101", "license": "mit", "hash": -8485780638522782000, "line_mean": 28.5915492958, "line_max": 68, "alpha_frac": 0.4117087101, "autogenerated": false, "ratio": 2.581081081081081, "config_test": false, "...
''' 3b_angle_usage.py ========================= AIM: Plots the diagonistic angle usage of the PST in SALSA. Requires the monitor_angle_usage=True in 1_compute_<p>.py and log_all_data = .true. in straylight_<orbit_id>_<p>/CODE/parameter. INPUT: files: - <orbit_id>_misc/orbits.dat - <orbit_id>_flux/angles_<orbit_nu...
{ "repo_name": "kuntzer/SALSA-public", "path": "3b_angle_usage.py", "copies": "1", "size": "3138", "license": "bsd-3-clause", "hash": 1437450933465167, "line_mean": 26.0517241379, "line_max": 188, "alpha_frac": 0.6427660931, "autogenerated": false, "ratio": 2.913649025069638, "config_test": fals...
# 3-bar pendulum # import all we need for solving the problem from pytrajectory import ControlSystem import numpy as np import sympy as sp from sympy import cos, sin from numpy import pi def n_bar_pendulum(N=1, param_values=dict()): ''' Returns the mass matrix :math:`M` and right hand site :math:`B` of moti...
{ "repo_name": "akunze3/pytrajectory", "path": "examples/ex9_TriplePendulum.py", "copies": "1", "size": "13108", "license": "bsd-3-clause", "hash": -250199391809554460, "line_mean": 29.8423529412, "line_max": 118, "alpha_frac": 0.5215898688, "autogenerated": false, "ratio": 3.014026212922511, "c...
## 3. Base Cases ## # Recursive factorial function def factorial(n): # Check the base case if n == 0: return 1 # Recursive case return n * factorial(n - 1) factorial1 = factorial(1) factorial5 = factorial(5) factorial25 = factorial(25) ## 5. Fibonacci ## # Add your function below def fib(n): if n...
{ "repo_name": "vipmunot/Data-Analysis-using-Python", "path": "Data Structures & Algorithms/Recursion and Advanced Data Structures-109.py", "copies": "1", "size": "1571", "license": "mit", "hash": -5955157774082165000, "line_mean": 23.1846153846, "line_max": 69, "alpha_frac": 0.6804583068, "autogene...
## 3. Bikesharing distribution ## import pandas bikes = pandas.read_csv("bike_rental_day.csv") prob_over_5000 = bikes[bikes["cnt"] > 5000].shape[0] / bikes.shape[0] ## 4. Computing the distribution ## import math # Each item in this list represents one k, starting from 0 and going up to and including 30. outcome_co...
{ "repo_name": "vipmunot/Data-Analysis-using-Python", "path": "Probability Statistics Intermediate/Probability distributions-135.py", "copies": "1", "size": "2530", "license": "mit", "hash": 8564072370799763000, "line_mean": 24.5656565657, "line_max": 92, "alpha_frac": 0.709486166, "autogenerated": ...
''' 3c_angle_usage.py ========================= AIM: Plots the diagonistic angle usage of the PST in SALSA. Requires the monitor_angle_usage=True in 1_compute_<p>.py and log_all_data = .true. in straylight_<orbit_id>_<p>/CODE/parameter. INPUT: files: - <orbit_id>_misc/orbits.dat - <orbit_id>_flux/angles_<orbit_n...
{ "repo_name": "kuntzer/SALSA-public", "path": "3c_angle_usage.py", "copies": "1", "size": "2662", "license": "bsd-3-clause", "hash": 7039105860325497000, "line_mean": 29.25, "line_max": 189, "alpha_frac": 0.6202103681, "autogenerated": false, "ratio": 2.847058823529412, "config_test": false, ...
## 3. Class Syntax ## class Car(): def __init__(self): self.color = "black" self.make = "honda" self.model = "accord" black_honda_accord = Car() print(black_honda_accord.color) class Team(): def __init__(self): self.name = "Tampa Bay Buccaneers" bucs = Team() print(bucs.name)...
{ "repo_name": "vipmunot/Data-Analysis-using-Python", "path": "Python Programming Intermediate/Classes-162.py", "copies": "1", "size": "2186", "license": "mit", "hash": 8971483250927273000, "line_mean": 22.5161290323, "line_max": 74, "alpha_frac": 0.5626715462, "autogenerated": false, "ratio": 3.0...
# 3. Cleanse CSV format [ ] # 4. Insert into SQL db to be called by the app [ ] import csv import psycopg2 import sys from datetime import datetime def main(): try: conn = psycopg2.connect("dbname=speedcams user=ubuntu host=localhost password=Kypw123!") except: print('Cannot connect to db') ...
{ "repo_name": "kptyap/speedcam", "path": "cleancsv.py", "copies": "1", "size": "3419", "license": "mit", "hash": 2387267364120208400, "line_mean": 39.7142857143, "line_max": 189, "alpha_frac": 0.569757239, "autogenerated": false, "ratio": 3.994158878504673, "config_test": false, "has_no_keywo...
# 3 (continued). tnrs/ot/names # This service seems to be the same as tnrs/ot/resolve, but with POST # instead of GET. # Maybe we should just run the same tests? """ __Parameters:__ * *Name:* scientificNames * *Category:* mandatory * *Data Type:* list of string * *Description:* list of scientific names ...
{ "repo_name": "jar398/tryphy", "path": "tests/test_tnrs_ot_names.py", "copies": "1", "size": "2184", "license": "bsd-2-clause", "hash": 2005073281707309800, "line_mean": 30.2, "line_max": 130, "alpha_frac": 0.6515567766, "autogenerated": false, "ratio": 3.4502369668246446, "config_test": true, ...
"""3D backpropagation algorithm""" import ctypes import multiprocessing as mp import numexpr as ne import numpy as np import pyfftw import scipy.ndimage from . import util ncores = mp.cpu_count() mprotate_dict = {} def _cleanup_worker(): if "X" in mprotate_dict: mprotate_dict.pop("X") if "X_shape"...
{ "repo_name": "paulmueller/ODTbrain", "path": "odtbrain/_alg3d_bpp.py", "copies": "2", "size": "19612", "license": "bsd-3-clause", "hash": -2736602947750555600, "line_mean": 34.0485611511, "line_max": 78, "alpha_frac": 0.5676604916, "autogenerated": false, "ratio": 3.439286974938228, "config_te...
"""3D backpropagation algorithm with a tilted axis of rotation""" import multiprocessing as mp import warnings import numexpr as ne import numpy as np import pyfftw import scipy.ndimage from . import util _ncores = mp.cpu_count() def estimate_major_rotation_axis(loc): """ For a list of points on the unit ...
{ "repo_name": "paulmueller/ODTbrain", "path": "odtbrain/_alg3d_bppt.py", "copies": "2", "size": "35592", "license": "bsd-3-clause", "hash": -4720322253566234000, "line_mean": 36.3315789474, "line_max": 79, "alpha_frac": 0.5886648809, "autogenerated": false, "ratio": 3.435865142414261, "config_t...
"""3D backpropagation with tilted axis of rotation: sphere coordinates""" import numpy as np import odtbrain import odtbrain._alg3d_bppt def test_simple_sphere(): """simple geometrical tests""" angles = np.array([0, np.pi/2, np.pi]) axes = [[1, 0, 0], [0, 1, 0], [0, 0, 1], [0, 1, 1], [1, 0, 1], [1, 1, 1]...
{ "repo_name": "RI-imaging/ODTbrain", "path": "tests/test_spherecoords_from_angles_and_axis.py", "copies": "2", "size": "3039", "license": "bsd-3-clause", "hash": -2287857034767263000, "line_mean": 33.9310344828, "line_max": 79, "alpha_frac": 0.5123395854, "autogenerated": false, "ratio": 2.829608...
"""3D cone shape settings.""" from ctypes import byref, c_float from .fmodobject import _dll from .utils import ckresult class ConeSettings: """Convenience wrapper class to handle 3D cone shape settings for simulated occlusion which is based on direction. """ def __init__(self, sptr, class_name): ...
{ "repo_name": "tyrylu/pyfmodex", "path": "pyfmodex/cone_settings.py", "copies": "1", "size": "3371", "license": "mit", "hash": 3076296166176087000, "line_mean": 30.5046728972, "line_max": 88, "alpha_frac": 0.6093147434, "autogenerated": false, "ratio": 3.9152148664343787, "config_test": false, ...
"""3D cube example.""" from galry import * import numpy as np # cube creation function def create_cube(color, scale=1.): """Create a cube as a set of independent triangles. Arguments: * color: the colors of each face, as a 6*4 array. * scale: the scale of the cube, the ridge length is 2*scale...
{ "repo_name": "rossant/galry", "path": "examples/3dcube.py", "copies": "1", "size": "3035", "license": "bsd-3-clause", "hash": 5687697177946649000, "line_mean": 19.2333333333, "line_max": 66, "alpha_frac": 0.2962108731, "autogenerated": false, "ratio": 3.1032719836400817, "config_test": false, ...
# 3D CUBE MicroPython version with ESP32 and ssd1306 OLED from machine import Pin, I2C from micropython import const from time import sleep_ms from math import sin, cos from ssd1306 import SSD1306_I2C X = const(64) Y = const(32) f = [[0.0 for _ in range(3)] for _ in range(8)] cube = ((-20,-20, 20), (20,-20, 20), (2...
{ "repo_name": "CUEICHI/micropython", "path": "sample/3dcube.py", "copies": "1", "size": "2377", "license": "mit", "hash": 7266997936898778000, "line_mean": 43.0185185185, "line_max": 85, "alpha_frac": 0.4530921329, "autogenerated": false, "ratio": 2.1968576709796674, "config_test": false, "ha...
"""3D DenseNet Model file""" import tensorflow as tf class DenseNet3D(object): """3D DenseNet Model class""" def __init__( self, video_clips, # Shape: [batch_size, sequence_length, height, width, channels] labels, # Shape: [batch_size, num_classes] initial_l...
{ "repo_name": "frankgu/3d-DenseNet", "path": "source_dir/densenet_3d_model.py", "copies": "1", "size": "10162", "license": "mit", "hash": -6838488191977322000, "line_mean": 34.5314685315, "line_max": 111, "alpha_frac": 0.546250738, "autogenerated": false, "ratio": 4.046993229788929, "config_tes...
# 3D example of viewing aggregates from SA using VTK from pyamg.aggregation import standard_aggregation from pyamg.vis import vis_coarse, vtk_writer from pyamg.gallery import load_example # retrieve the problem data = load_example('unit_cube') A = data['A'].tocsr() V = data['vertices'] E2V = data['elements'] # perfor...
{ "repo_name": "pombreda/pyamg", "path": "Examples/VisualizingAggregation/demo2.py", "copies": "1", "size": "1338", "license": "bsd-3-clause", "hash": 5362754349692463000, "line_mean": 35.1621621622, "line_max": 77, "alpha_frac": 0.6464872945, "autogenerated": false, "ratio": 3.6859504132231407, ...
"""3D frustum representation.""" # Copyright © 2014 Mikko Ronkainen <firstname@mikkoronkainen.com> # License: MIT, see the LICENSE file. from math import * from pymazing import plane TOP = 0 BOTTOM = 1 LEFT = 2 RIGHT = 3 NEAR = 4 FAR = 5 class Frustum: def __init__(self): self.planes ...
{ "repo_name": "mikoro/pymazing", "path": "pymazing/frustum.py", "copies": "1", "size": "2631", "license": "mit", "hash": 3341514919957270500, "line_mean": 32.6052631579, "line_max": 71, "alpha_frac": 0.5870722433, "autogenerated": false, "ratio": 3.49269588313413, "config_test": false, "has_n...
"""3D mesh manipulation utilities.""" from builtins import str from collections import OrderedDict import numpy as np def frustum(left, right, bottom, top, znear, zfar): """Create view frustum matrix.""" assert right != left assert bottom != top assert znear != zfar M = np.zeros((4, 4), dtype=np.float32) ...
{ "repo_name": "tensorflow/lucid", "path": "lucid/misc/gl/meshutil.py", "copies": "1", "size": "4745", "license": "apache-2.0", "hash": -1723399036655642400, "line_mean": 27.244047619, "line_max": 78, "alpha_frac": 0.5997892518, "autogenerated": false, "ratio": 2.8862530413625302, "config_test":...
"""3D Projective Geometric Algebra. Written by a generator written by enki. """ __author__ = 'Enki' import math class CGA: def __init__(self, value=0, index=0): """Initiate a new CGA. Optional, the component index can be set with value. """ self.mvec = [0] * 32 ...
{ "repo_name": "enkimute/ganja.js", "path": "codegen/python/cga.py", "copies": "1", "size": "39258", "license": "mit", "hash": -4138712392566444500, "line_mean": 53.6008344924, "line_max": 454, "alpha_frac": 0.4281929798, "autogenerated": false, "ratio": 1.7332450331125828, "config_test": false,...
"""3D Projective Geometric Algebra. Written by a generator written by enki. """ __author__ = 'Enki' import math class C: def __init__(self, value=0, index=0): """Initiate a new C. Optional, the component index can be set with value. """ self.mvec = [0] * 2 self....
{ "repo_name": "enkimute/ganja.js", "path": "codegen/python/c.py", "copies": "1", "size": "5174", "license": "mit", "hash": 6599231279891997000, "line_mean": 22.201793722, "line_max": 166, "alpha_frac": 0.4586393506, "autogenerated": false, "ratio": 3.1338582677165356, "config_test": false, "h...
"""3D Projective Geometric Algebra. Written by a generator written by enki. """ __author__ = 'Enki' import math class DUAL: def __init__(self, value=0, index=0): """Initiate a new DUAL. Optional, the component index can be set with value. """ self.mvec = [0] * 2 ...
{ "repo_name": "enkimute/ganja.js", "path": "codegen/python/dual.py", "copies": "1", "size": "5240", "license": "mit", "hash": -507750122268628700, "line_mean": 22.4977578475, "line_max": 166, "alpha_frac": 0.4679389313, "autogenerated": false, "ratio": 3.1509320505111247, "config_test": false, ...
"""3D Projective Geometric Algebra. Written by a generator written by enki. """ __author__ = 'Enki' import math class HYPERBOLIC: def __init__(self, value=0, index=0): """Initiate a new HYPERBOLIC. Optional, the component index can be set with value. """ self.mvec = [0]...
{ "repo_name": "enkimute/ganja.js", "path": "codegen/python/hyperbolic.py", "copies": "1", "size": "5434", "license": "mit", "hash": -8663207635289836000, "line_mean": 23.3677130045, "line_max": 166, "alpha_frac": 0.4847258005, "autogenerated": false, "ratio": 3.0408505875769447, "config_test": ...
"""3D Projective Geometric Algebra. Written by a generator written by enki. """ __author__ = 'Enki' import math class MINK: def __init__(self, value=0, index=0): """Initiate a new MINK. Optional, the component index can be set with value. """ self.mvec = [0] * 4 ...
{ "repo_name": "enkimute/ganja.js", "path": "codegen/python/mink.py", "copies": "1", "size": "6342", "license": "mit", "hash": 75175144384030350, "line_mean": 23.6770428016, "line_max": 166, "alpha_frac": 0.4441816462, "autogenerated": false, "ratio": 2.7526041666666665, "config_test": false, ...
"""3D Projective Geometric Algebra. Written by a generator written by enki. """ __author__ = 'Enki' import math class PGA3D: def __init__(self, value=0, index=0): """Initiate a new PGA3D. Optional, the component index can be set with value. """ self.mvec = [0] * 16 ...
{ "repo_name": "enkimute/ganja.js", "path": "codegen/python/pga3d.py", "copies": "1", "size": "18084", "license": "mit", "hash": 3751141442031898600, "line_mean": 33.7769230769, "line_max": 214, "alpha_frac": 0.4350254369, "autogenerated": false, "ratio": 2.091844997108155, "config_test": false,...
"""3D Projective Geometric Algebra. Written by a generator written by enki. """ __author__ = 'Enki' import math class QUAT: def __init__(self, value=0, index=0): """Initiate a new QUAT. Optional, the component index can be set with value. """ self.mvec = [0] * 4 ...
{ "repo_name": "enkimute/ganja.js", "path": "codegen/python/quat.py", "copies": "1", "size": "6342", "license": "mit", "hash": -7595225626792239000, "line_mean": 23.6770428016, "line_max": 166, "alpha_frac": 0.4441816462, "autogenerated": false, "ratio": 2.7526041666666665, "config_test": false,...
"""3D Projective Geometric Algebra. Written by a generator written by enki. """ __author__ = 'Enki' import math class R2: def __init__(self, value=0, index=0): """Initiate a new R2. Optional, the component index can be set with value. """ self.mvec = [0] * 4 sel...
{ "repo_name": "enkimute/ganja.js", "path": "codegen/python/r2.py", "copies": "1", "size": "6280", "license": "mit", "hash": 1969324215358765000, "line_mean": 23.4357976654, "line_max": 166, "alpha_frac": 0.4386942675, "autogenerated": false, "ratio": 2.7256944444444446, "config_test": false, ...
"""3D Projective Geometric Algebra. Written by a generator written by enki. """ __author__ = 'Enki' import math class R3: def __init__(self, value=0, index=0): """Initiate a new R3. Optional, the component index can be set with value. """ self.mvec = [0] * 8 sel...
{ "repo_name": "enkimute/ganja.js", "path": "codegen/python/r3.py", "copies": "1", "size": "8914", "license": "mit", "hash": -6061443992692504000, "line_mean": 26.4276923077, "line_max": 166, "alpha_frac": 0.4099169845, "autogenerated": false, "ratio": 2.265311308767471, "config_test": false, ...
"""3D Projective Geometric Algebra. Written by a generator written by enki. """ __author__ = 'Enki' import math class SPACETIME: def __init__(self, value=0, index=0): """Initiate a new SPACETIME. Optional, the component index can be set with value. """ self.mvec = [0] *...
{ "repo_name": "enkimute/ganja.js", "path": "codegen/python/spacetime.py", "copies": "1", "size": "16879", "license": "mit", "hash": 8925271623927796000, "line_mean": 35.6138828633, "line_max": 226, "alpha_frac": 0.419752355, "autogenerated": false, "ratio": 1.9472773419473928, "config_test": fa...
# 3dproj.py # """ Various transforms used for by the 3D code """ from __future__ import (absolute_import, division, print_function, unicode_literals) import six from six.moves import zip import numpy as np import numpy.linalg as linalg def line2d(p0, p1): """ Return 2D equation of l...
{ "repo_name": "louisLouL/pair_trading", "path": "capstone_env/lib/python3.6/site-packages/mpl_toolkits/mplot3d/proj3d.py", "copies": "2", "size": "4775", "license": "mit", "hash": -638823608366406400, "line_mean": 22.5221674877, "line_max": 77, "alpha_frac": 0.4827225131, "autogenerated": false, ...
#3D Reconstruct from a tilt series using Direct Fourier Method # #NOTE: Tilt Axis needs to be in the third dimension # #developed as part of the tomviz project (www.tomviz.com) def transform_scalars(dataset): from tomviz import utils import numpy as np #----USER SPECIFIED VARIABLES-----# TILT_AXIS = ...
{ "repo_name": "yijiang1/tomviz", "path": "tomviz/python/Recon_DFT.py", "copies": "2", "size": "3883", "license": "bsd-3-clause", "hash": -9173106542765551000, "line_mean": 30.8278688525, "line_max": 105, "alpha_frac": 0.5717228947, "autogenerated": false, "ratio": 2.9195488721804512, "config_te...
"""3D renderer module """ # Uses jsc3d: https://github.com/humu2009/jsc3d/tree/master/jsc3d import os import furl from mako.lookup import TemplateLookup from mfr.core import extension from mfr.extensions.jsc3d import settings from mfr.extensions.utils import munge_url_for_localdev, escape_url_for_template class JSC...
{ "repo_name": "felliott/modular-file-renderer", "path": "mfr/extensions/jsc3d/render.py", "copies": "2", "size": "1455", "license": "apache-2.0", "hash": -6230121727354762000, "line_mean": 29.9574468085, "line_max": 80, "alpha_frac": 0.6336769759, "autogenerated": false, "ratio": 3.66498740554156...
#3d room import math memoP = {} memoC = {} memoC[0] = 0 def shortestCuboidPathSq(w, h, l): p1sq = (h+l) * (h+l) + w * w p2sq = (w+h) * (w+h) + l * l p3sq = (w+l) * (w+l) + h * h return min(p1sq, p2sq, p3sq) def isCuboidPathInteger(w, h, l): pathSq = shortestCuboidPathSq(w, h, l) path = math.f...
{ "repo_name": "feliposz/project-euler-solutions", "path": "python/euler86.py", "copies": "1", "size": "2126", "license": "mit", "hash": 710832501234180700, "line_mean": 21.1354166667, "line_max": 67, "alpha_frac": 0.4988235294, "autogenerated": false, "ratio": 2.7208706786171577, "config_test":...
# 3D surface fitting to N random points # using inverse distance weighted averages. # FB - 201003162 from PIL import Image import random import math # image size imgx = 512 imgy = 512 image = Image.new("RGB", (imgx, imgy)) # random color palette coefficients kr = random.randint(1, 7) kg = random.randint(1, 7) kb = ra...
{ "repo_name": "ActiveState/code", "path": "recipes/Python/577119_3d_Surface_fitting_N_random/recipe-577119.py", "copies": "1", "size": "1460", "license": "mit", "hash": -6081211230372909000, "line_mean": 22.1746031746, "line_max": 72, "alpha_frac": 0.5164383562, "autogenerated": false, "ratio": 2...
## 3-D tictactoe Ruth Chabay 2000/05 from visual import * from tictacdat import * scene.width=600 scene.height=600 scene.title="3D TicTacToe: 4 in a row" # draw board gray = (1,1,1) yo=2. base=grid (n=4, ds=1, gridcolor=gray) base.pos=base.pos+vector(-0.5, -2., -0.5) second=grid(n=4, ds=1, gridcolor=gray) ...
{ "repo_name": "crmathieu/Orbital", "path": "visual/examples/tictac.py", "copies": "1", "size": "3713", "license": "mit", "hash": -4811907296012711000, "line_mean": 27.7829457364, "line_max": 86, "alpha_frac": 0.502827902, "autogenerated": false, "ratio": 3.006477732793522, "config_test": false,...
# 3D tidal channel demo # ===================== # # .. highlight:: python # # This example demonstrates a 3D barotropic model in a tidal channel with sloping # bathymetry. We also add a constant, passive salinity tracer to demonstrate local # tracer conservation. This simulation uses the ALE moving mesh. # # We begi...
{ "repo_name": "tkarna/cofs", "path": "demos/demo_3d_channel.py", "copies": "2", "size": "6787", "license": "mit", "hash": -2456392084588889000, "line_mean": 35.4892473118, "line_max": 90, "alpha_frac": 0.6986886695, "autogenerated": false, "ratio": 3.0724309642372116, "config_test": false, "h...
'3D visualization tools' # Authors: Afshine Amidi <lastname@mit.edu> # Shervine Amidi <firstname@stanford.edu> # MIT License import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D from enzynet.PDB import PDB_backbone from enzynet.volume import adjust_size, coords_to_vol...
{ "repo_name": "shervinea/enzynet", "path": "enzynet/visualization.py", "copies": "1", "size": "6094", "license": "mit", "hash": -1721245739844582700, "line_mean": 32.8555555556, "line_max": 104, "alpha_frac": 0.5725303577, "autogenerated": false, "ratio": 2.8881516587677725, "config_test": fals...
# 3D Volume Graph using Mayavi # 2015-09-09 # By Jay and Cheng # This program reads ascfiles from 'filedir', creates 3d matrix, # uses mayavi display the 3d matrix, and also saves a screenshot in # the working directory. # Notice: Files must be in some format, and the filedir must be specified from os import listdir ...
{ "repo_name": "HPCGISLab/STDataViz", "path": "InitialVersion/draw_volume.py", "copies": "1", "size": "4706", "license": "bsd-3-clause", "hash": 5911903450475629000, "line_mean": 26.2080924855, "line_max": 99, "alpha_frac": 0.5960475988, "autogenerated": false, "ratio": 3.085901639344262, "confi...
# 3D Volume Graph using Mayavi # 2016/02/18 # By Jay and Cheng # This program reads ascfiles from 'filedir', creates 3d matrix, # uses mayavi display the 3d matrix, and also saves a screenshot in # the working directory. # Notice: Files must be in some format, and the filedir must be specified from os import listdir ...
{ "repo_name": "HPCGISLab/STDataViz", "path": "WorkingVersion/draw_volume.py", "copies": "1", "size": "5795", "license": "bsd-3-clause", "hash": -8505266946312206000, "line_mean": 24.875, "line_max": 99, "alpha_frac": 0.5746333046, "autogenerated": false, "ratio": 3.201657458563536, "config_test...
## 3. Exercise: Dynamic Arrays ## # Retrieving an item in an array by index retrieval_by_index = "constant" # Searching for a value in an unordered array search = "linear" # Deleting an item from an array, and filling the gap # by shifting all later items back by one deletion = "linear" # Inserting an item into...
{ "repo_name": "vipmunot/Data-Analysis-using-Python", "path": "Data Structures & Algorithms/Data Structures-94.py", "copies": "1", "size": "2263", "license": "mit", "hash": 6250929031577893000, "line_mean": 35.5161290323, "line_max": 292, "alpha_frac": 0.7277949624, "autogenerated": false, "ratio"...