Skip to content

Commit

Permalink
week 18 challenge
Browse files Browse the repository at this point in the history
  • Loading branch information
arcanous committed May 5, 2021
1 parent f4cbc8c commit 7671fb8
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 1 deletion.
37 changes: 37 additions & 0 deletions 2021/w18/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Week 18 challenge

![Vegeta with scouter](image.jpg)

You've been tasked to help Vegeta read data from his scouter. Unfortunately he can't read digits because of the shitty free font used by the developers. Please write a script that accepts a number as input and gives back the number as text.

Examples:
```
getSaiyanLevel(0); // zero
getSaiyanLevel(10); // ten
getSaiyanLevel(30); // thirty
getSaiyanLevel(5000); // five thousand
getSaiyanLevel(1234); // one thousand two hundred and thirty four
```

Since Vegeta doesn't comprehend levels beyond 9000 just let him know:

```
getSaiyanLevel(9001); // it's over 9000!
```

## Background
![meme origin](over9000.png)

[Over 9000 on Wikipedia](https://en.wikipedia.org/wiki/It%27s_Over_9000!)

## Author

Mettin

## Upload link

[https://forms.gle/Q9ZHpSfHJVpNE3U49]


## Results

Binary file added 2021/w18/image.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 2021/w18/over9000.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions 2021/w18/solutions/solution.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const getSaiyanLevel = (input) => {
// your solution here

return undefined;
};

module.exports = getSaiyanLevel;
1 change: 1 addition & 0 deletions 2021/w18/test-cases/spec.json

Large diffs are not rendered by default.

28 changes: 28 additions & 0 deletions 2021/w18/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const fs = require("fs");
const path = require("path");
const spec = require("./test-cases/spec.json");
const solutions = fs.readdirSync(path.resolve(__dirname, "solutions"));

describe.each(solutions)("%s", (filename) => {
const evaluate = require(path.resolve(__dirname, "solutions", filename));
test.each([
[0, 'zero'],
[1, 'one'],
[100, 'one hundred'],
[200, 'two hundred'],
[40, 'forty'],
[420, 'four hundred and twenty'],
[1234, 'one thousand two hundred and thirty four'],
[9001, 'it\'s over nine thousand!'],
])("%j = %j", (input, result) => {
expect(evaluate(input)).toBe(result);
});

test.each(spec.map(({ inputs, result }) => [inputs[0], result]))(
"%j = %j",
(input, result) => {
expect(evaluate(input)).toEqual(result);
}
);

});
2 changes: 1 addition & 1 deletion evaluate.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const { table } = require('table');
const humanizeDuration = require('humanize-duration');

// update for challenge you wish to evaluate, what is the tie margin and amount of default runs
const CHALLENGE = '2021/w17';
const CHALLENGE = '2021/w18';
const PERCENT_MARGIN_FOR_TIE = 5;
const TIMES_TO_EVAL_EACH = parseInt(process.argv[2], 10) || 1000;
const LOG_PAD = 35;
Expand Down

0 comments on commit 7671fb8

Please sign in to comment.