How do I manipulate a list so the elements within the sublist are sorted from greatest to largest?

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

Is this 9th-level spell Find Greatest Steed balanced with respect to other 9th-level spells?

Since the paladin gets the spells find steed and find greater steed, it only seemed natural to take this theme to its logical end: find greatest steed:

FIND GREATEST STEED
9th-level conjuration

Casting Time: 10 minutes
Range: 30 feet
Components: V, S
Duration: Instantaneous

You summon a spirit that assumes the form of the loyalest, majestic-est mount. Appearing in an unoccupied space within range, the spirit takes on a form you choose: a unicorn, a bulette, a felidar, or a nightmare. The creature has the statistics provided in the appropriate statblock for the chosen form, though it is a celestial, a fey, or a fiend (your choice) instead of its normal creature type. Additionally, if it has an Intelligence score of 7 or lower, its Intelligence becomes 8, and it gains the ability to understand one language of your choice that you speak.

You control the mount in combat. While the mount is within 1 mile of you, you can communicate with it telepathically. While mounted on it, you can make any spell you cast that targets only you also target the mount.

The mount disappears temporarily when it drops to 0 hit points or when you dismiss it as an action. Casting this spell again re-summons the bonded mount, with all its hit points restored and any conditions removed.

You can’t have more than one mount bonded by this spell or find steed at the same time. As an action, you can release a mount from its bond, causing it to disappear permanently.

Whenever the mount disappears, it leaves behind any objects it was wearing or carrying.

A mount summoned with this spell cannot take legendary actions. If it normally would have legendary actions, on its turn, it can use its action to take one of its legendary actions.

A paladin can cast this spell consuming two 5th-level spell slots, instead of one 9th-level spell slot.

This spell would appear only on the Paladin spell list, and could be prepared and cast by a paladin once the paladin was 19th-level. Additionally, this spell would be available to an 18th level Bard via magical secrets. I think this spell only being available to 18th level and higher characters is going to be enough to balance it. Compared to true polymorph, the effects here actually seem pretty modest for a 9th level spell; and for the paladin, casting is always going to be limited to once per long rest, as it uses up all of their highest level spell slots.

The mounts I have chosen range from CR 3 to CR 5. The original 2nd-level spell find steed mounts range from CR 1/8 to CR 1/2, and the now penultimate 4th-level spell find greater steed provides mounts ranging from CR 1 to CR 2. These two spells are given a comparative analysis in this answer. This CR 3-5 range seems like an appropriate increase in power, but as with both its predecessors, some of these greatest steeds will be less greatest than others. I’ve carefully chosen four creatures for this spell, I feel that each brings something unique to the table, even though one of them seems to be a head above the rest. Speaking of which…

The Unicorn (CR 5)

If I’m being totally honest, this spell could have been called find unicorniest steed. The unicorn is easily the best mount on the list. It is not the best damage dealer, not even close, but the utility and support the unicorn provides is unparalleled by other creatures on this list. It can cast pass without trace at will, and its ability healing touch is equivalent to a 2nd-level cure wounds twice a day.

The unicorn is the only creature on the list with legendary actions. I felt that giving the unicorn unbridled access to its legendary actions was too much. Additionally, its just easier to keep track of things when I’m not keeping up with my own turn, my mount’s turn, and legendary actions for my mount on other turns. Instead, the unicorn can opt to use one of its legendary actions on its turn. In particular the unicorn’s shimmering shield ability is quite good, and allows the unicorn to excel in its support role.

The Bulette (CR 5)

This guy is the bruiser of the group. At +7 to hit for 4d12+4 damage, the bulette’s bite attack hits like a truck, and AC 17 averaging 93 hp gives him respectable staying power. The bulette really gets interesting with his movement: burrow 40 ft. If you’re nostalgic about catching your first diglet in a cave outside of Vermilion City, the bulette is for you.

The Felidar (CR 5)

The felidar packs a similar punch to the bulette with identical AC and hitpoints, but the felidar is for the more psychically minded adventurer. The felidar has the ability to form a special bond with another creature, granting these benefits:

• The felidar can sense the direction and distance to the bonded creature if they’re on the same plane of existence.

• As an action, the felidar or the bonded creature can sense what the other sees and hears, during which time it loses its own sight and hearing. This effect lasts until the start of its next turn.

Similar combat prowess as the bulette, but has some interesting abilities that make the felidar an excellent scout and great insurance policy if his owner gets kidnapped.

The Nightmare (CR 3)

This goth version of the pegasus features an ability that makes it better than his winged celestial brother, earning him a spot on this list. For the most part, the nightmare is identical to the pegasus, which makes him probably the weakest choice on this list. But the nightmare has one ability the earns him his place here:

Ethereal Stride. The nightmare and up to three willing creatures within 5 feet of it magically enter the Ethereal Plane from the Material Plane, or vice versa.

This guy can disappear to the ethereal plane at will. And he can bring his three closest friends. The utility of this ability is limited only by your imagination and how annoyed your DM is that your flaming horse can walk through walls.

Need help optimizing an algorithm that’s supposed to maximize the greatest common divisor of n elements by removing at most one element

Alright, first here’s the text of the problem:

You’re given n bags of candies where the i-th bag contains a[i] candies and all numbers a[i] are in the segment [1,m]. You can choose a natural number x and each second remove x candies from one of the bags if it contains at least x candies. The goal is to empty all the bags except at most one of them. Find the greatest possible value of x that allows you to achieve this goal.

The desired time complexity is O(n* log m);

What I managed(I think) to do is write an O(n^2 * log m) algorithm (the two nested for loops are O(n^2) and Euclid’s algorithm is O(log m)).

The code written in c++ is below. The second for loop calculates the gcd of the numbers excluding the i-th number and I calculate the maximum by considering all values of i, but apparently it can be done linearly. Any ideas on how to optimize it to O(n* log m)?

int gcd(int a, int b){     if(b == 0)         return a;     return gcd(b, a%b); }   int greatestPossibleGcd(int *arr, int n){     int maxgcd = 0;     int current = 0;      for(int i=0;i<n;i++){         maxgcd = gcd(maxgcd, arr[i]);     }      for(int i=0;i<n;i++){         for(int j=0;j<n;j++){             if(j == i)                 continue;             current = gcd(current, arr[j]);         }         if(current > maxgcd)             maxgcd = current;          current = 0;     }      return maxgcd;  } 

What’s the greatest number of hands I can have to annoy my mother-in-law with?

My mother in law is coming to visit tonight, for dinner. She hates me, and will criticize my food. But tonight is my night. I’ve prepared the dish she most hates, a beautiful roasted Tarrasque chop, and as soon as she makes her first comment,

Oh dear lord, this meal looks dreadful!

I want to flip her off. To give her the bird, as the High-Elves say. As many times as I can. And to do so, I require as many hands as possible! From my research, I have managed to create 9 hands to flip her off with, using a Sorcerer-3/Wizard-17 combination with Mage Hand, Chill Touch, Quicken Spell, Glyph of Warding, Bigby’s Hand, and True Polymorph.

I cast my Mage Hand, which lasts for a minute. I prepared Bigby’s Hand in a Glyph of Warding, which lasts 1 minute and triggers when I walk into it. It mimics my own hands. In the following turn, I cast Chill Touch, which leaves a hand on my mother-in-law (and some necrotic damage, but she deserves it). Using my Sorcerer Quicken Spell Metamagic, I also True Polymorph myself with a Bonus Action into a 6-handed Marilith, taking my concentration.

Using 20 levels, I managed to flip my mother-in-law off 9 times. I didn’t find other monsters with many arms, but the fact that I have an entire day to prepare leads me to believe I can do better (although I don’t want to prepare more than 1 Glyph of Warding, it’s too cheesy for my dinner meal). Any ideas how?

Only officially published materials apply. Magic items are also valid. Consider you have an entire day / long rest worth of time to prepare. After she arrives, she’ll only stay for a couple of hours and then leave to go back to the Underdark she crawled from.

Select 4 points of $n$ in 2d to make rectangle with the greatest area and sides parellel to the axes

On the plane $$n$$ points $$(x_i, y_i)$$ are marked. Select 4 points so that they define a rectangle with the greatest area and sides parallel to the axes.

Time limit for python is 10 seconds, for other programming languages – 2 seconds.

Input data:

• in first string integer $$n$$, $$(4 \leq n \leq 3000)$$
• in next $$n$$ strings pairs of integer coordinates $$x_i\ y_i$$ $$(-10\ 000 \leq x_i,\ y_i \leq 10\ 000)$$

Output data:

• 4 different indices (numbers from $$1$$ to $$n$$), specifying the vertices of the rectangle.

I made in python, but even with tests of $$n \leq 111$$ it have TL.

n = int(input()) l = [] for i in range(n):     a, b = map(int, input().split())     l.append((a, b))  ans = [1, 2, 3, 4] mS = 0  for i in range(0, n - 3):     for j in range(i, n - 2):         for k in range(j, n - 1):             for t in range(k, n):                 r = [l[i], l[j], l[k], l[t]]                 w = sorted(r, key=lambda element:(element[0], element[1]))                 if w[0][0] == w[1][0] and w[1][1] == w[3][1] and w[3][0] == w[2][0] and w[2][1] == w[0][1]:                     s = (w[1][1] - w[0][1]) * (w[3][0] - w[1][0])                     if s > mS:                         mS = s                         ans = [i + 1, j + 1, k + 1, t + 1]  ans = sorted(ans) print(ans[0], ans[1], ans[2], ans[3])  

Greatest prime factor of n and n+1

For a positive integer $$n$$ we denote its largest prime factor by $$\operatorname{gpf}(n)$$. Let’s call a pair of distinct primes $$(p,q)$$ $$\textbf{nice}$$ if there are no natural numbers $$n$$ such that $$\operatorname{gpf}(n)=p, \operatorname{gpf}(n+1)=q$$ or $$\operatorname{gpf}(n)=q, \operatorname{gpf}(n+1)=p$$. For example, $$(2,19)$$ is nice.

Are there nice pairs $$(p,q)$$ with $$p,q>100$$?

Spectral radius is the greatest lower bound for some matrix norm

I’m studying matrix analysis with Horn and Johnson’s book.

I have something trouble while reading the book.

There is lemma 5.6.10 lemma and the following is the proof of that Proof of lemma.

I have trouble in two lines below from the matrix such that 1-norm of (D_t \triangle D_t^{-1}) is less and equal to (\rho(A)+\epsilon).

1-norm is defined as the sum of all element in the matrix.

I understood that off-diagonal elements can be bounded by epsilon for large t. However, I cannot understand how does the sum of absolute values of eigenvalues will be bounded by spectral radius of A.

[ Movies ] Open Question : Why isn’t Leonardo DiCaprio rated more highly in debates about the greatest actors of all time?

He easily passes all the criteria: (1) won an Oscar for Best Actor, deserves at least 8-10 more (2) did extremely difficult roles that no other actors could (3) starred in films with other greatest actors (4) starred in one of the highest grossing films of all time (5) has a widely known legendary reputation throughout the world (6) worked with some of the best directors and producers (7) has starred in at least 10 films that deserve a Best Film Oscar. (8) all of his roles are interesting and unique (9) has no bad performance (10) has at least 5 classics He is easily number one on my all time actors list and I’m a movie enthusiast.

[Get] 2001 Greatest Headlines Ever Written

I am not a content expert. That's why i need this, I hope this will be helpful for all fellow members