From 28074210312b4dff85a771da968e8b785f83b0ed Mon Sep 17 00:00:00 2001 From: Dimitri Lozeve Date: Tue, 19 May 2020 16:04:05 +0200 Subject: [PATCH] Solve problem 2 --- Contest2020/Contest2020.dyalog | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Contest2020/Contest2020.dyalog b/Contest2020/Contest2020.dyalog index 119d6e3..5d83ae6 100644 --- a/Contest2020/Contest2020.dyalog +++ b/Contest2020/Contest2020.dyalog @@ -25,8 +25,16 @@ ∇ steps←{p}Steps fromTo ⍝ 2020 APL Problem Solving Competition Phase II - ⍝ Stub function for Problem 2, Task 1 - Steps - ⍝ Put your code and comments below here + ⍝ Problem 2, Task 1 - Steps + :If 0=⎕NC'p' ⍝ No left argument: same as Problem 5 of Phase I + steps←{(⊃⍵)+(-×-/⍵)×0,⍳|-/⍵}fromTo + :ElseIf p<0 + steps←(-⌊p){(⊃⍵)+(-×-/⍵)×0,(⍳⍺)×|-/⍵÷⍺}fromTo + :ElseIf p>0 + steps←p{(⊃⍵)+(-×-/⍵)×(|-/⍵)⌊⍺×0,⍳⌈(|-/⍵)÷⍺}fromTo + :ElseIf p=0 + steps←⊃fromTo + :EndIf ∇ ∇ urls←PastTasks url;r;paths