Re: OT: IDL math problem solving [message #91628 is a reply to message #91619] |
Thu, 06 August 2015 19:13   |
Dick Jackson
Messages: 347 Registered: August 1998
|
Senior Member |
|
|
On Thursday, 6 August 2015 12:00:11 UTC-7, Helder wrote:
> Hi,
> this is not directly related to IDL and partially Off Topic.
> I found a nice quiz that I put together in a post here:
>
> http://blog.marchetto.de/opening-and-closing-lockers
>
> If you can't solve it, you can find the solution here:
>
> http://blog.marchetto.de/solution-opening-and-closing-locker s
>
> The graph that I put in the solution was made with IDL and the code can be found here:
>
> http://idl.marchetto.de/opening-and-closing-lockers/
>
> The code is not particularly efficient (not at all!), but given the dimensions of the system, it takes longer to initialize the function graphics than computing with for loops.
>
> Please notice that the blog.* webpage is on a RaspPi in my cellar and runs rather slow... Be patient!
>
> Cheers,
> Helder
Cool! Fine explanations, and a lovely, clear graphic explaining it all. Thanks, Helder.
Now, for a tangent to this tangent, anyone for code golf? (IDL is a fine language for this sport... http://en.wikipedia.org/wiki/Code_golf)
Write IDL code to actually do this computation and print the numbers of the open lockers, using as few characters of IDL code as possible. Not looking for pretty or understandable code here!
Here's my best shot:
o=BYTARR(101)&FOR i=1,100 DO o XOR= INDGEN(101) MOD i EQ 0&PRINT, WHERE(o)
(74 characters)
I won't spoil the puzzle by printing the actual puzzle result here.
Cheers,
-Dick
Dick Jackson Software Consulting Inc.
Victoria, BC, Canada --- http://www.d-jackson.com
|
|
|