« first day (2473 days earlier)      last day (174 days later) » 

10:52 AM
@Adám understood! Got a solution, and have some parens for you to remove ;)
 
 
2 hours later…
12:59 PM
Welcome to APL Quest 2022-2! Today's quest is Attack of the Mutations!:
> Write a function that:
• takes right and left arguments that are character vectors or scalars of equal length – these represent DNA strings.
> • returns an integer representing the Hamming distance (the number of differences in corresponding positions) between the arguments.
This is trivial. For those that need an additional challenge. Try pretending that T and U are the same letter.
This is also one of those cases where APL tends to be significantly shorter than more popular languages, even when they take inspiration from APL. Try it!
Here's how NOT to do it in APL: {r⊣⍺{r+←⍺≠⍵}¨⍵⊣r←0}
 
+/≠
 
Good. And since we're dealing with arguments of rank≤1 we can make this into an inner product.
 
+.≠
 
Exactly.
Up for trying the U/T normalisation?
 
+/≠⍥('U'@('T'∘=))
 
1:11 PM
Right, that's what I had as well.
Shorter, but slower, is ⍥('U'⎕R'T')
 
+/≠∧⍲⍥(∊∘'TU') also seems to work.
 
Ooh, clever.
And much faster!
      d←'ACGT'[?1e6⍴4]
      e←'ACGT'[?1e6⍴4]
…
  d(+/≠⍥('U'@('T'∘=)))e → 2.2E¯3 |   0% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
  d(+/≠∧⍲⍥(∊∘'TU'))e    → 8.6E¯4 | -60% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
 
Yay :)
 
Btw, don't forget De Morgan's laws: +/≠>∧⍥(∊∘'TU') might be easier to follow.
I find +/=⍱∧⍥(∊∘'TU') pretty natural too.
neither equal, nor both member of
 
I was thinking of it as "different, but not both T or U"
 
1:19 PM
right, but is an
I read > as but not
 
Ah, that's a really nice way to think about it
 
It works visually, as the alligator will only eat that which is.
@Richard You had …⍥('U'@('T'∘=)) too?
 
@Adám I don't get it. Is that a reference to something?
 
I ended up with 1⊥=⍱∧⍥(∊∘'UT') as well. Felt natural to work the boolean masks
 
@mitchelljohnstone Nice.
 
1:26 PM
ah....... did I miss it...
 
I thought the alligator/crocodile mnemonic for comparisons was commonly known.
 
stupid time differences
 
ikr, we should all just switch to utc
 
(+/≠⍥('U'@('T'=⊢)))
so yes, the same more or less
 
and no, i can't remove any parens :(((
 
1:30 PM
Ah, thats's cute :)
 
And with that, see you next week for 2022-3: Uniquely Qualified!
Btw, the 2023 problems are now on the site too.
 
@Adám Cultural difference maybe? I'm from Hong Kong and I've never heard about it
See you all next week!
 
next week!
 
 
1 hour later…
2:32 PM
@mitchelljohnstone oh, yeah - didn't think to work with the mask. I just had +.≠⍥('T'@{'U'=⍵})
 
 
4 hours later…
6:18 PM
@Adám eh, here's how not to do it in apl:
 ∇res←a Mutations b
 res←0
 :For i :In ⍳≢a
   :If a[i]≠b[i]
     res+←1
   :EndIf
 :EndFor
 ∇
 

« first day (2473 days earlier)      last day (174 days later) »