Skip to content

Commit 87d81ae

Browse files
author
Andrei Volchenko
committed
🐣 initial commit
0 parents  commit 87d81ae

10 files changed

+3199
-0
lines changed

.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.DS_Store
2+
node_modules
3+
app.bundle.js
4+
app.bundle.js.map
5+
npm-debug*

README.md

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
### Guessing game
2+
3+
---
4+
⚠️ DO NOT SUBMIT PRS WITH SOLUTIONS TO THIS REPO ⚠️
5+
6+
### Description
7+
8+
Your task is to implement `GuessingGame` class
9+
10+
#### Methods:
11+
12+
##### `setRange(min, max)`
13+
this method accepts min and max value of range of number to guess
14+
15+
##### `guess()`
16+
this method returns solution candidate (you make an assumption based on range and previous assumptions)
17+
18+
##### `lower()`
19+
this method is called if prev call of `guess()` returned number which is lower than answer
20+
21+
##### `greater()`
22+
this method is called if prev call of `guess()` returned number which is greater than answer
23+
24+
Your implementation should use [binary search algorithm](https://en.wikipedia.org/wiki/Binary_search_algorithm) under the hood to pass all tests
25+
26+
### Prerequisites
27+
* Install [nodejs](https://nodejs.org/en/) (>= v6.9.4)
28+
* open bash in this folder
29+
* `npm install`
30+
31+
### Run tests
32+
```sh
33+
npm test
34+
```
35+
36+
### Run in browser
37+
```sh
38+
npm start
39+
```
40+
41+
open http://localhost:8080
42+
43+
---
44+
45+
© [R1ZZU](https://github.com/R1ZZU)

index.html

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Document</title>
6+
<style>
7+
body {
8+
margin: 0;
9+
}
10+
</style>
11+
</head>
12+
<body>
13+
<script src="./app.bundle.js"></script>
14+
</body>
15+
</html>

index.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
const GuessingGame = require('./src/guessing-game.js');
2+
3+
window.game = new GuessingGame();

package.json

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "guessing-game",
3+
"version": "1.0.0",
4+
"description": "",
5+
"scripts": {
6+
"test": "mocha -r ./test/setup-mocha.js",
7+
"start": "webpack-dev-server"
8+
},
9+
"author": "",
10+
"license": "ISC",
11+
"devDependencies": {
12+
"chai": "^3.5.0",
13+
"mocha": "^3.0.2",
14+
"sinon": "^1.17.5",
15+
"sinon-chai": "^2.8.0",
16+
"webpack": "^1.13.1",
17+
"webpack-dev-server": "^1.14.1"
18+
}
19+
}

score-weight.json

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"GuessingGame": {
3+
"weight": 100,
4+
"suitesWeights": {
5+
"#guess": 100
6+
}
7+
}
8+
}

src/guessing-game.js

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
class GuessingGame {
2+
constructor() {}
3+
4+
setRange(min, max) {
5+
6+
}
7+
8+
guess() {
9+
10+
}
11+
12+
lower() {
13+
14+
}
15+
16+
greater() {
17+
18+
}
19+
}
20+
21+
module.exports = GuessingGame;

0 commit comments

Comments
 (0)