Anything Really. Just keep it clean!
Moderators: JRL, Dorian (MJT support)
-
Djek
- Pro Scripter
- Posts: 148
- Joined: Sat Feb 05, 2005 11:35 pm
- Location: Holland
-
Contact:
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

-
Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
-
Contact:
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

Looks like those snippets were deleted.
-
Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
-
Contact:
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.
-
hagchr
- Automation Wizard
- Posts: 331
- Joined: Mon Jul 05, 2010 7:53 am
- Location: Stockholm, Sweden
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
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
-
Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
-
Contact:
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

-
JRL
- Automation Wizard
- Posts: 3529
- Joined: Mon Jan 10, 2005 6:22 pm
- Location: Iowa
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?
-
jpuziano
- Automation Wizard
- Posts: 1085
- Joined: Sat Oct 30, 2004 12:00 am
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!
-
Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
-
Contact:
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.