Sherlock Holmes and the Beast (In class method challenge)

Solution: https://gist.github.com/bytecodeman/8e838d5f7c0e88af2f2b96c8aebf56ac

Sherlock Holmes suspects his archenemy Professor Moriarty is once again plotting something diabolical. Sherlock’s companion, Dr. Watson, suggests Moriarty may be responsible for MI6’s recent issues with their supercomputer, The Beast.

Shortly after resolving to investigate, Sherlock receives a note from
Moriarty boasting about infecting The Beast with a virus. He also
gives him a clue: an integer. Sherlock determines the key to removing
the virus is to find the largest Decent Number having that number of
digits.

A Decent Number has the following properties:

  1. Its digits can only be 3’s and/or 5’s.
  2. The number of 3’s it contains is divisible by 5.
  3. The number of 5’s it contains is divisible by 3.
  4. It is the largest such number for its length.

Moriarty’s virus shows a clock counting down to /The Beast/’s
destruction, and time is running out fast. Your task is to help Sherlock
find the key before The Beast is destroyed!

For example, the numbers 55533333 and 555555 are both decent numbers because there are 3 5’s and 5 3’s in the first, and 6 5’s in the second. They are the largest values for those length numbers that have proper divisibility of digit occurrences.

Function Description

Create a the decentNumber function in our class template. Function takes as input number of digits in decency. It should return a String of the numbers for the given length, or -1 if a decent number of that length cannot be formed.

In the template prompt for the number of digits in the decent Number, call the function, and output its result.

Sample Input

Input: 1
Output: -1

Input: 3
Output: 555

Input 5
Output: 33333

Input 11
Output: 55555533333