algorithms – Group similar objects using multiple stacks

I am trying to write an algorithm to solve the following problem.

Let’s say we have n buckets each with capacity 4. There would be exactly n-2 type of objects. The initial state being that the (n-2)*4 objects are randomly distributed among n-2 objects with exactly two empty buckets. The desired end state we are trying to reach is to group similar type of objects into a single bucket.

Only the following operation are permitted

  1. Move object from top of bucket to an empty bucket or a bucket having same type of object on top.


  1. The buckets can never exceed the capacity of 4.
  2. We cannot partially transfer the objects of similar type as long as there is capacity.

I am trying to code how to find the sequence of operations to reach the desired end state.


Bucket 1: C B A
Bucket 2: A B C
Bucket 3: A B C
Bucket 4:
Bucket 5: 

Move C from bucket 2,3 to 4 (two steps)
Move B from bucket 2,3 to 5 (two steps)

Bucket 1: C B A
Bucket 2: A  
Bucket 3: A  
Bucket 4: C C
Bucket 5: B B

Move A from bucket 1 to 2   
Move A from bucket 3 to 2

Bucket 1: C B
Bucket 2: A A A 
Bucket 3: 
Bucket 4: C C
Bucket 5: B B

Move B from Bucket 1 to 5
Move C from Bucket 1 to 4

Bucket 1: 
Bucket 2: A A A 
Bucket 3: 
Bucket 4: C C C
Bucket 5: B B B

I was thinking of solving it by backtracking. Trying to move the top of bucket to another bucket backtrack if there are no possible moves.
Is there a better approach to solve this problem more efficiently.

java – Designing around potentially multiple RESTful API calls to a downstream service

To set up the problem, let’s imagine we have a downstream service that we need to call for some information. We set up an API endpoint and call another method which will hold our business logic and make the HTTP request. Based off of certain parameters that were sent to this method, we may potentially have to make several calls to the same endpoint, depending on what it returns. The method is currently setup like so:

public HttpEntity<String> getInfo(//parameters) {
    //setup HTTP headers etc.
    HttpEntity response = here);

    //based off of on the parameters given to this method, we will know whether or not we need to make additional calls
    //if we DO need to make additional calls, we will also need to inspect the response for information
    //this is difficult, because as you see below, this method doesn't start to procces the response until after error checking
    //do all error checking ie. checking for no data and other HTTP errors
    OurDataClass dataClass = objectmapper.writeValueasString(response.getBody());

Given the current structure of this method, I don’t know how to work it into something that’s more extendable and maintainable. My first instinct was to just encapsulate the restTemplate and take care of additional calls there, but given the fact that I need to inspect the request contents of each call, something that is not done until the end of the current method, it would seem like we’re doing a lot of double work. On the other hand, working the solution into the method without any encapsulation would make it even more difficult to maintain down the road (it’s already a bit of a mess with error checking).

design patterns – Python: Function pipeline with multiple return/input values, or use OOP? Best Practices?

I have a ‘processing’ function and a ‘serializing’ function. Currently the processor returns 4 different types of data structures to be serialized in different ways.

Looking for the best practise on what to do here.

def process(input):
   return a,b,c,d

def serialize(a,b,c,d):
   # Different serialization patterns for each of a-d.

a,b,c,d = process(input)

That feels janky.
Should I instead use a class where a,b,c,d are member variables?

class VeryImportantDataProcessor:
   def process(self,input):
      self.a = ...
      self.b = ...

   def serialize(self):

vipd = VeryImportantDataProcessor()

Keen to hear your thoughts on what is best here!

Note after processing and serializing, the code goes on to use variable d for further unrelated shenanigans. Not sure if that changes anything.

Weird shapes are showing on my Google Docs Spreadsheets, on multiple computers


Since a few weeks, all kinds of weird shapes are randomly showing on my google docs.


  • not on all docs;
  • not on specific times;
  • not always;
  • not only on one computer.

Anyone has an idea? I have tried GPU settings, but quit thinking that’s the issue when it started on different pc’s.

8 – Multiple forms on one page

I try to input several forms into one page via Controller. With code which is
under, I see those forms but after submit one of them, nothing happens. Any of data is send to database. Has anyone idea how to fix this?


namespace DrupalCoreEntityContentEntityForm;
namespace DrupalstudentController;
use DrupalnodeEntityNode;
use DrupalCoreFormFormStateInterface;
use DrupalCoreControllerControllerBase;
use DrupalnodeNodeInterface;
use DrupalnodeEntity;
use DrupalnodeNodeForm;
use DrupalCoreFormFormBase;
use DrupalCoreUrl;
use DrupalCoreLink;
use DrupalCoreRouting;
use DrupalCoreEntityContentEntityForm;

class SFormController extends ControllerBase {

  function new_form() { 
    $build = ();
    foreach ($stud as $id => $name) {
      $node = DrupalnodeEntityNode::create(('type' => 'student'));
      $form = Drupal::service('entity.form_builder')->getForm($node, 'student_form');
      $build() = $form;
    return $build;


linear algebra – Re-write this expression with Einstein summation convention multiple different ways

$mathbf{r}’ = r – hat{mathbf{s}} (mathbf{r}.hat{mathbf{e}}_3)/s_3$

I was asked to re-write the expression above with Einstein summation convention multiple different ways.

First I changed all of the vectors to their indexed formats, that is:

$mathbf{r_i}’ = r_i – {mathbf{s_i}} (mathbf{r_i}.hat{mathbf{e}}_3j)/s_3$

Which made it easier to find the solution(s), such as : $mathbf{r_i}’ = r_i – {mathbf{s_i}} mathbf{r_3}/s_3$

However, there are 3 other solutions that weren’t so easy/obvious (in order of difficulty):

  • $mathbf{r_i}’ = r_i – {mathbf{s_i}}(hat{mathbf{e}}_3)_j mathbf{r_j}/s_3$
  • $mathbf{r_i}’ = (I_ij – {mathbf{s_i}}(hat{mathbf{e}}_3)_j /s_3) mathbf{r_j}$
  • $mathbf{r_i}’ = (I_ij – {mathbf{s_i}}I_3j/s_3) mathbf{r_j}$

How do these also solve the expression in Einstein summation convention?

What is the purpose of the (square) brackets, but especially where does the $mathbf{} I$ come from?

google pagespeed – Avoid multiple page redirects about from HTTP to HTTPS and from non-www HTTPS to with-www HTTPS

Humbly, In Google PageSpeed Insights test I got 95 score for mobile and 95 score for desktop with pretty much just one error:

Avoid multiple page redirects

The first entry of the error is about HTTP to HTTPS redirects and the second entry of the error is about non-www HTTPS to with-www HTTPS redirects.

The first entry is weird because its Google themselves who passionately promote HTTP to HTTPS usage, so why would they give me an error for doing so?…

FireFox 86 Released Has Multiple Picture-in-Picture and "Total Cookie Protection"

Firefox 86 now released extends Picture-in-Picture to multiple PIP, and, now offers Total Cookie Protection in Enhanced Tracking Protection (ETP) Strict Mode.

php – How can I add multiple if in elseif condititon?

How can I add one additional condition for is_tax=’listing_amenity’?

This is the code:

            if (is_category()) {

            } elseif(is_tag()) {
            }  elseif(is_tax()) {
            if (is_tax('listing_area', ('paris', 'london'))) {
            echo "Accommodation in ";
            } else {
            echo "Accommodation on ";

This is the new condition I want to add:

}  elseif(is_tax('listing_amenity', ('pool'))) {    
            echo "Accommodation with ";
    } else {
        echo "Accommodation for ";

Thank you in advance for your help. – How can I add schema mark up for multiple holiday resorts?

Our client is a holiday company that offers villa accommodation at a list of different resorts in Menorca. We want to mark up the homepage for the handful of top resorts. Is it possible to mark up one page for multiple resorts do this or would we only be able to mark up one resort per page? I also can’t find a schema generator or plugin for resorts, does anyone know if there is one or would we need to write the code ourselves? Thanks