« first day (2144 days earlier)      last day (500 days later) » 

5:32 AM
AoC day9, today is easy but I guess most people give up trying before read the problem
 
 
2 hours later…
7:32 AM
@xpqz ∨\≤<\
 
 
1 hour later…
8:38 AM
@Adám What's a good search term in aplcart to find all these types of bit twiddles?
 
I just do boolean \
 
 
4 hours later…
12:14 PM
@JayFoad It has been a while!
 
12:57 PM
@Sirch Hi there. Interested in APL?
Welcome to APL Quest 2017-5! Today's quest is Slice(s) of Pie(s):
> Write a a function that takes a string representing a nucleotide and returns a 1 if it is a valid DNA string, 0 otherwise. In other words, are all the characters in the set 'ACGT'?
This should be easy.
 
'ACGT'(∧/∊⍨)
or
{∧/⍵∊'ACGT'}
 
That first one isn't a proper function you could give a name.
 
ok, then I should bring 'ACGT' inside the function
 
Or bind it to the outside, or add a right tine for an Agh fork.
 
@Adám Yeah, first time here after joining the discord! I'm having fun learning from you all.
 
1:02 PM
Great to have you here.
@Richard, did you solve the additional challenges I gave you?
 
almost, I'll show you
 
And for everyone: Write this using neither nor a reduction.
 
I first tried with ⍤ (rank)
 
''≡~∘'ACGT'
 
Exactly what I had in mind!
 
1:04 PM
then I tried this
{1<⊃⍴⍵:∇¨⍵⋄ ∧/⍵∊'ACGT'}¨
 
That looks more promising.
 
rank does not go inside a nested array, at least I didn't succeed
 
No, it never does. You need Depth for that. Hence the plan to add it.
 
"is nothing but ACGT" :)
 
Yeah.
Here are the additional challenges I gave Richard:
∘ You'll get a nested structure where the leaf nodes are "strings" (i.e. character vectors). Return a similar structure, but each such vector replaced by a scalar indicating if it is valid DNA.
∘ Check if a given string is valid DNA or RNA, but not a mixture.
∘ Ignore whitespace and case.
The first one will be {∧/⍵∊'ACGT'}⍥1 in Dyalog 20.0
 
1:07 PM
@Adám I only have to change the condition, Now it splits it up to scalars
 
Right. All you need to do is check whether the absolute depth is greater than 1.
Also, the outer ¨ shouldn't be there.
 
yes
{1<|≡⍵:∇¨⍵⋄ ∧/⍵∊'ACGT'}
 
That looks right to me.
Any takers for the DNA/RNA and normalising challenges?
@Richard Did you succeed in making the tacit version "proper"?
 
(∧/('ACGT'∊⍨⊢))
(∧/'ACGT'∊⍨⊢)
 
can be neater, imo
 
1:16 PM
using 'ACGT'⍨ like you did in your video?
 
{(∧/⍵∊'AGCT')≠∧/⍵∊'ACGU'} for dna/rna
 
use
 
(∧/∊∘'ACGT')
 
@SilasPoulson Ooh, XOR. would have worked too, as they cannot both be true.
@Richard Exactly. neat, no?
 
yes :)
 
1:19 PM
@SilasPoulson Can you collapse repeated code?
 
Was trying to tacitify but can do that too
 
ovs
@Adám They can be both true, but I guess the intention is 'ACG' -> 1?
 
Oh, right! So it has to be
 
ovs
I would've made the same mistake, for some reason I read not a mixture as not both valid DNA and RNA
 
Subtle.
Ooh, I found a nice one: 1≥∘≢'TU'∩~∘'ACG'
No, wait, this ignores invalid chars.
 
1:27 PM
think you just want 1= on the front
 
Could be none. And still doesn't handle invalid chars.
 
oh, seemed to for me - (1=∘≢'TU'∩~∘'ACG')¨'AW' 'AGUT' 'ACGTTT' 'ACGUUUU' gives 0 0 1 1
which thought what you want
 
ovs
Maybe {3>+/∪'TU'⍳⍵~'ACG'}?
 
Nice.
@SilasPoulson Fails on 'AG'
Anyway, I have to go. Feel free to continue this, and I'll come back to have a look.
 
oh yeah - goes to show need good test cases
 
1:31 PM
See you next week for 2017-6: k-mers!
 
ovs
@Adám That cases could be fixed by replacing = with . The larger issue is that it returns 1 for 'XYZT'
 
ok, and thanks for the extra task!
 
 
3 hours later…
4:04 PM
Day9 -- I have a bug somewhere :/ gist.github.com/xpqz/4e3e8729e883aa593aa387140531a824 Comparing it with a python solution, it gets it right until the 2885th step. Can't work out why..
 
I'm just a beginner but if you want to explain what your code is doing maybe it will generate some ideas. You could do it as a gist.
I'm sure better answers will come along though ;)
 
4:22 PM
@xpqz did you include the initial position 0 0?
 
@Jeremygee Fair. I've added explanatory comments.
@LdBeth I believe so. At least that what I intended +\0,moves to do.
 
And the rule I use to move the tail is: find the difference of x y position of head and tail, if either one is more than 1, add the sign of the difference to the position of tail
 
Yes.. so if positions in either x or y differs by more than 1, we get a diagonal move.
I'll rewrite without the complex numbers and see if that makes a difference.
 
4:37 PM
@xpqz you're not handling multi-digit movement distances
 
Lol
R 4 means R R R R, instead of jump to right with distance 4
 
@dzaima offs
@LdBeth Sure, that should be ok. But as @dzaima says R15 means RRRRRRRRRRRRRRR, not a single R, as in my case, assuming magnitude is a single digit.
@dzaima That was it...! Now it works. Good spot, and boy do I feel silly.
 

« first day (2144 days earlier)      last day (500 days later) »