Dataset Preview
Duplicate
The full dataset viewer is not available (click to read why). Only showing a preview of the rows.
The dataset generation failed because of a cast error
Error code:   DatasetGenerationCastError
Exception:    DatasetGenerationCastError
Message:      An error occurred while generating the dataset

All the data files must have the same columns, but at some point there are 4 new columns ({'total_lines', 'first_object_keys_sorted', 'source_url', 'sha256_first_100_lines_bytes'}) and 7 missing columns ({'blob_id', 'score', 'path', 'length_bytes', 'repo_name', 'content', 'int_score'}).

This happened while the json dataset builder was generating data using

hf://datasets/dongbobo/annoy-datasync-rawcode-1k-summary/summary.json (at revision 58d1cb1a953ba8810ab464a9b2ef316566ac4aa2), [/tmp/hf-datasets-cache/medium/datasets/73335701257376-config-parquet-and-info-dongbobo-annoy-datasync-r-26575685/hub/datasets--dongbobo--annoy-datasync-rawcode-1k-summary/snapshots/58d1cb1a953ba8810ab464a9b2ef316566ac4aa2/sample_50.jsonl (origin=hf://datasets/dongbobo/annoy-datasync-rawcode-1k-summary@58d1cb1a953ba8810ab464a9b2ef316566ac4aa2/sample_50.jsonl), /tmp/hf-datasets-cache/medium/datasets/73335701257376-config-parquet-and-info-dongbobo-annoy-datasync-r-26575685/hub/datasets--dongbobo--annoy-datasync-rawcode-1k-summary/snapshots/58d1cb1a953ba8810ab464a9b2ef316566ac4aa2/summary.json (origin=hf://datasets/dongbobo/annoy-datasync-rawcode-1k-summary@58d1cb1a953ba8810ab464a9b2ef316566ac4aa2/summary.json)]

Please either edit the data files to have matching columns, or separate them into different configurations (see docs at https://hf.co/docs/hub/datasets-manual-configuration#multiple-configurations)
Traceback:    Traceback (most recent call last):
                File "/usr/local/lib/python3.12/site-packages/datasets/builder.py", line 1887, in _prepare_split_single
                  writer.write_table(table)
                File "/usr/local/lib/python3.12/site-packages/datasets/arrow_writer.py", line 674, in write_table
                  pa_table = table_cast(pa_table, self._schema)
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                File "/usr/local/lib/python3.12/site-packages/datasets/table.py", line 2272, in table_cast
                  return cast_table_to_schema(table, schema)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                File "/usr/local/lib/python3.12/site-packages/datasets/table.py", line 2218, in cast_table_to_schema
                  raise CastError(
              datasets.table.CastError: Couldn't cast
              source_url: string
              total_lines: int64
              first_object_keys_sorted: list<item: string>
                child 0, item: string
              sha256_first_100_lines_bytes: string
              to
              {'blob_id': Value('string'), 'repo_name': Value('string'), 'path': Value('string'), 'length_bytes': Value('int64'), 'score': Value('float64'), 'int_score': Value('int64'), 'content': Value('string')}
              because column names don't match
              
              During handling of the above exception, another exception occurred:
              
              Traceback (most recent call last):
                File "/src/services/worker/src/worker/job_runners/config/parquet_and_info.py", line 1333, in compute_config_parquet_and_info_response
                  parquet_operations = convert_to_parquet(builder)
                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^
                File "/src/services/worker/src/worker/job_runners/config/parquet_and_info.py", line 966, in convert_to_parquet
                  builder.download_and_prepare(
                File "/usr/local/lib/python3.12/site-packages/datasets/builder.py", line 884, in download_and_prepare
                  self._download_and_prepare(
                File "/usr/local/lib/python3.12/site-packages/datasets/builder.py", line 947, in _download_and_prepare
                  self._prepare_split(split_generator, **prepare_split_kwargs)
                File "/usr/local/lib/python3.12/site-packages/datasets/builder.py", line 1736, in _prepare_split
                  for job_id, done, content in self._prepare_split_single(
                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^
                File "/usr/local/lib/python3.12/site-packages/datasets/builder.py", line 1889, in _prepare_split_single
                  raise DatasetGenerationCastError.from_cast_error(
              datasets.exceptions.DatasetGenerationCastError: An error occurred while generating the dataset
              
              All the data files must have the same columns, but at some point there are 4 new columns ({'total_lines', 'first_object_keys_sorted', 'source_url', 'sha256_first_100_lines_bytes'}) and 7 missing columns ({'blob_id', 'score', 'path', 'length_bytes', 'repo_name', 'content', 'int_score'}).
              
              This happened while the json dataset builder was generating data using
              
              hf://datasets/dongbobo/annoy-datasync-rawcode-1k-summary/summary.json (at revision 58d1cb1a953ba8810ab464a9b2ef316566ac4aa2), [/tmp/hf-datasets-cache/medium/datasets/73335701257376-config-parquet-and-info-dongbobo-annoy-datasync-r-26575685/hub/datasets--dongbobo--annoy-datasync-rawcode-1k-summary/snapshots/58d1cb1a953ba8810ab464a9b2ef316566ac4aa2/sample_50.jsonl (origin=hf://datasets/dongbobo/annoy-datasync-rawcode-1k-summary@58d1cb1a953ba8810ab464a9b2ef316566ac4aa2/sample_50.jsonl), /tmp/hf-datasets-cache/medium/datasets/73335701257376-config-parquet-and-info-dongbobo-annoy-datasync-r-26575685/hub/datasets--dongbobo--annoy-datasync-rawcode-1k-summary/snapshots/58d1cb1a953ba8810ab464a9b2ef316566ac4aa2/summary.json (origin=hf://datasets/dongbobo/annoy-datasync-rawcode-1k-summary@58d1cb1a953ba8810ab464a9b2ef316566ac4aa2/summary.json)]
              
              Please either edit the data files to have matching columns, or separate them into different configurations (see docs at https://hf.co/docs/hub/datasets-manual-configuration#multiple-configurations)

Need help to make the dataset viewer work? Make sure to review how to configure the dataset viewer, and open a discussion for direct support.

blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
content
string
b7b944e5d5dd1cd1b41952c55bc13c348f905024
Oyekunle-Mark/Graphs
/projects/ancestor/ancestor.py
1,360
3.671875
4
from graph import Graph from util import Stack def earliest_ancestor(ancestors, starting_node): # FIRST REPRESENT THE INPUT ANCESTORS AS A GRAPH # create a graph instance graph = Graph() # loop through ancestors and add every number as a vertex for parent, child in ancestors: # add the pa...
150d0efefb3c712edc14a5ff039ef2082c43152b
syurskyi/Python_Topics
/125_algorithms/_exercises/templates/_algorithms_challenges/leetcode/LeetCode_with_solution/111_Minimum_Depth_of_Binary_Tree.py
1,281
4.03125
4
# Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None c_ Solution o.. # def minDepth(self, root): # """ # :type root: TreeNode # :rtype: int # """ # # Recursio...
039dd3727cdd229548d94108ee220efa4a5b4838
mertdemirlicakmak/project_euler
/problem_5.py
1,144
4.0625
4
""""2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder. What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20?""" # This function returns the smallest number that is divisible to # 1 to num def find_smallest_divisible(nu...
0437daed01bce0f5a3046616917a2c29a1ed15d0
zhouyuhangnju/freshLeetcode
/Combination Sum.py
1,252
3.71875
4
def combinationSum(candidates, target): """ :type candidates: List[int] :type target: int :rtype: List[List[int]] """ res = [] candidates = sorted(candidates) def combinationRemain(remain, curr_res): if remain == 0: res.append(curr_res) return ...
246130cc6d8d3b7c3fee372774aa2f93018f4e35
alexleversen/AdventOfCode
/2020/08-2/main.py
1,119
3.625
4
import re file = open('input.txt', 'r') lines = list(file.readlines()) def testTermination(swapLine): if(lines[swapLine][0:3] == 'acc'): return False instructionIndex = 0 instructionsVisited = [] acc = 0 while(True): if(instructionIndex == len(lines)): return acc ...
f9af5624fe12b3c6bd0c359e5162b7f9f48234e7
Yarin78/yal
/python/yal/fenwick.py
1,025
3.765625
4
# Datastructure for storing and updating integer values in an array in log(n) time # and answering queries "what is the sum of all value in the array between 0 and x?" in log(n) time # # Also called Binary Indexed Tree (BIT). See http://codeforces.com/blog/entry/619 class FenwickTree: def __init__(self, exp): ...
25ce186e86fc56201f52b12615caa13f98044d99
travisoneill/project-euler
/python/007.py
327
3.953125
4
from math import sqrt def is_prime(n): if n < 2: return False for i in range(2, int(sqrt(n)) + 1): if n % i == 0: return False return True def nth_prime(n): count = 2 i = 3 while count < n: i+=2 if is_prime(i): count += 1 print(i) nth_prime(...
5bb4299f898d7a3957d4a0fd1ed4eb151ab44b47
efeacer/EPFL_ML_Labs
/Lab04/template/least_squares.py
482
3.5625
4
# -*- coding: utf-8 -*- """Exercise 3. Least Square """ import numpy as np def compute_error_vector(y, tx, w): return y - tx.dot(w) def compute_mse(error_vector): return np.mean(error_vector ** 2) / 2 def least_squares(y, tx): coefficient_matrix = tx.T.dot(tx) constant_vector = tx.T.dot(y) ...
0a186e9f92527a8509f7082f2f4065d3b366e957
vinnyatanasov/naive-bayes-classifier
/nb.py
3,403
3.6875
4
""" Naive Bayes classifier - gets reviews as input - counts how many times words appear in pos/neg - adds one to each (to not have 0 probabilities) - computes likelihood and multiply by prior (of review being pos/neg) to get the posterior probability - in a balanced dataset, prior is the same for both, so we ignore it...
ceca83f8d1a6d0dbc027ad04a7632bb8853bc17f
harshablast/numpy_NN
/nn.py
2,183
3.734375
4
import numpy as np def sigmoid(x): return 1 / (1 + np.exp(-x)) def d_sigmoid(x): return x * (1 - x) def relu(x): return x * (x > 0) def d_relu(x): return 1 * (x > 0) class neural_network: def __init__(self, nodes): self.input_dim = nodes[0] self.HL01_dim = nodes[1] ...
235fee728f7853aa65b05a101deeb1dfeb5ebf8f
syurskyi/Python_Topics
/125_algorithms/_examples/_algorithms_challenges/leetcode/leetCode/DynamicProgramming/198_HouseRobber.py
469
3.609375
4
#! /usr/bin/env python # -*- coding: utf-8 -*- class Solution(object): # Dynamic Programming def rob(self, nums): if not nums: return 0 pre_rob = 0 pre_not_rob = 0 for num in nums: cur_rob = pre_not_rob + num cur_not_rob = max(pre_rob, pre_no...
0d0892bf443e39c3c5ef078f2cb846370b7852e9
JakobLybarger/Graph-Pathfinding-Algorithms
/dijkstras.py
1,297
4.15625
4
import math import heapq def dijkstras(graph, start): distances = {} # Dictionary to keep track of the shortest distance to each vertex in the graph # The distance to each vertex is not known so we will just assume each vertex is infinitely far away for vertex in graph: distances[vertex] = math....
c3626ea1efb1c930337e261be165d048d842d15a
Razorro/Leetcode
/72. Edit Distance.py
3,999
3.515625
4
""" Given two words word1 and word2, find the minimum number of operations required to convert word1 to word2. You have the following 3 operations permitted on a word: Insert a character Delete a character Replace a character Example 1: Input: word1 = "horse", word2 = "ros" Output: 3 Explanation: horse -> rorse (rep...
b3a6e632568dd13f128eda2cba96293e2bd0d3cd
sniperswang/dev
/leetcode/L265/test.py
1,452
3.640625
4
""" There are a row of n houses, each house can be painted with one of the k colors. The cost of painting each house with a certain color is different. You have to paint all the houses such that no two adjacent houses have the same color. The cost of painting each house with a certain color is represented by a n x k ...
a1b41adcda2d3b3522744e954cf8ae2f901c6b01
drunkwater/leetcode
/medium/python3/c0099_209_minimum-size-subarray-sum/00_leetcode_0099.py
798
3.546875
4
# DRUNKWATER TEMPLATE(add description and prototypes) # Question Title and Description on leetcode.com # Function Declaration and Function Prototypes on leetcode.com #209. Minimum Size Subarray Sum #Given an array of n positive integers and a positive integer s, find the minimal length of a contiguous subarray of which...
40a908c9b3cf99674e66b75f56809d485f0a81f9
Gborgman05/algs
/py/populate_right_pointers.py
1,019
3.859375
4
""" # Definition for a Node. class Node: def __init__(self, val: int = 0, left: 'Node' = None, right: 'Node' = None, next: 'Node' = None): self.val = val self.left = left self.right = right self.next = next """ class Solution: def connect(self, root: 'Optional[Node]') -> 'Option...
c2f622f51bbddc54b0199c4e0e2982bc2ebfa030
qdm12/courses
/Fundamental Algorithms/Lesson-03/algorithms.py
2,479
3.875
4
from operator import itemgetter from math import floor def radix_sort_alpha(words): l = len(words[0]) for w in words: if len(w) != l: raise Exception("All words should be of same length") for i in range(l, 0, -1): words = sorted(words, key=itemgetter(i - 1)) ...
baa6b0b8905dfc9e832125196f3503f271557273
syurskyi/Python_Topics
/125_algorithms/_exercises/templates/_algorithms_challenges/leetcode/leetCode/Array/SlidingWindowMaximum.py
2,656
4.03125
4
""" 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. Return the max sliding window. Example: Input: nums = [1,3,-1,-3,5,3,6,7], and k = 3 O...
8496596aefa39873f8321a61d361bf209e54dcbd
syurskyi/Python_Topics
/125_algorithms/_exercises/templates/_algorithms_challenges/leetcode/LeetCode_with_solution/108_Convert_Sorted_Array_to_Binary_Search_Tree.py
977
3.859375
4
# Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None c_ Solution o.. # def sortedArrayToBST(self, nums): # """ # :type nums: List[int] # :rtype: TreeNode # """ # ...
0be537def5f8cc9ba9218267bf774b28ee44d4c7
SoumyaMalgonde/AlgoBook
/python/graph_algorithms/Dijkstra's_Shortest_Path_Implementation_using_Adjacency_List.py
2,933
3.921875
4
class Node_Distance : def __init__(self, name, dist) : self.name = name self.dist = dist class Graph : def __init__(self, node_count) : self.adjlist = {} self.node_count = node_count def Add_Into_Adjlist(self, src, node_dist) : if src not in self.adjlist : ...
8130b1edf4df29a9ab76784289a22d5fb90863e7
ridhishguhan/faceattractivenesslearner
/Classify.py
1,158
3.6875
4
import numpy as np import Utils class Classifier: training = None train_arr = None classes = None def __init__(self, training, train_arr, CLASSES = 3): self.training = training self.train_arr = train_arr self.classes = CLASSES #KNN Classification method def OneNNClassi...
fa0a2e8e0ec8251c6d735b02dfa1d7a94e09c6b2
paul0920/leetcode
/question_leetcode/1488_2.py
1,538
3.984375
4
import collections import heapq rains = [1, 2, 0, 0, 2, 1] # 0 1 2 3 4 5 rains = [10, 20, 20, 0, 20, 10] # min heap to track the days when flooding would happen (if lake not dried) nearest = [] # dict to store all rainy days # use case: to push the subsequent rainy days into the heap for wet lakes...
ef0440b8ce5c5303d75b1d297e323a1d8b92d619
AndreiBoris/sample-problems
/python/0200-numbers-of-islands/number-of-islands.py
5,325
3.84375
4
from typing import List LAND = '1' WATER = '0' # TODO: Review a superior solutions def overlaps(min1, max1, min2, max2): overlap = max(0, min(max1, max2) - max(min1, min2)) if overlap > 0: return True if min1 == min2 or min1 == max2 or max1 == min2 or max1 == max2: return True if (min...
227925521077e04140edcb13d50808695efd39a5
erikseulean/machine_learning
/python/linear_regression/multivariable.py
1,042
3.671875
4
import numpy as np import matplotlib.pyplot as plt import seaborn as sns iterations = 35 alpha = 0.1 def read_data(): data = np.loadtxt('data/housing_prices.in', delimiter=',') X = data[:, [0,1]] y = data[:, 2] y.shape = (y.shape[0], 1) return X, y def normalize(X): return (X - X.mean(0))/X.s...
c7b567bde9e143c404c3670793576644a26f6142
AhmadQasim/Battleships-AI
/gym-battleship/gym_battleship/envs/battleship_env.py
4,760
3.53125
4
import gym import numpy as np from abc import ABC from gym import spaces from typing import Tuple from copy import deepcopy from collections import namedtuple Ship = namedtuple('Ship', ['min_x', 'max_x', 'min_y', 'max_y']) Action = namedtuple('Action', ['x', 'y']) # Extension: Add info for when the ship is sunk cl...
d818d77f017fb908113dbdffbbaafa2b301d5999
dlaststark/machine-learning-projects
/Programming Language Detection/Experiment-2/Dataset/Train/Python/fibonacci-n-step-number-sequences-3.py
549
3.671875
4
from itertools import islice, cycle def fiblike(tail): for x in tail: yield x for i in cycle(xrange(len(tail))): tail[i] = x = sum(tail) yield x fibo = fiblike([1, 1]) print list(islice(fibo, 10)) lucas = fiblike([2, 1]) print list(islice(lucas, 10)) suffixes = "fibo tribo tetra penta...
d6ddba1536a4377251089a3df2ad91fb87b987b8
jeremyyew/tech-prep-jeremy.io
/code/techniques/8-DFS/M341-flatten-nested-list-iterator.py
606
4
4
''' - Only pop and unpack what is necessary. - Pop and unpack when `hasNext` is called - it ensures there is a next available for `next`, if there really is a next. - At the end only need to check if stack is nonempty - stack nonempty and last element not integer is not possible. ''' class NestedIterator(object): ...
eeb2068deeec87798355fe1bdd1e0f3508cbdcab
jiqin/leetcode
/codes/212.py
2,112
3.53125
4
class Solution(object): def findWords(self, board, words): """ :type board: List[List[str]] :type words: List[str] :rtype: List[str] """ word_map = {} for word in words: for i in range(len(word)): word_map[word[0:i+1]] = 0 f...
5185d421330d59dc45577e6ed4e046a961461ae6
m-hawke/codeeval
/moderate/17_sum_of_integers.py
970
3.703125
4
import sys for line in open(sys.argv[1]): numbers = [int(x) for x in line.strip().split(',')] max_ = sum(numbers) for length in range(1, len(numbers), 2): # N.B increment by 2 sum_ = sum(numbers[:length]) max_ = sum_ if sum_ > max_ else max_ for i in range(len(numbers)-length): ...
9d1ed42cd4a586df38bb7f2a122db69fbece314a
aidank18/PythonProjects
/montyhall/MontyHall.py
1,052
3.78125
4
from random import random def game(stay): doors = makeDoors() choice = int(random() * 3) for i in range(0, 2): if (i != choice) and doors[i] == "g": doors[i] = "r" break if stay: return doors[choice] else: doors[choice] = "r" for door in door...
4b7ef56e7abace03cacb505daa6b34bdf90897b5
sandrahelicka88/codingchallenges
/EveryDayChallenge/happyNumber.py
796
4.09375
4
import unittest '''Write an algorithm to determine if a number is "happy". A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the number equals 1 (where it will stay), or it loops endl...
35f9a1fc4c45112660f9cd871d1514b348990ddf
Jyun-Neng/LeetCode_Python
/103-binary-tree-zigzag-level-order.py
1,644
4.09375
4
""" Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and alternate between). For example: Given binary tree [3,9,20,null,null,15,7], 3 / \ 9 20 / \ 15 7 return its zigzag level order traversal as: [ ...
eee031351c4115a1057b3b81293fe25a17ad8066
jrinder42/Advent-of-Code-2020
/day15/day15.py
767
3.5
4
''' Advent of Code 2020 - Day 15 ''' lookup = {0: [1], 3: [2], 1: [3], 6: [4], 7: [5], 5: [6]} turn = 7 prev = 5 while turn != 2020 + 1: # Part 1 #while turn != 30_000_000 + 1: # Part 2 if prev in lookup and len(lookup[prev]) == 1: prev = 0 i...
0838fcd3cd4ab10f7dffb318fdf9534e7db0e079
rongduan-zhu/codejam2016
/1a/c/c.py
2,061
3.578125
4
#!/usr/bin/env python import sys class Node: def __init__(self, outgoing, incoming): self.outgoing = outgoing self.incoming = incoming def solve(fname): with open(fname) as f: tests = int(f.readline()) for i in xrange(tests): f.readline() deps = map(int, f.readline().split(' ')) ...
d6c1dd48d0c1b6bdc9c5bd7ebd936b30201112e5
febikamBU/string-matching
/bmh.py
2,182
4.03125
4
from collections import defaultdict from sys import argv, exit from comparer import Comparer def precalc(pattern): """ Create the precalculation table: a dictionary of the number of characters after the last occurrence of a given character. This provides the number of characters to shift by in the cas...
ed83eebfc06efbb76af1baf6f9996f4389556824
jhgdike/leetCode
/leetcode_python/1-100/43.py
686
3.578125
4
class Solution(object): """ Python can do it directly by str(int(num1)*int(num2)) """ def multiply(self, num1, num2): """ :type num1: str :type num2: str :rtype: str """ res = [0] * (len(num1) + len(num2)) lengh = len(res) for i, n1 in en...
db6be99a0fb8e2a18b0470e53a21557ef47a026a
akaliutau/cs-problems-python
/problems/dp/Solution32.py
426
3.875
4
""" Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring. Example 1: Input: s = "(()" Output: 2 Explanation: The longest valid parentheses substring is "()". Example 2: Input: s = ")()())" Output: 4 E...
f1d2f920c551650c468ce2db140b2a45bd44bbf7
DayGitH/Python-Challenges
/DailyProgrammer/DP20141231B.py
1,290
4.09375
4
""" [2014-12-31] Challenge #195 [Intermediate] Math Dice https://www.reddit.com/r/dailyprogrammer/comments/2qxrtk/20141231_challenge_195_intermediate_math_dice/ #Description: Math Dice is a game where you use dice and number combinations to score. It's a neat way for kids to get mathematical dexterity. In the game, y...
4b2eb7f54b2898ce241dddfc0cc7966971ac4589
Keshav1506/competitive_programming
/Hashing/006_geeksforgeeks_Swapping_Pairs_Make_Sum_Equal/Solution.py
3,297
4.03125
4
# # Time : O(N^3); Space: O(N) # @tag : Hashing # @by : Shaikat Majumdar # @date: Aug 27, 2020 # ************************************************************************** # GeeksForGeeks - Swapping pairs make sum equal # # Description: # # Given two arrays of integers A[] and B[] of size N and M, the task is to check...
545049864c75b1045885c8eddba22cc60de252d9
betty29/code-1
/recipes/Python/577289_Maclaurinsseriestan1/recipe-577289.py
1,615
4.0625
4
#On the name of ALLAH and may the blessing and peace of Allah #be upon the Messenger of Allah Mohamed Salla Allahu Aliahi Wassalam. #Author : Fouad Teniou #Date : 06/07/10 #version :2.6 """ maclaurin_tan-1 is a function to compute tan-1(x) using maclaurin series and the interval of convergence is -1 <= x <= +1 sin(x)...
c56d992234d558fd0b0b49aa6029d6d287e90f2a
ARSimmons/IntroToPython
/Students/Dave Fugelso/Session 2/ack.py
2,766
4.25
4
''' Dave Fugelso Python Course homework Session 2 Oct. 9 The Ackermann function, A(m, n), is defined: A(m, n) = n+1 if m = 0 A(m-1, 1) if m > 0 and n = 0 A(m-1, A(m, n-1)) if m > 0 and n > 0. See http://en.wikipedia.org/wiki/Ackermann_funciton Create a new module called ack.py in...
2b6b64ed41e1ed99a4e8a12e1e6ab53e6a9596ef
AusCommsteam/Algorithm-and-Data-Structures-and-Coding-Challenges
/Challenges/shortestWayToFormString.py
7,619
3.78125
4
""" Shortest Way to Form String From any string, we can form a subsequence of that string by deleting some number of characters (possibly no deletions). Given two strings source and target, return the minimum number of subsequences of source such that their concatenation equals target. If the task is impossible, retu...
6c8e13d208beafae5b669f07b0dadd18d1c6a2b4
dltech-xyz/Alg_Py_Xiangjie
/第5章/huo.py
1,953
3.921875
4
class Node(object): def __init__(self, value, left=None, right=None): self.value = value self.left = None self.right = None class Huffman(object): def __init__(self, items=[]): while len(items)!=1: a, b = items[0], items[1] newvalue = a.value + b.value ...
5b5b2327e84313fca65952be1f103454b6f63797
annatjohansson/complex_dynamics
/Python scripts/M_DEM.py
2,566
3.8125
4
def M_Dist(cx, cy, max_it, R): """Computes the distance of a point z = x + iy from the Mandelbrot set """ """Inputs: c = cx + cy: translation max_it: maximum number of iterations R: escape radius (squared)""" x = 0.0 y = 0.0 x2 = 0.0 y2 = 0.0 dist = 0.0 it = 0 ...
5dda83f2be9b2a8a87c459d3ba1dfe867633e9a2
dexterchan/DailyChallenge
/MAR2020/PhoneNumbers.py
2,568
3.9375
4
#Skill: Tries #Difficulty : EASY #Given a phone number, return all valid words that can be created using that phone number. #For instance, given the phone number 364 #we can construct the words ['dog', 'fog']. #Here's a starting point: #Analysis #If done by brutal force, time cost is exponent to find all possibiltie...
2e027c271f142affced4a4f873058702cea3487b
Leahxuliu/Data-Structure-And-Algorithm
/Python/Binary Search Tree/669.Trim a Binary Search Tree.py
1,471
4.09375
4
# !/usr/bin/python # -*- coding: utf-8 -*- # @Time : 2020/03/30 # @Author : XU Liu # @FileName: 669.Trim a Binary Search Tree.py ''' 1. 题目类型: BST 2. 题目要求与理解: Trim a Binary Search Tree(修剪树) 给定一个二叉搜索树,同时给定最小边界 L 和最大边界 R。通过修剪二叉搜索树,使得所有节点的值在 [L, R] 中 (R>=L) 3. 解题思路: 对比R, L, root之间的大小关系,类似二分法里找一定范围...
304f5e570b6810e9a79473cfa6b1fbda91a02a90
boop34/adventofcode-2020
/day_13/day_13.py
1,810
3.609375
4
#!/usr/bin/env python3 # fetch the input with open('input.txt', 'r') as f: # initialize the departure time d_time = int(f.readline().strip()) # get the bus information bus_ids = f.readline().strip().split(',') # include the 'x' for the second part of the puzzle bus_ids = list((int (i) if i != '...
16c125fbe1b7e1dfeba8515f38a5e88cf73e5380
sanket-qp/IK
/16-Strings/longest_repeating_substring.py
6,042
4.125
4
""" Longest repeating substring Approaches: (1) Brute force: Generate all substrings and count their occurrence Time Complexity: O(N^4) = O(N^2) for generating all substrings + O(N^2) for num_occurrence (string compare also takes O(N)) Space Complexity: ...
0bb7b65666ac17d8207a34eea9141ea700d5aa46
N11K6/Digi_FX
/Distortion/Valve.py
1,552
3.5
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ This function applies distortion to a given audio signal by modelling the effects from a vacuum tube. Input parameters are the signal vector x, pre-gain G, "work point" Q, amount of distortion D, and pole positions r1 and r2 for the two filters used. @author: nk """ i...
3690eb92ccb03029609dfd0ac4f38bfb363fb90e
zeroviral/leetcode_stuff
/trapping-rain-water/trapping-rain-water.py
1,519
3.75
4
class Solution: def trap(self, height: List[int]) -> int: ''' Setup: We need - leftmax, rightmax, left pointer, right pointer and area. 1. We will begin by declaring the variables, which are all 0 except right, which is going to close from the end. 2. While left < right, we iterate a...
null
null
null
null
null
null
null

No dataset card yet

Downloads last month
11