5 kyu

Find All the Possible Numbers Multiple of 3 with the Digits of a Positive Integer.

208 of 303raulbc777

Description:

Given a certain number, how many multiples of three could you obtain with its digits?

Suposse that you have the number 362. The numbers that can be generated from it are:

362 ----> 3, 6, 2, 36, 63, 62, 26, 32, 23, 236, 263, 326, 362, 623, 632 

But only 3, 6, 36, 63 are multiple of three.

We need a function that can receive a number and may output in the following order:

  • the amount of multiples

  • the maximum multiple

Let's see a case the number has a the digit 0 and repeated digits:

6063 ----> 0, 3, 6, 30, 36, 60, 63, 66, 306, 360, 366, 603, 606, 630, 636, 660, 663, 3066, 3606, 3660, 6036, 6063, 6306, 6360, 6603, 6630

In this case the multiples of three will be all except 0

6063 ----> 3, 6, 30, 36, 60, 63, 66, 306, 360, 366, 603, 606, 630, 636, 660, 663, 3066, 3606, 3660, 6036, 6063, 6306, 6360, 6603, 6630

So the expected result given the above cases:

Given 362, should return [4, 63]
(amount of multiples = 4, maximum multiple = 63)

Given 6063, should return [25, 6630]
(amount of multiples = 25, maximum multiple = 6630)

The function will receive only positive integers (num > 0), and you don't have to worry for validating the entries.

Features of the random tests:

Number of test = 100
1000 ≤ num ≤ 100000000

Enjoy it!!

Fundamentals
Data Structures
Algorithms
Mathematics
Logic
Strings
Permutations

Stats:

CreatedNov 13, 2016
PublishedNov 13, 2016
Warriors Trained1753
Total Skips189
Total Code Submissions1966
Total Times Completed303
Python Completions208
Ruby Completions26
JavaScript Completions85
Total Stars80
% of votes with a positive feedback rating82% of 74
Total "Very Satisfied" Votes53
Total "Somewhat Satisfied" Votes16
Total "Not Satisfied" Votes5
Total Rank Assessments5
Average Assessed Rank
5 kyu
Highest Assessed Rank
3 kyu
Lowest Assessed Rank
6 kyu
Ad
Contributors
  • raulbc777 Avatar
  • ZED.CWT Avatar
  • Just4FunCoder Avatar
  • saudiGuy Avatar
Ad