OZONE Asylum
Forums
Server-Side Scripting - Oh my!
Latin Square Trick That Blew My Mind
This page's ID:
33340
Search
QuickChanges
Forums
FAQ
Archives
Register
Edit Post
Who can edit a post?
The poster and administrators may edit a post. The poster can only edit it for a short while after the initial post.
Your User Name:
Your Password:
Login Options:
Remember Me On This Computer
Your Text:
Insert Slimies »
Insert UBB Code »
Close
Last Tag
|
All Tags
UBB Help
Okay, I'm starting to lose my mind. My brain has been going so fast lately that my coding/writing can't keep up. I got home yesterday and wrote for a good 2 hours. I got home today and did something pretty funny. I am more than several step ahead of where I left off. But I need to organize my thoughts better before I can get explicit about them. But I will tell you the funny thing that I did a few minutes ago that I find rather entertaining - and it is something that I don't do very often: brute force. I mentioned that there are only 2 latin squares of size 5. I sat down, coded the brute force in a few minutes, and got exactly 2. My brute force version of them look like this: [code] 0 1 2 3 4 1 0 3 4 2 2 4 0 1 3 3 2 4 0 1 4 3 1 2 0 0 1 2 3 4 1 0 4 2 3 2 3 0 4 1 3 4 1 0 2 4 2 3 1 0 [/code] They don't look like the ones that I did on graph paper (which I still can't find), but they are the real deal. Absolutely any 5x5 that you can create is merely a perm of one of those two. So, my plan as of right now, is to finish the writing that I started yesterday and post that in this thread. It does start to get kind of out there a bit, but close enough. And then maybe start a new thread about brute forcing these things with wicked speed in the logic. Well, not perfectly efficient with regards to code, but some understanding/insight in the method can greatly speed things up. For example, brute forcing those two 5x5 starts with two loops and two conditionals. Check it out: [code] #!/usr/bin/env python import itertools s=5 for i in itertools.permutations(range(s)): for j in range(s): if i[j]==0: if i[0]==j: print(i) [/code] And that's it for the first step. Stay tuned and I will get to it eventually. --------------- Alright, hang on second. I just did a quick test in the code and it matches the probablity math in my head. Thinking about size=8, I have the expression 7! + 7 * 6! = 10,080 possible solutions. I plugged s=8 into the above code and got the *exact* same number of code-valided solutions. Damn, I rock. edit: Brain still going crazy even while sleeping. I was able to reduce 7!+7*6! down to just 6!=720. The general being (n-2)! possible transversals. [small](Edited by [url=https://ozoneasylum.com/user/351]warjournal[/url] on 03-25-2021 01:29)[/small]
Loading...
Options:
Enable Slimies
Enable Linkwords
« Backwards
—
Onwards »
Maximum Security
OZONE
DHTML/Javascript
Server-Side Scripting - Oh my!
CSS - DOM - XHTML - XML - XSL - XSLT
Stupid Basic HTML
Visual Therapy
Photoshop
Photoshop Pong, Anyone?
***WARNING*** BIG SIG APPROACHING
Photography
3D Modelling & Rendering
Multimedia/Animation
Print Graphics
Holding Pens
Philosophy and other Silliness
Outpatient Counseling
Site reviews!
Mad Scientists' Laboratory
Getting to know the Grail