Categories
Mastering Development

k-way merge sort base case

i don’t understand this particular sample code from geeksforgeeks on k-way merge sort. More specifically, I don’t understand what the "n" in the for loop in the base case for divide() is. Is it the number of students in each array? (which in this case is 4) Also could you please explain what the for […]

Categories
Mastering Development

Join objects with one same property within different arrays

I have this array, that contains more arrays with objects inside that contains information about words founded in pages. Here one example: let data = [ [], [{ "word": "society", "count": 5, "pageIndex": 1 }, { "word": "identity", "count": 2, "pageIndex": 1 } ], [{ "word": "society", "count": 2, "pageIndex": 2 }, { "word": "identity", […]

Categories
Mastering Development

Recreate Excel formula in SQL

I am trying to recreate the below Excel formula/table and have True/False display but am stuck. Excel Formula: =ABS(ROUND(MEDIAN(C$2:C2),0)-ROUND(MODE.SNGL(C$2:C2),0))<[sample.xlsx]variables!$B$2 I have 200+ rows of data and I need the Median and the Mode only calculated from the first row to the current row. I can create the Median for all rows in SQL, but this […]

Categories
Mastering Development

How to get depth of tree of arrays given total num items and max array size?

Given this divide algorithm and sample data: const data = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, […]

Categories
Mastering Development

Partition N where the count of parts and each part are a power of 2, and part size and count are restricted

How do you take a number representing a list of items, and divide it into chunks, where the number of chunks is a power-of-two, AND where each chunk also has a power-of-two number of items (where size goes up to a max power of two, so 1, 2, 4, 8, 16, 32, 32 being the […]

Categories
Mastering Development

Partition N where the count of parts and each part are a power of 2, and part size and count are restricted

How do you take a number representing a list of items, and divide it into chunks, where the number of chunks is a power-of-two, AND where each chunk also has a power-of-two number of items (where size goes up to a max power of two, so 1, 2, 4, 8, 16, 32, 32 being the […]

Categories
Mastering Development

How to divide an array into a tree of buckets sized by powers of two?

How do you take a number representing a list of items, and divide it into chunks, where the number of chunks is a power-of-two, AND where each chunk also has a power-of-two number of items (where size goes up to a max power of two, so 1, 2, 4, 8, 16, 32, 32 being the […]

Categories
Mastering Development

Create an open ended question with learnr:tutorial in r

I want to allow students to input their student ID at the beginning of every quiz they take. There are no correct answers as long as they input a 7 digit number. This is what I have right now but the function does not run when the defined answers are sot one single text. How […]

Categories
Mastering Development

HOMER findMotifs.pl raises errors about cleanUpSequences.pl

I was using HOMER to find motif units in a bunch of RNA sequences. The command shows as below. findMotifs.pl ${target_file} human ${out_dir} -fasta ${bg_utr} -len 4,6,8,10,12 -rna -p 4 The terminal raised stderrors, which mostly indicated some compiling errors of another HOMER software that was called in this process, cleanUpSequences.pl. However, it still output […]

Categories
Mastering Development

Python speed up permutation of bits within 32Bit number

I’m interested in reordering the bits within a number, and since I want to do it several trillion times, I want to do it fast. Here are the details: given a number num and an order matrix order. order contains up to ~6000 lines of permutations of the numbers 0..31. These are the positions to […]