On Thu, 09 Jun 2005 11:21:50 -0500 you wrote: > >> >>It appears to require 6 shifts, six ANDs, and 5 ORs... seems unlikely >>it would be faster than the "straightforward" implementation? It looks >>like a case of someone trying to be clever after they learned why a >>quicksort is better than something like a bubble sort (what he does is >>swap bits 0/1, 2/3, 4/5, 6/7... then 0-1/2-3, 4-5/6-7, and finally 0- >>3/4-7). The problem is that with only 8 bits there's not any speedup >>yet that I can see -- just as smart general purpose sorting routines >>will revert to something like a bubble sort of lists of less than, say, >>10 items! > >Unless someone pops up from left field here with a new solution, I'm >going to say that we have a couple of nice solutions now, and call >this one "done". > >The table lookup is, somewhat surprisingly efficient, other than on >code space, especially when the table can be located on an even page. >Interestingly enough, I think it executes in the equivalent of one >instruction on the PIC. VBG! > >The external loopback is fun, if you have the pins available. > >That's the point of challenges like this, to encourage "out of the >box" thinking and explore ideas. > > > >So, anyone want to propose a new little problem? This one is known but can prove a puzzler if one doesn't know it. How do you swap the contents of 2 registers without using any other registers or stack? -- Ralph Hilton http://www.ralphhilton.org C-Meter: http://www.cmeter.org FZAOINT http://www.fzaoint.net
Message
Re: [AVR-Chat] Re: Challenge
2005-06-09 by Ralph Hilton
Attachments
- No local attachments were found for this message.