Manafall Daily Quest

Raindrop Resonance

Function Name: generateSoundPattern

Description

In this challenge, the task is to create a function that simulates the sound pattern produced by raindrops. The function will take an array representing different frequencies of raindrops and return a string representing the combined sound pattern.

Each frequency will be an integer, and for each frequency 'n', the pattern will consist of a 'pling' every 'n' characters, with periods filling the spaces in between. The output should overlay these patterns on top of each other, starting with a capital 'P' for the first 'pling' and using lowercase 'p' for the subsequent ones.

The function should handle combining the patterns where multiple 'plings' may coincide. In the case of coinciding 'plings', a single 'P' takes precedence over any number of lowercase 'p's, and multiple 'p's are represented by a single lowercase 'p'.

The returned pattern string should only be as long as necessary to complete one full cycle of all input frequencies.

Requirements

  • The function must take two parameters: an array of integers (representing the frequencies) and an integer representing the length of the pattern to generate.
  • The function must return a string representing the sound pattern.
  • The function should handle zero or more frequencies. If the input array is empty or all frequencies are zero, it should return an empty string.
  • Frequencies of 1 should not be included as they would create a continuous 'pling' sound.

Examples

If the function is called with the frequencies [2, 3] and a length of 5, the expected output should be 'P.pPp'.If the function is called with the frequencies [5, 7] and a length of 15, the expected output should be 'P....p...P...p'.

Links

https://en.wikipedia.org/wiki/Superposition_principle

Merge Intervals

Tue Sep 03 2024

Write a function that merges overlapping intervals. The function should take an array of intervals, where each interval is represented as an array of two integers, and merge all overlapping intervals. The input array of intervals is not necessarily ordered in any way. The function should return an array of the merged intervals sorted in ascending order by the start of the intervals.

Prev Quest

Prime Factorization

Thu Sep 05 2024

Write a function that takes a positive integer as an argument and returns its prime factorization in the form of an array. Prime factorization means breaking down a composite number into its prime factors. The function needs to return the prime factors sorted in ascending order.For example, the prime factorization of 18 is [2, 3, 3], as it can be expressed as 2 * 3 * 3.A prime number has exactly two distinct natural number divisors: 1 and itself. Your task is to efficiently compute the prime factors for any given positive integer.

Next Quest