Construct Matrix with given Permanent
|
01-03-2024, 05:53 PM
Post: #1
|
|||
|
|||
Construct Matrix with given Permanent
Thread Happy New Year 2024 ... and 2023's last teaser !
(01-01-2024 08:29 PM)Maximilian Hohmann Wrote: Hello! Except for first row, we start with this: [ first row, [0,0,0,0,0,0,0,0,0,0,1,1], [0,0,0,0,0,0,0,0,0,1,1,1], [0,0,0,0,0,0,0,0,1,1,1,1], [0,0,0,0,0,0,0,1,1,1,1,1], [0,0,0,0,0,0,1,1,1,1,1,1], [0,0,0,0,0,1,1,1,1,1,1,1], [0,0,0,0,1,1,1,1,1,1,1,1], [0,0,0,1,1,1,1,1,1,1,1,1], [0,0,1,1,1,1,1,1,1,1,1,1], [0,1,1,1,1,1,1,1,1,1,1,1], [1,1,1,1,1,1,1,1,1,1,1,1]] Permanent = total paths of 1's from top to bottom (different columns) Permanent = 2^0 = 1 if first row is [0,0,0,0,0,0,0,0,0,0,0,1] [0,0,0,0,0,0,0,0,0,0,1,0] Permanent = 2^1 = 2 if first row is [0,0,0,0,0,0,0,0,0,1,0,0] Permanent = 2^2 = 4 if first row is [0,0,0,0,0,0,0,0,1,0,0,0] Permanent = 2^3 = 8 if first row is [0,0,0,0,0,0,0,1,0,0,0,0] ... x = first row bits → Permanent = (x//2) + (x%2) Either of these as first row will produce Permanent = 2023 = 0b11111100111 [1,1,1,1,1,1,0,0,1,1,0,1] [1,1,1,1,1,1,0,0,1,1,1,0] To make puzzle challenging, we randomly swap rows and cols, which does not change value of Permanent. To solve puzzle, we undo randomization, to make above "standard form". Then, we just read off first row pattern for Permanent. |
|||
01-03-2024, 06:06 PM
Post: #2
|
|||
|
|||
RE: Construct Matrix with given Permanent
(01-03-2024 05:53 PM)Albert Chan Wrote: To solve puzzle, we undo randomization, to make above "standard form". VA Square Matrix Permanent Puzzle VA Solution posted yesterday, so this is not a spoiler anymore. > m := [ [1,0,1,1,1,0,1,1,1,1,1,1], [0,0,1,1,0,0,0,0,0,1,0,1], [1,0,1,1,0,0,0,1,0,1,1,1], [0,0,1,0,0,0,0,0,0,1,0,0], [1,0,1,1,1,1,1,1,1,1,1,1], [0,0,1,1,0,0,0,0,0,1,1,1], [1,0,1,1,1,0,0,1,0,1,1,1], [0,1,0,1,1,1,1,1,1,1,0,1], [1,0,1,1,0,0,0,0,0,1,1,1], [1,1,1,1,1,1,1,1,1,1,1,1], [0,0,1,0,0,0,0,0,0,1,0,1], [1,0,1,1,1,0,1,1,0,1,1,1]] > s:=map(sum,m) → [10,4,7,2,11,5,8,9,6,12,3,9] If Permanent Puzzle setup as I predicted, "first row" has 9 1's We make them slightly different for sorting purpose. > s[0]:=9.5 > m:=map(sort(s), k->m[index(s,k)]) \(\left(\begin{array}{cccccccccccc} 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 & 1 \\ 0 & 0 & 1 & 1 & 0 & 0 & 0 & 0 & 0 & 1 & 0 & 1 \\ 0 & 0 & 1 & 1 & 0 & 0 & 0 & 0 & 0 & 1 & 1 & 1 \\ 1 & 0 & 1 & 1 & 0 & 0 & 0 & 0 & 0 & 1 & 1 & 1 \\ 1 & 0 & 1 & 1 & 0 & 0 & 0 & 1 & 0 & 1 & 1 & 1 \\ 1 & 0 & 1 & 1 & 1 & 0 & 0 & 1 & 0 & 1 & 1 & 1 \\ 0 & 1 & 0 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 0 & 1 \\ 1 & 0 & 1 & 1 & 1 & 0 & 1 & 1 & 0 & 1 & 1 & 1 \\ 1 & 0 & 1 & 1 & 1 & 0 & 1 & 1 & 1 & 1 & 1 & 1 \\ 1 & 0 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\ 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \end{array}\right)\) > SWAPCOL(m,10,12) > SWAPCOL(m,3,11) > SWAPCOL(m,4,9) > SWAPCOL(m,3,8) > SWAPCOL(m,1,7) > SWAPCOL(m,3,6) > SWAPCOL(m,1,4) > SWAPCOL(m,1,3) > SWAPCOL(m,1,2) \(\left(\begin{array}{cccccccccccc} 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 1 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 1 & 1 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 1 & 1 & 1 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 1 & 1 & 1 & 1 \\ 0 & 0 & 0 & 0 & 0 & 0 & 1 & 1 & 1 & 1 & 1 & 1 \\ 0 & 0 & 0 & 0 & 0 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\ 0 & 0 & 0 & 0 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\ 1 & 1 & 1 & 1 & 1 & 1 & 0 & 0 & 1 & 1 & 0 & 1 \\ 0 & 0 & 0 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\ 0 & 0 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\ 0 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\ 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \end{array}\right) \) "First row" bits (if we move 8th row to top) for Permanent > 0b11111100110 + 1 2023 |
|||
01-03-2024, 06:17 PM
Post: #3
|
|||
|
|||
RE: Construct Matrix with given Permanent
Hello Albert,
I was about to suggest that you make your method public but you beat me to it! Now it becomes a lot clearer. Thank you! Max |
|||
01-03-2024, 11:55 PM
(This post was last modified: 01-04-2024 01:20 AM by Albert Chan.)
Post: #4
|
|||
|
|||
RE: Construct Matrix with given Permanent
We can use DSU (Decorate Sort Undecorate) to avoid manually swapping columns.
Starting from original puzzle m > m:=concat(transpose(map(sum,m)), m) > m:=sort(m) > DELCOL(m,1) > m:=transpose(m) Do the same for its transpose > m:=concat(transpose(map(sum,m)), m) > m:=sort(m) > DELCOL(m,1) > m:=transpose(m) \(\left(\begin{array}{cccccccccccc} 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 1 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 1 & 1 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 1 & 1 & 1 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 1 & 1 & 1 & 1 \\ 0 & 0 & 0 & 0 & 0 & 0 & 1 & 1 & 1 & 1 & 1 & 1 \\ 0 & 0 & 0 & 0 & 0 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\ 0 & 0 & 0 & 0 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\ 1 & 1 & 1 & 1 & 1 & 1 & 0 & 0 & 1 & 1 & 0 & 1 \\ 0 & 0 & 0 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\ 0 & 0 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\ 0 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\ 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \end{array}\right) \) > horner(m[8],2) → 4045 > ceiling(Ans/2) → 2023 // = permanent(m) |
|||
01-05-2024, 09:19 PM
Post: #5
|
|||
|
|||
RE: Construct Matrix with given Permanent
(01-04-2024 01:01 PM)J-F Garnier Wrote: If you look closely at my solution, you will see that I sorted the array rows by the number of 1 in each row, not by the value of the binary representation: If we sort columns the same way, then move red row to top, we have "standard form" But, we don't need actual sorting. Columns zeros count can be used to locate where red cells are, if sorted. > r := [0,1,0,1,1,1,1,1,1,1,0,1]; /* red row */ > z := [4,10,0,2,6,9,7,5,8,0,3,1]; /* column zeroes count, without red row */ > r * 2^z /* permanent(m), note: * is dot product */ 2023 |
|||
01-07-2024, 04:09 PM
Post: #6
|
|||
|
|||
RE: Construct Matrix with given Permanent
A follow up of previous post example, to produce recursive formula for permanent(m)
PM to JFG Wrote:Imagine row 8 is all 1's, and we move that to the end Let f(x) = permanent of "standard form" matrix m, with first row bits = x Let n = bit_length of x // leading zeroes ignored f(2^n-1) = 2^(n-1) // explained in quote f(x) = 2^(n-1) - f(2^n-1 - x) // 2nd term argument = flip(x), smaller than x f(x) = x, if x = 0 or 1 // base case (01-03-2024 06:06 PM)Albert Chan Wrote: "First row" bits (if we move 8th row to top) for Permanent f(0b111111001101) = 2^11 - f(0b110010) = 2^11 - 2^5 + f(1101) = 2^11 - 2^5 + 2^3 - f(0b10) = 2^11 - 2^5 + 2^3 - 2^1 + 1 = 2048 - 32 + 8 - 2 + 1 = 2023 |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 4 Guest(s)