Categories
Mastering Development

Need to generate output in the following format year, q1,q2,q3,q4 in the MS SQL server for below data

CREATE TABLE acquisition ( id INT PRIMARY KEY IDENTITY, company_name VARCHAR(100), cost_amount INT NOT NULL, acquired_at DATE NOT NULL ); INSERT INTO acquisition(company_name, cost_amount, acquired_at) VALUES (1,’HOFA’, 6850, ‘2010-01-17′), (2,’POGA’, 9256, ‘2019-09-04′), (3,’CUPU’, 9329, ‘2012-08-21′), (4,’BULO’, 5162, ‘2020-11-21′), (5,’GICE’, 5301, ‘2012-10-04′), (6,’TOSE’, 1790, ‘2018-09-30′), (7,’POWU’, 7183, ‘2019-05-21′), (8,’YEJO’, 1491, ‘2010-12-12′), (9,’XAMO’, 5974, ‘2010-03-23′), (10,’TEFA’, 9456, […]

Categories
Mastering Development

Refer to variable in loop when arranging rows using dplyr

I am trying to arrange rows in a dataset based on the year column in a second dataset. Since the column names that need arranging will be indexed from a vector, how can I enter them as an argument in the arrange function? Note that I cannot simply order year in the first dataset as […]

Categories
Mastering Development

how does this concat command work with this array?

I came across this JS problem but I can’t figure out the syntax of how it’s working, could someone please help to explain? I don’t understand the empty square bracket syntax at the start and then how the concat is being applied with another empty square bracket? it’s just quite confusing for me. Appreciate any […]

Categories
Mastering Development

How to create a directional vector that moves a certain entity to a certain location

General explanation: I’m building this game where I have to move a certain ball to a location depending on where the rotation is facing, basically there are a bunch of blocks in the background and some barriers and there’s a collision detection algorithm implemented so the ball returns to its original position upon collision Problem: […]

Categories
Mastering Development

How to have multiple styles of buttons in ResourceDictionary.MergedDictionaries

Alright, so I am pretty new to WPF and I’ve tasked myself with a pretty hard challenge. I’m trying to make a program for the company I work for. I’ve already designed the Login Window and now, I’d like to design the dashboard. Here is a screenshot of the login Window, with it’s XAML below: […]

Categories
Mastering Development

Javascript Sorting Matrix Diagonally

There is an algorithm question asking to sort a matrix diagonally. I’m not finding a solution for this quesiton. const matrix = [ [1, 3, 9, 4], [9, 5, 7, 7], [3, 6, 9, 7], [1, 2, 2, 2] ] Should output: [ [1, 9, 9, 7], [3, 5, 6, 9], [3, 4, 7, 7], […]

Categories
Mastering Development

Deep merging two Immutable maps while ignoring nested arrays

const map1 = Immutable.Map({ a: { x: 1, z: 1, y: 1, values: 1, 2, 3] } }); const map2 = Immutable.Map({ a: { x: 2, values: [4, 5, 6] } }); const map3 = map1.mergeDeep(map2) // Output I want is: // { a: { x: 2, z: 1, y: 1 values: [4, 5, 6] […]

Categories
Mastering Development

Ionic date time picker update columns dynamically

I have the following requirement which aim looking for some thing similar ready. Time select where user select Hours and minutes. Hours will be provider could be any (1,5,6,13,19) etc. Each hour has its own minutes the data structure like this [ { hour: 1, minutes: [0, 15, 30], }, { hour: 4, minutes: [15, […]

Categories
Mastering Development

A logarithmic constraint using fmincon in MATLAB

I want to minimize the following minimization problem using fmincon in MATLAB The code below (Strategy 1) that I have written solves the problem when I replace the logarithmic (nonlinear) constraint by the linear constraint sum(x) = 5. So how can I change it to introduce the logarithmic constraint? I am blocked here. MATLAB CODE […]

Categories
Mastering Development

What is the efficient way to find an array inside an array?

Find an Array of Values Inside an Array Lets say I have an array [1,2,3,8,2,3,4,5,6,7,8] and I want to find the first occurrence of the values [3,4,5,6] together, how might I do that? I can use Array.prototype.findIndex, but when I am looking for a large amount of values in a large array, it doesn’t feel […]