The Unofficial Macro Scheduler Puzzler #9

Anything Really. Just keep it clean!

Moderators: Dorian (MJT support), JRL

User avatar
Djek
Pro Scripter
Posts: 147
Joined: Sat Feb 05, 2005 11:35 pm
Location: Holland
Contact:

Re: The Unofficial Macro Scheduler Puzzler #9

Post by Djek » Wed May 21, 2014 6:39 am

Jäklar !!
learned a few things in this topic.

off-topic:
i can not see the snippets in the previous postings, I get "no such snippet"
I see only a green vertical line and the number 1
But the normal postings en scripts i can see.
I ve tried in IE en Firefox

Image

User avatar
Marcus Tettmar
Site Admin
Posts: 7378
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: The Unofficial Macro Scheduler Puzzler #9

Post by Marcus Tettmar » Wed May 21, 2014 6:41 am

Djek wrote:Jäklar !!
learned a few things in this topic.

off-topic:
i can not see the snippets in the previous postings, I get "no such snippet"
I see only a green line and the number 1
But the normal postings en scripts i can see.
I ve tried in IE en Firefox

Image
Looks like those snippets were deleted.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

User avatar
Marcus Tettmar
Site Admin
Posts: 7378
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: The Unofficial Macro Scheduler Puzzler #9

Post by Marcus Tettmar » Wed May 21, 2014 6:45 am

hoangvo81 wrote:this is just stating the fact that its a one liner really.
Yes, but I'd like to see the result being returned to a variable as that would be the usual use-case and you'd normally want to use the new value later in the script. Just showing it in a message box isn't very useful. But I'm not the esteemed panel so that's just my 2p.

While it's a fun challenge to reduce to the smallest number of lines, - and we can ignore readability in pursuit of that challenge - I'd still like it to be useful. IMO that needs the result to be in a variable.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

hagchr
Automation Wizard
Posts: 327
Joined: Mon Jul 05, 2010 7:53 am
Location: Stockholm, Sweden

Re: The Unofficial Macro Scheduler Puzzler #9

Post by hagchr » Wed May 21, 2014 8:02 am

Sorry, I managed to clean out the two snippets, it looked ok on the screen so I did not realize the problem. Can I put them back or will that not work with links etc?


Just to complete my learning experience,

If one want message:
Let>BinVal=10111010001000010
VBEval>Execute("Bin=""%BinVal%"":Res=0:For I = len(Bin) to 1 step -1:Dig=mid(Bin,I,1):select case Dig:case ""0"":case ""1"":Res=Res+(2^(len(Bin)-I)):end select:Next:MsgBox(""Binary=""&Bin & vbCrLf & ""Decimal="" & Res)"),

  View Snippet Page
If one want variable:
Let>BinVal=10111010001000010
VBEval>Execute("Bin=""%BinVal%"":Res=0:For I = len(Bin) to 1 step -1:Dig=mid(Bin,I,1):select case Dig:case ""0"":case ""1"":Res=Res+(2^(len(Bin)-I)):end select:Next:"),
VBEval>Res,Res

  View Snippet Page

hoangvo81
Pro Scripter
Posts: 69
Joined: Tue Feb 07, 2012 8:02 pm

Re: The Unofficial Macro Scheduler Puzzler #9

Post by hoangvo81 » Wed May 21, 2014 10:47 pm

beautiful solution hagchr.
I don't think there's a way to get it down to one line code using your solution, but i am sure someone will prove me wrong

User avatar
Marcus Tettmar
Site Admin
Posts: 7378
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: The Unofficial Macro Scheduler Puzzler #9

Post by Marcus Tettmar » Thu May 22, 2014 10:41 am

My solution is very similar but with a slightly different and shorter algorithm:

Code: Select all

Let>BinVal=10111010001000010
VBEval>Execute("bin=""%BinVal%"":Dec=0:For x=1 to Len(bin):Dec=Dec+(Cint(Mid(bin,Len(bin)-x+1,1))*(2^(x-1))):Next"),nul
VBEval>Dec,nDecVal
Just 162 characters in all :-)
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

User avatar
JRL
Automation Wizard
Posts: 3497
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Re: The Unofficial Macro Scheduler Puzzler #9

Post by JRL » Sat May 24, 2014 5:18 am

Congratulations and 15 points go to hagchr. Least number of lines (2)
Congratulations and 15 points go to Grovkillen. Least number of characters. (151)
Honorable mention to Marcus. (2) lines and (137) characters. Unfortunately as part of the mjtnet staff, it's incongruous for him to receive forum points.

I'm impressed by everybody's efforts

Wait... we have a new forum... I don't see any way to award points nor do I have any to bestow. Am I missing something?

User avatar
jpuziano
Automation Wizard
Posts: 1085
Joined: Sat Oct 30, 2004 12:00 am

Re: The Unofficial Macro Scheduler Puzzler #9

Post by jpuziano » Mon Jun 16, 2014 4:14 pm

JRL wrote:Wait... we have a new forum... I don't see any way to award points nor do I have any to bestow. Am I missing something?
The point system (board module?) does not seem to have been included... Maybe its not compatible with the new forum? If so that would be too bad as it will be missed. What's the story there Marcus?

Congratulations to all posters on this post... quiet an amazing competition and great creative ideas out there, very impressive... and a big reason why I like to read the forums daily and keep up with things... though occasionally vacations do happen and I just can't get here. Thanks for posting these Puzzlers JRL, they are a hoot!
jpuziano

Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post - :-)

User avatar
Marcus Tettmar
Site Admin
Posts: 7378
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: The Unofficial Macro Scheduler Puzzler #9

Post by Marcus Tettmar » Fri Jun 20, 2014 3:50 pm

Sorry, yes, that points system was old and no longer compatible. I've been looking for a decent one to replace it but haven't found anything that really fits yet.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts