« first day (493 days earlier)      last day (2738 days later) » 

10:52 AM
@LuisMendo I already commented there didn't I? (Q is deleted now)
 
 
7 hours later…
5:30 PM
@Adriaan You commented Cells usually mean looping. Vectorisation in MATLAB is a matrix thing. This is true, but the biggest problem here is that the desired result cannot even exist (a cell array with "holes" in it)
 
I guess he(the poster) wants NA or NaNs in it...
This "anonymous" user is really active...
 
Yes, I've seen her other times, with better questions
@Divakar numpy.unique doesn't have a stable option :-(
 
5:59 PM
@LuisMendo you can use the indices as return value, and index with the sort of that
5 messages moved to Trash can
so, again: you can use the indices as return value, and index with the sort of that:P
>>> a = np.array([1, 2, 6, 4, 2, 3, 2])
>>> u,inds = np.unique(a,return_index=True)
>>> a[sorted(inds)]
array([1, 2, 6, 4, 3])
 
@LuisMendo yeah was about to link to something similar to what Andras did - stackoverflow.com/questions/15637336/…
@LuisMendo You getting into numpy or is it CG thing? Do those try it online with Python support NUmPy?
 
a[sorted(np.unique(a,return_index=1)[1])] # might be golfier; especially with Divakar's help:P
 
more like return_index=1
 
\o/
edited, thanks
 
:~B)
 
6:10 PM
what is that?:D
 
people being transposed
 
ok:P
 
Do they care about performance on PP&CG?
I think I saw some in which it was a mix of bytes and speed
 
yeah, depends on the type of question
 
@AndrasDeak Thanks! I saw that in SO. But I wanted a builtin function (it's for golfing)
 
6:21 PM
So, do those try-it-online for python support NumPy?
 
@Divakar It was for golfing. I wanted to answer this
@Divakar Not Try-it-online (Dennis' platform). But there are several online compilers for Python. Not sure about Numpy; probably that too
 
hmm I see. They should!
 
@Divakar There are challenges (the majority), but also
 
Nothing on <fastest-code>?
ahhh those are tagged on SO questions
 
Here's an example
47
Q: Calculate the number of primes up to n

Liamπ(n) is the number of primes less than or equal to n. Input: a natural number, n. Output: π(n). Scoring: This is a fastest-code challenge. Score will be the sum of times for the score cases. I will time each entry on my computer. Rules and Details Your code should work for n up to 2 bil...

What Dennis did here is amazing
 
6:29 PM
Thanks for linking all those!
Looks quite popular that Q&A
 
There are some with a few hundred votes, but not many
 
How old is PP,CG site? any idea?
 
This one is funny, because, believe it or not, Mathematica has a builtin function for detecting goats
216
Q: Upgoat or Downgoat?

DowngoatGiven an image of a goat, your program should best try to identify whether the goat is upside down, or not. Examples These are examples of what the input may be. Not actual inputs Input: Output: Downgoat Spec Your program should be at most 30,000 bytes The input will contain the full goa...

 
yeah I saw that, its just crazy!
 
@Divakar A few months ago it got out from the beta stage. I think it's about 6 years old
 
6:31 PM
ah okay
so what do you think about the indexing in python? :)
 
This is the online Python compiler I used in my one Python answer up to now
 
ISn't that chaining of indexing fun? Not sure again if "chaining" is the right term there
 
@Divakar I like that negative values count from the end :-) Also that end is implicit (things like [:2])
 
yeah those things make it much nicer for golfing!
 
@Divakar Do you mean for several dimensions, C style? I have only indexed a single dimension up to now
 
6:35 PM
nah I mean like t[::-][1:]
as an example
 
I don't like that you can't grow an array via indexing
 
You cant? like what do you mean?
 
@Divakar So what does do? Wouldn't it be like Matlab's t(:,2:end))?
 
yeah that wasnt a great example I guess
 
@Divakar Ok, it was just to make sure. I have used it very little as of yet :-)
@Divakar I mean this
>>> t = [10, 20, 30]
>>> t[2] = 300
>>> t
[10, 20, 300]
>>> t[3] = 40
Traceback (most recent call last):
  File "<pyshell#79>", line 1, in <module>
    t[3] = 40
IndexError: list assignment index out of range
 
6:38 PM
because of 0 based indexing?
ah you cant grow, got it!
true, that's one thing missing there
 
You need append or extend methods
 
sure
or with tuples : +.
 
Can you give an example? I haven't used tuples yet
 
In [44]: a=(2,3)

In [45]: a+(4,)
Out[45]: (2, 3, 4)
 
@Divakar Ah, got it
Thanks
I think that use of + also applies to lists
 
6:42 PM
ah yeah I guess
 
>>> t = [1,2,3,4]
>>> t+[5,6]
[1, 2, 3, 4, 5, 6]
 
yup!
 
Also * behaves like repmat. That's funny
 
ah yes
pretty neat to initialize stuffs
a,b,c = [1]*3
 
Java also has + to concat strings. It makes sense to overload those operators for arrays / numbers, if the language has (unlike Matlab) a distinction between arrays and numbers
@Divakar Oh, that works?
 
6:44 PM
true, yup it works
 
Strange. An array equalling separate variables
 
no more deal like MATLAB :)
yeah thats the fun part
 
In Matlab you would need some parens on the left-hand-side
 
so two more bytes saved
 
I also get confused by two uses of if. The standard branch, and this
There the if affects the preceding stuff
It's a bit like its use in list comprehension I guess
 
6:47 PM
yeah its like you write everything in one line in that list comprehension
in that same order
[for i in range(3) if somethiing else smthin_else]
 
Heh
I want an immediate answer! — Niloufar 2 hours ago
Immediate downvote
 
7:07 PM
So, all those Pyth or Python solutions on PP,CG, do they use any Python module on a general basis? @LuisMendo
Like those itertools, etc. And when they need to, do they do it like import itertools? If so, wont it cost them bytes?
 
7:24 PM
@Divakar Yes, you need to count the import statement as additional bytes
Pyth doesn't need them I think. It probably incorporates part of those modules, but as a part of the Pyth language
 
ah thats clever from pyth then!
 
Yeah. You avoid importing things
 
It could do the same for NumPy too? But I guess its a choice made by the creator of it?
 
@Divakar Do you mean if Pyth includes Numpy? I don't know, I've used Pyth very seldom
 
yes
does it include it? I am assuming it doesnt
 
7:30 PM
It doesn't seem to include Numpy's arrays
 
kool, thanks for linking me!
 
Heh. Anything to get you into golfing :-P
 
haha still not sure, but never say never I guess :D
 
:-D
 
8:20 PM
0
Q: Parallel computing using Matlab

Ramanathan VaradharajanI am executing windows '.exe' file in 'cmd' prompt for various inputs through Matlab. The commands as follows. for i = 1:n filename = sprintf('input_%d.dat',i); string = sprintf('!sfbox.exe %s', filename); eval(string) end All input files are present and independent of ...

@Adriaan
Using eval to run comand line arguments
hooray!
 
There's a tag named eval? wow!
 
burnination special edition: burn the users
 
purge in hell!
 

« first day (493 days earlier)      last day (2738 days later) »