Can absorb elements be triggered on attacks that require a saving throw or be paralyzed, incapacitated… and elemental damage on a failed save?

Say an enemy is casting a spell or using an ability that forces the player to make a saving throw or be "conditioned and take X elemental damage".

Does absorb elements go off if the save is failed? Or because of the condition effect, does that mean the reaction can’t be used if you fail the save, take damage, and conditioned? Or even can it be cast before the save (and wasted if the save passes)?

Randomly assign n elements to n agents such that each agent only knows its own element


I’m working on an app that involves shuffling and distributing playing cards to players. As a challenge, I tried to solve this problem in a way that doesn’t require a trusted intermediary.

In other terms, the task is to find a distributed algorithm that

  • uniquely assigns $ n$ agents numbers $ 1..n$
  • allows each agent to know nothing about the assignment but its own
  • when revealing the assignment, allows other players to verify the assignment

We also assume that knowing other’s assignment is an advantage for each agent, and revealing its own prematurely a disadvantage. Agents are also assumed to be able to talk with each other in a way hidden from all other agents.

Partial solution

The solution I came up with works only under the assumption that adversaries do not collaborate.

The idea is to create a set of $ n$ nonces, and assign each agent exactly one nonce. The set is then passed from agent to agent in an agreed upon order, hidden from all others, until each agent received the set exactly once. Each time an agent receives the set, it swaps its nonce with a new one, memorizes the new nonce, and confirms receival of the set to the others. This entire procedure is done twice, at which point, all agents have received the set at least once after all other agents swapped their nonces, making it impossible to recognize and hence map the nonces to the other agents.

When the last agent receives the set the second time, it shares it with everyone, and all agents confirm to the others that their nonce is contained in the set. The agents then assign a number to each nonce in the set based on an agreed upon random seed, giving us the required unique assignment.

To allow ownership verification, instead of the nonces, agents put the hash value of their nonce on the set, revealing the actual nonce only when verification is required.

The problem with this solution is that if adversaries are allowed to collaborate, each time an adversary receives the set, they can compare their versions, identify changes and potentially derive which nonce belongs to other agents, allowing them to know what number got assigned to them.

All ideas are appreciated!

Recursively plotting specific elements in a list of lists

I am trying to build band structures and am looking to generate a general code that will work regardless of my list size. Here is what I am trying to do: say I have a list like

list = {{0.0, 1, 2, 3}, {0.1, 4, 5, 6}, {0.2, 7, 8, 9}, {0.3, 10, 11, 12}}; 

and I want to plot the nth element of each list against the first element of each list. How can I tell Mathematica to automatically produce a set of lists to plot like shown below

k = {0.0, 0.1, 0.2, 0.3}; band1 = {1, 4, 7, 10}; band2 = {2, 5, 8, 11}; band3 = {3, 6, 9, 12}; Show[ListLinePlot[k, band1], ListLinePlot[k, band2], ListLinePlot[k, band3]] 

Doing it manually one band at a time is possible but a waste of time when I have n=36+ bands. Any help would be much appreciated!

How to remove sublists whose difference of two elements is either 1 or 11?

I want to create a list of 3-element subsets of $ \{1,2,\cdots,12\}$ where no two elements in each subset can have difference of 1 or 11.

The following attempt fails because it returns just a list of all subsets without restriction.

Select[Subsets[Range[12], {3}]  , (Abs[#[[1]] - #[[2]]] != 1 || Abs[#[[1]] - #[[2]]] != 11) &&    (Abs[#[[1]] - #[[3]]] != 1 || Abs[#[[1]] - #[[3]]] != 11) &&    (Abs[#[[3]] - #[[2]]] != 1 || Abs[#[[3]] - #[[2]]] != 11) &] 


I just got the solution as follows, but can it be simplified?

Select[Subsets[Range[12], {3}]   , ! MemberQ[{1, 11}, Abs[#[[1]] - #[[2]]]] &&     ! MemberQ[{1, 11}, Abs[#[[1]] - #[[3]]]] &&     ! MemberQ[{1, 11}, Abs[#[[3]] - #[[2]]]] &] // Length 

Selecting n elements from array in sublinear time using indices?

Are GPUs or CPUs capable of selecting n elements from an array in sublinear time using indices? If so, what would be some good alternatives to achieve this?

Lets say I have an array A = {1, 5, 6, 3, 6, 2} and indices I = {2, 5, 2, 4, 1, 0}. The resulting array should be: B = {6, 2, 6, 6, 5, 1}. The time complexity for this should be sublinear with respect to the length of I.

What is the interaction between Green-Flame Blade and Absorb elements

Green-Flame Blade States:

…you must make a melee attack with a weapon against one creature…

…On a hit, the target suffers the attack’s normal effects, and green fire leaps from the target to a different creature of your choice that you can see within 5 feet of it. The second creature takes fire damage equal to your spellcasting ability modifier…

Absorb Elements States:

…the first time you hit with a melee attack on your next turn, the target takes an extra 1d6 damage of the triggering type…

Since Green-Flame Blade is a single attack that affects 2 targets at the same time. Does the Absorb Elements extra damage affect both the 1st and 2ndary targets as per RAW?