![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#21 |
|
Programming Guru
![]() Join Date: Apr 2005
Posts: 1,799
Rep Power: 5
![]() |
So what was this for anyways?
![]() |
|
|
|
|
|
#22 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
Pattern recognition. This is one of those cases where abstraction can't be afforded, unfortunately, because of the large number of operations. I need to go off and redesign the microprocessor. Incidentally, involving the center square is a substantial penalty, performance-wise.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#23 |
|
Programming Guru
![]() Join Date: Apr 2005
Posts: 1,799
Rep Power: 5
![]() |
Oh, so your request for a "Python" solution was a request for an efficient solution? I'm searching your post for any hints of sarcasm. Oh well. I guess you went with hydroxide's then.
![]() |
|
|
|
|
|
#24 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
There's no sarcasm there. None of the solutions given is effective. I'm a fan of abstraction. Elegance and clarity. Women and scotch. Sometimes they just don't happen to woik out.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#25 | ||
|
Programmer
Join Date: Apr 2005
Posts: 73
Rep Power: 4
![]() |
Quote:
Quote:
* Is it necessary to have your structure as a list of lists? * What about a flat list? 3*y + x gives the index for a flat list, which saves you a lookup. (is y+y+y+x faster??) * If using a flat list, you reuse the list with g[:] = [...] which IIRC is more efficient than creating a new list. * What about a dict? Complex numbers can function as points (0+0j, 0+1j,..., 2+2j) - assuming that they're compiled in. * How tight is memory? Can you have four lookup tables and just switch the table based on the rotation? If rotation is a frequent operation, the tradeoff might be worthwhile. The lookup tables would point to indices of a flat list. *For rotation using a flat list, if you have a dummy member at the end you could use multiplication and slicing: grid = [0,1,2,3,4,5,6,7,8, None] grid[:] = (grid*3)[2::3] -T. Last edited by hydroxide; Jul 28th, 2006 at 11:34 PM. |
||
|
|
|
|
|
#26 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
Thanks for the exercise
. In the reality of this usage no lookups or tricks or maps or sich be necessary. Flat is the way to go, of course, unless I whup up me a special set of hardware. The positional movements for a 90-degree rotation and for a mirror are fixed. I was just curious, again, what abstraction would cost.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| [Python] Grid encryptor | Jessehk | Show Off Your Open Source Projects | 7 | Nov 29th, 2007 7:11 PM |
| Distance between 2 grid references | Oddball | Show Off Your Open Source Projects | 7 | Mar 12th, 2006 2:52 PM |
| easiest way to represent a grid? | keweedsmo | C++ | 4 | Feb 10th, 2006 6:03 PM |
| Little off-topic... Grid coordinate handling | CodeCaster | C++ | 13 | Jul 4th, 2005 7:07 AM |
| Need assistance with program | DJ_Mittens | C++ | 4 | Apr 20th, 2005 7:48 AM |