Skip to content

Commit 855e8f6

Browse files
committed
Run prettier
1 parent 29f04a7 commit 855e8f6

File tree

48 files changed

+914
-619
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+914
-619
lines changed

README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ A [code golf](https://en.wikipedia.org/wiki/Code_golf) game server for JavaScrip
44

55
## Running
66

7-
+ Clone the repo
8-
+ Install dependencies via `npm install`
9-
+ Set the `CG_ADMIN_PASSWORD` environment variable to secure access the the `/admin` page (see package.json `start` script)
10-
+ Start the server locally via `npm start`
7+
- Clone the repo
8+
- Install dependencies via `npm install`
9+
- Set the `CG_ADMIN_PASSWORD` environment variable to secure access the the `/admin` page (see package.json `start` script)
10+
- Start the server locally via `npm start`
1111

1212
## URLs
1313

@@ -39,7 +39,7 @@ Players must write a script containing their solution. The solution must be a si
3939

4040
```js
4141
const play = (input) => {
42-
return "your answer";
42+
return 'your answer';
4343
};
4444

4545
module.exports = play;
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,6 @@
11
{
22
"title": "Narcissistic Number Generator",
3-
"input": [
4-
5,
5-
400
6-
],
7-
"output": [
8-
407,
9-
1634,
10-
8208,
11-
9474,
12-
54748
13-
],
3+
"input": [5, 400],
4+
"output": [407, 1634, 8208, 9474, 54748],
145
"description": "Generate the next X narcissistic numbers larger than the number Y, where your play function is called with the array [X, Y]. Return your answer in an array."
15-
}
6+
}

challenges/es5-4-never-gonna-give-you-up/challenge.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
"input": null,
44
"output": "We're no strangers to love\nYou know the rules and so do I\nA full commitment's what I'm thinking of\nYou wouldn't get this from any other guy\nI just wanna tell you how I'm feeling\nGotta make you understand\n\nNever gonna give you up\nNever gonna let you down\nNever gonna run around and desert you\nNever gonna make you cry\nNever gonna say goodbye\nNever gonna tell a lie and hurt you\n\nWe've known each other for so long\nYour heart's been aching but\nYou're too shy to say it\nInside we both know what's been going on\nWe know the game and we're gonna play it\nAnd if you ask me how I'm feeling\nDon't tell me you're too blind to see\n\nNever gonna give you up\nNever gonna let you down\nNever gonna run around and desert you\nNever gonna make you cry\nNever gonna say goodbye\nNever gonna tell a lie and hurt you\n\nNever gonna give you up\nNever gonna let you down\nNever gonna run around and desert you\nNever gonna make you cry\nNever gonna say goodbye\nNever gonna tell a lie and hurt you\n\n(Ooh, give you up)\n(Ooh, give you up)\n(Ooh)\nNever gonna give, never gonna give\n(Give you up)\n(Ooh)\nNever gonna give, never gonna give\n(Give you up)\n\nWe've know each other for so long\nYour heart's been aching but\nYou're too shy to say it\nInside we both know what's been going on\nWe know the game and we're gonna play it\n\nI just wanna tell you how I'm feeling\nGotta make you understand\n\nNever gonna give you up\nNever gonna let you down\nNever gonna run around and desert you\nNever gonna make you cry\nNever gonna say goodbye\nNever gonna tell a lie and hurt you\n\nNever gonna give you up\nNever gonna let you down\nNever gonna run around and desert you\nNever gonna make you cry\nNever gonna say goodbye\nNever gonna tell a lie and hurt you\n\nNever gonna give you up\nNever gonna let you down\nNever gonna run around and desert you\nNever gonna make you cry\nNever gonna say goodbye\nNever gonna tell a lie and hurt you",
55
"description": "Write the shortest program that returns the entire lyrics of \"NeverGonnaGiveYouUp\" by Rick Astley. Your output must match exactly the format here: http://pastebin.com/raw.php?i=wwvdjvEj"
6-
}
6+
}

challenges/es5-5-caesar-cipher/challenge.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
"input": "aabbbxXxyyzzzz",
44
"output": "nnoookKkllmmmm",
55
"description": "Implement a ROT13 cipher that preserves case. Only a-zA-Z characters need to be considered. Your play function will be called with a string, return a ROT13 version of the string."
6-
}
6+
}

challenges/es6-1-palindromes/challenge.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1164,4 +1164,4 @@
11641164
],
11651165
"output": 1074,
11661166
"description": "Your play function will be called with an array containing words. You must return the total number of words contained within the array that are valid palindromes (https://en.wikipedia.org/wiki/Palindrome)."
1167-
}
1167+
}

challenges/es6-2-word-count/challenge.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
],
77
"output": 540,
88
"description": "Your play function will be called with an array [x,y], where x is a block of text to search, and y is the word to search for within x. Return the number of times the word y was found within the text x. The algorithm should be case insensitive."
9-
}
9+
}
+5-37
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,12 @@
11
{
22
"title": "ES6 Deduplication",
33
"input": [
4-
350,
5-
10,
6-
8807,
7-
2584,
8-
6454,
9-
9911,
10-
17711,
11-
4754,
12-
3835,
13-
4481,
14-
17711,
15-
210,
16-
25000,
17-
1,
18-
4481,
19-
12,
20-
6454,
21-
4481,
22-
4754,
23-
1
4+
350, 10, 8807, 2584, 6454, 9911, 17711, 4754, 3835, 4481, 17711, 210, 25000,
5+
1, 4481, 12, 6454, 4481, 4754, 1
246
],
257
"output": [
26-
350,
27-
10,
28-
8807,
29-
2584,
30-
6454,
31-
9911,
32-
17711,
33-
4754,
34-
3835,
35-
4481,
36-
17711,
37-
210,
38-
25000,
39-
1,
40-
12,
41-
1
8+
350, 10, 8807, 2584, 6454, 9911, 17711, 4754, 3835, 4481, 17711, 210, 25000,
9+
1, 12, 1
4210
],
4311
"description": "Your play function will be called with an array of numbers. Return a new array with duplicates removed, maintaining the original order. Oh, but we like duplicates that are Fibonacci numbers, so don't remove them."
44-
}
12+
}

challenges/es6-4-ascii-art/challenge.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
"input": null,
44
"output": "................................................................\n................................................................\n................................................................\n................................................................\n................................................................\n................................................................\n................................................................\n................................................................\n........################################################........\n........#..............................................#........\n........#..............................................#........\n........#..............................................#........\n........#...################........################...#........\n........#...#..............#........#..............#...#........\n........#...#..............#........#..............#...#........\n........#...#..............#........#..............#...#........\n........#...#..............#........#..............#...#........\n........#...#..............#........#..............#...#........\n........#...#..............#........#..............#...#........\n........#...#..............#........#..............#...#........\n........#...#..............#........#..............#...#........\n........#...#..............#........#..............#...#........\n........#...#..............#........#..............#...#........\n........#...#..............#........#..............#...#........\n........#...#..............#........#..............#...#........\n........#...#..............#........#..............#...#........\n........#...#..............#........#..............#...#........\n........#...################........################...#........\n........#..............................................#........\n........#..............................................#........\n........#..............................................#........\n........#..............................................#........\n........#..............................................#........\n........#..............................................#........\n........#..............................................#........\n........#..............................................#........\n........#..............................................#........\n........#..............................................#........\n........#..............................................#........\n........#..............................................#........\n........#...########################################...#........\n........#...#......................................#...#........\n........#...#......................................#...#........\n........#...#......................................#...#........\n........#...#......................................#...#........\n........#...#......................................#...#........\n........#...#......................................#...#........\n........#...#......................................#...#........\n........#...#......................................#...#........\n........#...#......................................#...#........\n........#...#......................................#...#........\n........#...########################################...#........\n........#..............................................#........\n........#..............................................#........\n........#..............................................#........\n........################################################........\n................................................................\n................................................................\n................................................................\n................................................................\n................................................................\n................................................................\n................................................................\n................................................................",
55
"description": "Your play function will be called with no input. Generate the following ASCII art and return it as a string, exactly as shown here: http://pastebin.com/raw.php?i=YsPK5Vdm"
6-
}
6+
}

jest.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
module.exports = {
22
preset: 'ts-jest',
33
testEnvironment: 'node',
4-
};
4+
};

public/css/app.css

+4-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ label span {
2323
color: #aaa;
2424
}
2525

26-
input[type='text'], textarea {
26+
input[type='text'],
27+
textarea {
2728
color: #555;
2829
padding: 8px;
2930
border: solid 1px #ccc;
@@ -177,7 +178,7 @@ code {
177178

178179
.bs-callout-danger {
179180
background-color: #fcf2f2;
180-
border-color: #dFb5b4;
181+
border-color: #dfb5b4;
181182
}
182183

183184
.bs-callout-warning {
@@ -202,4 +203,4 @@ code {
202203
.challenge-example {
203204
font-family: Courier, monospace;
204205
font-size: inherit;
205-
}
206+
}

src/challenges/c0-hello-world/index.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import type { Challenge } from "..";
2-
import solution from "./solution";
1+
import type { Challenge } from '..';
2+
import solution from './solution';
33

44
const challenge: Challenge = {
5-
input: "",
6-
title: "Hello World",
5+
input: '',
6+
title: 'Hello World',
77
output: solution(),
88
description: `Write a function that returns "Hello, World!".`,
99
example: `⟶ "Hello, World!"`,

src/challenges/c1-number-reader/index.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import type { Challenge } from "..";
2-
import solution from "./solution";
1+
import type { Challenge } from '..';
2+
import solution from './solution';
33

44
const input = 877209536;
55

66
const challenge: Challenge = {
77
input,
8-
title: "Number Reader",
8+
title: 'Number Reader',
99
output: solution(input),
1010
description: `Write a function that takes a number and converts it to the equivalant string.`,
1111
example: `12341 ⟶ "one two three four one"`,

src/challenges/c10-array-flatten/index.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
import type { Challenge } from "..";
2-
import solution from "./solution";
1+
import type { Challenge } from '..';
2+
import solution from './solution';
33

44
const input = [
55
[1, 2, 3, 4, 5],
6-
["unu", "du", "tri", "kvar", "kvin"],
7-
["v", "w", "x", "y", "z"],
6+
['unu', 'du', 'tri', 'kvar', 'kvin'],
7+
['v', 'w', 'x', 'y', 'z'],
88
];
99

1010
const challenge: Challenge = {
1111
input,
12-
title: "Array Flatten",
12+
title: 'Array Flatten',
1313
output: solution(input),
1414
description: `Write a function that takes an array of three other arrays and returns a single, flattened array. The second array's values should remain in the middle, but the first and third should be swapped.`,
1515
example: `[[4, 5, 6], ["a", "b", "c"], [1, 2, 3]] ⟶ [1, 2, 3, "a", "b", "c", 4, 5, 6]`,

src/challenges/c11-word-count/index.ts

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
import type { Challenge } from "..";
2-
import solution from "./solution";
1+
import type { Challenge } from '..';
2+
import solution from './solution';
33

4-
const input = "A purely peer-to-peer version of electronic cash would allow online payments to be sent directly from one party to another without going through a financial institution. Digital signatures provide part of the solution, but the main benefits are lost if a trusted third party is still required to prevent double-spending. We propose a solution to the double-spending problem using a peer-to-peer network. The network timestamps transactions by hashing them into an ongoing chain of hash-based proof-of-work, forming a record that cannot be changed without redoing the proof-of-work. The longest chain not only serves as proof of the sequence of events witnessed, but proof that it came from the largest pool of CPU power. As long as a majority of CPU power is controlled by nodes that are not cooperating to attack the network, they'll generate the longest chain and outpace attackers. The network itself requires minimal structure. Messages are broadcast on a best effort basis, and nodes can leave and rejoin the network at will, accepting the longest proof-of-work chain as proof of what happened while they were gone .";
4+
const input =
5+
"A purely peer-to-peer version of electronic cash would allow online payments to be sent directly from one party to another without going through a financial institution. Digital signatures provide part of the solution, but the main benefits are lost if a trusted third party is still required to prevent double-spending. We propose a solution to the double-spending problem using a peer-to-peer network. The network timestamps transactions by hashing them into an ongoing chain of hash-based proof-of-work, forming a record that cannot be changed without redoing the proof-of-work. The longest chain not only serves as proof of the sequence of events witnessed, but proof that it came from the largest pool of CPU power. As long as a majority of CPU power is controlled by nodes that are not cooperating to attack the network, they'll generate the longest chain and outpace attackers. The network itself requires minimal structure. Messages are broadcast on a best effort basis, and nodes can leave and rejoin the network at will, accepting the longest proof-of-work chain as proof of what happened while they were gone .";
56

67
const challenge: Challenge = {
78
input,
8-
title: "Word Count",
9+
title: 'Word Count',
910
output: solution(input),
1011
description: `Write a function that takes a string of text and returns the word count. A valid word is anything not made up of only of spaces or punctuation.`,
1112
example: `"You know what would make a great coffee table book? A coffee table book about coffee tables! Get it?" ⟶ 19, "Hello world ." ⟶ 2`,

src/challenges/c12-remainder/index.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import type { Challenge } from "..";
2-
import solution from "./solution";
1+
import type { Challenge } from '..';
2+
import solution from './solution';
33

44
const input = [7362, 392];
55

66
const challenge: Challenge = {
77
input,
8-
title: "Remainder",
8+
title: 'Remainder',
99
output: solution(input),
1010
description: `Write a function that takes an array of two numbers – the first the dividend, the second the divisor – and returns the remainder.`,
1111
example: `[10, 2] ⟶ 0, [25, 4] ⟶ 1, [12, 7] ⟶ 5`,
+5-19
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,16 @@
11
import { Challenge } from '..';
22
import solution from './solution';
33

4-
const input = [
5-
10,
6-
1,
7-
150,
8-
34,
9-
300,
10-
250,
11-
12,
12-
22,
13-
23,
14-
65,
15-
33,
16-
16,
17-
1,
18-
2,
19-
];
4+
const input = [10, 1, 150, 34, 300, 250, 12, 22, 23, 65, 33, 16, 1, 2];
205

216
const challenge: Challenge = {
227
input,
23-
title: "Sort The Numbers",
8+
title: 'Sort The Numbers',
249
output: solution(input),
25-
description: "Write a function that takes an array of numbers and returns a sorted array in ascending order.",
10+
description:
11+
'Write a function that takes an array of numbers and returns a sorted array in ascending order.',
2612
example: `[3, 5, 2, 4, 1] ⟶ [1, 2, 3, 4, 5]`,
27-
rules: ["no-sort"],
13+
rules: ['no-sort'],
2814
};
2915

3016
export = challenge;

src/challenges/c3-number-to-words/index.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { Challenge } from "..";
2-
import solution from "./solution";
1+
import { Challenge } from '..';
2+
import solution from './solution';
33

44
const input = 743243892;
55

66
const challenge: Challenge = {
77
input,
8-
title: "Number To Words",
8+
title: 'Number To Words',
99
output: solution(input),
1010
description: `Write a function that takes a number and converts it to words.`,
1111
example: `2 ⟶ "two", 301 ⟶ "three hundred one", 12341 ⟶ "twelve thousand three hundred forty one", 1290489 ⟶ "one million two hundred ninety thousand four hundred eighty nine"`,

src/challenges/c4-roman-numerals/index.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { Challenge } from "..";
2-
import solution from "./solution";
1+
import { Challenge } from '..';
2+
import solution from './solution';
33

44
const input = 2476;
55

66
const challenge: Challenge = {
77
input,
8-
title: "Roman Numerals",
8+
title: 'Roman Numerals',
99
output: solution(input),
1010
description: `Write a function that converts numbers to roman numerals.`,
1111
example: `23 ⟶ "XXIII", 2743 ⟶ "MMDCCXLIII"`,

src/challenges/c5-add/index.ts

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1-
import { Challenge } from "..";
2-
import solution from "./solution";
1+
import { Challenge } from '..';
2+
import solution from './solution';
33

44
const input: [number, number] = [64722, 87549];
55

66
const challenge: Challenge = {
77
input,
8-
title: "Add",
8+
title: 'Add',
99
output: solution(input),
10-
description: "Write a function to add two numbers without using the plus operator. The function will be called with an array of two numbers and should return the sum.",
10+
description:
11+
'Write a function to add two numbers without using the plus operator. The function will be called with an array of two numbers and should return the sum.',
1112
example: `[3, 4] ⟶ 7, [100, 200] ⟶ 300`,
12-
rules: ["no-add", "no-eval"],
13+
rules: ['no-add', 'no-eval'],
1314
};
1415

1516
export = challenge;

0 commit comments

Comments
 (0)