Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const getGets = (arr) => {
- let index = 0;
- return () => {
- const toReturn = arr[index];
- index += 1;
- return toReturn;
- };
- };
- // this is the test
- const test = [
- '1',
- '2',
- '7',
- '6'
- ];
- const gets = this.gets || getGets(test);
- const print = this.print || console.log;
- let input = []
- for (let i = 0; i < 3; i++) {
- input.push(Number(gets()));
- }
- let layers = Number(gets());
- print(input[0])
- print(`${input[1]} ${input[2]}`)
- let lastDigit = 0;
- let string = '';
- for (let i = 2; i < layers; i++) {
- for (let j = 0; j < i + 1; j++) {
- string += `${input.reduce((a, b) => a + b)} `
- lastDigit = input[0] + input[1] + input[2];
- input.shift()
- input.push(lastDigit)
- }
- print(string)
- string = ''
- }
- print(string)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement