Post Reply 
Happy New Year 2024 ... and 2023's last teaser !
01-02-2024, 12:53 PM (This post was last modified: 01-02-2024 01:05 PM by J-F Garnier.)
Post: #17
RE: Happy New Year 2024 ... and 2023's last teaser !
(01-01-2024 01:27 PM)brouhaha Wrote:  ... I did solve it using a general purpose matrix-permanent algorithm which I wrote in C++, using integer arithmetic. (It could easily use floating point if necesary, and that might actually be faster.). It computed the result in approximately 4ms on my power calc, which has an AMD Ryzen 7 3800X, 3.9+ GHz CPU.

I solved it too, using a BASIC code based on the VA711 article with a few obvious optimizations, and some code simplifications.
I got the answer in 2.5 s with Emu71/Win on my Ryzen5 PC , i.e. estimated to about 1h on a real HP-71B so perfectly doable.

BASIC is still relevant in 2024 !

Code:
1 ! VA2023
2 ! last va2023 "challenge"
3 ! solution based on VA711 article
5 ! 
10 OPTION BASE 1
15 DIM A(12,12)
20 DATA 0,0,1,0,0,0,0,0,0,1,0,0
21 DATA 0,0,1,0,0,0,0,0,0,1,0,1
22 DATA 0,0,1,1,0,0,0,0,0,1,0,1
23 DATA 0,0,1,1,0,0,0,0,0,1,1,1
24 DATA 1,0,1,1,0,0,0,0,0,1,1,1
25 DATA 1,0,1,1,0,0,0,1,0,1,1,1
26 DATA 1,0,1,1,1,0,0,1,0,1,1,1
27 DATA 0,1,0,1,1,1,1,1,1,1,0,1
28 DATA 1,0,1,1,1,0,1,1,0,1,1,1
29 DATA 1,0,1,1,1,0,1,1,1,1,1,1
30 DATA 1,0,1,1,1,1,1,1,1,1,1,1
31 DATA 1,1,1,1,1,1,1,1,1,1,1,1
35 ! 
40 READ A(,)
45 T=TIME
50 CALL MPER(A(,),D)
55 T=TIME-T
60 DISP D,T
70 END 
75 ! 
100 SUB MPER(A(,),D) @ N=UBND(A,1)
110 IF N=2 THEN D=A(1,1)*A(2,2)+A(1,2)*A(2,1) @ END 
120 D=0 @ DIM B(N-1,N-1)
130 FOR K=1 TO N
135 IF A(1,K)=0 THEN 145 ! little optimization
136 FOR I=2 TO N
137 FOR J=1 TO K-1 @ B(I-1,J)=A(I,J) @ NEXT J
138 FOR J=K+1 TO N @ B(I-1,J-1)=A(I,J) @ NEXT J
140 NEXT I
142 CALL MPER(B,E) @ D=D+A(1,K)*E
145 NEXT K @ END SUB
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Happy New Year 2024 ... and 2023's last teaser ! - J-F Garnier - 01-02-2024 12:53 PM



User(s) browsing this thread: 3 Guest(s)