Should casting Confusion centered on yourself from Wild Magic Surge be trivial to end because it’s a concentration spell?

The entry for a roll of 13 or 14 on the Wild Magic Surge table is:

You cast confusion centered on yourself. (PHB, emphasis mine)

Confusion is a 4th level concentration spell. The rules for concentration state that:

If a spell must be maintained with concentration, that fact appears in its Duration entry, and the spell specifies how long you can concentrate on it. You can end concentration at any time (no action required). (PHB)

The intent of the entry on the Wild Magic table seems to be for everyone nearby, including the caster, to be hit by confusion, essentially a less-bad version of casting Fireball centered on yourself. However, since the table doesn’t specify anything special about concentrating on the spell, the caster needs to maintain concentration on it, and consequentially the spell should end if they stop concentrating on it.

RAW, is there any reason someone who rolls this result on the Wild Magic Surge table couldn’t immediately drop concentration and end the spell?

Confusion with memoization

Consider the following function that generates a sparse diagonal Matrix

W[n_] := W[n] = Exp[(2 Pi I)/n]//N;  Clear[X];  X[n_, L_, power_ : 1][i_, chain_] := X[n, L, power][i, chain] = DiagonalMatrix@SparseArray@Table[ W[n]^(-IntegerDigits[a,n,2 L][[chain*L-i+1]]power), {a, 0,n^(2 L)-1}] 

Due to the f[x_]:=f[x]=SlowFunction definition, I expect this code to be much faster on a second run. If I evaluate the following on my laptop several times

X[3, 7][1, 1] // Timing 

I get $ 12$ seconds on the first run then around $ 2.8$ seconds on any evaluation after that. Clearly the memoization trick seems to have made this faster, but it is still much slower than it should be. For example if I run

a = X[3, 7][1, 1] 

then

a //Timing 

I get $ 10^{-6}$ seconds. Running X[3, 7][1, 1] the second time should also be this fast, since the matrix is already computed and saved. But it seems that instead it is still doing some computation. Any reason this happens?

Does the Confusion Spell Affect Ghosts that are Possessing a Character?

Let me lay out the scenario: I’m running a D&D 5e session where the party enters a haunted castle and begins snooping around. They encounter four ghosts and one of the PCs gets possessed by a ghost. After a few rounds of combat, the Druid decides to cast Confusion on an area that the possessed PC is in. I know the following things:

  1. Ghost possession rules state that the Ghost cannot be targeted by attacks or spells unless the attack or spell turns undead.

  2. Confusion “targets” an area, not individual creatures (based on my understanding of what “target” means) so the possessing Ghost isn’t targeted but in the area of effect.

  3. Ghosts are not immune to Confusion because although they are immune to being charmed, Confusion does not state in its description that creatures immune to being charmed are immune to the spell.

  4. If the spell were a fireball or lightning bolt or a different AoE spell, the ghost would be unaffected and the spell would simply harm the vessel.

The party argued that this would mean that the ghost can be affected, especially since the ghost is acting as the PC’s mind. Since they were in a tough spot, I decided to allow it this time, but I told them I’d reach a decision about that sort of thing after doing some research.

Here is my question: Would a ghost possessing a PC be affected by a Confusion spell? My instinct is to think that the Confusion spell hits the PC instead of the ghost and since the PC is incapacitated, the spell basically has no effect.

Confusion about definition of languages accepted by Turing Machine, very basic question

I’m studying for an upcoming exam and my book gives the following definition:

Let $ M$ be a Turing machine, then the accepted language $ T(M)$ of $ M$ is defined as $ T(M) = \{x \in \Sigma^* \mid z_0 x \vdash^* \alpha z \beta; \alpha, \beta \in \Gamma^*; z \in E\}$ .

As a side note, $ \vdash$ denotes the transition from one configuration of the TM to the next, and the $ ^*$ denotes an arbitrary number of applications of this relation.

What I’m confused about is that under this definition of acceptance, I only have to enter the end state once and even if I leave it, the word would be accepted, or I could loop in this end state. In push down automata or regular automata, we do not have this problem as we move through the word sequentially from beginning to very end, especially in push down automata where the stack is separated from the input word.

Now I read in most other definitions, additionally to ending up in an end state, the Turing machine must also halt, meaning that it must end in a state that has no transitions. Although I’m not sure what this would mean for deterministic Turing machines as they have to have transitions for all configurations of the machine.

To wrap it up:

Question 1: Is halting required? Is it a useful property for accepting languages or is there a reason the definition was given as is?

Question 2: How would you define "halting" for deterministic Turing machines?

Confusion in Reduction of Hamiltonian-Path to Hamiltonian-Cycle

The following is an excerpt from a material on NP-Theory:
"Let G be an undirected graph and let s and t be vertices in G. A Hamiltonian path in G is a path from s to t using edges of G, on which each vertex of G appears once and only once. By HAM-PATH we denote the problem of determining, given G, s and t, whether G contains a Hamiltonian path from s to t. I now explain a reduction HAM-PATH < HAM-CYCLE. Let G, s, t constitute an input for HAM-PATH. We want to convert it to an input G′ (an undirected graph) for HAM-CYCLE. We add a new vertex u to the vertex set of G in order to obtain the vertex set for G′. The edges of G′ are all the edges of G plus two extra edges (u, s) and (t, u). I leave it to the reader to visualize that G′ contains a Hamiltonian cycle if and only if G contains a Hamiltonian path from s to t."

I am confused as to why do we need to add a vertex u to create G′. Why can’t we simply connect s and t and then check for a Hamiltonian Cycle. If it exists, then a path would also exist(as path is a sub-graph of cycle in an undirected graph) and we would be done. What am I missing? I am specially asking this for undirected graphs. I am clear about directed graphs that existence of cycle having s and t does not guarantee Hamiltonian path.
Illustrations or counter examples are welcome!

Confusion of halting problem

Show that the following problem is solvable.Given two programs with their inputs and the knowledge that exactly one of them halts, determine which halts.

lets P be program that determine one of the program will be halted.

P(Program x,Program y){      if(x will be halted)            then return 1;      else             then return 2; } 

since we know that exactly one of them will be halted,if 1 then program x will be halted.Otherwiae program y will be halted.

then we construct a new program call D

D(X,Y){       if(P(X,Y) == 2)           D will halt;        else           while(1)//D will not halt;    } 

lets S be aritbrary program.

So if we have D(D,S)

if D will halt then D will not halt

if D will not halt then D will halt

It impiles a contradiction same as halting problem.

But the question stated that it is solvable.

What range is used to determine targets for the victim of a Spectator’s Confusion Ray

The Spectator has an Eye Ray option, Confusion Ray, that says:

[The target] uses its action to make a melee or ranged attack against a randomly determined creature within range.

Unlike the spell Confusion which limits the attack to melee attacks, the Spectator’s victim can be compelled to make a ranged attack.

When determining the random target are creatures that are outside of the weapon’s normal range but within the weapon’s long range included?

For a specific example a Rogue with a light crossbow is hit by the ray and fails their save. On their turn there are three allies within 80 ft, and the Spectator is 90 ft away. Is there a chance that the Rogue randomly targets the Spectator?

Adaptive arithmetic coding confusion

I’m confused about the point of adaptive arithmetic coding.

I understand that static arithmetic coding involves using preset probabilities of symbols that remain static during the whole process. I also understand that adaptive arithmetic coding involves change all probabilities after each symbol encountered.

However, what is the point of changing the probability after each symbol? Why wouldn’t you just go through an entire file first and determine the probabilities and then do the arithmetic coding as a second pass?

Additionally, I don’t understand how changing the probability of symbols impacts the compression? If we know the true probabilities of the symbols in the file we are compressing, then will it make the file smaller?

Confusion about “false sharing”

This is a homework problem that I have

  In a multicore system, you are running the code on the right on each core, and it suffers from false    sharing. You can assume t_id is set to a unique thread identifier (e.g. 0-15). How could you change    the code to reduce false sharing?    for (int i=0; i<N; i++)   totals[t_id] += a[i]; 

What I’m having trouble with is seeing where the false sharing is occurring. It says state t_id is set to a unique thread identifier, so doesn’t that mean there’s only 1 thread that’s accessing the data here?

We only briefly went over false sharing, but from what I’ve learned false sharing occurs when a cache miss occurs because the data was invalidated previously due to an “irrelevant” data being written/read from a different cache. But if the thread is the same, then doesn’t that mean it’s the same cache being used to write/read? How would false sharing occur here?