Is there a realistically implementable algorithm for testing the termination of a given petri net?

I am trying to implement this petri net simulator. Amongst it’s specifications it has to return a map of reachable markings from the current state. I don’t really want it to give me an OutOfMemoryError or something if I’m given a petri net with infinite reachable markings. Can this be resolved more elegantly?

In my case the net can have inputs and outputs of any natural value, as well as reset and inhibitor arcs.

What is the maximum number of attacks given the below constraints for AD&D?

A former DM has had the same recurring NPC/GMPC since I started playing in his game. This was 20+ years ago and we started in 1st edition and slowly made our way through the years and editions. We updated our characters as we went to the new editions. Now this NPC/GMPC is the most reviled in his games, any time he shows up all the players immediately want him dead. We stick to character though.

The question will be broken up to hopefully get expert answers from each of the editions in which we played in this particular question it will be specific to 1e. I am skipping 4e (as we all hated it and only played one session) and 5e because I know for a fact that it is not possible there (yet).

The question is as follows:

Give the following constraints what is the maximum number of attacks in this edition:

  1. NPC is an Elf (This is just to set the prerequisite for the below multiclass possibility).
  2. He was a Thief-Acrobat and I assume multiclassed, probably Fighter-Thief.
  3. The weapon of choice was throwing knives.
  4. Assume unlimited ammunition as he had a bandalier that had the knives return.
  5. I know he could throw 3 knives at a time (pretty sure this was a thing for shuriken from Oriental Adventures).
  6. Assume all official sources and Dragon Magazine since the first issue are open.
  7. I know of this question and assume there is a variant with knives.
  8. If I recall he threw with both hands as well.
  9. We were always between 8th and 15th level when I met this character.
  10. I do not recall spell-casting but not ruling it out entirely but main build would likely have been focused on mundane means.
  11. Assume focused magical item augmentation as well, just calling it out even though the aforementioned bandolier alluded to it, but for the most part official items other than that.

The end result in game was quite literally at least 2 dozen attacks per round, perhaps more. Which I have questioned him multiple times about the build and legitimacy but he as refused to provide any answers. I know DMs do not have to justify but this, combined with a number of other things over the years has lead to distrust. I have since stopped playing his games altogether, so this is just a verification on whether I have overreacted.

This was broken into 3 questions for each of the editions.

AD&D, AD&D 2nd Edition, and Dungeons & Dragons 3.X.

Partition a multiset into pairs that sum up to given numbers?

Given a multiset of $ 2m$ positive numbers, $ S=\{s_1,s_2,\ldots,s_{2m}\}$ and given $ m$ targets $ t_1,t_2,\ldots,t_m$ . Can we partition $ S$ into $ m$ pairs $ (a_i,b_i)$ such that $ a_i+b_i=t_i$ , where $ a_i\ne b_i$ and $ a_i,b_i\in S$ ?

For example for $ S=\{1,4,6,1,2,5\}$ and $ t_1=7$ , $ t_2=t_3=6$ . The answer is YES and the pairs are $ (1,6)$ , $ (2,4)$ , and $ (1,5)$ .

Which stat should I use for a given madness save?

I’m running Out of the Abyss, and I can’t figure out whether a given madness save should require a Wisdom or a Charisma save. In chapter 2, it merely says that one of these may be required. The DMG says the same.

Based on what I’ve been able to find online, the consensus seems to be that Wisdom saves are one’s ability to notice they’re being messed with, while Charisma saves are more about repression/subjugation of one’s entire psyche. Given this, it’s understandable why eg the Demogorgon encounter requires a Cha save, but what about if the PCs eg ran into a cursed statue. Would that be Wis since it is not as immediate an assault on the sense of self?

Maybe I just answered my own question, but I would love a second opinion borne from more experience.

Minimise the difference under given constraints

Given $ M$ arrays, pick one element from each array so that, the difference between the maximum and minimum of the resulting array is the smallest possible. Provide an efficient algorithm for finding such a minimum difference.


The total number of elements in $ M$ arrays <=$ 10^5$

$ M$ <=$ 10^5$

Time limit: 1secs

Example: Let $ M$ arrays be,( $ M=3$ in the following)

$ 10,16,21$

$ 15,28$

$ 18,30$

The optimum way to pick elements is 16 from the first set, 15 from the second set, 18 from 3rd set.Hence the answer is $ 18-15=3$

Whether given language is decidable or not?

Let $ L$ be a language containing only strings in $ s$ . Where,

$ s = \begin{cases} 0 \space \space \space \space if\space God\space does\space not\space exists\space \ 1 \space \space \space \space if\space God\space exists\space \end{cases}$

Is $ L$ decidable?

Answer given is that $ L$ is decidable.

I’m confused because I think that if we are given string let say $ 0$ for instance how can we necessarily determine whether it belongs to $ L$ or not? Because we are not sure about content of set $ s$ itself.

Number of multiplications and additions in the given code

$ N:=2^p$

Input: $ f \in \mathbb C^N$

1: $ n=N/2$

2: initialize vectors $ f^{(1)}, f^{(2)} \in \mathbb C^n$

3: $ w_N^0=1$

4: for $ j=0,\ldots,n-1$ do

5: $ \ \ \ \ \ f_j^{(1)}=f_j+f_{j+n}$

6: $ \ \ \ \ \ f_j^{(2)}=(f_j-f_{j+n})w_N^j$

7: $ \ \ \ \ \ w_N^{j+1}=\exp(-2\pi i/N)w_N^j$

8: end for

9: if $ N=2$ then

10: $ \ \ \ \ \, $ set $ c:=(f^{(1)},f^{(2)})\in \mathbb C^2$

11: else

12: $ \ \ \ \ \, $ evaluate (recursively) $ c^{(1)}=FFT(f^{(1)})$

13: $ \ \ \ \ \, $ evaluate (recursively) $ c^{(2)}=FFT(f^{(2)})$

14: $ \ \ \ \ \, $ set $ c=\Big(c_0^{(1)},c_0^{(2)},c_1^{(1)},c_1^{(2)},\ldots,c_{n-1}^{(1)},c_{n-1}^{(2)}\Big) \in \mathbb C^n$

15: end if

Let $ m_p$ be the number of multiplications and $ a_p$ the number of additions for $ N=2^p$ . I want to show that

$ $ m_p\le p2^p, \ \ \ \ \ a_p\le p2^p, \ \ \ \ \ p\in \mathbb N$ $

Therefore we have a total complexity of about $ N \log (N)$ complex additions/ multiplications

A notion dual to a product type having a given type

Consider this class:

class Has record part where   extract :: record -> part   update :: (part -> part) -> record -> record 

It captures the notion of some product type record having a field of the type part which can be extracted from the record, or the functions on which can be used to update the whole record (in a lens-ish manner).

What happens if we turn the arrows? Following the types and noting that a sum type is dual to a product type, and a “factor” in a product type is analogous to an option in a sum type, we get

class CoHas sum option where   coextract :: option -> sum   coupdate :: (sum -> sum) -> option -> option 

Firstly, is this line of reasoning correct at all?

If it is, what is the meaning of coextract and coupdate? Obviously, coextract produces the sum out of one of its options, so it might as well be called inject or something similar.

coupdate is more interesting. My intuition is that, given a function f that updates a sum type, it gives us a function that can be used to update one of its options. But, obviously, not every f is fit for this! Consider

badF :: Either Int Char -> Either Int Char badF (Left n) = n badF (Right _) = Left 0 

then coupdate badF does not make sense where coupdate is taken from CoHas (Either Int Char) Char. One requirement seems to be that the function passed to coupdate must not change the tags of the sum type.

So here’s the second question: what’s the dual of this requirement in the Has/update case?

My intuition is that it’s not as straightforward because Has produces a function and CoHas consumes a function. Things get more symmetric if we consider the rules for the type classes, something along the lines of

  1. update f . update g = update (f . g)
  2. update id = id
  3. extract . update f = f . extract

Now we can actually talk about bad instances of Has producing update functions breaking these rules. But even with this additional constraint, I’m not sure I follow what the laws for the functions that coupdate accepts should be and how one could derive them from such duality-based reasoning.

Given a DCEL, how do you identify the unbounded face

I have constructed a DCEL using the procedure described in How do I construct a doubly connected edge list given a set of line segments?.

This correctly identifies all faces, however I’m struggling to come up with a way to identify the unbounded face surrounding my graph.

So far my only idea is that by building a polygonal representation of every face, I could find the face polygon which ‘contains’ all the others, but this seems kind of messy.