« first day (1324 days earlier)      last day (1591 days later) » 

2:31 PM
Hi @LuisMendo
I want to write an answer to your challenge (codegolf.stackexchange.com/q/197379/59487) in MATL
But I need some assistance, because I don't know how to do a couple of things
I'll share my attempt in a minute
The first bit of code is J4:!^Z^!Ys, which I think works the way I want it to work
The algorithm I want to use is the following: generate [1,-1,i,+i] and its cartesian power corresponding to the input, then finding the proportion of lists with non-repeated cumulative sums.
But how should I go about checking whether a row/column only contains unique elements?
I tried J4:!^Z^!Ys"@u@X=]Ym but it doesn't seem to work
 
3:06 PM
So the code QJ4:!^Z^!Ys"@u@X=] generates the correct list of 0s and 1s, the problem is that I don't know how to "collect" the results from the loop and do something with them before outputting
 
Hey @Mr.Xcoder!
I don't think you need the first !. Z^ doesn't care if the input is a column of a row vector:
It just so happens that floating-point inaccuracies are slightly different, I don't know why
Also, you can shorten that with this trick using fft (ZS). Let me know if you need help with that
@Mr.Xcoder You only need v before Ym, to concatenate everything into a column vector before computing its mean
Also, note that with that approach the result for input n actually corresponds to n-1, because you generate visited points, not steps. You would need to add an initial Q in the code, which will take the implicit input and add 1: QJ4:!^Z^!Ys"@u@X=]vYm
Instead of the loop, you could use S to sort each column, then d to find consecutive differences
 
@LuisMendo Okay thanks a lot! I didn't know that
@LuisMendo The result is waaaay off without it
 
3:28 PM
Hmm, I am unable to find a way to shorten the code with the last suggestion
After working with Sd, I would have to get 1 for all the rows without zeros and 0 otherwise
But I can't find a way to save bytes
Anyway, thanks a lot for the help! I'll try to golf it as much as I can
 
3:59 PM
@Mr.Xcoder You can use A for that. It works vertically, i.e. gives a result for each column
 
Oh, nice
And regarding the trick with FFT
Should I generate the list [0,0,0,1] and apply ZF or should I use ZS some other way?
 
@Mr.Xcoder Sorry, I meant ZF, not ZS, yes
To generate that list, the flipped binary expansion of 8 is helpful
 
Yep, that's exactly what I was trying now
 
"Great minds" :-D
 
I'll show you my "final" attempt very shortly
@LuisMendo I have Q8BPZFZ^!YsSdAYm. If you have any other suggestions, please let me know
Huh actually 8BPZF doesn't improve anything compared to J4:!^? (maybe I just did it the wrong way)
 
4:11 PM
@Mr.Xcoder No, I don't see how that could be improved
@Mr.Xcoder Oh, I thoought it would be shorter with the FFT
Pity that !. I don't see why it's needed
 
Great, I think I'm posting it then. Again, thank you very much for your time
 
@Mr.Xcoder It's an Octave thing: 1 2. It doesn't happen in Matlab
@Mr.Xcoder My pleasure!
 

« first day (1324 days earlier)      last day (1591 days later) »