Chances of specific sequence in X amount of dice?

So after fumbling around in AnyDice for awhile, I’m struggling to find a solution. Here’s what I’m looking for:

  • What are the chances of rolling a specific number that matches a specific sequence in order in multiple dice?
  • For example, in Xd6, I’m trying to figure out what that chances of rolling a 5+, THEN a 4+ in the remaining dice (as long as I get a 5+ first), then a 3+ in the remaining dice (as long as I get the 5+ and 4+ previously).
  • Bonus cookies and many thanks to you if your function allows me to easily change the numbers I’m looking for (like if I’m trying to find a 4+, 2+,5+ in that order)

Basically, a player rolls Xd6 and tries to match their different specific number sets, like 3+, 3+, 2+ or 1, 2, 3, exactly or 4+, 2, 6

Train chase sequence

In my next session, I want my players to have a chase sequence followed by a battle on board a moving train. They’ll be chasing Githyanki, so their mage hand, jump, and misty step spells will all come into play.

I have a better idea of how to run the combat following the chase, which is covered to some extent in this question. However, any 5e-specific suggestions in that area would be welcome as well.

The problem

I ran a chase sequence through a graveyard according to the stock rules (DMG 252-255) a few months ago, and everyone including me ended up getting bored before it was over, even after I put the Benny Hill theme on.

It was repetitive: players and NPCs both sprinted constantly, and few of the regular urban chase pitfalls really applied to graveyards (crowd of beggars? stained glass window? cart blocks your way?). To my discredit, I didn’t draw up a custom chase table in advance, which is why the same pitfalls kept happening over and over; that I’ll definitely fix this time around.

How do I keep things interesting throughout the chase?

Use Mathematica to split a sequence according to other two sequences

I want to use Mathematica to solve the following problem:

For example I have a sequence 101. I want to compare it with $ 1101$ and $ 0101$ . The comparison has the following procedure:

  1. Check the first term of $ 101$ is $ 1$ or $ 0$ . If it is $ 1$ , compare $ 101$ to $ 1101$ , term by term; If it is $ 0$ , compare $ 101$ to $ 0101$ . Stop the process before the first term they are different, or all the terms of $ 101$ have been compared without stopping the process, and report all the terms that have been compared.

In our case, the first term of $ 101$ is $ 1$ , so we compare it with $ 1101$ . Then, $ 101$ and $ 1101$ only has one term in common, the first term $ 1$ . So the program should report $ 1$ , and go to next step.

  1. Recording the remaining sequence of $ 101$ .

In our case, as only $ 1$ is reported, the remaining sequence is $ 01$ .

  1. Restart the process. Check the first term of $ 01$ is $ 0$ or $ 1$ . If it $ 0$ , compare $ 01$ with $ 0101$ , if it is $ 1$ , compare $ 01$ with $ 1101$ . Stop the process before the first term they are different, or the sequence of $ 01$ has been run out. Report all the timers that have been compared.

*In our case, the first term of $ 01$ is $ 0$ , so we compare $ 01$ with $ 0101$ . Then the first two terms agree, and then $ 01$ ran out. The program should report $ 01$ , and then stop.

  1. Repeating the process again and again until there is no remaining sequence.

I tried to use the commend "If" to write this but it did not work, since I did not know how to let Mathematica to "remember" what has been compared.

Then, I tried to use commend "Order" and "Sort", but it seems that I need to program a comparison function.

Is there anyway for me to achieve this using Mathematica? Thank you!

Evenly select Records on categorical column with Repeating Sequence and pagination in Postgres

Database: Postgres
I have a product(id, title, source, ...) table which contains almost 500K records. An example of data is:

| Id | title    | source   | |:---|---------:|:--------:| | 1  | product1 | source1  | | 2  | product2 | source1  | | 3  | product3 | source1  | | 4  | product4 | source1  | | .  | ........ | source1  | | .  | ........ | source2  | | x  | productx | source2  | |x+n |productX+n| sourceN  | 

There are are 5 distinct source values. And all records have source values random.

I need to get paginated results in such a way that: If I need to select 20 products then the results set should contain results equally distributed based on source and should be in a repeating sequence. 2 products from each source till the last source and again next 2 products from each source. For example:

| #  | title    | source   | |:---|---------:|:--------:| | 1  | product1 | source1  | | 2  | product2 | source1  | | 3  | product3 | source2  | | 4  | product4 | source2  | | 5  | product5 | source3  | | 6  | product6 | source3  | | 7  | product7 | source4  | | 8  | product8 | source4  | | 9  | product9 | source5  | | 10 |product10 | source5  | | 11 | ........ | source1  | | 12 | ........ | source1  | | 13 | ........ | source2  | | 14 | ........ | source2  | | .. | ........ | .......  | | 20 | ........ | source5  | 

What is the optimized PgSql query to achieve the above scenario considering the LIMIT, OFFSET, sources can increase or decrease?

What sequence of actions has to be taken in order to configure DB2 UDB SMTP mail?

I read and tried to run the command provided in the article, even though I fully expect SMTP to not work because my server requires a user name and password authentication that the command is missing.

So, just to try it out, I fired off:

db2 update db cfg using smtp_server 

It threw this error:

SQL1024N  A database connection does not exist.  SQLSTATE=08003 

Are there any prerequisites to the above command that I am missing?

And once we get this to work with the community’s help, how are we supposed to provide user name and password for the SMTP server in DB2 UDB?

Is there performance loss in out of sequence inserted rows (MySQL InnoDB)

I am trying to migrate from a bigger sized MySQL AWS RDS instance to a small one and data migration is the only method. There are four tables in the range of 330GB-450GB and executing mysqldump, in a single thread, while piped directly to the target RDS instance is estimated to take about 24 hours by pv (copying at 5 mbps).

I wrote a bash script that calls multiple mysqldump using ‘ & ‘ at the end and a calculated --where parameter, to simulate multithreading. This works and currently takes less than an hour with 28 threads.

However, I am concerned about any potential loss of performance while querying in the future, since I’ll not be inserting in the sequence of the auto_increment id columns.

Can someone confirm whether this would be the case or whether I am being paranoid for no reasons.

What solution did you use for a single table that is in the 100s of GBs? Due to a particular reason, I want to avoid using AWS DMS and definitely don’t want to use tools that haven’t been maintained in a while.

Ringed Wall of Fire: How does the damage sequence go?

When casting WoF, you can cast it as a ring, and designate the inside of the ring to be the damage side (thus, everyone inside must save or take 5d8 at the time of casting). The spell then says

“A creature takes the same damage when it enters the wall for the first time on a turn or ends its turn there.”

So, by making a ring-shaped wall, are the creatures inside forced to save again on their turn (because they either ended within 2 squares of the damaging side, or they entered the wall’s space)?

Minimizing cost of a given sequence by partitoning [closed]

Given a sequence of positive integers of size N(let) divide it into at most K(K > N/C) disjoint parts/subsequences in order to minimize the "cost" of the entire sequence.

Partitions cannot overlap, for example [1,2,3,4,5] can be divided into [1,2], [3,4] and [5] but not [1,3] and [2,4,5].

The cost of a subsequence is computed as the number of repeated integers in it. The cost of the entire sequence is computed as the sum of costs of all the subsequences and a fixed positive integer cost C times the number of partitions/divisions of the original sequence.

How should I go about determining the position and number of partitions to minimize the total cost?

Some more examples:

The given list = [1,2,3,1] Without any partitions, its cost will be 2 + C, as 1 occurs two times and the original sequence is counted as one partition.

[1,1,2,1,2] Without any partitions, its cost will be 5, as 1 occurs three times and 2 occurs two times. If we divided the subsequence like so [1,1,2],[1,2] then the cost becomes 2 + 2*C, where C is the cost of partitioning.

I have actually solved the problem for the case of C = 1, but am having problems generalizing it to higher values of C.

For C = 1 it makes sense to partition the sequence while traversing it from one direction as soon as a repetition occurs as the cost of a single repetition is 2 whereas the cost of partitioning is 1.

I’m trying to solve it in nlog(n) complexity ideally or at most a fast n^2.

Help understanding a theorem Kleinberg proves related to sequence alignment

This is from Kleinberg’s Algorithm Design text (Theorem 6.14)

Let $ M$ be an alignment of $ X$ and $ Y$ . If $ (m, n) \notin M$ , then either the $ m^{\text{th}}$ position of $ X$ or the $ n^{\text{th}}$ position of $ Y$ is not matched in $ Y$ .

The theorem does not state that $ m, n$ must be the last elements of $ X$ and $ Y$ respectively, but earlier, when introducing the topic, he uses $ m, n$ to denote the last entries of the two strings. Which of these is correct?

Find number of ways to create sequence $A$ of length $n$ satisfying $m$ conditions

Find number of ways to create sequence $ A$ of length $ n$ satisfying $ m$ conditions. This sequence $ A$ should consist of only non negative numbers. Each condition is described by three integers $ i,j,k$ signifying $ max$ ($ A_{i}$ ,$ A_{j}$ )=$ k$ .
It is guaranteed that each index of the sequence will be there in at least one condition i.e. there will be finite number of such sequences.
The maximum value of $ n$ will not exceed $ 18$ and maximum value of $ k$ will not exceed $ 2*10^4$ .
I tried it using dynamic programming but the time complexity came out to be exponential. Can you suggest me any better approach which will reduce the time complexity?