Manafall Daily Quest

Adjacent Element Product

Function Name: maxAdjacentProduct

Description

You are given an array of integers. Write a function that finds the pair of adjacent elements that has the largest product and returns that product.

For example, given the array [3, 6, -2, -5, 7, 3], the function should find the pair (7, 3) and return 21.

Requirements

  • The function should take an array of integers as its only parameter.
  • The array will have at least two elements.
  • The function should return an integer representing the maximum product of two adjacent elements.
  • If the array has only two elements, the function should return the product of those two elements.
  • The function must handle both positive and negative numbers.
  • Assume that the input will always be an array of integers, and no type checking is required.

Examples

Given the array [3, 6, -2, -5, 7, 3], the function maxAdjacentProduct should return 21.For the array [9, 5, 10, 2, 24, -1, -48], the function should return 50.

Links

https://en.wikipedia.org/wiki/Array_data_structurehttps://www.mathsisfun.com/numbers/product.html

Magic Square Validator

Wed Dec 18 2024

Write a function that takes a 2D array of integers and determines if the array represents a valid magic square. A magic square is a square grid filled with distinct positive integers such that the sum of the numbers in any horizontal, vertical, or diagonal line is always the same. Your function should return true if the 2D array is a magic square, and false otherwise.

Prev Quest

Sequential Digits

Fri Dec 20 2024

Create a function named sequentialDigits that takes two integers, low and high as input and returns a list of all the integers that contain sequential digits, where each digit is exactly one larger than the previous digit, and the integers are between the range of low and high (inclusive). The output list should be sorted in increasing order.

Next Quest