← Problems

Meow, Woof, Party!

Given a positive integer n, loop through every integer from 1 to n, inclusive.

For each number:

  • Use "meow" if the number is divisible by 4.
  • Use "woof" if the number is divisible by 7.
  • Use "party" if the number is divisible by both 4 and 7.
  • Otherwise, use the number as a string.

Implement the function meowWoofParty and return all results in an array. Returning an array lets the playground check the values that would normally be printed.

Example

Input: n = 7
Output: ["1", "2", "3", "meow", "5", "6", "woof"]
Input: n = 8
Output: ["1", "2", "3", "meow", "5", "6", "woof", "meow"]

Constraints

  • 1 <= n <= 10,000
Loading...
Output will appear here…