Skip to content

Commit 4a9e68c

Browse files
Update sol1.py
1 parent a177c81 commit 4a9e68c

File tree

1 file changed

+26
-4
lines changed

1 file changed

+26
-4
lines changed

project_euler/problem_345/sol1.py

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,32 @@
55
66
We define the Matrix Sum of a matrix as the maximum possible sum of
77
matrix elements such that none of the selected elements share the same row or column.
8-
Find the Matrix Sum of the following matrix.
98
10-
Brute force solution, with caching intermediate steps to speed up the calculation.
9+
For example, the Matrix Sum of the matrix below equals 3315 ( = 863 + 383 + 343 + 959 + 767):
10+
7 53 183 439 863
11+
497 383 563 79 973
12+
287 63 343 169 583
13+
627 343 773 959 943
14+
767 473 103 699 303
15+
16+
Find the Matrix Sum of:
17+
7 53 183 439 863 497 383 563 79 973 287 63 343 169 583
18+
627 343 773 959 943 767 473 103 699 303 957 703 583 639 913
19+
447 283 463 29 23 487 463 993 119 883 327 493 423 159 743
20+
217 623 3 399 853 407 103 983 89 463 290 516 212 462 350
21+
960 376 682 962 300 780 486 502 912 800 250 346 172 812 350
22+
870 456 192 162 593 473 915 45 989 873 823 965 425 329 803
23+
973 965 905 919 133 673 665 235 509 613 673 815 165 992 326
24+
322 148 972 962 286 255 941 541 265 323 925 281 601 95 973
25+
445 721 11 525 473 65 511 164 138 672 18 428 154 448 848
26+
414 456 310 312 798 104 566 520 302 248 694 976 430 392 198
27+
184 829 373 181 631 101 969 613 840 740 778 458 284 760 390
28+
821 461 843 513 17 901 711 993 293 157 274 94 192 156 574
29+
34 124 4 878 450 476 712 914 838 669 875 299 823 329 699
30+
815 559 813 459 522 788 168 586 966 232 308 833 251 631 107
31+
813 883 451 509 615 77 281 613 459 205 380 274 302 35 805
1132
12-
>>> solution(MATRIX_1)
13-
3315
33+
Brute force solution, with caching intermediate steps to speed up the calculation.
1434
"""
1535

1636
import numpy as np
@@ -75,6 +95,8 @@ def solution(matrix_str: list[str] = MATRIX_2) -> int:
7595
7696
>>> solution(["1 2", "3 4"])
7797
5
98+
>>> solution(MATRIX_1)
99+
3315
78100
"""
79101

80102
n = len(matrix_str)

0 commit comments

Comments
 (0)