« first day (72 days earlier)      last day (3163 days later) » 

9:19 PM
@Dustiny may have a point... 7.7 in IMDB is quite a lot!
You should really watch "Blade Runner"
It's a masterpiece
Did you guys see "Moon"? Not very well known, but definitely worth it too!
 
I will :)
Love me some harrison ford
 
I don't know Moon... checking...
 
Harrison Ford is great!
@beaker You won't be disappointed. And it was the first movie from its director, if I recall correctly! Son of singer David Bowie, BTW
 
apparently Harrison Ford hated Blade Runner ;)
 
@beaker Yeah, so I read
But he's WRONG
:-)
 
9:23 PM
he simply lacked the broader view at the time
;)
 
Do you recall Coruscant in Attack of the Clones? It's inspired by Blade Runner
The dark, rainy, crowded city
 
somewhat
 
hm... star wars... is that still a thing?
;)
 
For now it is... next December, I'm not so sure :-D
 
hehe
see you guys monday! Work is done :) Time for the weekend!woo
 
9:31 PM
Enjoy the weekend!
 
Thx Luis, you too
 
@LuisMendo - Buenas moches!
 
Hola, @rayryeng!
 
Buenas mochas?
Good coffees?
 
Jaja.
Sorry, that's Spanish for "haha"
He meant "noches" I presume ;-)
 
9:33 PM
yes lol sorry.
 
prolly ;)
 
was typing without looking.
was talking to someone else while typing to you :D oops
Yes the J is silent I know :)
 
In Spanish? Not really
It's like a stronger "h"
 
I thought it was!
yes that's what I meant sorry
silent as in you don't say it as a g sound... more an h sound.
 
do you know the Scottish word "Loch"? It's like that "ch" I think
Ah, ok
What you said, yes
 
9:35 PM
:D ll
lol
I didn't do that much work today.. .catching up now. Been busy on SO.
Got 245 rep today :| lol
 
Wow! You're close to the cap then
 
I think so!
 
Very nice 3D pictures earlier in this chat!
 
oh you saw :D thanks.
 
That must be a very nice job
 
9:37 PM
It was late last night... early for you.
 
I read over it. Very quickly
 
was talking about what I do for a living.
 
Yes, you mentioned four programming languages!
Matlab and?
 
I actually don't use MATLAB at work :D lol. No license. I'm using the academic license from my university as an alumni.
what I use is Java, Python, C++ and OpenGL/WebGL.
so there's no code that I wrote at work that uses MATLAB. Can't use it!
 
Pity :-)
 
9:40 PM
yes I know :D
things would be done a lot faster if I could
 
Those are all very interresting languages. I know some Java, and Python is kind-of in "fashion", and has a name for being a clear and powerful language. Maybe one day I'll learn it
 
yeah when you have time :) I'm using it because I was rather forced to learn it... not because I didn't have a choice... but because python numpy was the closest thing to MATLAB that I could use.
and that's where it started
It's a bit comical because most of the problems I solve here are in a language I don't use in practice :( lol
 
That's what I lack: I reason to learn it
Well, I don't use much bsxfun or accumarray in my simulation programs either :-)
20
Q: Is this number a prime?

DennisBelieve it or not, we do not yet have a code golf challenge for a simple primality test. While it may not be the most interesting challenge, particularly for "usual" languages, it can be nontrivial in many languages. Rosetta code features lists by language of idiomatic approaches to primality te...

I'm thinking @(n)all(mod(n,2:n-1))
 
isprime has already been used :)
 
Yes, that's why
 
9:46 PM
ah shit
lol
 
Better: @(n)all(mod(n,2:n/2))
 
You only have to check up to sqrt(n).
 
make sure n is even
 
but that eats up more bytes.
never mind, misread the problem
 
won't mod fail if you give it a non-integer?
 
9:47 PM
Yes, isprime is shorter
I don't
The colon takes care of that (implicit step 1)
 
aaah
that's right :)
 
@LuisMendo - So true if it's prime and false if it isn't?
 
numel(factor(input('')))<2 is even longer :-(
@rayryeng Yes, that's what I (quickly) read
It's hard to beat isprime!
 
definitely lol
There's nothing that I can think of that can
OH... what about gcd?
Let me figure something out
 
Good idea, gcd is three bytes!
 
9:53 PM
the tricky part is, what do you compare the input to?
 
gcd(n,2:n-1) gives you the GCD of n from 2 up to n-1
If the entire vector is all 1, the number n is prime.
 
nice
 
so you can wrap this with all... but that takes up more bytes.
example
 
so, the same as mod
 
>> n = 10;
>> gcd(n,2:n-1)

ans =

     2     1     2     5     2     1     2     1

>> n=11;
>> gcd(n,2:n-1)

ans =

     1     1     1     1     1     1     1     1     1
 
9:56 PM
any(primes(n)==n)
 
My golf submission would be:
 
Same as mod again
 
n=input(''); all(gcd(n,2:n-1)==1)
that still doesn't beat isprime. pooey.
 
if you restrict it to Octave you can save a couple of bytes
 
Also, use @(n)...
 
9:58 PM
OH
@(n)all(gcd(n,2:n-1)==1)
24 characters
 
run with it
 
Sounds good.
 
Or @(n)all(mod(n,2:n-1)). Same bytes
 
Do we need to ask for input?
I'm confused with the golf requirements.
This only creates a function for us.
 
Ah, no, sorry, mod is shorter!
The usual thing is: stdin or function
 
10:01 PM
ok
yeah I'm gonna try and shave some of
off*
 
Hey, look: the challange says:
If (and only if) your language in unable to accept any kind of user-input, you may hardcode the input in your program.
In this case, the hardcoded integer must be easily exchangeable. In particular, it may appear only in a single place in the entire program.
 
well MATLAB can read in input lol
 
But wee are using the input twice :-(
Unless we cheat: all(mod(n,2:2^32-1))
 
hahahaha
 
:-D
 
10:03 PM
well MATLAB can accept user input though.... don't think we can pull that off :(
 
that would match n mod n
 
Oooh
It says "unable"
I read "able"
 
yes lol
 
:-D
Makes more sense this way, of course
 
yeah this is for more esoteric languages, like Brainf*ck.
 
10:04 PM
F* ck Brainf* ck
Those languages remove all the fun
 
LOL
 
I can't type two asterisks properly LOL
The markup
 
hhahahahah :)
I submitted my code golf. 32 bytes. Doesn't beat isprime. :(
 
Why not @(n) instead of input? That'd be shorter
 
It's a complete program that accepts an integer, right?
oh wait, never mind. function or input
I need two more bytes to assign the anonymous function to a variable.
so 26 bytes
 
10:13 PM
In Codegolf the consensus (I think) is you don't need that
I've done it before
No name
Then call it with ans(17)
 
you sure?
repeated calls with overwrite the ans variable.
so you're allowed to do that?
 
I was told so, I think. Let me find it
 
ok. in the mean time, I'll modify
 
2
A: Sign that word!

Luis MendoMatlab, 13 5 bytes The code simply defines a function handle to the sort function: @sort To call it, use ans('this'), where 'this' represents the input string (thanks to Alex A. and Stewie Griffin): >> @sort ans = @sort >> ans('this') ans = hist

 
Thanks, @beaker!
I couldn't find it :-D
 
10:18 PM
Thanks! 24 bytes it is
 
This one too
15
A: Stop, stand there where you are!

Luis MendoMatlab, 33 bytes function f(t) tic;while toc<t,end Or you can also use this in Octave: try it online Matlab, 31 bytes As suggested by @flawr, it can be done with an anonymous function (it should be assigned a name in order to use it): @(t)eval('tic;while toc<t,end') Example: >> f=@(t)ev...

Watch also the eval trick to pack several statements. It's an even more evil use of eval!
 
hey code golf is not for the faint hearted :)
 
Suggested by flawr, not my idea
 
haha :D
 
:-)
 
10:27 PM
Nice job with sprintf Luis!
 
Yours is nice too, and doesn't require removing unwanted characters at the end!
 
I'd say yours is faster. Removing the last two characters is fine.
 
10:43 PM
Testing if Zalgo test can be used here:
C̷̢̲͔̪̭̫͉ͣ̑͋̏̅͛̆̇̓̒̀̒ͦ͒̌̐͘ą̬̯͍̥̞͓͎̯̩̫̥͕̗̇͒͆ͪ͂̐͌̈́̑̐̍ͭ́̕͠n͍͓͙͓̼̠̦͍̥̻̓̉̉ͦ̀̉ͯ͛́̕͡͠ ̜̘͈͈̰͕͙̉͂̅ͬ̂̈́͐͟͢yͨ̈́͆̌ͣͭ́ͣͦ͐̉̅ͫ͆͏̧͓̺̰̬̙̳͇͔̝̼̮̭͓͉̕ͅo̧̰͉̩̩͚̰͎̞̱͗̏̉̌̐͑̕͞ͅu̴͛̐ͤ̍͛͛͝͏̡͙̼̠͙͔̳̙̯̦͓̲͔̭̰̘͖͓͞ ̛̛̛͇̲̫͉͓͚͕̦̻̣̮̼͕̥̺̺͌̒͛̾͛͒̽ͫ̂ͪ̐͗̽̓͌͆ͥ̀͝r̵̴̶̬͉̤̬ͯ̎ͥ͑͘͜ę́ͩͭ͛́͂̇͝҉͖̰̹a̛̒̋̔̓̎ͦ͊̃͒͑͗̀͏̢̖͓̙͕̳̝̻̦̥̲̦͉̯͉̖̝̕ͅͅd̵̠̠̲͇̜̲͔̏ͬ͂͋͑͘͘ ̸̢̧̛͓̖̲̞̖̰͉̲̹̖͍̞ͮ̏͊̿̔͗̌ͦ͒ͭ͂ͅͅt̐ͣ͑͋̄͞҉̫͎͖̫̹̲̼͕̫̹̞̼̱͉͇̀͢ͅh̢̬̝̹̲̳̼̫̹͕͔̱̥ͭͨ̍ͯͨ̔ͨ̋̂̐ͦ̌ͯ͆ͣ́͜͡ͅĩ̶̧̪̣̙͓͖͍̞͓͈̜̼̗͙̖̥̥̤̿̆́ͦ͘͜ṣ̷̨̨̝̯͈̦̭̦̝͖̮̮̥̦̙̤̌͂̿ͬͤ̅͛̐̑̋͢͟ͅ ̇͗̉̀̒҉̟̦̠̰̫͕̠̣͇͖̟͞o̵̴̶̡̦̹̠͈͙̘͙̥̣̙̱͕̰͍̲͓̳͓̙͒̀ͯͬͫͧ̍̊̍͋͌̽̓ͥ͠h̸̟̯̭̺̞̠̹̼̱̰̼̯͙̥̰͚̼̲͆ͬ̃̐ͥ̾ͤͬ̀ͩ͜͜ͅ ͊ͣ͗ͤ̒̈́̊͋ͯ͑̃̓ͬ͛̊ͣͨ̊̀̀͠͏̡̩̣͉̻̟̙̩̭͎̯̙̲̤̥̰̞͚̱m̶͂ͬͪ͊͛͒̈́̍ͣ̊͂̍̋ͫ͋͗҉͏
 
what the hell!?
 
Hahah, looks like it works :-D
Ļet'͠ş ̸tr̵y̷ ͝som͘et҉hing ͟so̷fter
 
heh :)
What the hell is this question?
0
Q: Modelling of a Flat plate collector/ Solar water heater in MATLAB

JessI am currently busy with my thesis and I desperately need help. I am trying to model a steady state flat plate collector/ solar water heater in MATLAB. I feel like I am coming to a dead end with too many unknowns to solve for. Can anyone perhaps help with a template of some sorts or know of any m...

I want to model a water heater. I don't know where to start. Please help me!
 
It's a very suitable example of 4 or 5 close reasons
 
I don't know which one to choose lol
It can be too broad, unclear what you're asking, close because you want to know why the code isn't working.
 
10:46 PM
I just picked one :-)
 
hehe :)
I'm going to refrain from commenting at the risk of sounding rude.
The news feed for questions at the top is great. Lets me catch up on unanswered questions :D
 
Yes, I always forget to tell you about that. Initially I doubted it was a good idea. But indeed it is. Specially the blogs you set as feeds!
 
I initially wanted to place them directly in our chat window... but Dev-iL said it was a bad idea. He made it less intrusive by making it pop up at the top left window
@LuisMendo - Thanks :D
the blogs they don't update often, so putting them into the chat window is suitable.
 
Yes, they are the rigtht amount/frequency. Not too intrusive. And they are interesting blogs
 
very nice :)
I added some. Dev-iL added the others.
@LuisMendo - I'm going to borrow your code for a Python 2 submission if you don't mind
def f(n):print(all([n%i for i in range(2,n)]))
 
10:58 PM
Sure not!! Go ahead!
 
It's basically the same as MATLAB :)
Python has an all function that accepts a variable that can be iterated over and returns True or False like you'd expect.
 
What does the % mean? mod, right?
 
correct!
def defines a function f that takes in an integer n.
print obviously. all obviously
all takes in anything that can be iterated over... so [] is a list
and I create a list of n mod i for i=2,3,...,n-1.
We then check to see if every value in this list is non-zero. If it is, the number is prime, so it prints True. Else, False.
 
Thanks for the explanation!
I keep hearing of Python's lists
They seem to be a very basic data type there
 
Python lists are basically their version of a cell array
 
11:04 PM
Any analog in Matlab?
Oh, ok
 
Yup. Cell arrays
You can put ANYTHING in lists.
 
So they can have mixed content
 
Correct.
When it comes to "iterables", no data type in Python is just for a single data type.
so you don't have an array of just integers, or an array of just floats.
Lists are basically cell arrays. You also have what are known as tuples, which are the same as lists but they are IMMUTABLE.
which means you can't change their contents once created. If you want to change the contents, you must create a new tuple with that entry modified.
You create tuples with () instead of [].
And you can also have sets which ensure that there are only unique entries inside the collection.
 
The concept of immutable is strange, coming from Matlab
 
Yes that's correct.
It takes a little bit to get used to!
 
11:07 PM
A set is something Matlab could definitely use. I sometimes miss that type
I see!
 
oh yes :)
So you can do something like
A = set([1,2,3]), then trying to add 2 to the set ensures that you just have [1,2,3] rather than [1,2,3,2].
Lists, sets, tuples, and there are dictionaries. It's basically a containers.map.
You assign things to it by key/value pairs very much like in MATLAB.
 
A set type could be defined with Matlab's OOP I guess (I've never used OOP, other than graphic handle stuff)
Or throw in a lot of uniques :-)
 
yeah me too
hehe :)
If you do get around to it, Python numpy is very nice to use since broadcasting is built-in to the framework.
So there's no bsxfun calls.
 
That's good on one side, but bad on the other
Some of the magic is lost :-)
 
definitely. You're prone to have errors if you're not careful.
 
11:10 PM
Yes, also that
 
There's also no need for a sub2ind equivalent. You can very well keep row and column indices as separate lists and modify values in the matrix accordingly.
 
Hard to debug
 
so if r and c were arrays, doing A[r,c] = d where d is also an array of the same size works.
 
I see. So no automatic "combinations" of subindices?
 
Yes, you can still use logical indexing :)
A[mask] = b[mask]. That is naturally supported.
 
11:12 PM
I mean, it you want Matlab's A([2 3],[3 4]) = 10:10:40, what do you do?
 
yup you can do that.
However, there is an intricacy you must look out for.
So if A was a 10 x 10 matrix... collecting every other element in MATLAB is just
A(2:2:end,2:2:end), right?
in numpy it's different. What happens is that at each dimension, it returns the sliced version of the matrix already
 
right!
 
so in numpy what actually happens is that it gives you every other row first and that gets stored in a temporary matrix
which you then index into after.
so at each dimension, it returns a temporary matrix that is already sliced.
 
But isn't that what Matlab does too?
 
That was one of the things that always bit me in the butt.
 
11:15 PM
>> A = magic(5)
A =
    17    24     1     8    15
    23     5     7    14    16
     4     6    13    20    22
    10    12    19    21     3
    11    18    25     2     9
>> A(2:2:end,2:2:end)
ans =
     5    14
    12    21
What would Python return?
 
Yes it would return the same thing
I just chose a poor example lol
I'm trying to remember the exact instance of my problem.
 
:-D
 
ok it'll come back to me later :)
 
No worries! Hehe
See:
0
Q: ForLoop to flip every third element in array of logical values (1 and 0)?

kalLet's say I have an array 1 x N of 1 and 0 values. Using for loop I am trying to flip every third value of the array. How would I go about this? An example of what I would like to achieve V = [1 0 1 0 0 1] V = [1 0 0 0 0 0]

Very easy!
 
oh shoot. I should have let you answer lol.
 
11:19 PM
No, haha, that's ok!
+1 already
 
oh btw Luis... one thing about lists in Python... is that simply assigning a variable to a list actually makes a "reference" to it. A pointer if you will
so if you did:
a = [1,2,3]
b = a
b[1] = 5 #0-indexing
a would become [1,5,3]
if you want to make a "deep-copy", you'd do b = a[:], or use the explicit list function: b = list(a)
It's also one of those things that have bit me in the past.
 
Aah. So they are pointers, I see. Like objects in Java, if I recall correctly
 
yes that's right!
 
That means when passing them to a function, it's pass-by-reference, right?
And thus the function can modify the outside
 
yup that's right.
 
11:26 PM
At university I studied Modula-2, which is more or less like Pascal
It has a fine concept for that. You can choose to pass by reference or by value
You add VAR if I recall correctly, and the variable becomes a reference
and so changes to it are seen outside
That's very clear syntax (or is it grammar?) I think
I may be wrong, It was long ago :-)
 
oh no that's fine :) that makes sense to me!
 
yeah in python, whenever you have a variable pointing to a value,
And another one that also points tot eh same value
like a = b = c
it's equivalent to a = c and b = c
a isn't connected to b in any way assuming c is the value
in java a is assigned to b which is assigned to c :)
 
That's... confusing (at first!) :-)
I'm trying to make sense of this
1
Q: Generate ordered binary combinations without repetitions

fpg1503Challenge Write the shortest program that receives two signed integers n and i and for each i between 1 and 2^n - 1 returns the next ordered permutation based on the binary representation of the number. There is no specific order of the combinations but the number of 1s in the binary representa...

I don't see what the challenge consists in
 
Yeah it's a bit confusing, just think about python always assigning the variable to the address of the value
 
I'll brb guys!
 
11:36 PM
Well, if it's always this way, it's less confusing. But then functions don't make much sense? I mean, if everything is by-reference. Not that I like functions in Matlab very much. I tend to have everything in one or several scripts, where every part of the code sees the other part's variables. The parts trust each other :-)
@rayryeng I'm soon going to sleep! See you!
 
ah yeah, in java I make sure I practice encapsulation
@LuisMendo and pass by reference to parameters instead of each function taking the global variables
np ray!
By the way, downloading matlab as we speak haha.
It's a 3 month trial for the stanford machine learning course - I'm really excited :)
whaaat matlab doesn't have pass by reference?
 
no. no it doesn't
it's a bit of a pain sometimes :)
 
darn... that's gonna prove to be a pain later on
yep... So people don't usually use matlab for projects that get really complicated right?
wait so exp(x) is e^x
can't you just say e^x then?
 
11:54 PM
^ works on scalars
 
@beaker oh, so exp(x) applies it to a matrix/scalar while ^x only does it to a scalar?
 
as far as i understand
gotta run... dinner time
 
gotcha. Thank you! Enjoy your dinner :)
 

« first day (72 days earlier)      last day (3163 days later) »