From 9628a7a04b98753d1c965caeff5cb7088536a7a4 Mon Sep 17 00:00:00 2001 From: Dimitri Lozeve Date: Tue, 12 May 2020 10:14:14 +0200 Subject: [PATCH] Add first steps of solution to problem 9 --- Contest2020/Contest2020.dyalog | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Contest2020/Contest2020.dyalog b/Contest2020/Contest2020.dyalog index 34e08e6..119d6e3 100644 --- a/Contest2020/Contest2020.dyalog +++ b/Contest2020/Contest2020.dyalog @@ -153,10 +153,22 @@ :EndIf ∇ - ∇ weights←Weights filename + ∇ weights←Weights filename;mobile;branches;mat ⍝ 2020 APL Problem Solving Competition Phase II ⍝ Stub function for Problem 9, Task 1 - Weights ⍝ Put your code and comments below here + + ⍝ Parse the mobile input file. + mobile←↑⊃⎕NGET filename 1 + branches←⍸mobile∊'┌┴┐' + ⍝ TODO: Build the matrix of coefficients mat. + + ⍝ Solve the system of equations (arbitrarily setting + ⍝ the first variable at 1 because the system is + ⍝ overdetermined), then multiply the coefficients by + ⍝ their least common multiple to get the smallest + ⍝ integer weights. + weights←((1∘,)×(∧/÷))mat[;1]⌹1↓[2]mat ∇ :EndNamespace