Genii Weblog

I outgeeked Andrew!

Thu 6 Jan 2005, 04:26 PM



by Ben Langhinrichs
For those who don't know Andrew Pollack, he is an awesome geek.  No, not some pocket protector wearing dweeb sort of geek (no offense meant to any pocket protecting dweebs who read my blog), but the sort who can take apart a broken laptop while sitting at a meeting, have it in pieces all over the table, fix the problem and put it back together and make it work, all without interrupting his train of thought.  His sessions at Lotusphere and elsewhere absolutely rock, and you should attend each and every one, including the repeats.  All that, and he's a fireman too.

Anyway, Rocky started this really, really, really long thread about what surprises people about you, which is well worth reading in its own right, and got sidetracked into a discussion of how to use formula language to reverse the old advertising ditty
twoallbeefpattiesspecialsaucelettucecheesepicklesonionsonasesameseedbun
to be
bunseedsesamieaononionspicklescheeselettucesaucespecialpattiesbeefalltwo
and not
nubdeesemasesanosnoinoselkcipeseehcecuttelecuaslaicepsseittapfeebllaowt
which doesn't sound too good to customers.  Andrew's answer was clean and elegant, as his code usually is (and I quote):
Yawn.

a := @Explode"two all beef patties special sauce lettuce cheese pickles onions on a sesame seed bun"" ");
@For( X := 0 ; X < @Elements(a) ; X := X + 1 ; T := T + " "@Subset(@Subset(a; @Elements(a) - X); -1));
@Prompt([Ok];"";T)


And I'm not kidding about the "Yawn".  Andrew likes to be a bit obnoxious.

Anyway, I was reading this, and realizes that I knew a geekier way, due to the special characteristics of this particular saying.  I tried it, and it works, and I posted it, but since it is comment #69, I'm not sure anybody will be able to appreciate the amazingness of my outgeeking Andrew.

So, here it is.
a:=@Explode"two all beef patties special sauce lettuce cheese pickles onions on a sesame seed bun"" ");
T:=@Implode(@Sort(a; [CustomSort];
                                          @Member($a;a)<@Member($b;a)); "");
@Prompt([Ok]; ""; T) 


Now, would you have ever thought of using @Sort?  Granted, I don't know whether my formula is faster than Andrews, or even much shorter than Andrew's, and I know full well mine is less useful than Andrew's since it depends on an odd characteristic of the specific sequence, but in the geekiness world, an @Sort with [CustomSort] parameter beats out an @For and in-line assignments with or without the @Member kicker.

Just thought I should share.

Copyright © 2005 Genii Software Ltd.

What has been said:


264.1. Andrew Pollack
(01/06/2005 02:12 PM)

And yet, Ben, I ask this of your readers...

If you were paying to have something created for you...which would you prefer?

Both are three lines of code. One will work again in similar situations to reverse other strings of words. One will appear to work, but will produce results which do not match the expectation.

What happens to Ben's "customer" if McDonalds adds (gasp) bacon to the Big Mac one day?

I'll take the bacon-safe solution, and use the time I don't spend coding the fix to buy Ben a vanilla milkshake at Lotusphere 2005.

--Andrew

PS: Yes, Ben did in fact see me disassemble a Dell laptop, remove the motherboard, fix a bent pin on the pcmcia card slot, and re-assemble and reboot the machine during a round table discussion at a Penumbra meeting in D.C. What he failed to mention, is that the only tool I had was my leatherman. Yes, there are pictures.


264.2. Andrew Pollack
(01/06/2005 02:20 PM)

I should point out, that to fail, Ben's McDonalds would have to add "two strips of bacon" or use a "special sesame seed bun".


264.3. Ben Langhinrichs
(01/06/2005 02:24 PM)

You're just jealous!

As I said, there was a special characteristic of this string which made it work (no repeats), and I said mine was less useful than yours for that very reason. Nonetheless, I outgeeked you fair and square.

Make mine a chocolate, as vanilla doesn't have enough "kick" for Lotusphere.


264.4. Richard Schwartz
(01/07/2005 12:08 AM)

Hey guys... take a look back over at Rocky's for my contribution to this Geek-a-Thon :-)

-rich


264.5. Nathan T. Freeman
(01/07/2005 01:56 AM)

You girly men and your R6 @function dependence...

src := @Explode("two all beef patties special sauce lettuce cheese pickles onions on a sesame seed bun"; " ");

digits := (0:1:2:3:4:5:6:7:8:9);

digitsRev := (9:8:7:6:5:4:3:2:1:0);

numList := @Subset(((digits*10) *+ digits); @Elements(src));

numListRev := @Subset(((digitsRev*10) *+ digitsRev);-@Elements(src));

targList := @Text(numList) + @Char(250) + src;

@Word(@Replace(@Text(numListRev); @Text(numList); targList); @Char(250); 2)

Who's needs Damien? ;)


264.6. Lars
(07-01-2005 03:31)

Andrew ... A leatherman is considered cheating.

You must perform the 'disassemble laptop' assignment using only tools common at roundtable meetings, such as whiteboard markers, notepad spiralbacks and plastic coffeecups.

Geez - with tools in hand, what's the challenge? ;o)


264.7. Andrew Pollack
(01/07/2005 04:57 AM)

Lars, speaking of gurlyman! A leatherman tool is a common tool available at any meet at which I am present. It lives on my belt. When I fly, it is the last thing to go into the suitcase at the airport, and the first to come out in bag claim.

Since the silliness in airports, I now also carry an incredibly small screwdrive kit inside my tech bag as well.

:-)

With respect to the plastic stuff -- The dissassembly is entirely possible using only my hands. Reassembly however, becomes somewhat more complex.


264.8. Ben Langhinrichs
(01/07/2005 05:32 AM)

Nathan, I stand in awe. I kept trying to figure out how to do this with pre-ND6 formulas and couldn't think of a way. I hand on the baton.


264.9. Nathan T. Freeman
(01/08/2005 08:52 AM)

/me bows. Believe me, Ben... I've stood in awe of what you've done for a long time. :)