I got the 9867312 answer in about 10 minutes, using just thinking and a calculator. Sure, the brain is slower than the PC but probably the overall time to write the program and run it is more than 10 minutes :)
Heuristics:
- the number must have at most 9 digits
- 5,2 mutually exclusive (0 in the end)
- 5,4 mutually exclusive (0 in the end)
- 5,8 mutually exclusive (0 in the end)
=> 5 probably not in
- the remaining are 1 2 3 4 6 7 8 9
- 9 divides a number iff the sum of its digits is divisible by 9, same goes for 3 and 6
- the sum of these digits is 40, so if you take 4 out, it is 36, so we can have a number with 1 2 3 6 7 8 9 divisible by 1 3 6 9 independently of the digits' order
- place 2 last so that the resulting number is divisible by 2
- you want it to be the largest, so first try 9876312
- it won't work, and after a few trials and some luck you get the right answer which is 9867312
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|