-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
61 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#!/usr/bin/env node | ||
|
||
import app from '../src/index.js'; | ||
import calc from '../src/calc.js'; | ||
import calc from '../src/games/calc.js'; | ||
|
||
app(calc); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#!/usr/bin/env node | ||
|
||
import app from '../src/index.js'; | ||
import even from '../src/even.js'; | ||
import even from '../src/games/even.js'; | ||
|
||
app(even); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#!/usr/bin/env node | ||
|
||
import app from '../src/index.js'; | ||
import gcd from '../src/gcd.js'; | ||
import gcd from '../src/games/gcd.js'; | ||
|
||
app(gcd); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#!/usr/bin/env node | ||
|
||
import app from '../src/index.js'; | ||
import prime from '../src/prime.js'; | ||
import prime from '../src/games/prime.js'; | ||
|
||
app(prime); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#!/usr/bin/env node | ||
|
||
import app from '../src/index.js'; | ||
import progression from '../src/progression.js'; | ||
import progression from '../src/games/progression.js'; | ||
|
||
app(progression); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import predicateGame from '../utils/predicateGame.js'; | ||
|
||
const isEven = (num) => num % 2 === 0; | ||
const even = (questionCount = 3) => predicateGame(isEven, questionCount); | ||
|
||
export default even; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import predicateGame from '../utils/predicateGame.js'; | ||
|
||
const isPrime = (num) => { | ||
if (num < 2) { | ||
return false; | ||
} | ||
const halfNum = Math.floor(num / 2); | ||
for (let i = halfNum; i > 1; i -= 1) { | ||
if (num % i === 0) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
}; | ||
const prime = (questionCount = 3) => predicateGame(isPrime, questionCount); | ||
|
||
export default prime; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import randomize from './randomize.js'; | ||
|
||
const predicateGame = (predicateFunc, questionCount) => { | ||
const rules = 'Answer "yes" if given number is prime. Otherwise answer "no".'; | ||
const questionsAnswers = []; | ||
for (let i = 0; i < questionCount; i += 1) { | ||
const number = randomize(0, 100); | ||
const correctAnswer = predicateFunc(number) ? 'yes' : 'no'; | ||
questionsAnswers.push({ | ||
question: number, | ||
correctAnswer, | ||
}); | ||
} | ||
return { rules, questionsAnswers }; | ||
}; | ||
|
||
export default predicateGame; |