We can model a rail network as a directed graph, where each node is a train station and each edge is a train connecting two train stations. We'll assume that each train leaves go between their stations at a regular schedule and takes a fixed amount of time Your code should take a list of trains, ...
Inspired by this Your task today: given two strings, find the string with the lowest maximum Levenshtein distance to the input strings. For example, using Steffan and Seggan, the average string will be Steggan. It is distance 2 from Steffan (replace the gg with ff), and 1 from Seggan (add a t)....
I have shuffled the image pixels using the code: img = cv2.imread('car.jpg') np.random.shuffle(img) is there anyway to rearrange the pixels so that image gets back to its original form again? Is there any builtin function to make this thing easy to rearrange the pixels?
I was solving cloudyday problem on hackerrank: City has many towns. p is an array of population of n towns. x is an array of location of towns on 1 dimensional array (thus a numeric location). y is an array of location of clouds. r is an array of extent or breadth of clouds. Population in city u...
Given two non-negative integers e.g. 27, 96 their multiplication expression would be 27 x 96 = 2592. If now each digits is replaced with a symbol, such that two digits are replaced with the same symbol if and only if they are equal we could get something like AB x CD = AECA or 0Q x 17 = 0Z10 or !>
Implement String Projection Given two strings: a string s and an alphabet a, implement string projection in the shortest code possible. String projection returns a string o that contains the characters in s that are in a. The order of the characters in o must match the order of characters in s. S...
Solving an easy Sudoku in increasing order Tags: code-golfsudokunumbergridpuzzle-solver Introduction: I'm old-fashioned and still read a physical newspaper in the morning while eating my breakfast. Although I don't like Sudoku that much, I do solve the Light-complexity ones, which are extremely e...
Make a super fair number An even distribution number is a number such that if you select any of it's digits at random the probability of it being any particular value (e.g. 0 or 6) is the same, \$\frac1{10}\$. A precise definition is given later on. Here are a few examples: \$\frac{137174210}{1...
Implement Bloom filter insertion A Bloom filter is a probabilistic data structure that is used to determine whether an element is in a set in a fixed number of bits. It consists of: a bit array \$B\$ of fixed size \$m\$, initialized as all \$0\$s, and \$k\$ different hash functions \$h_1,\ldots,...
« first day (461 days earlier) ← previous day next day → last day (641 days later) »