Board Game Sequences - A possible New Problem

Back to General discussions forum

CSFPython     2022-09-14 09:35:52

This is a fairly straightforward problem so it should attract a reasonable number of solutions. Hopefully it is not too similar to any previous problems. The main motivation for suggesting it is to be able to follow it with an advanced version which requires a more sophisticated approach. The following is a draft problem description:

A board game consists of a linear sequence of squares. Players throw a six-sided die to determine the number of squares to move their playing piece at each turn. Moves are forwards only. The first move takes a player onto the board. So a first move throw of 5 takes a player to square 5 on the board. The game ends when a player reaches the final square on the board. If a player is close to the final square and throws a number which would take them beyond this square, they ignore this throw and continue throwing the die until they get a number which keeps them on the board; so that they are either on or before the final square. When all players have completed the game, the sequence of die throws for any given player (excluding those that were ignored) must therefore be a sequence of numbers which adds up to be the number of squares on the board.

The problem is to find out how many possible sequences there are for a board of given size and a given six-sided die. The die has a different number on each of its 6 faces. However, unlike a normal die, the numbers are not 1, 2, 3, 4, 5 and 6. None of the numbers on the die will be larger than 30. Even for a small board, the number of possible sequences of die throws is a very large number. You should give the answer modulo 1000000007 (10^9 + 7).

Because of the fact that there is an advanced version of this problem, you are asked not to post a solution to the simpler problem which will also solve the advanced problem.

Input/Output description: The first line of the input data will contain 6 space-separated integers. These are the numbers on the 6 faces of the die. The next line contains a single integer N. N lines of data follow. Each of these contains a single integer which is the number of squares on the board. You need to find the number of possible die throw sequences for this size of board with the given die. Combine all N answers into a single string, separated by single spaces. Remember that each answer should be given modulo 1000000007.

Example:

input:
1 11 18 22 23 28
6
100
1000
10000
100000
1000000
10000000

answer:
85578459 787831311 569622963 602449829 723608589 229835172
Rodion (admin)     2022-09-21 19:52:59
User avatar

Ooops, sorry, it seems I didn't noticed these news in time, going to add these two problems in few hours!

Hello, Clive, and thanks a lot!

CSFPython     2022-09-21 22:05:17

Rodion,

Thanks for spotting the problems. I also sent you another e-mail which hopefully you have now found and dealt with.

Rodion (admin)     2022-09-22 07:29:04
User avatar

Thanks, the problems are ready! I'm not sure we can enforce requirement not to submit advanced version for the simpler problem, but I recollected the feature of hiding solution for simpler problem until the larger is solved and tried to employ it here (please tell if it works incorrectly or doesn't work at all).

gardengnome     2022-09-22 20:20:35
User avatar

For the math fans out there, and as this does not really help with solving the two new problems: have a look at the composition of a number, and in particular A-restricted compositions or S-restricted compositions. Lots of quite recent research papers, but you have to write the algorithms here all by yourselves.

zelevin     2022-09-24 17:48:19

Clive:

This is tremendous. I am honestly not sure I'd manage to make every leap of thought required for the second problem if you haven't thoughtfully separated the first challenge into a separate problem.

Thanks!

V.

CSFPython     2022-09-24 20:13:23

Vladimir,

Thanks for the encouraging feedback. It's good to know that I can always rely on you and Mathias to solve my problems. It is, however, a little disappointing that so few others are doing so.

zelevin     2022-09-26 16:29:43

Clive:

Yes, I agree it's disappointing, in particular because I consider some of the recent problems with only a few solvers to be quite accessible.

Rodion, perhaps the site can introduce something like "the challenge of the week", where one of the simpler recent problems is showcased on the home page for exactly one week, and the folks who successfully solve it get some special reward (like, I don't know, a star) to display on their profile?

V.

sam_bandara     2022-10-25 02:13:26

Thanks Gardengnome for the tip. I was just about to ask for help. I am niether math exper nor a python expert, but I love challenges. Let's give this a go!!

Cheers, Sam.

zelevin     2022-10-25 03:46:45

Sam:

You might want to start with problems number 40 and 60 (in any order) and see if you find any commonality between them.

sam_bandara     2022-10-25 04:56:11

Sure Zelevin, I will try. Thanks!!

Please login and solve 5 problems to be able to post at forum