## sequences and series – New chess grains problem

The original chess grains math problem stablished that on the first square of the chess board you put a rice grain, on the second you put two, the third four and so on, everytime having in the next square available the double from the last one. Now my question is how to calculate the rice on any square and on the entire board if instead of doubling the quantity of the last one, you multiply it by itself (except for the fisrt square of course, that would be too easy). In the first you will have one, in the second 2, in the third you have 4 and in the fourth 16, then 256, 65536, and so on.

Posted on

## sequences and series – Is it true that if \$sum x_n0\$ so that \$sum n^alpha x_n

Your privacy

By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.

## dnd 5e – Can I learn sigil sequences for teleportation circles before learning a spell that can use them?

Think of it like this.

Without knowing Chinese, how to read, write or speak it…copy down a page of Chinese text from a recipe book.

Then, years later, having learned Chinese, use that page of text by handing it over to a waiter, and you have to eat whatever he brings you.

Magic results may be worse than that, it’s notoriously finicky, and the waiter can be befriended into bringing you actual edible things and not bricks or other atypical Chinese ingredients.

Posted on

## Clean algorithm for generating Scrabble tile sequences

I am trying to come up with an algorithm that generates every possible combination of Scrabble tile sequence on a player’s rack. I want the sequence to be comprised of n number of indices depending on the number of tiles on a player’s rack.

So for example, in Scrabble, a player MUST have at least 1 tile on his rack but no more than 7.

Therefore, there are 7 possible scenarios to consider:

``````Player has 1 tile on his rack (minimum)
Player has 2 tiles on his rack
Player has 3 tiles on his rack
Player has 4 tiles on his rack
Player has 5 tiles on his rack
Player has 6 tiles on his rack
Player has 7 tiles on his rack (maximum)
``````

In the case where the player only has 1 tile, this is easy since we only have a single index to worry about.
The answer is:

``````1: (0) - This means the tile on index 0 on the rack can not be repositioned any further.
``````

In the case where the player only has 2 tiles, this too is easy since we only have 2 combinations.
The answer is:

``````1: (0)(1) – First tile on the rack remains in position 0
Second tile on the rack remains in position 1
2: (1)(0) - First tile on the rack swaps to position 1
- Second tile on the rack swaps to position 0
``````

In the case where the player has exactly 3 tiles on his rack, there are even more combinations:
The answer is:

``````1: (0)(1)(2)
2: (0)(2)(1)
3: (1)(0)(2)
4: (1)(2)(0)
5: (2)(0)(1)
6: (2)(1)(0)
``````

Of course, in the 3 examples above, the answers represent those situations where the player has managed to play ALL his tiles on a single play.

In Scrabble, however, a player can play any number of tiles on his rack or even none at all. Ignoring the situation where no tiles are played, we need sets to encompass any type of play.

Let’s revisit a rack with 1 tile. We have no more extra sets to create; the answer is still:

``````1: (0)
``````

For 2 tile racks, the answer is now:

``````1: (0)(1) – All 2 tiles are played
2: (1)(0) – All 2 tiles are played
3: (0) – Only 1st tile is played, other stays on rack
4: (1) – Only 2nd tile is played, other stays on rack
``````

For 3 tile racks, the answer is:

`````` 1: (0)(1)(2) - All 3 tiles played
2: (0)(2)(1) - All 3 tiles played
3: (1)(0)(2) - All 3 tiles played
4: (1)(2)(0) - All 3 tiles played
5: (2)(0)(1) - All 3 tiles played
6: (2)(1)(0) - All 3 tiles played
7: (0)(1) - Only 2 of 3 tiles played
8: (0)(2) - Only 2 of 3 tiles played
9: (1)(0) - Only 2 of 3 tiles played
10: (1)(2) - Only 2 of 3 tiles played
11: (2)(0) - Only 2 of 3 tiles played
12: (2)(1) - Only 2 of 3 tiles played
13: (0) – A single tile played
14: (1) – A single tile played
15: (2) – A single tile played
``````

The number of combinations grows dramatically when we start looking at racks with 4, 5, 6 and 7 tiles but can we use a clean reusable algorithm that will work in all cases?

I did come up with a solution but it is not very clean as I needed to create 7 separate classes, one for each possible tile count for a given rack.

For example, here is the java class for generating all combinations for a 7 tile rack but I am looking for something that can be expressed more elegantly.

``````import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;

public class TileCombinationSet07 {

private static final int NUM_TILES = 7;
private static final List<TileCombination> TILE_01_COMBOS = new ArrayList<TileCombination>();
private static final List<TileCombination> TILE_02_COMBOS = new ArrayList<TileCombination>();
private static final List<TileCombination> TILE_03_COMBOS = new ArrayList<TileCombination>();
private static final List<TileCombination> TILE_04_COMBOS = new ArrayList<TileCombination>();
private static final List<TileCombination> TILE_05_COMBOS = new ArrayList<TileCombination>();
private static final List<TileCombination> TILE_06_COMBOS = new ArrayList<TileCombination>();
private static final List<TileCombination> TILE_07_COMBOS = new ArrayList<TileCombination>();

static  {
Set<Integer> unique = new LinkedHashSet<Integer>();
Set<String> UNIQUE_TILE_SET_01 = new LinkedHashSet<String>();
Set<String> UNIQUE_TILE_SET_02 = new LinkedHashSet<String>();
Set<String> UNIQUE_TILE_SET_03 = new LinkedHashSet<String>();
Set<String> UNIQUE_TILE_SET_04 = new LinkedHashSet<String>();
Set<String> UNIQUE_TILE_SET_05 = new LinkedHashSet<String>();
Set<String> UNIQUE_TILE_SET_06 = new LinkedHashSet<String>();
Set<String> UNIQUE_TILE_SET_07 = new LinkedHashSet<String>();

for(int one = 0; one < NUM_TILES; one++) {
for(int two = 0; two < NUM_TILES; two++) {
for(int three = 0; three < NUM_TILES; three++) {
for(int four = 0; four < NUM_TILES; four++) {
for(int five = 0; five < NUM_TILES; five++) {
for(int six = 0; six < NUM_TILES; six++) {
for(int seven = 0; seven < NUM_TILES; seven++) {
unique.clear();
unique.add(one);
unique.add(two);
unique.add(three);
unique.add(four);
unique.add(five);
unique.add(six);
unique.add(seven);

String result = "";
for(Integer value : unique) {
result += value;
}

if(unique.size() == 1) {UNIQUE_TILE_SET_01.add(result);}
else if(unique.size() == 2) {UNIQUE_TILE_SET_02.add(result);}
else if(unique.size() == 3) {UNIQUE_TILE_SET_03.add(result);}
else if(unique.size() == 4) {UNIQUE_TILE_SET_04.add(result);}
else if(unique.size() == 5) {UNIQUE_TILE_SET_05.add(result);}
else if(unique.size() == 6) {UNIQUE_TILE_SET_06.add(result);}
else if(unique.size() == 7) {UNIQUE_TILE_SET_07.add(result);}
else {
throw new IllegalStateException("FATAL: Set size is wrong");
}
}
}
}
}
}
}
}

initTileCombinationList(UNIQUE_TILE_SET_01, TILE_01_COMBOS);
initTileCombinationList(UNIQUE_TILE_SET_02, TILE_02_COMBOS);
initTileCombinationList(UNIQUE_TILE_SET_03, TILE_03_COMBOS);
initTileCombinationList(UNIQUE_TILE_SET_04, TILE_04_COMBOS);
initTileCombinationList(UNIQUE_TILE_SET_05, TILE_05_COMBOS);
initTileCombinationList(UNIQUE_TILE_SET_06, TILE_06_COMBOS);
initTileCombinationList(UNIQUE_TILE_SET_07, TILE_07_COMBOS);
}

public static final List<TileCombination> tileCombinations(int tilesToPlay) {
if(tilesToPlay == 1) {return TILE_01_COMBOS;}
if(tilesToPlay == 2) {return TILE_02_COMBOS;}
if(tilesToPlay == 3) {return TILE_03_COMBOS;}
if(tilesToPlay == 4) {return TILE_04_COMBOS;}
if(tilesToPlay == 5) {return TILE_05_COMBOS;}
if(tilesToPlay == 6) {return TILE_06_COMBOS;}
if(tilesToPlay == 7) {return TILE_07_COMBOS;}
throw new IllegalArgumentException("FATAL: tilesToPlay is wrong");
}

private static final void initTileCombinationList(
Set<String> unique,
List<TileCombination> list) {

for(String tokens : unique) {
list.add(new TileCombination(tokens));
}
}
}
``````

A simple pseudocode or suggestion on a more elegant algorithm would be appreciated.
Thanks!

Posted on

## co.combinatorics – Path sequences and isomophy of graphs

Let $$G=(V,E)$$ be a finite, simple, undirected graph. For each $$vin V$$ we define the path sequence $$text{ps}^G_v: omegato omega$$ where $$text{ps}_v(n)$$ is the number of vertices that can be reached from $$v$$ via a path of length at most $$n$$. (So $$text{ps}^G_v(0) = 1$$ for all $$vin V$$.) Of course, these path sequences are eventually constant.

What is an example of pairwise non-isomorphic graphs $$G_i = (V_i, E_i)$$ for $$i in {1,2}$$ such that there is a bijection $$varphi:V_i to V_2$$ and $$text{ps}^{G_1}_v = text{ps}^{G_2}_{varphi(v)}$$ for all $$vin V$$?

Posted on

## Sequences of numbers / percentage change

Anyone have an idea how to convert other numbers in a series like this, but the percentage relation stays the same?

• 15 —> 10
• 9 —-> ?
• 7 —-> ?
• 3 —-> ?
• 2 —-> ?
• 1 —-> 3
Posted on

## nt.number theory – Parametrize non-negative integers by binary sequences

Given $$nin mathbb{Z}_{geq 0}$$ denote by $$B_n$$ the set of binary sequences of length $$n$$. Denote $$B=bigcup_{ngeq 0} B_n$$.

Let $$P, Q:mathbb{Z}_{geq 0}tomathbb{Z}_{geq 0}$$ be two computable functions. We have a map $$f_{P, Q}:Bto mathbb{Z}_{geq 0}$$ given by applying $$P$$ and $$Q$$ to $$0$$ in the order specified by the sequence.

Are there $$P$$ and $$Q$$ such that $$f_{P, Q}$$ is bijective? In particular $$P$$ and $$Q$$ cannot have fixed points.

Posted on

## sequences and series – Evaluate \$(2 + frac{1}{sqrt 2})^5 + (2 – frac{1}{sqrt 2})^5\$

My question says: Without using tables, find the value of

$$(2 + frac{1}{sqrt 2})^5 + (2 – frac{1}{sqrt 2})^5$$

I have said:

$$(2 + frac{1}{sqrt 2}) = 2(1 + frac{1}{2sqrt2})$$

$$(2 + frac{1}{sqrt 2})^5 = 2^5(1 + frac{1}{2sqrt2})^5$$

$$(2 + frac{1}{sqrt 2})^5 = 2^5(1 + frac{5}{2sqrt2} + frac{5.4.}{2!}(frac{1}{2sqrt2})^2 + frac{5.4.3}{3!}(frac{1}{2sqrt2})^3 + frac{5.4.3.2}{4!}(frac{1}{2sqrt2})^4 + frac{5.4.3.2.1}{5!}(frac{1}{2sqrt2})^5)$$

$$(2 – frac{1}{sqrt 2})^5 = 2^5(1 – frac{5}{2sqrt2} + frac{5.4.}{2!}(frac{1}{2sqrt2})^2 – frac{5.4.3}{3!}(frac{1}{2sqrt2})^3 + frac{5.4.3.2}{4!}(frac{1}{2sqrt2})^4 – frac{5.4.3.2.1}{5!}(frac{1}{2sqrt2})^5)$$

$$(2 + frac{1}{sqrt 2})^5 + (2 – frac{1}{sqrt 2})^5 = 32(2 + frac{5}{2} + frac{5}{64}) = 146.5$$

But my text book says the answer is 149.

Have I adopted the wrong approach or have I merely slipped up somewhere? I have checked my working several times.

Posted on

## integer sequences – Convergence of rivers of numbers

$$DeclareMathOperator{river}{river}DeclareMathOperator{leadingsum}{ls}DeclareMathOperator{digitsum}{ds}newcommand{qed}{square}$$
A 1999 British Informatics Olympiad question asks about recursively-defined integer sequences called (digital) rivers. In any sequence, the number following $$n$$ is $$n$$ plus the digit sum of $$n$$ (in base $$10$$). By $$river k$$, we mean the sequence with first term $$k > 0$$. Two rivers meet when they have terms in common. (All formalised below in case you care.)

Let’s consider $$river 173$$ for example. After $$173$$ comes $$173+1+7+3=184$$, after $$184$$ comes $$184+1+8+4=197$$, after $$197$$ comes $$197 + 1 + 9 + 7 = 214$$, and so on.

We find that $$river 91 = (91, 101, 103, dots)$$ meets $$river 100=(100, 101, 103, dots)$$, and that they both meet $$river 173$$.

The question asserts the following without proof (and does not ask candidates for a proof).

Claim: All rivers eventually meet $$river 1$$, $$river 3$$ or $$river 9$$.

We’ll agree to call these three the main rivers. (One may calculate that $$river 173$$, $$river 91$$ and $$river 100$$ all meet $$river 1$$). My attempts to write a proof of the claim have yielded only partial progress (details below). I’ve asked others in my department to no avail and so I’m casting the net wider.

I am grateful for any insight you can shed and any literature references you may think relevant. I am equally content to see this attacked with elementary tools as with sledgehammers. I also include an alternative characterisation of “$$n$$ plus the digit sum of $$n$$“, in case it helps. Many thanks in advance!

For the avoidance of doubt, here are some formal definitions.

Any positive integer $$n$$ has a unique base-$$10$$ representation $$sum_{j=0}^infty 10^j a_j$$, where each $$a_j in {0,1,2, dots, 9}$$. In this representation, the digit sum of $$n$$ is $$digitsum n := sum_{j=0}^infty a_j$$. (The digit sum is not to be confused with what others call the “digital root”.) We define $$f(n) := n + digitsum n$$, and then $$river k := (f^k(n))_{k geq 0}$$.

We say $$river k$$ meets $$river k’$$ if there exist $$J,J’ geq 0$$ with $$f^J(k)=f^{J’}(k’)$$.

The following simple argument shows that $$river 1$$, $$river 3$$ and $$river 9$$ are distinct (and so any river meets at most one of them). Recall that the doubling map $$x mapsto 2x pmod 9$$ on $${0,1,2,dots,9}$$ permutes elements as follows: $$9 mapsto 9$$, $$3 mapsto 6 mapsto 3$$, $$1 mapsto 2 mapsto 4 mapsto 8 mapsto 7 mapsto 5 mapsto 1$$. Observe in particular that $$1$$, $$3$$ and $$9$$ lie on distinct cycles.

Lemma 1. $$k equiv digitsum k pmod 9$$

Proof 1. $$k = sum_{j=0}^infty 10^j a_j equiv sum_{j=0}^infty 1^j a_j =sum_{j = 0}^infty a_j = digitsum k$$. $$qed$$

Lemma 2. $$f(n) equiv 2n pmod 9$$.

Proof 2. For any $$j >0$$, $$f(n) = n + digitsum n equiv n + n = 2 n pmod 9$$ by Lemma 1. $$qed$$

Lemma 3. The rivers $$river 1$$, $$river 3$$, $$river 9$$ are distinct.

Proof 3. Reduce the entries of these rivers modulo $$9$$, and find that they are the periodic sequences $$(1,2,4,8,7,5,1,dots)$$, $$(3,6,3,dots)$$ or $$(9,9,dots)$$, by Lemma 2. None shares any entries with another. $$qed$$

Consequently, $$river k$$ can meet at most one main river, depending on which cycle of the doubling permutation lies the residue of $$k$$ modulo $$9$$.

I’ll end with an alternative characterisation of $$f(n)$$.

First, I need to define the number $$operatorname{tr} n$$ of trailing 9s of $$n$$, which uses the base-$$10$$ representation of $$n$$ as above. Informally, it’s the number of $$9$$s at the end of $$n$$, so that for example $$operatorname{tr} 78 = 0$$, $$operatorname{tr} 79 = 1$$, $$operatorname{tr}99 = 2$$, $$operatorname{tr} 7999 = 3$$. Formally,
$$operatorname{tr}left(sum_{j=0}^infty 10^j a_jright) := max{r geq 0 colon a_j = 9 text{ for all } j in {0,1, dots, r}}text{.}$$
Equivalently,
$$operatorname{tr} n := max{j geq 1 colon n+1 text{ is a multiple of }10^j}text{.}$$

Lemma 4. $$digitsum(n+1)-digitsum n = 1 -9operatorname{tr} n$$

Proof 4. What happens to the digits when we add $$1$$ to $$n$$? The leftmost non-$$9$$ digit is increased by $$1$$, and all the trailing $$9$$s to the right of it are reduced from $$9$$ to $$0$$. Remaining digits are unaffected. The result follows. $$qed$$

Lemma 5. $$f(n+1)-f(n) = 2-9operatorname{tr} (n)$$

Proof 5. Follows trivially from Lemma 4. $$qed$$

Next, define the leading sum of an integer $$n>0$$ to be $$leadingsum n := sum_{j=1}^infty leftlfloor frac{n}{10^j}rightrfloor$$ (beware: indices $$j$$ start at $$1$$, not $$0$$.) Some examples: $$leadingsum 12345 = 1234 + 123 + 12 + 1 = 1370$$ and $$leadingsum 173 = 17 + 3 = 20$$.

Lemma 6. $$sum_{j=1}^{n-1} operatorname{tr}(j) = leadingsum(n)$$

Proof 6. There are $$leftlfloor frac{n}{10}rightrfloor$$ multiples of $$10$$ that are equal to or less than $$n$$ and each contributes $$1$$ to this sum. There are $$leftlfloor frac{n}{100}rightrfloor$$ multiples of $$100$$ that are equal to or less than $$n$$ and each contributes a further $$1$$. Etc. The result follows. $$qed$$

Lemma 7. $$f(n) = 2n – leadingsum n$$

Proof 7. We can form a telescoping sum
$$f(n) – f(1) = sum_{j=1}^{n-1} f(j+1) – f(j) = sum_{j=1}^{n-1} (2-9operatorname{tr}j) = 2(n-1) – 9sum_{j=1}^{n-1}operatorname{tr} j = 2(n-1) -9 leadingsum ntext{.}$$
To this, we simply add $$f(1)=2$$ and we’re done. $$qed$$

Posted on

## sequences and series – Sum of elements of \$A cap(B cup C)=400 times 274\$. Find the closed form of \$C\$.

Question:

$$A={x: x=3$$ digit natural number $$}$$
$$B={x: x=9 k+2 ; k in N}$$
$${C}={{x}: {x}=9 {k}+I ; {k} in {Z}},$$ $$0 leq {I}<9$$
Sum of elements of $$A cap(B cup C)=400 times 274 .$$
Find the value of $$I$$

To be honest, I don’t know how to start without making an assumption.
$$A cap(B cup C)=(A cap B)cup (A cap C)$$
Assuming that $$(A cap B)$$ and $$(A cap C)$$ doesn’t have any element common, one can find the sum of elements of $$(A cap B)$$ and $$(A cap C)$$ which would be equal to $$400 times 274$$.

Sum of elements of $$(A cap B)$$:
$$sum_{k=11}^{110}(9k+2)=54450+200=54650$$

Sum of elements of $$(A cap C)$$:
Elements of $$C$$ are $$cdotscdots90+I,99+I,108+Icdots990+I,999+Icdotscdots$$
Elements of $$A$$ are $$100,101,102cdots 999$$
So possible elements of $$(A cap C)$$ (By keeping $$0 leq {I}<9$$ in mind) must be:$$99+I,108+Icdots990+Itag1label{eq1}$$
So
$$sum_{k=11}^{110}(9k+I)=54450+100I$$
Then after adding and solving $$I=5$$
And by luck $$9k+2$$ and $$9k+5$$ does not have any element common from $$k=11$$ to $$k=110$$.

How can this be solved without making that risky assumption? Any alternate.
Seeing range in $$eqref{eq1}$$ and guessing the elements of $$(A cap C)$$ worked well in this question but there is a single value of $$I$$ so that won’t work every time.