6 kyu

Averaging in an Infinite Array

58 of 74At1029

Description:

In an infinite array with two rows, the numbers in the top row are denoted

. . . , A[−2], A[−1], A[0], A[1], A[2], . . .

and the numbers in the bottom row are denoted

. . . , B[−2], B[−1], B[0], B[1], B[2], . . .

For each integer k, the entry A[k] is directly above the entry B[k] in the array, as shown:

...|A[-2]|A[-1]|A[0]|A[1]|A[2]|...
...|B[-2]|B[-1]|B[0]|B[1]|B[2]|...

For each integer k, A[k] is the average of the entry to its left, the entry to its right, and the entry below it; similarly, each entry B[k] is the average of the entry to its left, the entry to its right, and the entry above it.

Given A[0], A[1], A[2] and A[3], determine the value of A[n]. (Where range of n is -1000<n<1000)

Test Cases are called as an array of ([A[0], A[1], A[2], A[3]], n)

Hint: Calculate B[k]

FOR JS Node v10.x -> Inputs and Outputs in BigInt!

Adapted from 2018 Euclid Mathematics Contest. https://www.cemc.uwaterloo.ca/contests/past_contests/2018/2018EuclidContest.pdf

Mathematics
Algorithms

More By Author:

Check out these other kata created by At1029

Stats:

CreatedJul 5, 2019
PublishedJul 5, 2019
Warriors Trained435
Total Skips13
Total Code Submissions471
Total Times Completed74
JavaScript Completions17
Python Completions58
Haskell Completions9
Total Stars3
% of votes with a positive feedback rating91% of 34
Total "Very Satisfied" Votes30
Total "Somewhat Satisfied" Votes2
Total "Not Satisfied" Votes2
Total Rank Assessments7
Average Assessed Rank
5 kyu
Highest Assessed Rank
3 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • At1029 Avatar
  • JohanWiltink Avatar
Ad