## ICPC DP Question: Cutting a slab of marble, such that we minimize the amount of wasted marble

I’m struggling to come up with an approach towards this problem. Any hints would be much appreciated.

## Woocommerce Booking – Display selected block amount or duration

I am using Woocommerce Booking plugin and I would like to display the number of blocks a user is about to book.

eg:

• Create bookable product with 30 minute blocks, min:1, max;4
• User selects start:9:00, end:10:30
• Front end displays calculated price and “3 Blocks”

Is this possible? and how would I go about doing this? Is there a hook or is it a template change?

## Minimum amount of time for two enemies to reach their destinations?

Given an undirected, unweighted, and connected graph $$G = (V, E)$$, what is the minimum amount of time it takes for party $$X$$ to go from $$s_x$$ to $$t_x$$ and party $$Y$$ to go from $$s_y$$ to $$t_y$$? At each unit of time, $$X$$ and $$Y$$ can either move to a vertex adjacent to their current position or not move at all. However, $$X$$ and $$Y$$ are enemies with each other and if they go less than a distance of $$k$$ to each other they will go to war. The distance of $$X$$ and $$Y$$ is defined as the number of edges between them. What is an efficient algorithm to find the two optimal paths such that $$X$$ and $$Y$$ do not go to war and they both reach their destinations in the minimum amount of time? Note that the two paths can share edges as long as $$X$$ and $$Y$$ do not go less than k units of each other during their traversal. In the example below with $$k$$ = 1 the optimal path for $$X$$ is in blue and y is in red. This allows for both $$X$$ and $$Y$$ to reach their destination in two units of time Notice, if $$X$$ instead took the black path, this would be suboptimal as $$Y$$ would have to rest for one unit of time as $$X$$ moved out of the way. (This would take 3 units of time.)

So far I’ve started by computing the shortest paths between all pairs of vertices in $$V$$ by doing a BFS at each vertex. This will take $$O(EV)$$ Then, I suggest the following greedy algorithm:

At each time tick, $$X$$ and $$Y$$ should move to the vertex that is closest to their destination. If that vertex is less than k edges from the other party, choose the next closest vertex and so on. If no such vertex exists, then the current party will rest until the other party moves at least k units away from any of the adjacent vertices. Give priority to $$X$$ or $$Y$$ based on who has fewer options.

However, I don’t think the greedy solution will work. Some other ideas include A* or a max flow reduction.

## How do I design a DP algorithm to count the minimum amount of continuous palindromic subsequences in sequence?

Taking a sequence, I am looking to calculate the minimum amount of continuous palindromic subsequences to build up such a sequence. I believe the best way is using a recursive DP algorithm.

I tried to start by coming up with the base cases, subproblem and recurrence but having trouble picturing the problem space or the most efficient way to do it. (For example, is it best to find the longest palindromic continuous subsequence first, or rather find the earliest one first?)

For example:

Sequence: [A, B, A, G, C, C, G, T, O, O, T ] is made up from 3 subsequences, namely [A, B, A] + [G, C, C, G] + [T, O, O, T]

So, therefore, my output for this example would be 3.

## How can one algorithmically define the required amount of centroids in K-Means clustering?

Say I have a dataset of n vectors. These are, by nature, clustered so that there is a significant distance difference between any two points within a cluster and any two points in separate clusters.

I want to create a single centroid per single cluster. However, I cannot initially know how many clusters there are – thus I cannot pre-define the k in K-means clustering.

What is the best way to define the k in K-Means, given the dense and clear clustering of the data?

## As a DM how can i manage a group with different amount of free time?

I’ve started playing D&D 5e with a group of friend recently. I’m the DM and there are 4 players. In this time of crisis, one is still working and is only available during week ends and the other 3 (and me) have quite a lot of spare time and are eager to play on a daily basis.

Is there a viable option for me and the 3 players to do some side questing or something else and play while not creating a gap between the players ?

Solutions like doing a side campaign without earning neither experience point nor gold seems to ruin the experience. I thought of multi classing but it seems to really impact the character even if the player only use its original class.

I see 3 solutions so far, but none are satisfying : 1: make player create another character 2: create a copy of the current character which will evolve separately 3: do an adventure where all exp and gold won’t be carried over to the main adventure

So i wondered if there is anything that i didn’t’ think of. Sorry if this is a duplicate but i didn’t find anything cause i don’t really know how to write the question in the first place.

## Assign resources that each have a certain amount of work they can provide to tasks that require a certain amount of work

I’m attempting to do a hobby automation project and have come to a roadblock. I have a certain problem I need to solve, but can’t think of the solution nor what the name for the problem would be.

Say we have n tasks where each task requires $$x_i$$ amount of work to be done and m resources where each resource can provide $$y_j$$ work. The total amount of work required will equal the the total amount of work the resources can provide, i.e. $$\sum_{i=1}^{n} y_i = \sum_{j=1}^{m}x_j$$. For all j from 1 to m, $$y_j \in \left \{1, 2, 6, 12, 24\right \}$$ and each $$x_i = a*1 +b *2 + c*6+d*12+e*24$$. I was looking at task assignment problems, but those seemed to be a bit overkill since they were concerned with optimization where I’m just simply trying to slot the correct blocks in the right place so that I don’t have tasks that are given too few or too many resources.

My current guess is that you can iterate over each task, and give it the largest resource available that doesn’t go over the amount of work that is left for the task to be completed. It’s almost analagous to filling a jar with different sized rocks; the best way is to start with the largest rocks and then go down in size from there, so that the smaller rocks fill in the space between the larger ones. Am I not taking something into consideration that complicates this problem further? I’m sorry if this is an obvious one, but I’m a hobbyist programmer and couldn’t think of the name of the problem or of a good set of keywords to google. The closest I could find is task assignment so far.

## Amount of expected loop iterations when searching an array by random index

Lets say we have an array A of size n. It has 1 as its first index and n as its last index. It contains a value x, with x occurring k times in A where 1<=k<=n

If we have a search algorithm like so:

while true:   i := random(1, n)   if A[i] == x     break 

random(a,b) picks a number uniformly from a to b

From this we know that the chances of finding x and terminating the program is k/n with each iteration. However what I would like to know is what would be the expected value for the number of iterations or more specifically the amount of times the array was accessed in this program given the array A as described above.

## How do you figure out the max amount of spells that can be prepared? [duplicate]

I have a druid character, and I want to find out how many spells I can prepare at any one time.

## How can I perform a brute force attack on a webmail site which has no firewall and has an unlimited amount of tries?

My professor made this site for us and gave us a project to find the password if we have the email. Is it possible? Not sure if this is relevant, but the site isn’t HTTPS also