## dnd 5e – To maximize a combo with True Strike, which is the most damaging spell with attack roll?

I’m pretty sure that inflict wounds is your best bet. The 5e spell list is small enough that it’s possible to scan the whole thing, and there’s nothing that deals more damage under the specific constraints you listed (pre-cast true strike, attack roll, not using any daily powers other than the ninth-level spell slot).

I’ve got some space left in this answer, so I’d like to address a related question. This is a question you haven’t asked, but it’s a question which some of the people reading this answer might be curious about: “I’m fighting something that has Legendary Resistance and will choose to succeed at any saving throws I offer. I have a buff spell pre-cast. What’s the most damage I can deal, ideally without walking into melee range?”

It turns out that most of the good answers don’t take advantage of the true strike. For instance, the old standby meteor swarm deals half of 40d6 on even a successful save, so that’s 70 damage plus whatever bonuses you can get from modifiers.

The true strike spell grants advantage on the first attack per round, but a twentieth-level caster might be willing to use a stronger buff, such as greater invisibility. Used against a creature that can’t see through it, this spell grants advantage on all attacks in a given round. With this buff, scorching ray is better than inflict wounds: it fires ten rays maximum and deals 2d6 damage per ray, for an average of 70 damage, or 58.8 damage after applying the 84% hit chance.

## macos – Keyboard Shortcut to maximize a window?

macos – Keyboard Shortcut to maximize a window? – Ask Different

## complex – Is this a correct result about maximize of sum of moduls?

I am trying to find maximize of the expression
$$S = |z-1| + |z+1| + |z+sqrt(3)i|$$ knowing that $$|sqrt(3) z + i| = 2$$. I tried

``````Maximize(ComplexExpand /@ {Abs(x + I y - 1) + Abs(x + I y + 1) +
Abs(x + I y + Sqrt(3) I),
Abs(Sqrt(3) x + Sqrt(3) y + I) == 2}, {x, y})
``````

and get

{(Infinity), {x -> Indeterminate, y -> Indeterminate}}

Is this a correct result?

## algorithm – How to maximize enclosed area and minimize perimeter on a grid with obstacles?

Developing an RTS game, I have a tile-based terrain (grid) filled with obstacles. It looks like this (red shapes are obstacles):

Now I need to plan an enclosed area on the terrain with some restrictions:

• tile marked with a “star” must be included (it is a seed)
• area needs to be at least 20 tiles (for this example)
• farthest area tile from the seed needs to be no more than 7 steps away (for this example)
• area needs to traversable by moving in 4 directions
• area should be bound by existing obstacles and by new fences
• new fences building takes time and resources, it is beneficial to use existing obstacles as much as possible and have the smallest number of fences placed.
• there are cases where terrain could be free of any obstacles, or contrary to that – be a maze-like labyrinth)
• it is okay to fail (e.g. there’s not enough walkable tiles around the seed), or the area/fences ratio is too low.
• processing is done on CPU (if that matters)

So, here are some “manual” attempts at outlining an area of required size using the least fences:

As you can see, there are 3 enclosed areas (green, blue, orange) with very similar perimeters, yet different areas. Best one in this case would be “green” one – it has the least fences added (just 10) and has the sufficient area (21).

## What is the algorithm to allow to plan area of given size (~20) while minimizing the amount of additional fences required?

So far I have tried the A* to get the area within reach (7 steps), clipped the last step (since it is unexplored and has no neighbor info) and clipped the obvious protruding buds, but I’m out of good ideas on how to improve from that:

• yellow tile is the seed
• red tiles are walkable (saturation shows distance from the seed)
• dark grey tiles are obstacles
• light grey tiles are obstacles that also need fences
• purple tiles got clipped by existing incomplete algo
• black tiles are unexplored
• yellow dashes are required fences

As you can see, it looks quite sub-optimal, but I’m at loss as to how to proceed.

## dynamic programming – Select each item from a sequence of \$n\$ buckets to maximize value?

You have a sequence of n buckets. Each bucket $$B_i$$ contains three items, where each item has some value and belongs to some category. Multiple items may belong to the same category. Your job is to select exactly one item from each bucket so that the total value of the selected items is maximized, but such that no two items selected from adjacent buckets belong to the same category.
Design an algorithm to determine which item should be selected from each bucket to maximize the total value. If there is no solution, your algorithm should state this.

## Problem

We are given 2 arrays `a` and `b` both of length `n`. We build a third array `c` by rearranging the values in `b`. The goal is to find the optimal `c` that maximizes

``````result = (a(0) ^ c(0)) & (a(1) ^ c(1)) & ... & (a(n - 1) ^ c(n - 1))
``````

where `^` is XOR and `&` is AND.

Is it possible to do this efficiently? It’s straightforward to iterate through all possible permutations of `b`, but this is infeasible for large `n`.

## More details

• The order of the values in `a` is fixed.
• The order of the values in `b` may be rearranged to form `c`. That is, starting with `b = (1, 2, 3)`, it may be that the maximum result is obtained when the values are rearranged to `c = (2, 1, 3)`.
• `b` may be rearranged in-place if needed.
• Since the optimal `c` is not necessarily unique, any optimal `c` may be returned.
• Assume all values are 32-bit unsigned integers.
• `1 <= n <= 10,000`.

## Test cases

``````Input:
a = (3, 4, 5)
b = (6, 7, 8)
Output:
c = (8, 7, 6) (result = 3)
``````
``````Input:
a = (1, 11, 7, 4, 10, 11)
b = (6, 20, 8, 9, 10, 7)
Output:
c = (8, 6, 10, 9, 7, 20) (result = 9)
``````
``````Input:
a = (0, 1, 2, 4, 8, 16)
b = (512, 256, 128, 64, 32, 16)
Output:
c = (16, 32, 64, 128, 256, 512) (result = 0)
``````

## optimization – Reordering an array to maximize expression

You are given 2 arrays $$a$$ and $$b$$ of size $$n$$.
Your task is to reorder array $$b$$ such that the following expression is maximized.
$$(a_1 ⊕ b_1) & (a_2 ⊕ b_2)& (a_3 ⊕ b_3)& … & (a_n ⊕ b_n )$$

Constraints:
$$1 le n le 10^5$$
$$0 le a_i,b_i le 2^{30}$$

## algorithms – Maximize payout of job scheduling

Suppose you have a set of jobs $$1, 2, dots, n$$ with corresponding payouts $$j_1, j_2, dots, j_n$$ where each job has a certain cooldown period $$p_1, p_2, dots, p_n$$. If you choose job $$i$$ you receive a payout of $$j_i$$ but must skip the next $$p_i$$ jobs before you can choose another job. You can only choose jobs in the order provided, but you can skip a job if the cooldown period is too large. Find a recursive relation to determine the maximum payout and prove its correctness.

I’ve been struggling to come up with a recursive solution, but here’s what I have so far: So suppose the optimal payout up to job $$i$$ can be expressed as $$P(i)$$. Then if we don’t choose $$i$$, $$P(i) = P(i – 1)$$. If we do choose $$i$$, we take payout $$j_i$$ and must skip the next $$p_i$$ jobs. Then is it the case that $$P(i) = j_i + P(i – p_i)$$ (job $$i$$‘s payout + the maximum payout from $$p_i$$ jobs before)? If so then we just take $$max{P(i-1), j_i + P(i – p_i)}$$, but I’m not 100% sure this is correct.

## mathematical optimization – Maximize a function over complexes

Assume that I have a bounded real valued function $$h(a,b)$$ such that $$ain mathbb{C}$$ and $$bin (0,1)$$. Can Mathematica maximize such function over $$mathbb{C}times (0,1)$$?

I tried some functions such as `Maximize` and `NMaximize`, but following the documentation, they only consider real parameters.

## maximum – Unable to formulate the correct formulation for maximize a function

So, i want to express these:

$$max(cos(x)cos(y)cos(z)),quad x+y+z=pi,quad x,y,zin(0,pi)$$

Attempt:

``````In(81):= NMaximize({Cos(x) Cos(y) Cos(z),
x + y + z == Pi && 0 < x <= (Pi) && 0 < y <= (Pi) &&
0 < z <= (Pi)}, {x, y, z})

Out(81)= {0.125, {x -> 1.0472, y -> 1.0472, z -> 1.0472}}
``````

But how so? I tried manually like this:

``````In(82):= N(Cos(30 Degree) Cos(30 Degree) Cos(30 Degree))

Out(82)= 0.649519
``````

The above calculation implies there are numbers greater than the maximum value, i mean $$0.649>0.125$$. I think, i made a mistake to formulate the expression. Could you help me please? If the formulation is correct that would be greater or equal to `Out(82)`. Thanks in advance?