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

Appending and reading list values in nested dictionaries

Need to check I’m understanding this right. I’m running a function that appends lists to a list in a nested dictionary. I thought I would be able to assign a variable to append and return the same values as the nested dictionary, but it returns ‘None’, (and interestingly still appends the nested dictionary even though […]

Categories
Mastering Development

What could you combine .uniq with to keep the original order of an array?

How would you either shift the order of an array or keep the natural order of an array when using the Ruby .uniq method or even .to_set? So for example: ([3,4,4,3,6,3]) # => [4,6,3]) ### with current method my solution outputs: Expected: [4, 6, 3], instead got: [3, 4, 6] These are all the other […]

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

I want to flatten array based on it depth like if depth is 1 it will flatten array 1 if depth is 2 it will flattern array 2

HI everyone thanks in Advance I want to flatten array based on it depth like if depth is 1 it will flatten array 1 if depth is 2 it will flattern array 2 please see the expected output var depth = 1; function flatten(ary,depth) { return ary.reduce(function(a, b) { if (Array.isArray(b)) { return a.concat(flatten(b)) } […]

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

Repeating elements in vector

I am a C++ student. And I need to solve this problem: "Write a program that receives a number and an array of the size of the given number. The program must find all the duplicates of the given numbers, push-back them to a vector of repeating elements, and print the vector". The requirements are […]

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 […]