[pythonvis] Re: Interesting problems from last night's chat

  • From: "Richard Dinger" <rrdinger@xxxxxxxxxx>
  • To: <pythonvis@xxxxxxxxxxxxx>
  • Date: Fri, 16 May 2014 10:43:32 -0700

Yes you are correct 24 is divisible by its digits not 42!  Sorry for the 
obvious error.

Richard

From: Joseph Lee 
Sent: Friday, May 16, 2014 10:13 AM
To: pythonvis@xxxxxxxxxxxxx 
Subject: [pythonvis] Re: Interesting problems from last night's chat

Hi Richard,

I think you meant 24? 42 is not divisible by 4 by the way unless I 
misunderstood the algorithm completely. If it was indeed 24, the algorithm 
would require loops and type conversion.

Cheers,

Joseph

 

From: pythonvis-bounce@xxxxxxxxxxxxx [mailto:pythonvis-bounce@xxxxxxxxxxxxx] On 
Behalf Of Richard Dinger
Sent: Friday, May 16, 2014 8:48 AM
To: pythonvis@xxxxxxxxxxxxx
Subject: [pythonvis] Interesting problems from last night's chat

 

There was a request at yesterday’s chat meeting to have some simple yet 
complete programming problems to solve.  The idea was to hold someone's 
interest a little better than writing ‘hello world’.

 

JDog is writing a small program that gets values for a height and width from 
the user and then draws the box using –, + and | characters.  This is small, 
but complete having input, processing and output.  Give it a try.

 

Once you have think python chapters 1 through 4 under your belt, you can try 
the following puzzle that I mentioned at the meeting.  This puzzle cries out 
for a brute force computer solution:

 

Find the largest number that is divisible exactly by each of its digits.  The 
number may not have any repeating digits or a 0 digit.  For example the number 
42 is divisible exactly by 2 and 4.  Note the largest number without any 
repeating digits is 987654321, but it is clearly not divisible exactly by some 
of its digits like 5.  That gives you a starting point though.  Hint: work out 
your algorithm on three or four digit numbers if grinding through nine digit is 
too slow.  After it works, how fast can you make it?

 

Richard

 

Other related posts: