comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » OT: IDL math problem solving
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
OT: IDL math problem solving [message #91619] Thu, 06 August 2015 12:00 Go to next message
Helder Marchetto is currently offline  Helder Marchetto
Messages: 520
Registered: November 2011
Senior Member
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
Re: OT: IDL math problem solving [message #91628 is a reply to message #91619] Thu, 06 August 2015 19:13 Go to previous messageGo to next message
Dick Jackson is currently offline  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
Re: OT: IDL math problem solving [message #91630 is a reply to message #91628] Fri, 07 August 2015 02:16 Go to previous message
Helder Marchetto is currently offline  Helder Marchetto
Messages: 520
Registered: November 2011
Senior Member
Hi Dick,
I find the golf challenge very nice, but I think I cannot compete... without using dirty tricks :-)

o=BYTARR(101)&FOR i=1,100 DO o XOR=INDGEN(101)MOD i EQ 0&print,WHERE(o)

(71 chars)

Spaces are so useless...
I like your trick though. There's a lot to learn. Thanks for the (very short) solution.

Since you like golfing... Here's another one: Check out http://idl.marchetto.de/calculating-buffons-pi/
It has to do with calculating pi (3.141592...) using a statistical method.
The basic idea behind this is: Given a floor with equidistant parallel lines and a stick shorter than the distance between the floor lines, if you through this randomly lots of times and count how often you end up on a line, then you will be able to determine the number pi.

I haven't even tried shortening the code. But I'm good at removing spaces ;-)

Cheers,
Helder





On Friday, August 7, 2015 at 4:13:59 AM UTC+2, Dick Jackson wrote:
> 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
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: function graphic property.
Next Topic: How to draw open circle of different radius with lat-lon axes?

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 09:19:37 PDT 2025

Total time taken to generate the page: 0.00418 seconds