solve 81 in uiua (fast)
This commit is contained in:
+25
@@ -0,0 +1,25 @@
|
||||
# project euler 81
|
||||
|
||||
$ 131 & 673 & 234 & 103 & 18
|
||||
$ 201 & 96 & 342 & 965 & 150
|
||||
$ 630 & 803 & 746 & 422 & 111
|
||||
$ 537 & 699 & 497 & 121 & 956
|
||||
$ 805 & 732 & 524 & 37 & 331
|
||||
≡◇(⋕°/$"_ & _") ⊜□⊸≠@\n
|
||||
ε ← # parsed example problem input
|
||||
|
||||
# find shortest path to lower right corner
|
||||
# ? cost-matrix
|
||||
Sol ← +⋅⊙⊡◡(
|
||||
°□⊢path(
|
||||
⊃(+0_1|+1_0) # get children
|
||||
∩↧⊙⤙⊙∘ ⊙⊙⊸(-1△) # clamp children to max index
|
||||
⤚⊡⊟ # get costs
|
||||
| ≍⊙(-1△) # are we at the corner yet?
|
||||
)
|
||||
) 0_0
|
||||
⍤⤙≍ 2427 Sol ε
|
||||
|
||||
&fras "cost-matrix.txt"
|
||||
⊜(⊜⋕⊸≠@,)⊸≠@\n
|
||||
Sol
|
||||
Reference in New Issue
Block a user