fix(challenges): Forgot to remove the space between the function name and first parenthesis
This commit is contained in:
@ -61,7 +61,7 @@ const solution = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100];
|
||||
|
||||
|
||||
```js
|
||||
function getFinalOpenedDoors (numDoors) {
|
||||
function getFinalOpenedDoors(numDoors) {
|
||||
// this is the final pattern (always squares).
|
||||
// thus, the most efficient solution simply returns an array of squares up to numDoors).
|
||||
const finalState = [];
|
||||
|
@ -80,7 +80,7 @@ function numberOfNames(num) {
|
||||
|
||||
|
||||
```js
|
||||
function numberOfNames (num) {
|
||||
function numberOfNames(num) {
|
||||
const cache = [
|
||||
[1]
|
||||
];
|
||||
|
@ -96,7 +96,7 @@ const words = ['bark', 'BooK', 'TReAT', 'COMMON', 'squAD', 'conFUSE'];
|
||||
|
||||
|
||||
```js
|
||||
function canMakeWord (word) {
|
||||
function canMakeWord(word) {
|
||||
const characters = 'BO XK DQ CP NA GT RE TG QD FS JW HU VI AN OB ER FS LY PC ZM';
|
||||
const blocks = characters.split(' ').map(pair => pair.split(''));
|
||||
|
||||
|
@ -72,7 +72,7 @@ const solution = [15043, 4, 4953];
|
||||
|
||||
|
||||
```js
|
||||
function getDPA (num) {
|
||||
function getDPA(num) {
|
||||
const dpa = [1, 0, 0];
|
||||
for (let n = 2; n <= num; n += 1) {
|
||||
let ds = 1;
|
||||
|
@ -70,7 +70,7 @@ if (testFn) {
|
||||
|
||||
|
||||
```js
|
||||
function accumulator (sum) {
|
||||
function accumulator(sum) {
|
||||
return function (n) {
|
||||
return sum += n;
|
||||
};
|
||||
|
@ -59,7 +59,7 @@ function ack(m, n) {
|
||||
|
||||
|
||||
```js
|
||||
function ack (m, n) {
|
||||
function ack(m, n) {
|
||||
return m === 0 ? n + 1 : ack(m - 1, n === 0 ? 1 : ack(m, n - 1));
|
||||
}
|
||||
|
||||
|
@ -155,7 +155,7 @@ const testArr = [
|
||||
|
||||
String.prototype.repeat = function (n) { return new Array(1 + parseInt(n)).join(this); };
|
||||
|
||||
function formatText (input, justification) {
|
||||
function formatText(input, justification) {
|
||||
let x, y, max, cols = 0, diff, left, right;
|
||||
for (x = 0; x < input.length; x++) {
|
||||
input[x] = input[x].split('$');
|
||||
|
@ -45,7 +45,7 @@ tests:
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
function amicablePairsUpTo (maxNum) {
|
||||
function amicablePairsUpTo(maxNum) {
|
||||
// Good luck!
|
||||
return true;
|
||||
}
|
||||
@ -86,7 +86,7 @@ const answer20000 = [
|
||||
|
||||
```js
|
||||
// amicablePairsUpTo :: Int -> [(Int, Int)]
|
||||
function amicablePairsUpTo (maxNum) {
|
||||
function amicablePairsUpTo(maxNum) {
|
||||
return range(1, maxNum)
|
||||
.map(x => properDivisors(x)
|
||||
.reduce((a, b) => a + b, 0))
|
||||
@ -101,7 +101,7 @@ function amicablePairsUpTo (maxNum) {
|
||||
}
|
||||
|
||||
// properDivisors :: Int -> [Int]
|
||||
function properDivisors (n) {
|
||||
function properDivisors(n) {
|
||||
if (n < 2) return [];
|
||||
|
||||
const rRoot = Math.sqrt(n);
|
||||
@ -117,7 +117,7 @@ function properDivisors (n) {
|
||||
}
|
||||
|
||||
// Int -> Int -> Maybe Int -> [Int]
|
||||
function range (m, n, step) {
|
||||
function range(m, n, step) {
|
||||
const d = (step || 1) * (n >= m ? 1 : -1);
|
||||
|
||||
return Array.from({
|
||||
|
@ -36,7 +36,7 @@ tests:
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
function mode (arr) {
|
||||
function mode(arr) {
|
||||
// Good luck!
|
||||
return true;
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ tests:
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
function pythagoreanMeans (rangeArr) {
|
||||
function pythagoreanMeans(rangeArr) {
|
||||
// Good luck!
|
||||
}
|
||||
```
|
||||
@ -88,7 +88,7 @@ const answer1 = {
|
||||
|
||||
|
||||
```js
|
||||
function pythagoreanMeans (rangeArr) {
|
||||
function pythagoreanMeans(rangeArr) {
|
||||
// arithmeticMean :: [Number] -> Number
|
||||
const arithmeticMean = xs =>
|
||||
foldl((sum, n) => sum + n, 0, xs) / length(xs);
|
||||
|
@ -37,7 +37,7 @@ tests:
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
function rms (arr) {
|
||||
function rms(arr) {
|
||||
// Good luck!
|
||||
}
|
||||
```
|
||||
@ -62,7 +62,7 @@ const answer1 = 6.2048368229954285;
|
||||
|
||||
|
||||
```js
|
||||
function rms (arr) {
|
||||
function rms(arr) {
|
||||
const sumOfSquares = arr.reduce((s, x) => s + x * x, 0);
|
||||
return Math.sqrt(sumOfSquares / arr.length);
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ tests:
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
function babbage (babbageNum, endDigits) {
|
||||
function babbage(babbageNum, endDigits) {
|
||||
// Good luck!
|
||||
return true;
|
||||
}
|
||||
@ -68,7 +68,7 @@ const answer = 25264;
|
||||
|
||||
|
||||
```js
|
||||
function babbage (babbageAns, endDigits) {
|
||||
function babbage(babbageAns, endDigits) {
|
||||
const babbageNum = Math.pow(babbageAns, 2);
|
||||
const babbageStartDigits = parseInt(babbageNum.toString().replace('269696', ''));
|
||||
let answer = 99736;
|
||||
|
@ -78,7 +78,7 @@ tests:
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
function isBalanced (str) {
|
||||
function isBalanced(str) {
|
||||
// Good luck!
|
||||
return true;
|
||||
}
|
||||
@ -122,7 +122,7 @@ const testCases = [
|
||||
|
||||
|
||||
```js
|
||||
function isBalanced (str) {
|
||||
function isBalanced(str) {
|
||||
if (str === '') return true;
|
||||
let a = str;
|
||||
let b;
|
||||
|
@ -68,7 +68,7 @@ tests:
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
function getCircles (...args) {
|
||||
function getCircles(...args) {
|
||||
// Good luck!
|
||||
return true;
|
||||
}
|
||||
@ -111,7 +111,7 @@ const pAng = (p1, p2) => Math.atan(p1.map((e, i) => e - p2[i]).reduce((p, c) =>
|
||||
const solveF = (p, r) => t => [parseFloat((r * Math.cos(t) + p[0]).toFixed(4)), parseFloat((r * Math.sin(t) + p[1]).toFixed(4))];
|
||||
const diamPoints = (p1, p2) => p1.map((e, i) => parseFloat((e + (p2[i] - e) / 2).toFixed(4)));
|
||||
|
||||
function getCircles (...args) {
|
||||
function getCircles(...args) {
|
||||
const [p1, p2, s] = args;
|
||||
const solve = solveF(p1, s);
|
||||
const halfDist = hDist(p1, p2);
|
||||
|
@ -102,18 +102,18 @@ tests:
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
const Point = function (x, y) {
|
||||
const Point = function(x, y) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
};
|
||||
Point.prototype.getX = function () {
|
||||
Point.prototype.getX = function() {
|
||||
return this.x;
|
||||
};
|
||||
Point.prototype.getY = function () {
|
||||
Point.prototype.getY = function() {
|
||||
return this.y;
|
||||
};
|
||||
|
||||
function getClosestPair (pointsArr) {
|
||||
function getClosestPair(pointsArr) {
|
||||
// Good luck!
|
||||
return true;
|
||||
}
|
||||
@ -238,14 +238,14 @@ const benchmarkPoints = [
|
||||
|
||||
|
||||
```js
|
||||
const Point = function (x, y) {
|
||||
const Point = function(x, y) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
};
|
||||
Point.prototype.getX = function () {
|
||||
Point.prototype.getX = function() {
|
||||
return this.x;
|
||||
};
|
||||
Point.prototype.getY = function () {
|
||||
Point.prototype.getY = function() {
|
||||
return this.y;
|
||||
};
|
||||
|
||||
@ -344,9 +344,9 @@ const closestPair = function _closestPair(Px, Py) {
|
||||
};
|
||||
};
|
||||
|
||||
function getClosestPair (points) {
|
||||
const sortX = function (a, b) { return (a.x < b.x) ? -1 : ((a.x > b.x) ? 1 : 0); }
|
||||
const sortY = function (a, b) { return (a.y < b.y) ? -1 : ((a.y > b.y) ? 1 : 0); }
|
||||
function getClosestPair(points) {
|
||||
const sortX = function(a, b) { return (a.x < b.x) ? -1 : ((a.x > b.x) ? 1 : 0); }
|
||||
const sortY = function(a, b) { return (a.y < b.y) ? -1 : ((a.y > b.y) ? 1 : 0); }
|
||||
|
||||
const Px = mergeSort(points, sortX);
|
||||
const Py = mergeSort(points, sortY);
|
||||
|
@ -50,7 +50,7 @@ tests:
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
function combinations (m, n) {
|
||||
function combinations(m, n) {
|
||||
// Good luck!
|
||||
return true;
|
||||
}
|
||||
@ -79,7 +79,7 @@ const testOutput2 = [[0, 1, 2, 3], [0, 1, 2, 4], [0, 1, 2, 5], [0, 1, 3, 4], [0,
|
||||
|
||||
|
||||
```js
|
||||
function combinations (m, n) {
|
||||
function combinations(m, n) {
|
||||
const nArr = [...Array(n).keys()];
|
||||
|
||||
return (function generateCombinations (size, numArr) {
|
||||
|
@ -57,7 +57,7 @@ tests:
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
function quibble (words) {
|
||||
function quibble(words) {
|
||||
// Good luck!
|
||||
return true;
|
||||
}
|
||||
@ -83,7 +83,7 @@ const results = ["{}", "{ABC}", "{ABC and DEF}", "{ABC,DEF,G and H}"];
|
||||
|
||||
|
||||
```js
|
||||
function quibble (words) {
|
||||
function quibble(words) {
|
||||
return "{" +
|
||||
words.slice(0, words.length - 1).join(",") +
|
||||
(words.length > 1 ? " and " : "") +
|
||||
|
@ -58,12 +58,12 @@ tests:
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
function allEqual (arr) {
|
||||
function allEqual(arr) {
|
||||
// Good luck!
|
||||
return true;
|
||||
}
|
||||
|
||||
function azSorted (arr) {
|
||||
function azSorted(arr) {
|
||||
// Good luck!
|
||||
return true;
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ tests:
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
function convertSeconds (sec) {
|
||||
function convertSeconds(sec) {
|
||||
// Good luck!
|
||||
return true;
|
||||
}
|
||||
@ -139,7 +139,7 @@ const results = ['2 hr, 59 sec', '1 d', '9 wk, 6 d, 10 hr, 40 min'];
|
||||
|
||||
|
||||
```js
|
||||
function convertSeconds (sec) {
|
||||
function convertSeconds(sec) {
|
||||
const localNames = ['wk', 'd', 'hr', 'min', 'sec'];
|
||||
// compoundDuration :: [String] -> Int -> String
|
||||
const compoundDuration = (labels, intSeconds) =>
|
||||
|
@ -46,7 +46,7 @@ tests:
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
function countSubstring (str, subStr) {
|
||||
function countSubstring(str, subStr) {
|
||||
// Good luck!
|
||||
return true;
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ tests:
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
function countCoins () {
|
||||
function countCoins() {
|
||||
// Good luck!
|
||||
return true;
|
||||
}
|
||||
@ -71,7 +71,7 @@ function countCoins () {
|
||||
|
||||
|
||||
```js
|
||||
function countCoins () {
|
||||
function countCoins() {
|
||||
let t = 100;
|
||||
const operands = [1, 5, 10, 25];
|
||||
const targetsLength = t + 1;
|
||||
|
@ -59,7 +59,7 @@ tests:
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
function cramersRule (matrix, freeTerms) {
|
||||
function cramersRule(matrix, freeTerms) {
|
||||
// Good luck!
|
||||
return true;
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ tests:
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
function standardDeviation (arr) {
|
||||
function standardDeviation(arr) {
|
||||
// Good luck!
|
||||
}
|
||||
```
|
||||
@ -54,7 +54,7 @@ function standardDeviation (arr) {
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
function standardDeviation (arr) {
|
||||
function standardDeviation(arr) {
|
||||
var sum = 0,
|
||||
sum_sq = 0,
|
||||
n = arr.length;
|
||||
|
@ -49,7 +49,7 @@ tests:
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
function isCusip (s) {
|
||||
function isCusip(s) {
|
||||
// Good luck!
|
||||
}
|
||||
```
|
||||
@ -61,7 +61,7 @@ function isCusip (s) {
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
function isCusip (s) {
|
||||
function isCusip(s) {
|
||||
if (s.length != 9) return false;
|
||||
var sum = 0;
|
||||
var ASCII = x => x.charCodeAt(0);
|
||||
|
@ -48,7 +48,7 @@ tests:
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
function cutRectangle (w, h) {
|
||||
function cutRectangle(w, h) {
|
||||
// Good luck!
|
||||
}
|
||||
```
|
||||
@ -60,7 +60,7 @@ function cutRectangle (w, h) {
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
function cutRectangle (w, h) {
|
||||
function cutRectangle(w, h) {
|
||||
if (w % 2 == 1 && h % 2 == 1)
|
||||
return;
|
||||
|
||||
|
@ -43,7 +43,7 @@ tests:
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
function getDateFormats () {
|
||||
function getDateFormats() {
|
||||
// Good luck!
|
||||
return true;
|
||||
}
|
||||
@ -78,7 +78,7 @@ const equalsMessage = `message: <code>getDataFormats()</code> should return <cod
|
||||
|
||||
|
||||
```js
|
||||
function getDateFormats () {
|
||||
function getDateFormats() {
|
||||
const date = new Date();
|
||||
const weekdays = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
|
||||
const months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
|
||||
|
@ -46,7 +46,7 @@ tests:
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
function add12Hours (dateString) {
|
||||
function add12Hours(dateString) {
|
||||
// Good luck!
|
||||
return true;
|
||||
}
|
||||
@ -61,7 +61,7 @@ function add12Hours (dateString) {
|
||||
|
||||
|
||||
```js
|
||||
function add12Hours (dateString) {
|
||||
function add12Hours(dateString) {
|
||||
const months = ['January', 'February', 'March', 'April', 'May', 'June',
|
||||
'July', 'August', 'September', 'October', 'November', 'December'];
|
||||
// Get the parts of the string
|
||||
|
@ -39,7 +39,7 @@ tests:
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
function findXmasSunday (start, end) {
|
||||
function findXmasSunday(start, end) {
|
||||
// Good luck!
|
||||
return true;
|
||||
}
|
||||
@ -65,7 +65,7 @@ const secondSolution = [2011, 2016, 2022, 2033, 2039, 2044, 2050, 2061, 2067, 20
|
||||
|
||||
|
||||
```js
|
||||
function findXmasSunday (start, end) {
|
||||
function findXmasSunday(start, end) {
|
||||
const xmasSunday = [];
|
||||
for (let year = start; year <= end; year++) {
|
||||
const xmas = new Date(year, 11, 25);
|
||||
|
@ -91,7 +91,7 @@ tests:
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
function dealFreeCell (seed) {
|
||||
function dealFreeCell(seed) {
|
||||
// Good luck!
|
||||
return true;
|
||||
}
|
||||
@ -135,7 +135,7 @@ const game617 = [
|
||||
|
||||
```js
|
||||
// RNG
|
||||
function FreeCellRNG (seed) {
|
||||
function FreeCellRNG(seed) {
|
||||
return {
|
||||
lastNum: seed,
|
||||
next() {
|
||||
|
@ -47,7 +47,7 @@ tests:
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
function deepcopy (obj) {
|
||||
function deepcopy(obj) {
|
||||
// Good luck!
|
||||
return true;
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ tests:
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
function Num (n) {
|
||||
function Num(n) {
|
||||
// Good luck!
|
||||
return n;
|
||||
}
|
||||
|
Reference in New Issue
Block a user