Solve problem 4 task 1
This commit is contained in:
parent
d5d2bbb2cc
commit
1b69aed5e9
2 changed files with 11 additions and 3 deletions
|
@ -39,10 +39,18 @@
|
||||||
urls←('https://www.dyalog.com/'∘,)¨paths
|
urls←('https://www.dyalog.com/'∘,)¨paths
|
||||||
∇
|
∇
|
||||||
|
|
||||||
∇ r←revp dna
|
⍝ Test if a DNA string is a reverse palindrome.
|
||||||
|
isrevp←{⍵≡⌽'TAGC'['ATCG'⍳⍵]}
|
||||||
|
⍝ Generate all subarrays (position, length) pairs, for
|
||||||
|
⍝ 4 ≤ length ≤ 12.
|
||||||
|
subarrays←{⊃,/(⍳⍵),¨¨3↓¨⍳¨12⌊1+⍵-⍳⍵}
|
||||||
|
∇ r←revp dna;positions
|
||||||
⍝ 2020 APL Problem Solving Competition Phase II
|
⍝ 2020 APL Problem Solving Competition Phase II
|
||||||
⍝ Stub function for Problem 4, Task 1 - revp
|
⍝ Stub function for Problem 4, Task 1 - revp
|
||||||
⍝ Put your code and comments below here
|
⍝ Put your code and comments below here
|
||||||
|
positions←subarrays⍴dna
|
||||||
|
⍝ Filter subarrays which are reverse palindromes.
|
||||||
|
r←↑({isrevp dna[¯1+⍵[1]+⍳⍵[2]]}¨positions)/positions
|
||||||
∇
|
∇
|
||||||
|
|
||||||
∇ r←sset n
|
∇ r←sset n
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
1 4
|
1 4
|
||||||
2 4
|
2 4
|
||||||
3 4
|
3 4
|
||||||
16 4
|
16 4
|
||||||
|
@ -86,4 +86,4 @@
|
||||||
423 10
|
423 10
|
||||||
445 10
|
445 10
|
||||||
422 12
|
422 12
|
||||||
444 12
|
444 12
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue