Manafall Daily Quest

Sum of Multiples

Function Name: findSumOfMultiples

Description

In this challenge, you are required to implement a function that calculates the sum of all multiples of a set of numbers up to a certain limit. For example, if the set is [3, 5] and the limit is 10, the function should return the sum of the numbers that are multiples of either 3 or 5 below the limit: 3, 5, 6, and 9, which adds up to 23.

Requirements

  • The function should take two parameters: an array of integers representing the set of numbers and an integer representing the upper limit (exclusive).
  • The function should return a single integer representing the sum.
  • If the array is empty or the limit is less than or equal to any of the numbers in the set, the function should return 0.
  • The function should handle cases where numbers in the array of multiples might be duplicates.
  • Optimize the function for time complexity.

Examples

Example call: findSumOfMultiples([3, 5], 10)Expected return: 23 (since 3+6+9+5 = 23)

Lights Out Puzzle

Tue Dec 10 2024

In the game 'Lights Out', there is a grid of lights that are either on (1) or off (0). When you toggle a light at position (i, j), it also toggles the lights vertically and horizontally adjacent to it. The task is to write a function that takes a 5x5 grid of the lights as an input and determines if the game is solvable. A game is considered solvable if there exists a sequence of moves that turns all the lights off.

Prev Quest

Frequency Sort

Thu Dec 12 2024

Write a function named 'frequencySort' that sorts an array based on the frequency of the elements. If two elements have the same frequency, then the smaller number comes first.The function will take one parameter, an array of integers, and should return a new array of integers sorted based on the aforementioned criteria.

Next Quest