« first day (2123 days earlier)      last day (541 days later) » 

8:46 AM
user image
2
I am quietly pleased with myself.
 
 
1 hour later…
9:53 AM
@xpqz Really impressive! What are you going to use it for? As a testing environment for new functionalities, understanding APL more thoroughly or just for fun?
 
10:06 AM
@xpqz I AM PLEASED FOR YOU
 
 
3 hours later…
1:00 PM
Welcome to APL Quest 2017-2! Today's quest is Good Evening:
> Write a function that takes an integer array and replaces all the odd numbers with the next greater even number.
 
{⍵/⍨(⍵='"')∨(~≠\'"'=⍵)}
 
@Richard Wat?
 
o sorry
wrong one
one moment :)
 
The automated testing system doesn't check for negative numbers.
 
{⍵+2|⍵}
 
1:02 PM
Nice.
Can you make that tacit?
If we had under: ⌈⍢(÷∘2) which can be written as {2×⌈⍵÷2}
 
(⊢+2|⊢)
 
Yup. What if we prohibited trains?
 
+∘(2∘|)⍨ ;)
 
That's right.
 
Or 2∘|⍛+ with behind
 
1:06 PM
Was just about to write that. 20.0 FTW.
Anything more we can say about this problem?
Industrial solution: {⊃⍤1-(⎕DR⍵)⎕DR⌽0@1⍤1⌽11⎕DR,⍤0-⍵}
May even be faster, as it doesn't need to compute the mod. Or not:
      a←?100 100 100⍴100
      ]runtime -c {⊃⍤1-(⎕DR⍵)⎕DR⌽0@1⍤1⌽11⎕DR,⍤0-⍵}a (⊢+2|⊢)a

  {⊃⍤1-(⎕DR⍵)⎕DR⌽0@1⍤1⌽11⎕DR,⍤0-⍵}a → 3.5E0  |    0% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
  (⊢+2|⊢)a                          → 0.0E0  | -100%
 
@Adám mind explaining this one?
 
Congratulations if you understand this solution.
 
or should I study it?
 
I can explain.
It is built on the principle that to change an odd number to the next lower even number, we simply need to null out the trailing 1 in its binary representation.
However, we actually want the next higher even number, so we work on the negated argument.
First, we add an additional axis ,⍤0 to work on each number separately (otherwise the data bits are contiguous for all elements).
Then we convert to binary with 11⎕DR and reverse for easy access @1 to the last bit.
After that, it is just reversing the entire process.
 
@Adám doesn't work for >127, and will have a bunch of problems across integer width boundaries
 
1:20 PM
Why do you use ⎕DR instead of 2⊥ (inversed)
 
@Richard Fun.
 
Good reason!
 
@dzaima Right. I'll update the test cases as they are clearly insufficient.
 
@dzaima (and largely could not be made to work for ≥2*31, at which point ⎕DR gets you the floating point bits)
 
Does say integer array, though.
 
1:23 PM
so 20000000001 isn't an integer?
 
Well, you could choose to understand integer as meaning internal integer.
 
I think a theoretically correct solution would be valid
 
Then we can make it base (10) independend and use a left argument for the base (10 in this case) But what is then the defintion of uneven?
;)
 
Even and odd doesn't depend on the base, methinks.
 
so base three has two times the amount of uneven numbers compared to the even numbers?
(sorry out of scope discussion)
 
1:30 PM
No, integers divisible by 2 (or 10₂) are even, all others odd.
@user16622930 Hi akamayu, if you want to participate here, please email access@apl.chat
@UtkarshDixit Hi there, interested in APL?
 
@Adám Q2017-3 and Q2017-4 are not very complicated. Can you gice me an additional task based on the original problem? (nevertheless still looking for a better solution for Q2017-3, maybe regex)
 
@Richard I have to go, but can you nudge me about it next week if I haven't gotten back to you?
 
@Adám sure!
 
See you next week for 2017-3: Miss Quoted!
 
1:54 PM
@Richard Well, you know. Writing code keeps me off the streets.
 
:)
Thought you might be trying to add different functions not yet available in Dyalog
or reimplementing them
 
For now it's a "understand how things work under the hood" thing.
 
Then you also could exchange ∘. whith a dot in the ∘ ? :) Everything has a single character but not this one ...
Unicode 2299
 
 
2 hours later…
4:15 PM
+ . + is a train
 
Well done @xpqz! Might try this out, as my brother's new graphing calculator has a python interpreter built-in
 
 
2 hours later…
6:21 PM
@SilasPoulson Probably not ready for human consumption yet.
 

« first day (2123 days earlier)      last day (541 days later) »