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 = ["3 4"];
- const gets = this.gets || getGets(test);
- const print = this.print || console.log;
- const [row, col] = gets()
- .split(" ")
- .map(Number);
- let r = 0;
- let c = 0;
- let ir = 1;
- let ic = 1;
- let sum = 1;
- while (
- !(
- (!r && c === col - 1) ||
- (r === row - 1 && !c) ||
- (r === row - 1 && c === col - 1)
- )
- ) {
- r += ir;
- c += ic;
- if (r === row - 1) ir = -1;
- if (c === col - 1) ic = -1;
- if (!r) ir = 1;
- if (!c) ic = 1;
- sum = bigInt(2).pow(r+c).add(sum);
- }
- print(sum.toString());
Advertisement
Add Comment
Please, Sign In to add comment