6 kyu

Simple Fun #258: Is Divisible By 6

403 of 1,214myjinxin2015

Description:

Task

A masked number is a string that consists of digits and one asterisk (*) that should be replaced by exactly one digit. Given a masked number s, find all the possible options to replace the asterisk with a digit to produce an integer divisible by 6.

Input/Output

[input] string s

A masked number.

1 ≤ inputString.length ≤ 10000.

[output] a string array

Sorted array of strings representing all non-negative integers that correspond to the given mask and are divisible by 6.

Example

For s = "1*0", the output should be ["120", "150", "180"].

For s = "*1", the output should be [].

For s = "1234567890123456789012345678*0",

the output should be

[
"123456789012345678901234567800",
"123456789012345678901234567830",
"123456789012345678901234567860",
"123456789012345678901234567890"]```
As you can see, the masked number may be very large ;-)
Puzzles

Stats:

CreatedMay 9, 2017
PublishedMay 9, 2017
Warriors Trained2061
Total Skips31
Total Code Submissions5657
Total Times Completed1214
JavaScript Completions403
Ruby Completions97
Crystal Completions8
Python Completions742
Total Stars42
% of votes with a positive feedback rating92% of 331
Total "Very Satisfied" Votes289
Total "Somewhat Satisfied" Votes33
Total "Not Satisfied" Votes9
Total Rank Assessments9
Average Assessed Rank
6 kyu
Highest Assessed Rank
6 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • myjinxin2015 Avatar
  • GiacomoSorbi Avatar
  • tachyonlabs Avatar
  • user9644768 Avatar
  • avermakov Avatar
Ad