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

Stats:

CreatedOct 3, 2018
PublishedOct 9, 2018
Warriors Trained136
Total Skips89
Total Code Submissions99
Total Times Completed9
JavaScript Completions9
Total Stars5
% of votes with a positive feedback rating88% of 4
Total "Very Satisfied" Votes3
Total "Somewhat Satisfied" Votes1
Total "Not Satisfied" Votes0
Total Rank Assessments5
Average Assessed Rank
6 kyu
Highest Assessed Rank
4 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • rds009 Avatar
Ad