## How do you find all integers in a sorted array of size n that appear n/k times?

I try to find the solution to this problem: How do you find all integers in a sorted array of size n that appear n/k times in less than O(klogn) time?

I could only find this question, where O(klogn) solution was provided.

## Can spells with cumulative or instantaneous ongoing effects affect a creature multiple times?

In the current campaign, the levels 2 and 3 PCs want to spam foes with the 1st-level Sor/Wiz spell cause fear [necro] (PH 208) and the 1st-level Sor/Wiz spell power word pain (Races of the Dragon 116), the former so that they can corner and beat into unconsciousness the rare creature that they want to take alive and the latter so that they can perpetrate dungeonwide loot-their-corpses-after-they-die-in-4d4-rounds murder sprees.

It seems reasonable that a creature affected twice by the spell cause fear becomes frightened rather than merely staying shaken for a new, longer duration. Likewise, it seems reasonable that a creature affected by two or more power word pain spells would be in more pain—and suffer more damage—rather than the new power word pain spell’s duration overwriting the previous’s.

Nonetheless, since these aren’t, like, polymorph effects or temporary hp or anything with a specific rule, I am consumed with self-doubt and suspicious of both tactics, thinking they conflict somehow with the rules about the Same Effect More than Once in Different Strengths (cf. Player’s Handbook 172), the rules about the Same Effect with Differing Results (ibid.), or both… or another rule somewhere.

Can these kinds of spells—that have ongoing durations but either cumulative different effects or instantaneous effects—affect the same creature more than once simultaneously?

## How many times can I use the Song of Rest?

I just got the Song of Rest and was wondering, can I use it every time we take a short rest when someone uses a Hit Dice?

## Time complexity of code running at most summation(N) times in a loop

Let’s say I have a JavaScript loop iterating over input of size N. Let’s say all elements in N are unique, so the includes method traverses the entire output array on each loop iteration:

let out = [] for (x in N) }   if (!out.includes(x)) {     out.push(x)   } } 

The worst case runtime of the code inside the loop seems to be not O(N), but the summation of N, which is substantially faster.

Is this properly expressed as O(N^2) overall or is there a standard way to convey the faster asymptotic behavior given the fact that the output array is only of size N at the end of the loop?

## How many times is taking mfcuk to find a key

I would like to copy a VIGIK RFID badge. It’s MIFARE type badge. I’ve an ARC122 USB reader / writer and my OS is Linux like. I compiled mfoc and mfcuk successfully. First I tried to copy the badge with mfoc using this command:

mfoc  -P 500 -O Matrice.dmp 

And I’ve got this error :

    Found Mifare Classic 1k tag ISO/IEC 14443A (106 kbps) target:     ATQA (SENS_RES): 00  04   * UID size: single * bit frame anticollision supported        UID (NFCID1): 63  0e  43  bc         SAK (SEL_RES): 08   * Not compliant with ISO/IEC 14443-4 * Not compliant with ISO/IEC 18092 .../... mfoc: ERROR:  No sector encrypted with the default key has been found, exiting.. 

After a search on the web, I found I’ve to use mfcuk tool like this for find a key :

mfcuk -C -O Matrice.dmp -R 0:A -s 250 -S 250 -v 3 

But it’s taking hour without result. How to do that quicker ?

## Can a spell be prepared once and cast multiple times?

Our group had some confusion about preparing spells for a Wizard and Cleric. The rules say that you prepare a number of spells from your list and that you tick off spell slots when you cast a spell. In D&D 3.x, if you wanted to cast a spell multiple times you had to prepare it multiple times, but we couldn’t figure out from the rules whether or not this was the case in D&D 5e.

So can a spell be prepared once and then cast multiple times?

## Can I Avoid Joining The Same Table 3 Times?

I have this database schema on a Oracle 12c database :

I’m trying to answer this question :

What is the game in which Dallas Mavericks had the biggest percentage of successful 3-point shots ?

I’ve managed to answer this question with this query:

SELECT HOME_TEAMS.TEAM_NAME                    "HOME TEAM",        AWAY_TEAMS.TEAM_NAME                    "AWAY TEAM",        GAMES.GAME_DATE                         "DATE",        TEAMS.TEAM_ID                           "GENERIC ID",        HOME_TEAMS.TEAM_ID                      "HOME_ID",        AWAY_TEAMS.TEAM_ID                      "AWAY_ID",        GAME_STATISTICS.X3POINTSHOTS_PERCENTAGE "3 POINTS PERCENTAGE" FROM GAMES_TEAMS_STATISTICS          INNER JOIN GAMES ON GAMES_TEAMS_STATISTICS.GAME_ID = GAMES.GAME_ID          INNER JOIN TEAMS ON GAMES_TEAMS_STATISTICS.TEAM_ID = TEAMS.TEAM_ID          INNER JOIN TEAMS HOME_TEAMS ON GAMES.HOME_TEAM = HOME_TEAMS.TEAM_ID          INNER JOIN TEAMS AWAY_TEAMS ON GAMES.AWAY_TEAM = AWAY_TEAMS.TEAM_ID          INNER JOIN GAME_STATISTICS ON GAMES_TEAMS_STATISTICS.STATS_ID = GAME_STATISTICS.STATS_ID WHERE TEAMS.TEAM_ACRONYM = 'DAL' ORDER BY GAME_STATISTICS.X3POINTSHOTS_PERCENTAGE DESC     FETCH FIRST 1 ROWS WITH TIES; 

However, to answer this question , I join the teams table 3 times. Is there any way I can write this query in a more efficient way , avoiding so many joins ?

## Can you add your the same modifier to damage rolls multiple times if they come from different instances?

A friend of mine is wanting to do a specific build and as far as I am aware you can not apply a modifier multiple times in this way. Can someone confirm if this is a RAW legal tactic?

Scenario: lv 6 tiefling celestial warlock, assuming 16 charisma

Cast shillelagh to make staff 1d8+cha [source: pact of the tome]

Then cast searing smite for 1d6+cha [source: teifling and celestial warlock’s radiant soul feature to add charisma mod]

A single hit would be 2d8+1d6+9

Do all these instances of charisma modifier stack like this?

## Can you pull the same enemy multiple times with Grasp of Hadar?

Based on the setting explained by KorvinStarmast in this question, I’d like to know if you can pull someone more than once with Eldritch Blast + Grasp of Hadar if you hit him with multiple blasts (meaning multiple beams or multiple casts of the same cantrip).

The spell description states that you shoot multiple beams as you level up instead of shooting a stronger one, kinda like the Magic Missile spell, which have been ruled by Jeremy Crowford to work a little different from other spells in terms of calculating some effects like the bonus damage from Empowered Evocation like noted in this answer.

I’m aware of the diference in spelling between Grasp of Hadar and Repelling Blast, probably due to 3D combat, but I’m not sure that is really intended to work like that if, for example, you cast it twice while hasted or something like that.

# Overview

The process manufacturing is (in contrast to discrete manufacturing) focused on the production of continuous goods such as oil. The planning is typically solvable by means of Linear Programming, come constraints can be introduced for MILP.

# Problem Formulation

The problem consists of

• Sequence of consecutive time intervals $$t\in\{1,\dots,n_t\}$$, each with start and end $$(s_t,e_t)$$ and length $$l_t=e_t-s_t$$. Consecutive means $$e_{t}=s_{t+1}$$ for all $$t\in\{1,\dots,n_t-1\}$$.
• List of type of goods that are being produced: $$j\in \{1,…,n_j\}$$
• Demand of each type of good per time interval $$d_{j,t}$$.
• List of production lines $$i\in{1,\dots,n_i}$$
• Availability of production lines per time interval $$a_{i,t}$$. $$a_{i,t}$$ is binary – whether available or not.
• Manufacturing speed per production line per type goods $$v_{i,j}$$.
• Setup time of production line from one type of goods to another one $$u_{i,j,j’}$$.
• Price for using a production line (leasing based), counted per minute $$c_{i}$$

The goal is to plan the production lines so the demand is covered and the price for leasing is minimal.

Notes:

• The setup time can be shorter or longer or equal to the length of the intervals
• It is acceptable that the production line will not work the whole time interval if the supply has been completed sooner
• The setup to the production of another good can start any time, not necessarily at the beginning of an interval.

# Example

There are two production lines, i.e., $$n_i = 2$$ and there are two types of goods, i.e. $$n_j=2$$.

We have two intervals, i.e. $$n_t=2$$, each has a leght of 1 hour. Say one starts at 1 pm, the second at 2 pm.

The demand is:

• $$d_{1,1}=1.1$$
• $$d_{1,2}=1$$
• $$d_{2,1}=0.5$$
• $$d_{2,2}=1$$

The of running the production lines are:

• $$c_{1} =c_{2} = 1$$ USD/minute

All possible setup times are twelve minutes, i.e.:

• $$u_{i,j,j’}=0.2$$ for all $$i,j,j’$$ where $$j\neq j’$$.

The speeds are:

• $$v_{1,1}=1.1$$
• $$v_{1,2}=1.5$$
• $$v_{1,1}=1$$
• $$v_{1,1}=1$$

Obviously, the demand is met for a total cost of $$4$$ if the first line is producing the first type of goods at both intervals and the second line is producing the second type.

However, it might be tempting to switch them after the first interval. If there would be no setup time needed, the cost would be $$1+1+1+0.5/1.5=3.33$$ which is better. However, this is not possible because of the setup time of the second production line.

# Question

What is the algorithm to schedule this manufacturing process optimally?

An answer is welcome even if it would outline the way and approach (MILP, SAT, CSP,…).

# Ideas fo far

• If the length of intervals would be fixed, say 1 hour and the setup time would be defined in terms of these units, say 2 hours. Then, it might be solvable by SAT/CSP.
• An idea is to use an evolutionary algorithm that would: consist of a sequence of activities with mutations (add an activity, delete activity, prolong activity) and crossover (mix two plans in a random way).