dynamic programming – Assign values {1, 2, 3, …, N} to N children nodes of all the nodes of an multi-ary tree such that sum of all values of all nodes is minimum

Given a multi-ary tree with N nodes. We start traversing from the root node with a value of 1. For each node to have a value V with n children, we have to assign ${V*1, V*2, V*3, …, V*n}$ values to all the children nodes in such a way that the sum of all the nodes of the tree is minimum.

The recurring relationship I’ve formed is:

$f(node, factor) = min(f(childnode, value*factor) + value*factor)$

where childnode is ${C_1, C_2, C_3, …, C_n}$ and value is ${1, 2, 3, …, n}$

Also, $f(node, value) = 0$ for all leaf nodes. We have to find $f(root, 1)$

Constraints: $N <= 5*10^5$

I’m not able to fill the dp array for this recurrence relationship.

magento2 – Magento 2 how to assign a custom order status when canceling an order with a specific payment method

You can use event order_cancel_after and change status this way:

$order = $observer->getEvent()->getData('order');

Then order will be saved by the OrderService in the cancel method:

public function cancel($id)
    $order = $this->orderRepository->get($id);
    if ($order->canCancel()) {
        $order->cancel(); // <<< Inside this method the event fired
        $this->orderRepository->save($order); // Magento saves order with new custom status
        return true;

    return false;

The payment method you can check inside observer using $order->getPaymentMethod(), it will return string (code).

plotting – How can I assign mixed colors to each point in ListPlot?

I have this data which is in the form {{xi,yi,{ri,bi,gi}}} where xi and yi are the data and {ri,bi,gi} are the weight of red, black and green colors that coincide with each point {xi,yi}. To visualize this I used Blend to give the assigned color for each point as follows

colorbar(rd_, bk_, gr_) := Blend({Red, Black, Blue}, Rescale({rd, bk, gr}, {0, 1})) 

and then I tried this

    ListPlot(data((All, 1 ;; 2)), ColorFunction -> (colorbar(#((1)), #((2)), #((3)))) & /@ 
  data((All, 3 ;; 3))((All, 1)), ColorFunctionScaling -> False)

Now, this should show each point with the assigned color, but all points appear with the same color

enter image description here

How can I solve this, please?

google sheets – How to automatically assign incomplete task next day?

I want my sheet to assign incomplete (pending/left) task next day/next time when the name is entered.
Also when the task is completed I don’t want it to re appear next day.


  • On the A column there’s Date
  • B Column will later be used for attendance
  • C col is for the employees name,
  • Col D contains their tasks and
  • Col E contains their final report of the task that day.
  • Finally Col F is for status update (Done, Pending, Left)

For Example: on 2 May Sunday, Wahid(Col C, Row 8-10) had 3 tasks, He completed 2 tasks(Done) but couldn’t finish one so it’s marked as left.
Thus I want a function that will automatically assign him that pending/left task next time he enters his name. Also when he completes that task it shouldn’t re appear again.

Task detail will be different for each task and each designer. So next time when Wahid enters his name the task will automatically appear as pending/left, Wahid will not change task detail, he will only change the report and status. So if he completes it next day he will write a report and change status to done.

I think these information might help-

  1. Once a Task name is given for a employee nobody can change it’s name.
  2. Naming order will never change.
  3. Position/Placement of columns will not be changed.

My Sheet Link (You can leave comments)

How to automatically assign incomplete task next day?

I want my sheet to assign incomplete (pending/left) task next day/next time when the name is entered.
Also when the task is completed I don’t want it to re appear next day.
enter image description here

My Sheet Link:(You can leave comments)

Assign IP Address to computer connected to switch from Router?

I have a bunch of computers connected to a switch whose ip address i have already configured…
Am trying to assign an ip address and sub net mask to a single machine on the subnet from the router.
I have the idea of trying to access the fast ether net from the router but how can i, when the interfaces are connected to the switch?

javascript – Foreach in a JSON file to assign objects to Electron application

Okay so in my JSON file, I have something like this:

    "items": {
        "1": {
            "name": "Coca Cola",
            "products": ["Coca Cola"],
            "cost": "$1.00",
            "quantity": 24,
            "category": "drinks",
            "description": ""
        "2": {
            "name": "Diet Coke",
            "products": ["Diet Coke"],
            "cost": "$1.00",
            "quantity": 24,
            "category": "drinks",
            "description": ""
        "3": {
            "name": "Mello Yello",
            "products": ["Mello Yello"],
            "cost": "$1.00",

Now in my program, I want it to loop through the json file and output each object to the page so it looks like this:
Old program

How can I do this?

2013 – Assign peoplepicker value in sharepoint from ASP.Net Web API 2.0

I have an API developed in ASP.net Web API 2.0 which inserts records into SharePoint 2013 list.

I am able to assign values to all the fields from the API except for the people picker fields, says

Invalid look-up value.nnA look-up field contains invalid data. Please check the value and try again.

My request body is:

{ "siteurl":"http://intranet.sbl.com/GAD/", "listname":"Appointment", "jsonfields":"{"Title":"Test1","Description":"Description1","Appointment_x0020_Detail":"Description1","Assign_x0020_To":"sbl\\roman.bajracharya"}" }

Where "Assign_x0020_To":"sbl\roman.bajracharya" is the value I am passing for the people picker with title Assign To, and “sbl” is the AD domain and “roman.bajracharya” is the username.

Can anybody help me out on this?

plotting – How to assign values of variables with index

I’m trying to plot the following function


in Mathematica.

For the expression of this function, I wrote

v(n_) := Sum(
   Boole(i < j) (1/Abs(r((i)) - r((j)))), {j, 1, n}, {i, 1, j - 1});

When I give the n-values, this expression works with the error “Part specification r((1)) is longer than depth of object.”

To plot, I wrote

vv(r1_, r2_) := v(2) /. {r((1)) -> r1, r((2)) -> r2};
Manipulate(Plot(vv(r1, r2), {r1, 0, 10}), {r2, 0, 10})

The code I wrote seems to work if I replace every r((i)) with ri every time for different n-values.

I want to improve the expression for more general cases. How can I assign values of r((i)) and r((j)), and fix the error above?

How to assign a db user to multiple databases at once from cPanel?

Inside cPanel, I can create a database and I can assign a specific db user to a specific database.

But what if I have like 100 databases. How can I assign the same user to all of the databases created in my cPanel account?