Imagine I have this sublist. [1]: https://i.stack.imgur.com/SqsDJ.png I want to sort it in an order so that [{Larger Number, Smaller Number}, {Larger Number, Smaller Number}, et cetera]. Any help would be appreciated Thanks

# Tag: elements

## Is there any specific order to Elements?

In Dungeons and Dragons, the four elements are Air, Earth, Fire, and Water (like the planes and the elementals). In the lore, is there any specific order to these elements? Or is the order just usually alphabetical and has no lore?

## 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

### Problem

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!

## GroupBy and Rule to select the first and third elements based on the second

Let’s say I have a matrix like

`m={{1,a,2},{4,b,3},{6,a,8},{7,c,10},{2,c,5}} `

How can I use GroupBy to pick the first and third elements using the second one? I tried

`GroupBy[m, #[[2]]&->#[[{1,3}]]&] `

which is apparently wrong.

## 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) &] `

# Edit

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.

## If I have a heap with 15 elements, all of them different, implemented using an array

Suppose I have a heap with 15 elements, all of them different, implemented using an array. In which position(s) of the array could the smallest element of the heap be at?

## 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?