[VA] My 2024's very first little teaser
|
01-17-2024, 09:44 PM
(This post was last modified: 01-17-2024 09:45 PM by PeterP.)
Post: #3
|
|||
|
|||
RE: [VA] My 2024's very first little teaser
Ok, assuming that i got the rules correct (which is a big assumption and if I have not I do apply for forgiveness), here is my attempt.
It is not pushing things into as few lines as possible as I was taught as a young kid at CERN that my code has to be readable easily if I want to survive there.... I think if one wanted to, the code could be squished into 4 lines, but it wont be pretty and I certainly would have a hard time understanding it) 10 Option Base 0 @ Dim A(2,2), B(2,2), C(5), D(5), X1(1), D2(1) 20 Mat B = ZER @ Mat D = CON @ Mat D2 = CON @ Mat Input A 30 For y = 0 to 3 Step 3 40 For x = 0 to 2 @ X1(0) = x 50 For i = 0 to 2 @ X1(1) = i 60 B(i,i) = A(i, Mod (dot(XI,D2),3)) 70 Next i 80 X1(1)=y @ C(dot(X1,D2)) = Det(B) 90 Next x // 100 Mat A = TRN(A) @ For i = 0 to 2 @ Varswap A(0,i),A(2,i) @ Next i 110 Next y 120 Disp Dot(C,D) @ End This, upon run, and entering the variables from the matrix, delivers the expected result -36 (The code uses the dot product extensively to add two numbers and det to calculate a product). Cheers, Peter. Cheers, PeterP |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 3 Guest(s)