fix(curriculum): format challenge markdown as per linting rules (#36326)
* fix: Format challenge markdown according to linting rules * fix: Put spaces after section tags
This commit is contained in:
committed by
mrugesh
parent
c387873640
commit
7d4dc382b4
@ -6,11 +6,13 @@ challengeType: 5
|
||||
|
||||
## Description
|
||||
<section id='description'>
|
||||
|
||||
Given a text file of many lines, where fields within a line are delineated by a single <code>$</code> character, write a program that aligns each column of fields by ensuring that words in each column are separated by at least one space. Further, allow for each word in a column to be either left justified, right justified, or center justified within its column.
|
||||
</section>
|
||||
|
||||
## Instructions
|
||||
<section id='instructions'>
|
||||
|
||||
Use the following text to test your programs:
|
||||
<pre>
|
||||
Given$a$text$file$of$many$lines
|
||||
@ -130,6 +132,7 @@ const centerAligned = ' Given a text file of many
|
||||
'justified, right justified\n' +
|
||||
' or center justified within its column. ';
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
@ -6,6 +6,7 @@ challengeType: 5
|
||||
|
||||
## Description
|
||||
<section id='description'>
|
||||
|
||||
Write a function that takes an array of numbers as parameter and returns the <a href="https://en.wikipedia.org/wiki/Standard Deviation">standard deviation</a> of the series.
|
||||
</section>
|
||||
|
||||
@ -39,6 +40,7 @@ tests:
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
@ -68,4 +70,4 @@ function standardDeviation(arr) {
|
||||
}
|
||||
```
|
||||
|
||||
</section>
|
||||
</section>
|
||||
|
@ -6,6 +6,7 @@ challengeType: 5
|
||||
|
||||
## Description
|
||||
<section id='description'>
|
||||
|
||||
A <b>CUSIP</b> is a nine-character alphanumeric code that identifies a North American financial security for the purposes of facilitating clearing and settlement of trades. The CUSIP was adopted as an American National Standard under Accredited Standards X9.6.
|
||||
</section>
|
||||
|
||||
@ -45,6 +46,7 @@ tests:
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
@ -88,4 +90,4 @@ function isCusip(s) {
|
||||
}
|
||||
```
|
||||
|
||||
</section>
|
||||
</section>
|
||||
|
@ -6,6 +6,7 @@ challengeType: 5
|
||||
|
||||
## Description
|
||||
<section id='description'>
|
||||
|
||||
A given rectangle is made from <i>m</i> × <i>n</i> squares. If <i>m</i> and <i>n</i> are not both odd, then it is possible to cut a path through the rectangle along the square edges such that the rectangle splits into two connected pieces with the same shape (after rotating one of the pieces by 180°). All such paths for 2 × 2 and 4 × 3 rectangles are shown below.
|
||||
<div style="width: 100%; text-align: center;">
|
||||
<svg xmlns="https://www.w3.org/2000/svg" xmlns:xlink="https://www.w3.org/1999/xlink" width="520" height="170" aria-hidden="true" alt="Diagram showing the possible paths for 2 by 2 and 4 by 3 rectangles">
|
||||
@ -87,6 +88,7 @@ tests:
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
@ -156,4 +158,4 @@ function cutRectangle(w, h) {
|
||||
}
|
||||
```
|
||||
|
||||
</section>
|
||||
</section>
|
||||
|
@ -6,6 +6,7 @@ challengeType: 5
|
||||
|
||||
## Description
|
||||
<section id='description'>
|
||||
|
||||
Create a function, to compute the <b><a href="https://en.wikipedia.org/wiki/Dot product">dot product</a></b>, also known as the <b>scalar product</b> of two vectors.
|
||||
</section>
|
||||
|
||||
@ -39,6 +40,7 @@ tests:
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
@ -62,4 +64,4 @@ function dotProduct(ary1, ary2) {
|
||||
}
|
||||
```
|
||||
|
||||
</section>
|
||||
</section>
|
||||
|
@ -6,15 +6,17 @@ challengeType: 5
|
||||
|
||||
## Description
|
||||
<section id='description'>
|
||||
A k-d tree (short for <i>k</i>-dimensional tree) is a space-partitioning data structure for organizing points in a k-dimensional space.
|
||||
k-d trees are a useful data structure for several applications, such as searches involving a multidimensional search key (e.g. range searches and nearest neighbor searches).
|
||||
|
||||
A k-d tree (short for <i>k</i>-dimensional tree) is a space-partitioning data structure for organizing points in a k-dimensional space.
|
||||
k-d trees are a useful data structure for several applications, such as searches involving a multidimensional search key (e.g. range searches and nearest neighbor searches).
|
||||
k-d trees are a special case of binary space partitioning trees. k-d trees are not suitable, however, for efficiently finding the nearest neighbor in high dimensional spaces. As a general rule, if the dimensionality is <i>k</i>, the number of points in the data, <i>N</i>, should be <i>N</i> ≫ 2<sup><i>k</i></sup>.
|
||||
Otherwise, when k-d trees are used with high-dimensional data, most of the points in the tree will be evaluated and the efficiency is no better than exhaustive search, and other methods such as approximate nearest-neighbor are used instead.
|
||||
</section>
|
||||
|
||||
## Instructions
|
||||
<section id='instructions'>
|
||||
Write a function to perform a nearest neighbor search using k-d tree. The function takes two parameters: an array of k-dimensional points, and a single k-dimensional point whose nearest neighbor should be returned by the function. A k-dimensional point will be given as an array of k elements.
|
||||
|
||||
Write a function to perform a nearest neighbour search using k-d tree. The function takes two parameters: an array of k-dimensional points, and a single k-dimensional point whose nearest neighbour should be returned by the function. A k-dimensional point will be given as an array of k elements.
|
||||
</section>
|
||||
|
||||
## Tests
|
||||
@ -44,6 +46,7 @@ tests:
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
@ -350,4 +353,4 @@ function kdNN(fpoints, fpoint) {
|
||||
}
|
||||
```
|
||||
|
||||
</section>
|
||||
</section>
|
||||
|
@ -6,6 +6,7 @@ challengeType: 5
|
||||
|
||||
## Description
|
||||
<section id='description'>
|
||||
|
||||
Given a set of positive integers, write a function to order the integers in such a way that the concatenation of the numbers forms the largest possible integer and return this integer.
|
||||
</section>
|
||||
|
||||
@ -39,6 +40,7 @@ tests:
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
@ -71,4 +73,4 @@ function maxCombine (xs) {
|
||||
}
|
||||
```
|
||||
|
||||
</section>
|
||||
</section>
|
||||
|
@ -6,6 +6,7 @@ challengeType: 5
|
||||
|
||||
## Description
|
||||
<section id='description'>
|
||||
|
||||
Write a function that returns the date of the last Friday of a given month for a given year.
|
||||
</section>
|
||||
|
||||
@ -45,6 +46,7 @@ tests:
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
@ -73,4 +75,4 @@ function lastFriday (year, month) {
|
||||
};
|
||||
```
|
||||
|
||||
</section>
|
||||
</section>
|
||||
|
@ -6,6 +6,7 @@ challengeType: 5
|
||||
|
||||
## Description
|
||||
<section id='description'>
|
||||
|
||||
Determine whether a given year is a leap year in the Gregorian calendar.
|
||||
</section>
|
||||
|
||||
@ -41,6 +42,7 @@ tests:
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
@ -61,4 +63,4 @@ function isLeapYear (year) {
|
||||
};
|
||||
```
|
||||
|
||||
</section>
|
||||
</section>
|
||||
|
@ -6,6 +6,7 @@ challengeType: 5
|
||||
|
||||
## Description
|
||||
<section id='description'>
|
||||
|
||||
The least common multiple of 12 and 18 is 36, because 12 is a factor (12 × 3 = 36), and 18 is a factor (18 × 2 = 36), and there is no positive integer less than 36 that has both factors. As a special case, if either <i>m</i> or <i>n</i> is zero, then the least common multiple is zero.
|
||||
One way to calculate the least common multiple is to iterate all the multiples of <i>m</i>, until you find one that is also a multiple of <i>n</i>.
|
||||
If you already have <i>gcd</i> for <a href="https://rosettacode.org/wiki/greatest common divisor" target="_blank">greatest common divisor</a>, then this formula calculates <i>lcm</i>.
|
||||
@ -14,6 +15,7 @@ If you already have <i>gcd</i> for <a href="https://rosettacode.org/wiki/great
|
||||
|
||||
## Instructions
|
||||
<section id='instructions'>
|
||||
|
||||
Compute the least common multiple of an array of intergers.
|
||||
Given <i>m</i> and <i>n</i>, the least common multiple is the smallest positive integer that has both <i>m</i> and <i>n</i> as factors.
|
||||
</section>
|
||||
@ -43,6 +45,7 @@ tests:
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
@ -69,4 +72,4 @@ function LCM (A) {
|
||||
}
|
||||
```
|
||||
|
||||
</section>
|
||||
</section>
|
||||
|
@ -6,6 +6,7 @@ challengeType: 5
|
||||
|
||||
## Description
|
||||
<section id='description'>
|
||||
|
||||
Five sailors are shipwrecked on an island and collect a large pile of coconuts during the day.
|
||||
That night the first sailor wakes up and decides to take his first share early so tries to divide the pile of coconuts equally into five piles but finds that there is one coconut left over, so he tosses it to a monkey and then hides "his" one of the five equally sized piles of coconuts and pushes the other four piles together to form a single visible pile of coconuts again and goes to bed.
|
||||
To cut a long story short, each of the sailors in turn gets up once during the night and performs the same actions of dividing the coconut pile into five, finding that one coconut is left over and giving that single remainder coconut to the monkey.
|
||||
@ -14,6 +15,7 @@ In the morning (after the surreptitious and separate action of each of the five
|
||||
|
||||
## Instructions
|
||||
<section id='instructions'>
|
||||
|
||||
Create a function that returns the minimum possible size of the initial pile of coconuts collected during the day for <code>N</code> sailors.
|
||||
<strong>Note:</strong>
|
||||
Of course the tale is told in a world where the collection of any amount of coconuts in a day and multiple divisions of the pile, etc. can occur in time fitting the story line, so as not to affect the mathematics.
|
||||
|
@ -6,6 +6,7 @@ challengeType: 5
|
||||
|
||||
## Description
|
||||
<section id='description'>
|
||||
|
||||
For each number list of 6-digit <a href="https://en.wikipedia.org/wiki/SEDOL" title="wp: SEDOL" target="_blank">SEDOL</a>s, calculate and append the checksum digit.
|
||||
That is, given the input string on the left, your function should return the corresponding string on the right:
|
||||
<pre>
|
||||
|
@ -6,6 +6,7 @@ challengeType: 5
|
||||
|
||||
## Description
|
||||
<section id='description'>
|
||||
|
||||
Soundex is an algorithm for creating indices for words based on their pronunciation.
|
||||
The goal is for homophones to be encoded to the same representation so that they can be matched despite minor differences in spelling (from <a href="https://en.wikipedia.org/wiki/soundex" target="_blank">the WP article</a>).
|
||||
There is a major issue in many of the implementations concerning the separation of two consonants that have the same soundex code! According to the <a href="https://www.archives.gov/research/census/soundex.html" target="_blank">official Rules</a>. So check for instance if <b>Ashcraft</b> is coded to <b>A-261</b>.
|
||||
@ -55,6 +56,7 @@ tests:
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
@ -96,4 +98,4 @@ function soundex(s) {
|
||||
}
|
||||
```
|
||||
|
||||
</section>
|
||||
</section>
|
||||
|
@ -6,6 +6,7 @@ challengeType: 5
|
||||
|
||||
## Description
|
||||
<section id='description'>
|
||||
|
||||
Produce a spiral array.
|
||||
A <i>spiral array</i> is a square arrangement of the first N<sup>2</sup> natural numbers, where the numbers increase sequentially as you go around the edges of the array spiraling inwards.
|
||||
For example, given <b>5</b>, produce this array:
|
||||
@ -44,6 +45,7 @@ tests:
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
@ -78,4 +80,4 @@ function spiralArray(n) {
|
||||
}
|
||||
```
|
||||
|
||||
</section>
|
||||
</section>
|
||||
|
@ -6,6 +6,7 @@ challengeType: 5
|
||||
|
||||
## Description
|
||||
<section id='description'>
|
||||
|
||||
Split a (character) string into comma (plus a blank) delimited strings based on a change of character (left to right).
|
||||
Blanks should be treated as any other character (except they are problematic to display clearly). The same applies to commas.
|
||||
For instance, the string:
|
||||
@ -48,6 +49,7 @@ tests:
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
@ -97,4 +99,4 @@ function split(str) {
|
||||
}
|
||||
```
|
||||
|
||||
</section>
|
||||
</section>
|
||||
|
@ -6,6 +6,7 @@ challengeType: 5
|
||||
|
||||
## Description
|
||||
<section id='description'>
|
||||
|
||||
This task is inspired by Mark Nelson's DDJ Column "Wordplay" and one of the weekly puzzle challenges from Will Shortz on NPR Weekend Edition <a href="https://www.npr.org/templates/story/story.php?storyId=9264290" target="_blank">[1]</a> and originally attributed to David Edelheit.
|
||||
The challenge was to take the names of two U.S. States, mix them all together, then rearrange the letters to form the names of two <i>different</i> U.S. States (so that all four state names differ from one another).
|
||||
What states are these?
|
||||
@ -15,6 +16,7 @@ A second challenge in the form of a set of fictitious new states was also presen
|
||||
|
||||
## Instructions
|
||||
<section id='instructions'>
|
||||
|
||||
Write a function to solve the challenge for the given array of names of states. The function should return an array. Each element should be an object in this form: <code>{"from":[],"to":[]}</code>. The "from" array should contain the original names and the "to" array should contain the resultant names.
|
||||
</section>
|
||||
|
||||
@ -37,6 +39,7 @@ tests:
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
@ -98,4 +101,4 @@ function solve(input) {
|
||||
}
|
||||
```
|
||||
|
||||
</section>
|
||||
</section>
|
||||
|
@ -6,7 +6,8 @@ challengeType: 5
|
||||
|
||||
## Description
|
||||
<section id='description'>
|
||||
Implement functions to encrypt and decrypt a message using the <a href="https://en.wikipedia.org/wiki/Straddling_checkerboard" target="_blank">straddling checkerboard</a> method. The functions will take a string and an array as parameters. The array has 3 strings representing the 3 rows of the checkerboard. The output will be a series of decimal digits.
|
||||
|
||||
Implement functions to encrypt and decrypt a message using the <a href="https://en.wikipedia.org/wiki/Straddling_checkerboard">straddling checkerboard</a> method. The functions will take a string and an array as parameters. The array has 3 strings representing the 3 rows of the checkerboard. The output will be a series of decimal digits.
|
||||
Numbers should be encrypted by inserting the escape character before each digit, then including the digit unencrypted. This should be reversed for decryption.
|
||||
</section>
|
||||
|
||||
@ -46,6 +47,7 @@ tests:
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
@ -105,4 +107,4 @@ function unstraddle(message, alphabet) {
|
||||
}
|
||||
```
|
||||
|
||||
</section>
|
||||
</section>
|
||||
|
@ -6,6 +6,7 @@ challengeType: 5
|
||||
|
||||
## Description
|
||||
<section id='description'>
|
||||
|
||||
Write a function that takes multiple sorted arrays of items, and returns one array of sorted items.
|
||||
</section>
|
||||
|
||||
@ -39,6 +40,7 @@ tests:
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
@ -79,4 +81,4 @@ function mergeLists(lists) {
|
||||
}
|
||||
```
|
||||
|
||||
</section>
|
||||
</section>
|
||||
|
@ -6,7 +6,9 @@ challengeType: 5
|
||||
|
||||
## Description
|
||||
<section id='description'>
|
||||
The task is to strip control codes and extended characters from a string.
|
||||
|
||||
The task is to strip control codes and extended characters from a string. The solution should demonstrate how to achieve each of the following results:
|
||||
A string with control codes and extended characters stripped.
|
||||
In ASCII, the control codes have decimal codes 0 through to 31 and 127. On an ASCII based system, if the control codes are stripped, the resultant string would have all of its characters within the range of 32 to 126 decimal on the ASCII table.
|
||||
On a non-ASCII based system, we consider characters that do not have a corresponding glyph on the ASCII table (within the ASCII range of 32 to 126 decimal) to be an extended character for the purpose of this task.
|
||||
</section>
|
||||
@ -41,6 +43,7 @@ tests:
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
@ -65,4 +68,4 @@ function strip(s) {
|
||||
}
|
||||
```
|
||||
|
||||
</section>
|
||||
</section>
|
||||
|
@ -6,6 +6,7 @@ challengeType: 5
|
||||
|
||||
## Description
|
||||
<section id='description'>
|
||||
|
||||
Write a function to solve a partially filled-in normal 9x9 <a href="https://en.wikipedia.org/wiki/Sudoku" target="_blank">Sudoku</a> grid and return the result. The blank fields are represented by 0s.
|
||||
<a href="https://en.wikipedia.org/wiki/Algorithmics_of_sudoku" target="_blank">Algorithmics of Sudoku</a> may help implement this.
|
||||
</section>
|
||||
@ -36,6 +37,7 @@ tests:
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
@ -233,4 +235,4 @@ function solveSudoku(puzzle) {
|
||||
}
|
||||
```
|
||||
|
||||
</section>
|
||||
</section>
|
||||
|
@ -6,6 +6,7 @@ challengeType: 5
|
||||
|
||||
## Description
|
||||
<section id='description'>
|
||||
|
||||
The objective is to write a function that finds the sum of all positive multiples of 3 or 5 below <i>n</i>.
|
||||
</section>
|
||||
|
||||
@ -39,6 +40,7 @@ tests:
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
@ -63,4 +65,4 @@ function sumMults(n) {
|
||||
}
|
||||
```
|
||||
|
||||
</section>
|
||||
</section>
|
||||
|
@ -6,6 +6,7 @@ challengeType: 5
|
||||
|
||||
## Description
|
||||
<section id='description'>
|
||||
|
||||
Compute the <b>n</b><sup>th</sup> term of a <a href="https://en.wikipedia.org/wiki/Series (mathematics)" target="_blank">series</a>, i.e. the sum of the <b>n</b> first terms of the corresponding <a href="https://en.wikipedia.org/wiki/sequence" target="_blank">sequence</a>.
|
||||
Informally this value, or its limit when <b>n</b> tends to infinity, is also called the <i>sum of the series</i>, thus the title of this task.
|
||||
For this task, use:
|
||||
@ -18,6 +19,7 @@ and compute $S_{1000}$
|
||||
|
||||
## Instructions
|
||||
<section id='instructions'>
|
||||
|
||||
Write a function that take $a$ and $b$ as parameters and returns the sum of $a^{th}$ to $b^{th}$ members of the sequence.
|
||||
</section>
|
||||
|
||||
@ -46,6 +48,7 @@ tests:
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
@ -71,4 +74,4 @@ function sum(a, b) {
|
||||
}
|
||||
```
|
||||
|
||||
</section>
|
||||
</section>
|
||||
|
@ -6,6 +6,7 @@ challengeType: 5
|
||||
|
||||
## Description
|
||||
<section id='description'>
|
||||
|
||||
Write a function to find the sum of squares of an array of integers.
|
||||
</section>
|
||||
|
||||
@ -39,6 +40,7 @@ tests:
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
@ -65,4 +67,4 @@ function sumsq(array) {
|
||||
}
|
||||
```
|
||||
|
||||
</section>
|
||||
</section>
|
||||
|
@ -6,6 +6,7 @@ challengeType: 5
|
||||
|
||||
## Description
|
||||
<section id='description'>
|
||||
|
||||
The <a href="https://en.wikipedia.org/wiki/Sutherland-Hodgman clipping algorithm" target="_blank">Sutherland-Hodgman clipping algorithm</a> finds the polygon that is the intersection between an arbitrary polygon (the "subject polygon") and a convex polygon (the "clip polygon").
|
||||
It is used in computer graphics (especially 2D graphics) to reduce the complexity of a scene being displayed by eliminating parts of a polygon that do not need to be displayed.
|
||||
Take the closed polygon defined by the points:
|
||||
@ -16,6 +17,7 @@ and clip it by the rectangle defined by the points:
|
||||
|
||||
## Instructions
|
||||
<section id='instructions'>
|
||||
|
||||
Write a function that takes 2 arrays as parameters. The first array contains the points of the subject polygon and the second array contains the points of the clipping polygon. The function should return an array containing the points of the clipped polygon. Each number should be rounded to 3 decimal places.
|
||||
</section>
|
||||
|
||||
@ -40,6 +42,7 @@ tests:
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
@ -93,4 +96,4 @@ function clip(subjectPolygon, clipPolygon) {
|
||||
}
|
||||
```
|
||||
|
||||
</section>
|
||||
</section>
|
||||
|
@ -6,6 +6,7 @@ challengeType: 5
|
||||
|
||||
## Description
|
||||
<section id='description'>
|
||||
|
||||
Given two <a href="https://rosettacode.org/wiki/set" target="_blank">set</a>s <i>A</i> and <i>B</i>, compute $(A \setminus B) \cup (B \setminus A).$
|
||||
That is, enumerate the items that are in <i>A</i> or <i>B</i> but not both. This set is called the <a href="https://en.wikipedia.org/wiki/Symmetric difference" target="_blank">symmetric difference</a> of <i>A</i> and <i>B</i>.
|
||||
In other words: $(A \cup B) \setminus (A \cap B)$ (the set of items that are in at least one of <i>A</i> or <i>B</i> minus the set of items that are in both <i>A</i> and <i>B</i>).
|
||||
@ -13,6 +14,7 @@ In other words: $(A \cup B) \setminus (A \cap B)$ (the set of items that are in
|
||||
|
||||
## Instructions
|
||||
<section id='instructions'>
|
||||
|
||||
Write a function that takes two arrays as parameters and returns the symmetric difference. Sort the resultant array before returning it.
|
||||
</section>
|
||||
|
||||
@ -41,6 +43,7 @@ tests:
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
@ -78,4 +81,4 @@ function symmetricDifference(A, B) {
|
||||
}
|
||||
```
|
||||
|
||||
</section>
|
||||
</section>
|
||||
|
@ -6,12 +6,14 @@ challengeType: 5
|
||||
|
||||
## Description
|
||||
<section id='description'>
|
||||
|
||||
Given a mapping between items, and items they depend on, a <a href="https://en.wikipedia.org/wiki/Topological sorting" title="wp: Topological sorting" target="_blank">topological sort</a> orders items so that no item precedes an item it depends upon.
|
||||
The compiling of a library in the <a href="https://en.wikipedia.org/wiki/VHDL" title="wp: VHDL" target="_blank">VHDL</a> language has the constraint that a library must be compiled after any library it depends on.
|
||||
</section>
|
||||
|
||||
## Instructions
|
||||
<section id='instructions'>
|
||||
|
||||
Write a function that will return a valid compile order of VHDL libraries from their dependencies.
|
||||
<ul>
|
||||
<li>Assume library names are single words.</li>
|
||||
|
@ -6,11 +6,13 @@ challengeType: 5
|
||||
|
||||
## Description
|
||||
<section id='description'>
|
||||
|
||||
A vector is defined as having three dimensions as being represented by an ordered collection of three numbers: (X, Y, Z).
|
||||
</section>
|
||||
|
||||
## Instructions
|
||||
<section id='instructions'>
|
||||
|
||||
Write a function that takes two vectors (arrays) as input and computes their cross product. Your function should return <code>null</code> on invalid inputs such as vectors of different lengths.
|
||||
</section>
|
||||
|
||||
|
@ -6,11 +6,13 @@ challengeType: 5
|
||||
|
||||
## Description
|
||||
<section id='description'>
|
||||
|
||||
A vector is defined as having three dimensions as being represented by an ordered collection of three numbers: (X, Y, Z).
|
||||
</section>
|
||||
|
||||
## Instructions
|
||||
<section id='instructions'>
|
||||
|
||||
Write a function that takes any numbers of vectors (arrays) as input and computes their dot product. Your function should return <code>null</code> on invalid inputs such as vectors of different lengths.
|
||||
</section>
|
||||
|
||||
|
@ -6,11 +6,13 @@ challengeType: 5
|
||||
|
||||
## Description
|
||||
<section id='description'>
|
||||
|
||||
Even today, with proportional fonts and complex layouts, there are still cases where you need to wrap text at a specified column. The basic task is to wrap a paragraph of text in a simple way.
|
||||
</section>
|
||||
|
||||
## Instructions
|
||||
<section id='instructions'>
|
||||
|
||||
Write a function that can wrap this text to any number of characters. As an example, the text wrapped to 80 characters should look like the following:
|
||||
<pre>
|
||||
Wrap text using a more sophisticated algorithm such as the Knuth and Plass TeX
|
||||
|
@ -6,12 +6,14 @@ challengeType: 5
|
||||
|
||||
## Description
|
||||
<section id='description'>
|
||||
|
||||
In strict <a href="https://en.wikipedia.org/wiki/Functional programming" title="wp: functional programming" target="_blank">functional programming</a> and the <a href="https://en.wikipedia.org/wiki/lambda calculus" title="wp: lambda calculus" target="_blank">lambda calculus</a>, functions (lambda expressions) don't have state and are only allowed to refer to arguments of enclosing functions. This rules out the usual definition of a recursive function wherein a function is associated with the state of a variable and this variable's state is used in the body of the function.
|
||||
The <a href="https://mvanier.livejournal.com/2897.html" target="_blank">Y combinator</a> is itself a stateless function that, when applied to another stateless function, returns a recursive version of the function. The Y combinator is the simplest of the class of such functions, called <a href="https://en.wikipedia.org/wiki/Fixed-point combinator" title="wp: fixed-point combinator" target="_blank">fixed-point combinators</a>.
|
||||
</section>
|
||||
|
||||
## Instructions
|
||||
<section id='instructions'>
|
||||
|
||||
Define the stateless Y combinator function and use it to compute <a href="https://en.wikipedia.org/wiki/Factorial" title="wp: factorial" target="_blank">factorial</a>. The <code>factorial(N)</code> function is already given to you.
|
||||
<strong>See also:</strong>
|
||||
<ul>
|
||||
|
@ -6,8 +6,11 @@ challengeType: 5
|
||||
|
||||
## Description
|
||||
<section id='description'>
|
||||
|
||||
This is an algorithm used to thin a black and white i.e. one bit per pixel images.
|
||||
For example, with an input image of:
|
||||
<!-- TODO write fully in markdown>
|
||||
<!-- markdownlint-disable -->
|
||||
<pre>
|
||||
################# #############
|
||||
################## ################
|
||||
@ -50,17 +53,17 @@ It produces the thinned output:
|
||||
Assume black pixels are one and white pixels zero, and that the input image is a rectangular N by M array of ones and zeroes.
|
||||
The algorithm operates on all black pixels P1 that can have eight neighbours. The neighbours are, in order, arranged as:
|
||||
|
||||
<table border="3">
|
||||
<tr><td style="text-align: center;">P9</td><td style="text-align: center;">P2</td><td style="text-align: center;">P3</td></tr>
|
||||
<tr><td style="text-align: center;">P8</td><td style="text-align: center;"><strong>P1</strong></td><td style="text-align: center;">P4</td></tr>
|
||||
<tr><td style="text-align: center;">P7</td><td style="text-align: center;">P6</td><td style="text-align: center;">P5</td></tr>
|
||||
<table border="3">
|
||||
<tr><td style="text-align: center;">P9</td><td style="text-align: center;">P2</td><td style="text-align: center;">P3</td></tr>
|
||||
<tr><td style="text-align: center;">P8</td><td style="text-align: center;"><strong>P1</strong></td><td style="text-align: center;">P4</td></tr>
|
||||
<tr><td style="text-align: center;">P7</td><td style="text-align: center;">P6</td><td style="text-align: center;">P5</td></tr>
|
||||
</table>
|
||||
|
||||
Obviously the boundary pixels of the image cannot have the full eight neighbours.
|
||||
<ul>
|
||||
<li>Define $A(P1)$ = the number of transitions from white to black, (0 -> 1) in the sequence P2, P3, P4, P5, P6, P7, P8, P9, P2. (Note the extra P2 at the end - it is circular).</li>
|
||||
<li>Define $B(P1)$ = the number of black pixel neighbours of P1. ( = sum(P2 .. P9) )</li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li>Define $A(P1)$ = the number of transitions from white to black, (0 -> 1) in the sequence P2, P3, P4, P5, P6, P7, P8, P9, P2. (Note the extra P2 at the end - it is circular).</li>
|
||||
<li>Define $B(P1)$ = the number of black pixel neighbours of P1. ( = sum(P2 .. P9) )</li>
|
||||
</ul>
|
||||
|
||||
<h3>Step 1:</h3>
|
||||
All pixels are tested and pixels satisfying all the following conditions (simultaneously) are just noted at this stage.
|
||||
|
Reference in New Issue
Block a user