Shortest sequence of jobs, with dependencies, subject to capacity constraints

Suppose I have $ n$ courses, some with some prerequisites, and I can take up to $ k$ courses in a semester. I want to compute the least number of semesters needed to complete all courses, while respecting prerequisites.

Equivalently: suppose I have a dag $ G=(V,E)$ , and a positive integer $ k$ . The desired output is a sequence $ S_1,\dots,S_m$ of vertices that minimizes $ m$ , subject to the constraint that $ S_1 \cup \dots \cup S_m = V$ , $ |S_i| \le k$ for all $ k$ , and every edge goes from some set $ S_i$ to $ S_j$ where $ i<j$ (i.e., there is no edge $ v \to w$ where $ v\in S_i$ , $ w\in S_j$ , and $ i \ge j$ ).

Is there a polynomial-time algorithm for this problem?


Approaches I’ve considered:

The obvious greedy strategy is a variant of Kahn’s algorithm is: in each semester, arbitrarily pick $ k$ courses whose prerequisites have all been previously taken, and take those $ k$ courses. Unfortunately, this algorithm is not guaranteed to generate an optimal schedule. For example, in the graph with vertices $ v_1,v_2,v_3,v_4$ and the single edge $ v_1 \to v_2$ , with $ k=2$ this algorithm might generate the schedule $ \{v_3,v_4\},\{v_1\},\{v_2\}$ , which is longer than the optimal schedule $ \{v_1,v_3\},\{v_2,v_4\}$ .

The next natural idea is to modify the above approach by breaking ties in favor of vertices that are part of longer dependency chains. I’m not sure whether this works or not.

Inspired by taking school courses efficiently.

Is a creature standing in an Antimagic Field subject to the effects of extreme weather produced by Control Weather?

Say, for example, that a person is standing in an Antimagic Field when a disgruntled Druid decides to create a 5 mile radius freezing hailstorm via Control Weather.

Would that person be subject to the effects of the hailstorm? More specifically:

  • What happens to the hailstones that enter the Antimagic Field?
  • What localized weather effects does the person experience? Is the weather within the Antimagic Field somehow the hypothetical weather conditions that would have existed if Control Weather hadn’t been cast?
  • Is the person subject to the effects of extreme cold like the rest of the people within the hailstorm?

Are monsters subject to the massive damage instant-death rules?

I have been looking at the following two questions recently:

  • Are Trolls immune to all instant death effects?
  • Does the Instant Death rule apply to zombies too?

The first states the following in the question itself:

[…] In addition to such spells, there are more general effects that cause death, mainly massive damage and failing three death saves […]

That and the answers there seem to work under the assumption that massive damage does apply to monsters.

However the second question’s currently most upvoted answer (36 upvotes) states the following:

The rule for dealing damage in excess of your total hit points is intended for player characters, not monsters […]

These two seem to be in direct opposition and I’m unsure then what the correct ruling is.


Here are the passages I believe are relevant to answering this question:

Monsters and Death

Most DMs have a monster die the instant it drops to 0 hit points, rather than having it fall unconscious and make death saving throws […]

Instant Death

Massive damage can kill you instantly. When damage reduces you to 0 hit points and there is damage remaining, you die if the remaining damage equals or exceeds your hit point maximum […]


Does the rule on instant death from massive damage apply to monsters?

Calculating the maxima of a function subject to a constraint

The first figure below shows the plots of a function $ f(x)$ plotted for different values of a parameter $ \lambda$ , i.e., $ f(x)=f(x,\lambda=\lambda_i);i=1,2,3,..;\lambda$ is maximum for the topmost curve and decreases downwards. The second figure shows the values of $ \lambda$ that corresponds to the extrema.

Each curve has one maxima and one minima. The dotted curve corresponds to the case that has no maxima or minima, i.e., the value of $ \lambda$ corresponding to the dotted curve is the threshold for existence of any extrema.

Note that figure-1 is obtained from particle dynamics where we have an expression for $ f(x)$ and we can obtain figure-2 by calculating the extreme values. However, in hydrodynamics we can only obtain figure-2 which matches exactly with that of particle dynamics. In this sense, figure-2 is the same for particle dynamics as well as hydrodynamics.

Figure 1 Figure 2

The following are my goals:

  • To find the threshold value of $ \lambda$ (corresponding to the black dotted curve): This I had already calculated by finding the minima of the $ \lambda-x$ curve.
  • To find the value of $ \lambda$ for which $ f(x)=1$ (corresponding to the black solid curve): Since all the points on the $ \lambda-x$ curve corresponds to extremum, I do not have any idea about how to use the constraint $ f(x)=1$ as the expression for $ f(x)$ is not available.

Additional details and useful hints:

  • In figure-1, all the curves saturates at $ f(x)=1$ at large values of $ x$ . So the constraint $ f(x)=1$ is satisfied for the black(solid) curve as seen in the figure at $ x=2.91$ and also for all the curves at large $ x$ . So I think that the asymptotic behaviour of $ f(x)$ might be related to the values of $ \lambda$ .

  • In figure-2, initially $ \lambda$ decreases steeply with $ x$ and after the minima, $ \lambda$ varies as $ \lambda=\sqrt x$ .

Any hint about the approach to solve the problem would be sufficient.

Is the Spell Bombardment additional damage die subject to critical hit dice doubling?

Level 18 Wild Magic sorcerers have the following feature (PHB, p. 103):

Spell Bombardment

Beginning at 18th level, when you roll damage for a spell and roll the highest number possible on any of the dice, choose one of those dice, roll it again and add that roll to the damage. You can use the feature only once per turn.

When you score a critical hit with an attack (even a spell attack), you double the amount of dice you roll.

Does the additional damage die from Spell Bombardment also get rolled twice on a critical hit?

Auto email subject line not updating when list is edited

On my site there are bulletins that get posted each day. When they are posted, Auto Email workflow sends emails to users using the bulletin title as the email subject line. When I edit the bulletin and change the title, in some cases it will not show the updated title in the subject line but still show the previous title.

In my workflow history, I am logging the item title and can see that it is recognizing the updated title but it is not always reflected in the email subject line.

enter image description here

Does SharePoint cache item titles?

Prestashop Añadir día de la semana subject Order Confirmation

Prestashop 1.6.0.9 Estoy intentando incluir en el subject del email que recibe el admin cuando hay un pedido nuevo el día de la semana que es en ese momento pero no consigo que funcione. Por ejemplo yo quiero recibir como admin en el subject esto:

Oscar Cuenca, New order : #4524 – YKSUCKDON – Lunes

Esto es porque estoy usando un CRM y me interesa que el email que recibo ponga el día actual de la semana en que el email se ha creado. Lo que hago es esto: Añado las variables:

$  fecha = array("domingo","lunes","martes","mi&eacute;rcoles","jueves","viernes","s&aacute;bado");     $  dia = $  fecha[date("w")]; 

En el archivo mailalerts.php, linea aprox 254

public function hookActionValidateOrder($  params) {     if (!$  this->merchant_order || empty($  this->merchant_mails))         return;      // Getting differents vars     $  context = Context::getContext();     $  id_lang = (int)$  context->language->id;     $  id_shop = (int)$  context->shop->id;     $  currency = $  params['currency'];     $  order = $  params['order'];     $  fecha = array("domingo","lunes","martes","mi&eacute;rcoles","jueves","viernes","s&aacute;bado");     $  dia = $  fecha[date("w")];     $  customer = $  params['customer'];     $  configuration = Configuration::getM........ 

Una vez hecho esto, en este mismo archivo aprox línea 466 en la funcion Mail::Send

 Mail::Send(                  $  mail_id_lang,                 'new_order',                 sprintf(Mail::l($  customer->lastname.', '.'New order : #%d - %s'.', '.$  dia, $  mail_id_lang), $  order->id, $  order->reference),                 $  template_vars,                 $  merchant_mail,                 null,                 $  customer->email,                 $  configuration['PS_SHOP_NAME'],                 null,                 null,                 $  dir_mail,                 null,                 $  id_shop             ); 

Hecho esto, no causa ningún efecto. Sigo recibiendo el mismo subject:

Oscar Cuenca, New order : #4524 – YKSUCKDON

Sin el día de la semana. 

Weird character sequence in email subject

I’ve noticed that the subject in one of the spam emails looks like this in source:

Subject: Offe=?UTF-8?Q?=EF=BB=BF?=r fr=?UTF-8?Q?=EF=BB=BF?=om C=?UTF-8?Q?=EF=BB=BF?=redi=?UTF-8?Q?=EF=BB=BF?=t On=?UTF-8?Q?=EF=BB=BF?=e Ba=?UTF-8?Q?=EF=BB=BF?=nk=?UTF-8?Q?=EF=BB=BF?==?UTF-8?Q?=EF=BB=BF?= 

but in web it looks normal

Offer from Credit One Bank 

The only thing I recognize is 0xEF, 0xBB, 0xBF, which is the UTF-8 BOM.

Which interpreter recognizes this character sequence =?UTF-8?Q?=EF=BB=BF?= ?

Is there a vulnerability around email subjects? What are they trying to do?