diff --git a/client/src/components/layouts/global.css b/client/src/components/layouts/global.css index 9f81a98d1a..f76c4894d0 100644 --- a/client/src/components/layouts/global.css +++ b/client/src/components/layouts/global.css @@ -348,6 +348,28 @@ hr { background-color: var(--tertiary-background); } +.challenge-instructions table { + display: inline-block; + overflow: auto; +} + +.challenge-instructions table thead { + display: table-header-group; + vertical-align: middle; + border-color: inherit; +} + +.challenge-instructions table th { + font-weight: 700; +} + +.challenge-instructions table th, +.challenge-instructions table td { + padding: 6px 13px; + border: 1px solid var(--secondary-color); + text-align: center; +} + .help-block { color: var(--quaternary-color); } diff --git a/curriculum/challenges/english/08-coding-interview-prep/algorithms/pairwise.english.md b/curriculum/challenges/english/08-coding-interview-prep/algorithms/pairwise.english.md index e05a9bf408..6c8f1e65ac 100644 --- a/curriculum/challenges/english/08-coding-interview-prep/algorithms/pairwise.english.md +++ b/curriculum/challenges/english/08-coding-interview-prep/algorithms/pairwise.english.md @@ -7,12 +7,31 @@ forumTopicId: 301617 ## Description
-Given an array arr, find element pairs whose sum equal the second argument arg and return the sum of their indices. -You may use multiple pairs that have the same numeric elements but different indices. Each pair should use the lowest possible available indices. Once an element has been used it cannot be reused to pair with another element. For instance, pairwise([1, 1, 2], 3) creates a pair [2, 1] using the 1 at index 0 rather than the 1 at index 1, because 0+2 < 1+2. -For example pairwise([7, 9, 11, 13, 15], 20) returns 6. The pairs that sum to 20 are [7, 13] and [9, 11]. We can then write out the array with their indices and values. -
Index01234
Value79111315
+ +Given an array `arr`, find element pairs whose sum equal the second argument `arg` and return the sum of their indices. + +You may use multiple pairs that have the same numeric elements but different indices. Each pair should use the lowest possible available indices. Once an element has been used it cannot be reused to pair with another element. For instance, `pairwise([1, 1, 2], 3)` creates a pair `[2, 1]` using the 1 at index 0 rather than the 1 at index 1, because 0+2 < 1+2. + +For example `pairwise([7, 9, 11, 13, 15], 20)` returns `6`. The pairs that sum to 20 are `[7, 13]` and `[9, 11]`. We can then write out the array with their indices and values. + +
+ + |Index|0|1|2|3|4| + |--- |--- |--- |--- |--- |--- | + |Value|7|9|11|13|15| + +
+ Below we'll take their corresponding indices and add them. -7 + 13 = 20 → Indices 0 + 3 = 3
9 + 11 = 20 → Indices 1 + 2 = 3
3 + 3 = 6 → Return 6 + +
+ + 7 + 13 = 20 → Indices 0 + 3 = 3
+ 9 + 11 = 20 → Indices 1 + 2 = 3
+ 3 + 3 = 6 → Return `6` + +
+
## Instructions diff --git a/curriculum/challenges/english/08-coding-interview-prep/project-euler/problem-54-poker-hands.english.md b/curriculum/challenges/english/08-coding-interview-prep/project-euler/problem-54-poker-hands.english.md index e9dbf4462b..2f47350bf7 100644 --- a/curriculum/challenges/english/08-coding-interview-prep/project-euler/problem-54-poker-hands.english.md +++ b/curriculum/challenges/english/08-coding-interview-prep/project-euler/problem-54-poker-hands.english.md @@ -22,12 +22,13 @@ The cards are valued in the order:2, 3, 4, 5, 6, 7, 8, 9, 10, Jack, Queen, King, If two players have the same ranked hands then the rank made up of the highest value wins; for example, a pair of eights beats a pair of fives (see example 1 below). But if two ranks tie, for example, both players have a pair of queens, then highest cards in each hand are compared (see example 4 below); if the highest cards tie then the next highest cards are compared, and so on. Consider the following five hands dealt to two players: -Hand Player 1 Player 2 Winner -1 5H 5C 6S 7S KDPair of Fives 2C 3S 8S 8D TDPair of Eights Player 2 -2 5D 8C 9S JS ACHighest card Ace 2C 5C 7D 8S QHHighest card Queen Player 1 -3 2D 9C AS AH ACThree Aces 3D 6D 7D TD QDFlush with Diamonds Player 2 -4 4D 6S 9H QH QCPair of QueensHighest card Nine 3D 6D 7H QD QSPair of QueensHighest card Seven Player 1 -5 2H 2D 4C 4D 4SFull HouseWith Three Fours 3C 3D 3S 9S 9DFull Housewith Three Threes Player 1 +|Hand|Player 1|Player 2|Winner| +|--- |--- |--- |--- | +|1|5H 5C 6S 7S KD
Pair of Fives|2C 3S 8S 8D TD
Pair of Eights|Player 2| +|2|5D 8C 9S JS AC
Highest card Ace|2C 5C 7D 8S QH
Highest card Queen|Player 1| +|3|2D 9C AS AH AC
Three Aces|3D 6D 7D TD QD
Flush with Diamonds|Player 2| +|4|4D 6S 9H QH QC
Pair of Queens
Highest card Nine|3D 6D 7H QD QS
Pair of Queens
Highest card Seven|Player 1| +|5|2H 2D 4C 4D 4S
Full House
with Three Fours|3C 3D 3S 9S 9D
Full House
with Three Threes|Player 1| The file, poker.txt, contains one-thousand random hands dealt to two players. Each line of the file contains ten cards (separated by a single space): the first five are Player 1's cards and the last five are Player 2's cards. You can assume that all hands are valid (no invalid characters or repeated cards), each player's hand is in no specific order, and in each hand there is a clear winner. How many hands does Player 1 win? diff --git a/curriculum/challenges/english/08-coding-interview-prep/project-euler/problem-61-cyclical-figurate-numbers.english.md b/curriculum/challenges/english/08-coding-interview-prep/project-euler/problem-61-cyclical-figurate-numbers.english.md index b1dacd98e5..600f1b4cfa 100644 --- a/curriculum/challenges/english/08-coding-interview-prep/project-euler/problem-61-cyclical-figurate-numbers.english.md +++ b/curriculum/challenges/english/08-coding-interview-prep/project-euler/problem-61-cyclical-figurate-numbers.english.md @@ -8,36 +8,16 @@ forumTopicId: 302173 ## Description
Triangle, square, pentagonal, hexagonal, heptagonal, and octagonal numbers are all figurate (polygonal) numbers and are generated by the following formulae: -Triangle -P3,n=n(n+1)/2 +|Type of Number|Formula|Sequence| +|--- |--- |--- | +|Triangle|P3,n=n(n+1)/2|1, 3, 6, 10, 15, ...| +|Square|P4,n=n2|1, 4, 9, 16, 25, ...| +|Pentagonal|P5,n=n(3n−1)/2|1, 5, 12, 22, 35, ...| +|Hexagonal|P6,n=n(2n−1)|1, 6, 15, 28, 45, ...| +|Heptagonal|P7,n=n(5n−3)/2|1, 7, 18, 34, 55, ...| +|Octagonal|P8,n=n(3n−2)|1, 8, 21, 40, 65, ...| -1, 3, 6, 10, 15, ... -Square - -P4,n=n2 - -1, 4, 9, 16, 25, ... -Pentagonal - -P5,n=n(3n−1)/2 - -1, 5, 12, 22, 35, ... -Hexagonal - -P6,n=n(2n−1) - -1, 6, 15, 28, 45, ... -Heptagonal - -P7,n=n(5n−3)/2 - -1, 7, 18, 34, 55, ... -Octagonal - -P8,n=n(3n−2) - -1, 8, 21, 40, 65, ... The ordered set of three 4-digit numbers: 8128, 2882, 8281, has three interesting properties. The set is cyclic, in that the last two digits of each number is the first two digits of the next number (including the last number with the first). Each polygonal type: triangle (P3,127=8128), square (P4,91=8281), and pentagonal (P5,44=2882), is represented by a different number in the set. diff --git a/curriculum/challenges/english/08-coding-interview-prep/project-euler/problem-68-magic-5-gon-ring.english.md b/curriculum/challenges/english/08-coding-interview-prep/project-euler/problem-68-magic-5-gon-ring.english.md index 091cc39777..2d533dbcd7 100644 --- a/curriculum/challenges/english/08-coding-interview-prep/project-euler/problem-68-magic-5-gon-ring.english.md +++ b/curriculum/challenges/english/08-coding-interview-prep/project-euler/problem-68-magic-5-gon-ring.english.md @@ -13,15 +13,20 @@ Consider the following "magic" 3-gon ring, filled with the numbers 1 to 6, and e Working clockwise, and starting from the group of three with the numerically lowest external node (4,3,2 in this example), each solution can be described uniquely. For example, the above solution can be described by the set: 4,3,2; 6,2,1; 5,1,3. It is possible to complete the ring with four different totals: 9, 10, 11, and 12. There are eight solutions in total. -TotalSolution Set -94,2,3; 5,3,1; 6,1,2 -94,3,2; 6,2,1; 5,1,3 -102,3,5; 4,5,1; 6,1,3 -102,5,3; 6,3,1; 4,1,5 -111,4,6; 3,6,2; 5,2,4 -111,6,4; 5,4,2; 3,2,6 -121,5,6; 2,6,4; 3,4,5 -121,6,5; 3,5,4; 2,4,6 +
+ + |
Total
|
Solution Set
| + |--- |--- | + |9|4,2,3; 5,3,1; 6,1,2| + |9|4,3,2; 6,2,1; 5,1,3| + |10|2,3,5; 4,5,1; 6,1,3| + |10|2,5,3; 6,3,1; 4,1,5| + |11|1,4,6; 3,6,2; 5,2,4| + |11|1,6,4; 5,4,2; 3,2,6| + |12|1,5,6; 2,6,4; 3,4,5| + |12|1,6,5; 3,5,4; 2,4,6| + +
By concatenating each group it is possible to form 9-digit strings; the maximum string for a 3-gon ring is 432621513. Using the numbers 1 to 10, and depending on arrangements, it is possible to form 16- and 17-digit strings. What is the maximum 16-digit string for a "magic" 5-gon ring? diff --git a/curriculum/challenges/english/08-coding-interview-prep/project-euler/problem-69-totient-maximum.english.md b/curriculum/challenges/english/08-coding-interview-prep/project-euler/problem-69-totient-maximum.english.md index ffc80cf8eb..e5dd069ad9 100644 --- a/curriculum/challenges/english/08-coding-interview-prep/project-euler/problem-69-totient-maximum.english.md +++ b/curriculum/challenges/english/08-coding-interview-prep/project-euler/problem-69-totient-maximum.english.md @@ -7,51 +7,29 @@ forumTopicId: 302181 ## Description
-Euler's Totient function, φ(n) [sometimes called the phi function], is used to determine the number of numbers less than n which are relatively prime to n. For example, as 1, 2, 4, 5, 7, and 8, are all less than nine and relatively prime to nine, φ(9)=6. -n -Relatively Prime -φ(n) -n/φ(n) -2 -1 -1 -2 -3 -1,2 -2 -1.5 -4 -1,3 -2 -2 -5 -1,2,3,4 -4 -1.25 -6 -1,5 -2 -3 -7 -1,2,3,4,5,6 -6 -1.1666... -8 -1,3,5,7 -4 -2 -9 -1,2,4,5,7,8 -6 -1.5 -10 -1,3,7,9 -4 -2.5 +Euler's Totient function, φ(n) [sometimes called the phi function], is used to determine the number of numbers less than n which are relatively prime to n. For example, as 1, 2, 4, 5, 7, and 8, are all less than nine and relatively prime to nine, φ(9)=6. + +
+ + |n|Relatively Prime|φ(n)|n/φ(n)| + |--- |--- |--- |--- | + |2|1|1|2| + |3|1,2|2|1.5| + |4|1,3|2|2| + |5|1,2,3,4|4|1.25| + |6|1,5|2|3| + |7|1,2,3,4,5,6|6|1.1666...| + |8|1,3,5,7|4|2| + |9|1,2,4,5,7,8|6|1.5| + |10|1,3,7,9|4|2.5| + +
+ +It can be seen that n=6 produces a maximum n/φ(n) for n ≤ 10. + +Find the value of n ≤ 1,000,000 for which n/φ(n) is a maximum. -It can be seen that n=6 produces a maximum n/φ(n) for n ≤ 10. -Find the value of n ≤ 1,000,000 for which n/φ(n) is a maximum.
## Instructions diff --git a/curriculum/challenges/english/08-coding-interview-prep/project-euler/problem-78-coin-partitions.english.md b/curriculum/challenges/english/08-coding-interview-prep/project-euler/problem-78-coin-partitions.english.md index 657e51614c..b11e43800b 100644 --- a/curriculum/challenges/english/08-coding-interview-prep/project-euler/problem-78-coin-partitions.english.md +++ b/curriculum/challenges/english/08-coding-interview-prep/project-euler/problem-78-coin-partitions.english.md @@ -9,13 +9,21 @@ forumTopicId: 302191
Let p(n) represent the number of different ways in which n coins can be separated into piles. For example, five coins can be separated into piles in exactly seven different ways, so p(5)=7. -OOOOO -OOOO   O -OOO   OO -OOO   O   O -OO   OO   O -OO   O   O   O -O   O   O   O   O +
+ + |Coin piles| + |--- | + |OOOOO| + |OOOO   O| + |OOO   OO| + |OOO   O   O| + |OO   OO   O| + |OO   O   O   O| + |O   O   O   O   O| + +
+ +Find the least value of n for which p(n) is divisible by one million. Find the least value of n for which p(n) is divisible by one million.
diff --git a/curriculum/challenges/english/08-coding-interview-prep/project-euler/problem-84-monopoly-odds.english.md b/curriculum/challenges/english/08-coding-interview-prep/project-euler/problem-84-monopoly-odds.english.md index 34077c3f8e..db0ce673a9 100644 --- a/curriculum/challenges/english/08-coding-interview-prep/project-euler/problem-84-monopoly-odds.english.md +++ b/curriculum/challenges/english/08-coding-interview-prep/project-euler/problem-84-monopoly-odds.english.md @@ -9,55 +9,83 @@ forumTopicId: 302198
In the game, Monopoly, the standard board is set up in the following way: -GO -A1 -CC1 -A2 -T1 -R1 -B1 -CH1 -B2 -B3 -JAIL -H2 - -C1 -T2 - -U1 -H1 - -C2 -CH3 - -C3 -R4 - -R2 -G3 - -D1 -CC3 - -CC2 -G2 - -D2 -G1 - -D3 -G2J -F3 -U2 -F2 -F1 -R3 -E3 -E2 -CH2 -E1 -FP +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
GOA1CC1A2T1R1B1CH1B2B3JAIL
H2 C1
T2 U1
H1 C2
CH3 C3
R4 R2
G3 D1
CC3 CC2
G2 D2
G1 D3
G2JF3U2F2F1R3E3E2CH2E1FP
+
A player starts on the GO square and adds the scores on two 6-sided dice to determine the number of squares they advance in a clockwise direction. Without any further rules we would expect to visit each square with equal probability: 2.5%. However, landing on G2J (Go To Jail), CC (community chest), and CH (chance) changes this distribution. In addition to G2J, and one card from each of CC and CH, that orders the player to go directly to jail, if a player rolls three consecutive doubles, they do not advance the result of their 3rd roll. Instead they proceed directly to jail. diff --git a/curriculum/challenges/english/08-coding-interview-prep/project-euler/problem-96-su-doku.english.md b/curriculum/challenges/english/08-coding-interview-prep/project-euler/problem-96-su-doku.english.md index 75176f4587..cdd6ea3fbd 100644 --- a/curriculum/challenges/english/08-coding-interview-prep/project-euler/problem-96-su-doku.english.md +++ b/curriculum/challenges/english/08-coding-interview-prep/project-euler/problem-96-su-doku.english.md @@ -10,28 +10,95 @@ forumTopicId: 302213 Su Doku (Japanese meaning number place) is the name given to a popular puzzle concept. Its origin is unclear, but credit must be attributed to Leonhard Euler who invented a similar, and much more difficult, puzzle idea called Latin Squares. The objective of Su Doku puzzles, however, is to replace the blanks (or zeros) in a 9 by 9 grid in such that each row, column, and 3 by 3 box contains each of the digits 1 to 9. Below is an example of a typical starting puzzle grid and its solution grid. -0 0 39 0 00 0 1 -0 2 03 0 58 0 6 -6 0 00 0 14 0 0 -0 0 87 0 00 0 6 -1 0 20 0 07 0 8 -9 0 00 0 82 0 0 -0 0 28 0 00 0 5 -6 0 92 0 30 1 0 -5 0 00 0 93 0 0 - - - -4 8 39 6 72 5 1 -9 2 13 4 58 7 6 -6 5 78 2 14 9 3 -5 4 87 2 91 3 6 -1 3 25 6 47 9 8 -9 7 61 3 82 4 5 -3 7 28 1 46 9 5 -6 8 92 5 34 1 7 -5 1 47 6 93 8 2 - +
+ + + + + + + + +
+ + + + + + + + + + + + + + + + + + +
+ 0 0 3
9 0 0
0 0 1 +
+ 0 2 0
3 0 5
8 0 6 +
+ 6 0 0
0 0 1
4 0 0 +
+ 0 0 8
7 0 0
0 0 6 +
+ 1 0 2
0 0 0
7 0 8 +
+ 9 0 0
0 0 8
2 0 0 +
+ 0 0 2
8 0 0
0 0 5 +
+ 6 0 9
2 0 3
0 1 0 +
+ 5 0 0
0 0 9
3 0 0 +
+
+
+
+ + + + + + + + + + + + + + + + + + +
+ 4 8 3
9 6 7
2 5 1 +
+ 9 2 1
3 4 5
8 7 6 +
+ 6 5 7
8 2 1
4 9 3 +
+ 5 4 8
7 2 9
1 3 6 +
+ 1 3 2
5 6 4
7 9 8 +
+ 9 7 6
1 3 8
2 4 5 +
+ 3 7 2
8 1 4
6 9 5 +
+ 6 8 9
2 5 3
4 1 7 +
+ 5 1 4
7 6 9
3 8 2 +
+
+
A well constructed Su Doku puzzle has a unique solution and can be solved by logic, although it may be necessary to employ "guess and test" methods in order to eliminate options (there is much contested opinion over this). The complexity of the search determines the difficulty of the puzzle; the example above is considered easy because it can be solved by straight forward direct deduction. The 6K text file, sudoku.txt (right click and 'Save Link/Target As...'), contains fifty different Su Doku puzzles ranging in difficulty, but all with unique solutions (the first puzzle in the file is the example above). diff --git a/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/hash-join.english.md b/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/hash-join.english.md index 0d3a6a5490..6ff8e3a57c 100644 --- a/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/hash-join.english.md +++ b/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/hash-join.english.md @@ -36,136 +36,109 @@ In pseudo-code, the algorithm could be expressed as follows: ## Instructions
+ Implement the "hash join" algorithm as a function and demonstrate that it passes the test-case listed below. The function should accept two arrays of objects and return an array of combined objects. +

Input

+ - - -
- - - - - - - - - - - -
A = - - - - - - - - - - - - - - - - - - - -
Age Name -
27 Jonah -
18 Alan -
28 Glory -
18 Popeye -
28 Alan -
-
- B = - - - - - - - - - - - - - - - - - - - -
Character Nemesis -
Jonah Whales -
Jonah Spiders -
Alan Ghosts -
Alan Zombies -
Glory Buffy -
-
jA = - Name (i.e. column 1) - jB = - Character (i.e. column 0) -
-
-
+ + + + + + + + + + + + + + + + +
A = + + + + + + + + + + + + + + + + + + + + + + + + + +
AgeName
27Jonah
18Alan
28Glory
18Popeye
28Alan
+
B = + + + + + + + + + + + + + + + + + + + + + + + + + +
CharacterNemesis
JonahWhales
JonahSpiders
AlanGhosts
AlanZombies
GloryBuffy
+
+ jA = + + Name (i.e. column 1) + + jB = + + Character (i.e. column 0) +
+ + + +

Output

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
A_age A_name B_character B_nemesis -
27 Jonah Jonah Whales -
27 Jonah Jonah Spiders -
18 Alan Alan Ghosts -
18 Alan Alan Zombies -
28 Glory Glory Buffy -
28 Alan Alan Ghosts -
28 Alan Alan Zombies -
+ +|A_age|A_name|B_character|B_nemesis| +|--- |--- |--- |--- | +|27|Jonah|Jonah|Whales| +|27|Jonah|Jonah|Spiders| +|18|Alan|Alan|Ghosts| +|18|Alan|Alan|Zombies| +|28|Glory|Glory|Buffy| +|28|Alan|Alan|Ghosts| +|28|Alan|Alan|Zombies| + The order of the rows in the output table is not significant. +
## Tests