Skip to content

Commit fbda2ee

Browse files
authored
fix(curriculum): remove before/after-user-code from rosetta challenges 21-25 (freeCodeCamp#66407)
1 parent 360c926 commit fbda2ee

5 files changed

Lines changed: 240 additions & 239 deletions

File tree

curriculum/challenges/english/blocks/rosetta-code-challenges/5951a53863c8a34f02bf1bdc.md

Lines changed: 126 additions & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,126 @@ Would return:
9898
**Note:** Sort the `pair` array by their `x` values in incrementing order.
9999

100100

101+
# --before-each--
102+
103+
```js
104+
function getPoints1_() {
105+
return [
106+
new Point(0.748501, 4.09624),
107+
new Point(3.00302, 5.26164),
108+
new Point(3.61878, 9.52232),
109+
new Point(7.46911, 4.71611),
110+
new Point(5.7819, 2.69367),
111+
new Point(2.34709, 8.74782),
112+
new Point(2.87169, 5.97774),
113+
new Point(6.33101, 0.463131),
114+
new Point(7.46489, 4.6268),
115+
new Point(1.45428, 0.087596)
116+
];
117+
}
118+
119+
const answer1 = {
120+
distance: 0.0894096443343775,
121+
pair: [
122+
{ x: 7.46489, y: 4.6268 },
123+
{ x: 7.46911, y: 4.71611 }
124+
]
125+
};
126+
127+
function getPoints2_() {
128+
return [
129+
new Point(37100, 13118),
130+
new Point(37134, 1963),
131+
new Point(37181, 2008),
132+
new Point(37276, 21611),
133+
new Point(37307, 9320)
134+
];
135+
}
136+
137+
const answer2 = {
138+
distance: 65.06919393998976,
139+
pair: [
140+
{ x: 37134, y: 1963 },
141+
{ x: 37181, y: 2008 }
142+
]
143+
};
144+
145+
function getPoints3_() {
146+
return [
147+
new Point(16910, 54699),
148+
new Point(14773, 61107),
149+
new Point(95547, 45344),
150+
new Point(95951, 17573),
151+
new Point(5824, 41072),
152+
new Point(8769, 52562),
153+
new Point(21182, 41881),
154+
new Point(53226, 45749),
155+
new Point(68180, 887),
156+
new Point(29322, 44017),
157+
new Point(46817, 64975),
158+
new Point(10501, 483),
159+
new Point(57094, 60703),
160+
new Point(23318, 35472),
161+
new Point(72452, 88070),
162+
new Point(67775, 28659),
163+
new Point(19450, 20518),
164+
new Point(17314, 26927),
165+
new Point(98088, 11164),
166+
new Point(25050, 56835),
167+
new Point(8364, 6892),
168+
new Point(37868, 18382),
169+
new Point(23723, 7701),
170+
new Point(55767, 11569),
171+
new Point(70721, 66707),
172+
new Point(31863, 9837),
173+
new Point(49358, 30795),
174+
new Point(13041, 39744),
175+
new Point(59635, 26523),
176+
new Point(25859, 1292),
177+
new Point(1551, 53890),
178+
new Point(70316, 94479),
179+
new Point(48549, 86338),
180+
new Point(46413, 92747),
181+
new Point(27186, 50426),
182+
new Point(27591, 22655),
183+
new Point(10905, 46153),
184+
new Point(40408, 84202),
185+
new Point(52821, 73520),
186+
new Point(84865, 77388),
187+
new Point(99819, 32527),
188+
new Point(34404, 75657),
189+
new Point(78457, 96615),
190+
new Point(42140, 5564),
191+
new Point(62175, 92342),
192+
new Point(54958, 67112),
193+
new Point(4092, 19709),
194+
new Point(99415, 60298),
195+
new Point(51090, 52158),
196+
new Point(48953, 58567)
197+
];
198+
}
199+
200+
const answer3 = {
201+
distance: 6754.625082119658,
202+
pair: [
203+
{ x: 46817, y: 64975 },
204+
{ x: 48953, y: 58567 }
205+
]
206+
};
207+
208+
function getClosestPair1_() {
209+
return getClosestPair(getPoints1_());
210+
}
211+
212+
function getClosestPair2_() {
213+
return getClosestPair(getPoints2_());
214+
}
215+
216+
function getClosestPair3_() {
217+
return getClosestPair(getPoints3_());
218+
}
219+
```
220+
101221
# --hints--
102222

103223
`getClosestPair` should be a function.
@@ -109,170 +229,50 @@ assert(typeof getClosestPair === 'function');
109229
`getClosestPair(points1).distance` should be `0.0894096443343775`.
110230

111231
```js
112-
assert.equal(getClosestPair(points1).distance, answer1.distance);
232+
assert.equal(getClosestPair1_().distance, answer1.distance);
113233
```
114234

115235
`getClosestPair(points1).pair` should be `[ { x: 7.46489, y: 4.6268 }, { x: 7.46911, y: 4.71611 } ]`.
116236

117237
```js
118238
assert.deepEqual(
119-
JSON.parse(JSON.stringify(getClosestPair(points1))).pair,
239+
JSON.parse(JSON.stringify(getClosestPair1_())).pair,
120240
answer1.pair
121241
);
122242
```
123243

124244
`getClosestPair(points2).distance` should be `65.06919393998976`.
125245

126246
```js
127-
assert.equal(getClosestPair(points2).distance, answer2.distance);
247+
assert.equal(getClosestPair2_().distance, answer2.distance);
128248
```
129249

130250
`getClosestPair(points2).pair` should be `[ { x: 37134, y: 1963 }, { x: 37181, y: 2008 } ]`.
131251

132252
```js
133253
assert.deepEqual(
134-
JSON.parse(JSON.stringify(getClosestPair(points2))).pair,
254+
JSON.parse(JSON.stringify(getClosestPair2_())).pair,
135255
answer2.pair
136256
);
137257
```
138258

139259
`getClosestPair(points3).distance` should be `6754.625082119658`.
140260

141261
```js
142-
assert.equal(getClosestPair(points3).distance, answer3.distance);
262+
assert.equal(getClosestPair3_().distance, answer3.distance);
143263
```
144264

145265
`getClosestPair(points3).pair` should be `[ { x: 46817, y: 64975 }, { x: 48953, y: 58567 } ]`.
146266

147267
```js
148268
assert.deepEqual(
149-
JSON.parse(JSON.stringify(getClosestPair(points3))).pair,
269+
JSON.parse(JSON.stringify(getClosestPair3_())).pair,
150270
answer3.pair
151271
);
152272
```
153273

154274
# --seed--
155275

156-
## --after-user-code--
157-
158-
```js
159-
const points1 = [
160-
new Point(0.748501, 4.09624),
161-
new Point(3.00302, 5.26164),
162-
new Point(3.61878, 9.52232),
163-
new Point(7.46911, 4.71611),
164-
new Point(5.7819, 2.69367),
165-
new Point(2.34709, 8.74782),
166-
new Point(2.87169, 5.97774),
167-
new Point(6.33101, 0.463131),
168-
new Point(7.46489, 4.6268),
169-
new Point(1.45428, 0.087596)
170-
];
171-
172-
const answer1 = {
173-
distance: 0.0894096443343775,
174-
pair: [
175-
{
176-
x: 7.46489,
177-
y: 4.6268
178-
},
179-
{
180-
x: 7.46911,
181-
y: 4.71611
182-
}
183-
]
184-
};
185-
186-
const points2 = [
187-
new Point(37100, 13118),
188-
new Point(37134, 1963),
189-
new Point(37181, 2008),
190-
new Point(37276, 21611),
191-
new Point(37307, 9320)
192-
];
193-
194-
const answer2 = {
195-
distance: 65.06919393998976,
196-
pair: [
197-
{
198-
x: 37134,
199-
y: 1963
200-
},
201-
{
202-
x: 37181,
203-
y: 2008
204-
}
205-
]
206-
};
207-
208-
const points3 = [
209-
new Point(16910, 54699),
210-
new Point(14773, 61107),
211-
new Point(95547, 45344),
212-
new Point(95951, 17573),
213-
new Point(5824, 41072),
214-
new Point(8769, 52562),
215-
new Point(21182, 41881),
216-
new Point(53226, 45749),
217-
new Point(68180, 887),
218-
new Point(29322, 44017),
219-
new Point(46817, 64975),
220-
new Point(10501, 483),
221-
new Point(57094, 60703),
222-
new Point(23318, 35472),
223-
new Point(72452, 88070),
224-
new Point(67775, 28659),
225-
new Point(19450, 20518),
226-
new Point(17314, 26927),
227-
new Point(98088, 11164),
228-
new Point(25050, 56835),
229-
new Point(8364, 6892),
230-
new Point(37868, 18382),
231-
new Point(23723, 7701),
232-
new Point(55767, 11569),
233-
new Point(70721, 66707),
234-
new Point(31863, 9837),
235-
new Point(49358, 30795),
236-
new Point(13041, 39744),
237-
new Point(59635, 26523),
238-
new Point(25859, 1292),
239-
new Point(1551, 53890),
240-
new Point(70316, 94479),
241-
new Point(48549, 86338),
242-
new Point(46413, 92747),
243-
new Point(27186, 50426),
244-
new Point(27591, 22655),
245-
new Point(10905, 46153),
246-
new Point(40408, 84202),
247-
new Point(52821, 73520),
248-
new Point(84865, 77388),
249-
new Point(99819, 32527),
250-
new Point(34404, 75657),
251-
new Point(78457, 96615),
252-
new Point(42140, 5564),
253-
new Point(62175, 92342),
254-
new Point(54958, 67112),
255-
new Point(4092, 19709),
256-
new Point(99415, 60298),
257-
new Point(51090, 52158),
258-
new Point(48953, 58567)
259-
];
260-
261-
const answer3 = {
262-
distance: 6754.625082119658,
263-
pair: [
264-
{
265-
x: 46817,
266-
y: 64975
267-
},
268-
{
269-
x: 48953,
270-
y: 58567
271-
}
272-
]
273-
}
274-
```
275-
276276
## --seed-contents--
277277

278278
```js

0 commit comments

Comments
 (0)