Beta
Weird Factory
Description:
On a secret factory two types of waste products are being stored. type A - radioactive and type B - safe. They are all being packed in special boxes and stored in lines. A line of boxes is considered explosive if it has at least 3 radioactive boxes in a row.
Your task is to write a function explosiveAmount that returns a total amount of explosive combinations for a given number of boxes N.
The output may be REALLY big so you will have to use BigNumber.js library. It is a library for arbitrary-precision arithmetic.
Here are some basic tools that you can use:
let a = new BigNumber(10);
//creates a BigNumber object with a value of 10.
let b = a.plus(2);
//adds 2 to a.
let b = a.minus(2);
//subtracts 2 from a.
let b = a.times(2);
//multiplies a by 2.
let b = a.divide(2);
//divides a by 2.
let b = a.pow(2);
//raises a to the power of 2.
a.equals(b);
//checks if a is equal to b.
Expected behavior:
explosiveAmount(5);
//should return new BigNumber(8).
explosiveAmount(2);
//should return new BigNumber(0).
explosiveAmount(-10);
//should return new BigNumber(0).
Good luck!
https://github.com/MikeMcl/bignumber.js/ - if you want to play around with BigNumber.js yourself.
Algorithms
Similar Kata:
Stats:
Created | Oct 3, 2018 |
Published | Oct 9, 2018 |
Warriors Trained | 136 |
Total Skips | 89 |
Total Code Submissions | 99 |
Total Times Completed | 9 |
JavaScript Completions | 9 |
Total Stars | 5 |
% of votes with a positive feedback rating | 88% of 4 |
Total "Very Satisfied" Votes | 3 |
Total "Somewhat Satisfied" Votes | 1 |
Total "Not Satisfied" Votes | 0 |
Total Rank Assessments | 5 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 4 kyu |
Lowest Assessed Rank | 7 kyu |