Feat: add new Markdown parser (#39800)
and change all the challenges to new `md` format.
This commit is contained in:
committed by
GitHub
parent
a07f84c8ec
commit
0bd52f8bd1
@ -5,14 +5,13 @@ challengeType: 1
|
||||
forumTopicId: 301620
|
||||
---
|
||||
|
||||
## Description
|
||||
<section id='description'>
|
||||
# --description--
|
||||
|
||||
Graphs can be represented in different ways. Here we describe one way, which is called an <dfn>adjacency list</dfn>. An adjacency list is essentially a bulleted list where the left side is the node and the right side lists all the other nodes it's connected to. Below is a representation of an adjacency list.
|
||||
|
||||
Graphs can be represented in different ways. Here we describe one way, which is called an <dfn>adjacency list</dfn>.
|
||||
An adjacency list is essentially a bulleted list where the left side is the node and the right side lists all the other nodes it's connected to. Below is a representation of an adjacency list.
|
||||
<blockquote>Node1: Node2, Node3<br>Node2: Node1<br>Node3: Node1</blockquote>
|
||||
Above is an undirected graph because <code>Node1</code> is connected to <code>Node2</code> and <code>Node3</code>, and that information is consistent with the connections <code>Node2</code> and <code>Node3</code> show. An adjacency list for a directed graph would mean each row of the list shows direction. If the above was directed, then <code>Node2: Node1</code> would mean there the directed edge is pointing from <code>Node2</code> towards <code>Node1</code>.
|
||||
We can represent the undirected graph above as an adjacency list by putting it within a JavaScript object.
|
||||
|
||||
Above is an undirected graph because `Node1` is connected to `Node2` and `Node3`, and that information is consistent with the connections `Node2` and `Node3` show. An adjacency list for a directed graph would mean each row of the list shows direction. If the above was directed, then `Node2: Node1` would mean there the directed edge is pointing from `Node2` towards `Node1`. We can represent the undirected graph above as an adjacency list by putting it within a JavaScript object.
|
||||
|
||||
```js
|
||||
var undirectedG = {
|
||||
@ -32,45 +31,54 @@ var undirectedGArr = [
|
||||
];
|
||||
```
|
||||
|
||||
</section>
|
||||
# --instructions--
|
||||
|
||||
## Instructions
|
||||
<section id='instructions'>
|
||||
Create a social network as an undirected graph with 4 nodes/people named `James`, `Jill`, `Jenny`, and `Jeff`. There are edges/relationships between James and Jeff, Jill and Jenny, and Jeff and Jenny.
|
||||
|
||||
Create a social network as an undirected graph with 4 nodes/people named <code>James</code>, <code>Jill</code>, <code>Jenny</code>, and <code>Jeff</code>. There are edges/relationships between James and Jeff, Jill and Jenny, and Jeff and Jenny.
|
||||
</section>
|
||||
# --hints--
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
`undirectedAdjList` should only contain four nodes.
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>undirectedAdjList</code> should only contain four nodes.
|
||||
testString: assert(Object.keys(undirectedAdjList).length === 4);
|
||||
- text: There should be an edge between <code>Jeff</code> and <code>James</code>.
|
||||
testString: assert(undirectedAdjList.James.indexOf("Jeff") !== -1 && undirectedAdjList.Jeff.indexOf("James") !== -1);
|
||||
- text: There should be an edge between <code>Jill</code> and <code>Jenny</code>.
|
||||
testString: assert(undirectedAdjList.Jill.indexOf("Jenny") !== -1 && undirectedAdjList.Jill.indexOf("Jenny") !== -1);
|
||||
- text: There should be an edge between <code>Jeff</code> and <code>Jenny</code>.
|
||||
testString: assert(undirectedAdjList.Jeff.indexOf("Jenny") !== -1 && undirectedAdjList.Jenny.indexOf("Jeff") !== -1);
|
||||
```js
|
||||
assert(Object.keys(undirectedAdjList).length === 4);
|
||||
```
|
||||
|
||||
</section>
|
||||
There should be an edge between `Jeff` and `James`.
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
```js
|
||||
assert(
|
||||
undirectedAdjList.James.indexOf('Jeff') !== -1 &&
|
||||
undirectedAdjList.Jeff.indexOf('James') !== -1
|
||||
);
|
||||
```
|
||||
|
||||
<div id='js-seed'>
|
||||
There should be an edge between `Jill` and `Jenny`.
|
||||
|
||||
```js
|
||||
assert(
|
||||
undirectedAdjList.Jill.indexOf('Jenny') !== -1 &&
|
||||
undirectedAdjList.Jill.indexOf('Jenny') !== -1
|
||||
);
|
||||
```
|
||||
|
||||
There should be an edge between `Jeff` and `Jenny`.
|
||||
|
||||
```js
|
||||
assert(
|
||||
undirectedAdjList.Jeff.indexOf('Jenny') !== -1 &&
|
||||
undirectedAdjList.Jenny.indexOf('Jeff') !== -1
|
||||
);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
## --seed-contents--
|
||||
|
||||
```js
|
||||
var undirectedAdjList = {};
|
||||
```
|
||||
|
||||
</div>
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
# --solutions--
|
||||
|
||||
```js
|
||||
var undirectedAdjList = {
|
||||
@ -80,5 +88,3 @@ var undirectedAdjList = {
|
||||
Jeff: ['James', 'Jenny']
|
||||
};
|
||||
```
|
||||
|
||||
</section>
|
||||
|
Reference in New Issue
Block a user