From d024b96a921c9bae3028d274e5bc6a339844fed8 Mon Sep 17 00:00:00 2001
From: Kris Koishigawa Compute the Root mean square of the numbers 1 through 10 inclusive. The root mean square is also known by its initials RMS (or rms), and as the quadratic mean. The RMS is calculated as the mean of the squares of the numbers, square-rooted: $$x_{\mathrm{rms}} = \sqrt {{{x_1}^2 + {x_2}^2 + \cdots + {x_n}^2} \over n}. $$ Charles Babbage, looking ahead to the sorts of problems his Analytical Engine would be able to solve, gave this example: - Babbage, letter to Lord Bowden, 1837; see Hollingdale and Tootill, Electronic Computers, second edition, 1970, p. 125. He thought the answer might be 99,736, whose square is 9,947,269,696; but he couldn't be certain. The task is to find out if Babbage had the right answer. Implement a function to return the lowest integer that satisfies the Babbage problem. If Babbage was right, return Babbage's number. Determine whether a generated string of brackets is balanced; that is, whether it consists entirely of pairs of opening/closing brackets (in that order), none of which mis-nest. (empty) true Given two points on a plane and a radius, usually two circles of given radius can be drawn through the points. Provide a function to find the closest two points among a set of given points in two dimensions, i.e. to solve the Closest pair of points problem in the planar case. The straightforward solution is a O(n2) algorithm (which we can call brute-force algorithm); the pseudo-code (using indexes) could be simply: A better algorithm is based on the recursive divide&conquer approach, as explained also at Wikipedia's Closest pair of points problem, which is O(n log n); a pseudo-code could be: For the input, expect the argument to be an array of objects (points) with Given non-negative integers m and n, generate all size m combinations of the integers from 0 (zero) to n-1 in sorted order (each combination is sorted and the entire table is sorted). 3 comb 5 is: Comma quibbling is a task originally set by Eric Lippert in his blog. Write a function to generate a string output which is the concatenation of input words from a list/sequence where: Test your function with the following series of inputs showing your output here on this page: Note: Assume words are non-empty strings of uppercase characters for this task. Given a list of arbitrarily many strings, implement a function for each of the following conditions: Implement a function which: Demonstrate that it passes the following three test-cases: Test Cases Details
-
Assume the input is an ordered array of all inclusive numbers.
For the answer, please output an object in the following format:
diff --git a/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/averages-root-mean-square.english.md b/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/averages-root-mean-square.english.md
index e94826d9200..e2d0099a2cd 100644
--- a/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/averages-root-mean-square.english.md
+++ b/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/averages-root-mean-square.english.md
@@ -6,9 +6,10 @@ challengeType: 5
## Description
-$ A(x_1, \ldots, x_n) = \frac{x_1 + \cdots + x_n}{n}$
-$ G(x_1, \ldots, x_n) = \sqrt[n]{x_1 \cdots x_n} $
-$ H(x_1, \ldots, x_n) = \frac{n}{\frac{1}{x_1} + \cdots + \frac{1}{x_n}} $
+ $ A(x_1, \ldots, x_n) = \frac{x_1 + \cdots + x_n}{n}$
+ $ G(x_1, \ldots, x_n) = \sqrt[n]{x_1 \cdots x_n} $
+ $ H(x_1, \ldots, x_n) = \frac{n}{\frac{1}{x_1} + \cdots + \frac{1}{x_n}} $What is the smallest positive integer whose square ends in the digits 269,696?
-
+ What is the smallest positive integer whose square ends in the digits 269,696?
+
+
+He thought the answer might be 99,736, whose square is 9,947,269,696; but he couldn't be certain.
+The task is to find out if Babbage had the right answer.
+Implement a function to return the lowest integer that satisfies the Babbage problem. If Babbage was right, return Babbage's number.
[] true][ false[][] true][][ false[]][[] false[[[[]]]] true
+(empty) true
+
[] true
+][ false
+[][] true
+][][ false
+[]][[] false
+[[[[]]]] true
+
+
+Task:
Implement a function that takes two points and a radius and returns the two circles through those points. For each resulting circle, provide the coordinates for the center of each circle rounded to four decimal digits. Return each coordinate as an array, and coordinates as an array of arrays.
-For edge cases, return the following:
-If points are on the diameter, return one point. If the radius is also zero however, return "Radius Zero".
-If points are coincident, return "Coincident point. Infinite solutions".
-If points are farther apart than the diameter, return "No intersection. Points further apart than circle diameter".
-Sample inputs:
+For edge cases, return the following:
+
+
+Sample inputs:
"Radius Zero"."Coincident point. Infinite solutions"."No intersection. Points further apart than circle diameter".
p1 p2 r
0.1234, 0.9876 0.8765, 0.2345 2.0
@@ -26,7 +31,7 @@ Sample inputs:
0.1234, 0.9876 0.8765, 0.2345 0.5
0.1234, 0.9876 0.1234, 0.9876 0.0
-Ref:
+Ref:
Finding the Center of a Circle from 2 Points and Radius from Math forum @ Drexel
-bruteForceClosestPair of P(1), P(2), ... P(N)
-if N < 2 then
- return ∞
-else
+bruteForceClosestPair of P(1), P(2), ... P(N)
+if N < 2 then
+ return ∞
+else
minDistance ← |P(1) - P(2)|
minPoints ← { P(1), P(2) }
- foreach i ∈ [1, N-1]
- foreach j ∈ [i+1, N]
- if |P(i) - P(j)| < minDistance then
+ foreach i ∈ [1, N-1]
+ foreach j ∈ [i+1, N]
+ if |P(i) - P(j)| < minDistance then
minDistance ← |P(i) - P(j)|
minPoints ← { P(i), P(j) }
- endif
- endfor
- endfor
- return minDistance, minPoints
-endif
+ endif
+ endfor
+ endfor
+ return minDistance, minPoints
+endif
-
-closestPair of (xP, yP)
+closestPair of (xP, yP)
where xP is P(1) .. P(N) sorted by x coordinate, and
yP is P(1) .. P(N) sorted by y coordinate (ascending order)
-if N ≤ 3 then
- return closest points of xP using brute-force algorithm
-else
+if N ≤ 3 then
+ return closest points of xP using brute-force algorithm
+else
xL ← points of xP from 1 to ⌈N/2⌉
xR ← points of xP from ⌈N/2⌉+1 to N
xm ← xP(⌈N/2⌉)x
@@ -42,31 +42,33 @@ else
(dL, pairL) ← closestPair of (xL, yL)
(dR, pairR) ← closestPair of (xR, yR)
(dmin, pairMin) ← (dR, pairR)
- if dL < dR then
+ if dL < dR then
(dmin, pairMin) ← (dL, pairL)
- endif
+ endif
yS ← { p ∈ yP : |xm - px| < dmin }
nS ← number of points in yS
(closest, closestPair) ← (dmin, pairMin)
- for i from 1 to nS - 1
+ for i from 1 to nS - 1
k ← i + 1
- while k ≤ nS and yS(k)y - yS(i)y < dmin
- if |yS(k) - yS(i)| < closest then
+ while k ≤ nS and yS(k)y - yS(i)y < dmin
+ if |yS(k) - yS(i)| < closest then
(closest, closestPair) ← (|yS(k) - yS(i)|, {yS(k), yS(i)})
- endif
+ endif
k ← k + 1
- endwhile
- endfor
- return closest, closestPair
-endif
+ endwhile
+ endfor
+ return closest, closestPair
+endif
-References and further readings:
- Closest pair of points problem
- Closest Pair (McGill)
- Closest Pair (UCSB)
- Closest pair (WUStL)
- Closest pair (IUPUI)
-x and y members set to numbers. For the output, return an object containing the key:value pairs for distance and pair (i.e., the pair of two closest points).x and y members set to numbers. For the output, return an object containing the key:value pairs for distance and pair (the pair of two closest points).
+References and further readings:
+
0 1 2
0 1 3
diff --git a/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/comma-quibbling.english.md b/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/comma-quibbling.english.md
index 294dd5474c5..48effb85735 100644
--- a/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/comma-quibbling.english.md
+++ b/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/comma-quibbling.english.md
@@ -6,18 +6,22 @@ challengeType: 5
## Description
+
+Test your function with the following series of inputs showing your output here on this page:
+
+
+Note: Assume words are non-empty strings of uppercase characters for this task.
+
100), and
-returns a string which shows the same duration decomposed into weeks, days, hours, minutes, and seconds as detailed below (e.g., 1 min, 40 sec).
-
+
+Demonstrate that it passes the following three test-cases:
+100), and1 min, 40 sec).
-
-
-
-
-input number
-output number
-
-
-7259
-
-2 hr, 59 sec
-
-86400
-
-1 d
-
-
+
+ 6000000
-
-9 wk, 6 d, 10 hr, 40 min
+
+ input number
+ output number
+
+
+ 7259
+
+ 2 hr, 59 sec
+
+ 86400
+
+ 1 d
+
+
6000000
+
+ 9 wk, 6 d, 10 hr, 40 min
-
-
-However, only include quantities with non-zero values in the output (e.g., return
-
-unit
-suffix used in output
-conversion
-
-
-week
-
-wk1 week = 7 days
-
-
-day
-
-d1 day = 24 hours
-
-
-hour
-
-hr1 hour = 60 minutes
-
-
-minute
-
-min1 minute = 60 seconds
-
-
-
-second
-
-sec
- 1 d and not 0 wk, 1 d, 0 hr, 0 min, 0 sec).Give larger units precedence over smaller ones as much as possible (e.g., return 2 min, 10 sec and not 1 min, 70 sec or 130 sec)Mimic the formatting shown in the test-cases (quantities sorted from largest unit to smallest and separated by comma+space; value and unit of each quantity separated by space).
-
| unit | +suffix used in output | +conversion | +
|---|---|---|
| week | +wk |
+ 1 week = 7 days | +
| day | +d |
+ 1 day = 24 hours | +
| hour | +hr |
+ 1 hour = 60 minutes | +
| minute | +min |
+ 1 minute = 60 seconds | +
| second | +sec |
+ + |
1 d and not 0 wk, 1 d, 0 hr, 0 min, 0 sec).
+ 2 min, 10 sec and not 1 min, 70 sec or 130 sec).
+ Create a function, or show a built-in function, to count the number of non-overlapping occurrences of a substring inside a string.
The function should take two arguments:
-the first argument being the string to search, and -the second a substring to be searched for. -It should return an integer count.
-The matching should yield the highest number of non-overlapping matches.
In general, this essentially means matching from left-to-right or right-to-left.
+Create a function, or show a built-in function, to count the number of non-overlapping occurrences of a substring inside a string. +The function should take two arguments: +There are four types of common coins in US currency:
-quarters (25 cents) -dimes (10 cents) -nickels (5 cents), and -pennies (1 cent) +There are four types of common coins in US currency: +There are six ways to make change for 15 cents:
-A dime and a nickel -A dime and 5 pennies -3 nickels -2 nickels and 5 pennies -A nickel and 10 pennies -15 pennies -Task: -Implement a function to determine how many ways there are to make change for a dollar using these common coins? (1 dollar = 100 cents).
-Reference: - an algorithm from MIT Press. +In linear algebra, Cramer's rule is an explicit formula for the solution of a system of linear equations with as many equations as unknowns, valid whenever the system has a unique solution. It expresses the solution in terms of the determinants of the (square) coefficient matrix and of matrices obtained from it by replacing one column by the vector of right hand sides of the equations.
-Given
- -$\left\{\begin{matrix}a_1x + b_1y + c_1z&= {\color{red}d_1}\\a_2x + b_2y + c_2z&= {\color{red}d_2}\\a_3x + b_3y + c_3z&= {\color{red}d_3}\end{matrix}\right.$
-which in matrix format is
-$\begin{bmatrix} a_1 & b_1 & c_1 \\ a_2 & b_2 & c_2 \\ a_3 & b_3 & c_3 \end{bmatrix}\begin{bmatrix} x \\ y \\ z \end{bmatrix}=\begin{bmatrix} {\color{red}d_1} \\ {\color{red}d_2} \\ {\color{red}d_3} \end{bmatrix}.$
-Then the values of $x, y$ and $z$ can be found as follows:
-$x = \frac{\begin{vmatrix} {\color{red}d_1} & b_1 & c_1 \\ {\color{red}d_2} & b_2 & c_2 \\ {\color{red}d_3} & b_3 & c_3 \end{vmatrix} } { \begin{vmatrix} a_1 & b_1 & c_1 \\ a_2 & b_2 & c_2 \\ a_3 & b_3 & c_3 \end{vmatrix}}, \quad y = \frac {\begin{vmatrix} a_1 & {\color{red}d_1} & c_1 \\ a_2 & {\color{red}d_2} & c_2 \\ a_3 & {\color{red}d_3} & c_3 \end{vmatrix}} {\begin{vmatrix} a_1 & b_1 & c_1 \\ a_2 & b_2 & c_2 \\ a_3 & b_3 & c_3 \end{vmatrix}}, \text{ and }z = \frac { \begin{vmatrix} a_1 & b_1 & {\color{red}d_1} \\ a_2 & b_2 & {\color{red}d_2} \\ a_3 & b_3 & {\color{red}d_3} \end{vmatrix}} {\begin{vmatrix} a_1 & b_1 & c_1 \\ a_2 & b_2 & c_2 \\ a_3 & b_3 & c_3 \end{vmatrix} }.$
+In linear algebra, Cramer's rule is an explicit formula for the solution of a system of linear equations with as many equations as unknowns, valid whenever the system has a unique solution. It expresses the solution in terms of the determinants of the (square) coefficient matrix and of matrices obtained from it by replacing one column by the vector of right hand sides of the equations. +Given + + $\left\{\begin{matrix}a_1x + b_1y + c_1z&= {\color{red}d_1}\\a_2x + b_2y + c_2z&= {\color{red}d_2}\\a_3x + b_3y + c_3z&= {\color{red}d_3}\end{matrix}\right.$ -Task -Given the following system of equations:
-$\begin{cases} -2w-x+5y+z=-3 \\ -3w+2x+2y-6z=-32 \\ -w+3x+3y-z=-47 \\ -5w-2x-3y+3z=49 \\ -\end{cases}$ -
-solve for $w$, $x$, $y$ and $z$, using Cramer's rule.
+which in matrix format is + + $\begin{bmatrix} a_1 & b_1 & c_1 \\ a_2 & b_2 & c_2 \\ a_3 & b_3 & c_3 \end{bmatrix}\begin{bmatrix} x \\ y \\ z \end{bmatrix}=\begin{bmatrix} {\color{red}d_1} \\ {\color{red}d_2} \\ {\color{red}d_3} \end{bmatrix}.$ + +Then the values of $x, y$ and $z$ can be found as follows: + + $x = \frac{\begin{vmatrix} {\color{red}d_1} & b_1 & c_1 \\ {\color{red}d_2} & b_2 & c_2 \\ {\color{red}d_3} & b_3 & c_3 \end{vmatrix} } { \begin{vmatrix} a_1 & b_1 & c_1 \\ a_2 & b_2 & c_2 \\ a_3 & b_3 & c_3 \end{vmatrix}}, \quad y = \frac {\begin{vmatrix} a_1 & {\color{red}d_1} & c_1 \\ a_2 & {\color{red}d_2} & c_2 \\ a_3 & {\color{red}d_3} & c_3 \end{vmatrix}} {\begin{vmatrix} a_1 & b_1 & c_1 \\ a_2 & b_2 & c_2 \\ a_3 & b_3 & c_3 \end{vmatrix}}, \text{ and }z = \frac { \begin{vmatrix} a_1 & b_1 & {\color{red}d_1} \\ a_2 & b_2 & {\color{red}d_2} \\ a_3 & b_3 & {\color{red}d_3} \end{vmatrix}} {\begin{vmatrix} a_1 & b_1 & c_1 \\ a_2 & b_2 & c_2 \\ a_3 & b_3 & c_3 \end{vmatrix} }.$ + +Task +Given the following system of equations: + + $\begin{cases} + 2w-x+5y+z=-3 \\ + 3w+2x+2y-6z=-32 \\ + w+3x+3y-z=-47 \\ + 5w-2x-3y+3z=49 \\ + \end{cases}$ + +solve for $w$, $x$, $y$ and $z$, using Cramer's rule.