Skip to content

Commit ad201ed

Browse files
committed
Chapter 9.1 - Grammarly + Upper Letter Titles
1 parent 1cfbac3 commit ad201ed

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

chapter-09-problems-for-champions.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ We have two sequences:
1313
- **a sequence of Tribonacci** (by analogy with the Fibonacci sequence), where each number is **the sum of the previous three** (with given three numbers)
1414
- a sequence generated by a **numerical spiral** defined by looping like a spiral (right, bottom, left, top, right, bottom, left, top, etc.) of a matrix of numbers starting from its center with a given starting number and incremental step, by storing the current numbers in the sequence each time we make a turn
1515

16-
Write a program that finds the first number that appears **in both sequences defined as describe above**.
16+
Write a program that finds the first number that appears **in both sequences defined as described above**.
1717

1818
### Problem
1919

@@ -70,13 +70,13 @@ Once we have the input data, we need to think about how we will generate the num
7070

7171
#### Generating Tribonacci Sequence
7272

73-
For the Tribonacci sequence, we will always **summing up the previous three values** and then move the values of those numbers (the three previous ones) to one position in the sequence, i.e., the value of the first one must accept the value of the second one, and so on. When we are ready with the number, we will store its value in **an array**. Since the problem description states that the numbers in the sequences do not exceed 1,000,000, we can stop generating this range at 1,000,000.
73+
For the Tribonacci sequence, we will always **sum up the previous three values** and then move the values of those numbers (the three previous ones) to one position in the sequence, i.e., the value of the first one must accept the value of the second one, and so on. When we are ready with the number, we will store its value in **an array**. Since the problem description states that the numbers in the sequences do not exceed 1,000,000, we can stop generating this range at 1,000,000.
7474

7575
![](assets/chapter-9-1-images/01.Crossing-sequences-03.png)
7676

7777
#### Generating Numerical Spiral
7878

79-
We need to think of **a relation** between numbers in the numerical spiral so we can easily generate every next number without having to look at matrices and loop through them. If we carefully look at the picture from the description, we will notice that **every 2 "turns" in the spiral, the numbers we skip are increased by 1**, i.e. from *5 to 7* and from *7 to 9*, not a single number is skipped, but we directly **add with the step** of the sequence. From *9 to 13* and from *13 to 17* we skip a number, i.e. we add the step twice. From *17 to 23* and from *23 to 29* we skip two numbers, i.e. we add the step three times and so on.
79+
We need to think of **a relationship** between numbers in the numerical spiral so we can easily generate every next number without having to look at matrices and loop through them. If we carefully look at the picture from the description, we will notice that **every 2 "turns" in the spiral, the numbers we skip are increased by 1**, i.e. from *5 to 7* and from *7 to 9*, not a single number is skipped, but we directly **add with the step** of the sequence. From *9 to 13* and from *13 to 17* we skip a number, i.e. we add the step twice. From *17 to 23* and from *23 to 29* we skip two numbers, i.e. we add the step three times and so on.
8080

8181
Thus, we see that for the first two we have **`the last number + 1 * the step`**, the next two we add with the **`2 * the step`**, and so on.
8282
Every time we want to get to the next number of the spiral, we will have to make such calculations.

0 commit comments

Comments
 (0)