I'm working on modernizing Rosetta Code's infrastructure. Starting with communications. Please accept this time-limited open invite to RC's Slack.. --Michael Mol (talk) 20:59, 30 May 2020 (UTC)

Talk:Non-transitive dice

From Rosetta Code

Exclude rotations?[edit]

If we have S < T, T < U and yet S > U then it follows we
also have T < U, U < S and yet T > S
as well as U < S, S < T and yet U > T - and that will be every single time, for every set, without fail.
Should we not just keep the one that starts numerically smallest? --Pete Lomax (talk) 23:27, 7 September 2020 (UTC)

As an aside, is it always the case that there is only one solution? Or is that just a coincidence? It would be nice to stop searching permutations early. --Chunes (talk) 00:59, 8 September 2020 (UTC)
It is a coincidence of the 1..4 limit. While I didn't search for them, there are at least two triplets of 6 dice with 1..9 faces, as shown at the end of the Phix output. I have also just added two optimisations: First, when checking a set if any k/k+1 fail then I set [k+2..$] to l ensuring k+1 is incremented next, a 3-fold speedup. Second, I cached the cmpd() results, a 10-fold speedup. So it is now 30 times faster than it was before. --Pete Lomax (talk) 03:05, 8 September 2020 (UTC)
Those are great optimisations, Pete. I'd like to apply them to the Python solution.
On rotations of solutions: I do have somewhere a version with rotations, but I can't remember why I dropped it - I probably flitted over to another "shiny" part of learning about non-transitive dice that caught my attention. The task wording seems to be consistent with the shown results, I think, if not then I'd need to change it.
P.S. I am floored by the maths aspect - reals and then quaternions loosing commutativity in higher dimensions compared to dice with one face/ "ints" and then dice with more faces loosing transitivity?!
--Paddy3118 (talk) 09:52, 8 September 2020 (UTC)
Thanks again, that's a lot of cache hits:
Out[45]: CacheInfo(hits=2148761, misses=1190, maxsize=None, currsize=1190)
--Paddy3118 (talk) 10:11, 8 September 2020 (UTC)

Allow for excluded rotations?[edit]

I could add the following to the task description
Any rotation of dice from an answer is also an answer. You may compute and show only the rotation with the "lowest sorted face numbers first". In sorting, faces numbers are compared in pairs from left to right. if current pair are the same then the next pair of face numbers are compared until there is a difference or all face numbers compare equal. E.g. A= 2, 3, 5 and B= 3, 3, 4 means A < B. C= 1, 4, 4 compares less-than both A and B due to the first face being 1. Although A, B, C do form a non-transitive list of dice, but if you elect to filter rotations then:
  1. Show the rotation with the "smallest" die first, i.e. C, A, B.
  2. Prominently state in the output that rotations of results are also solutions.

What do you think? --Paddy3118 (talk) 10:43, 8 September 2020 (UTC)

Sounds fine, though I'd probably say "Any rotation of dice from an answer is also an answer. You may compute and show only one of each such rotation sets, ideally the first when sorted in a natural way, and show the total number of rotations that are also solutions".
Anyway, rotation-squishing added to Phix, along with a newly invented stretch goal. --Pete Lomax (talk) 17:49, 8 September 2020 (UTC)