« first day (546 days earlier)      last day (4385 days later) » 

4:00 PM
wtf...
0
Q: C how to measure time correctly?

facundoThis is the "algorithm", but when I want to measure the execution time it gives me zero. Why? #define ARRAY_SIZE 10000 ... clock_t start, end; start = clock(); for( i = 0; i < ARRAY_SIZE; i++) { non_parallel[i] = vec[i] * vec[i]; } end = clock(); printf( "Number of seconds: %f\n", (end-st...

two wrong answers got upvoted
 
@Mysticial Inacceptable. I immediately downvoted that answer by this guy “Mysticial”
 
:)
I've seriously never seen 3 consecutive wrong answers (excluding my own) on an easy question before.
 
@Mysticial then downvote them
 
@Abyx No need, my answer is already voted above them.
I prefer negative comments over downvoting.
 
4:24 PM
I prefer both a negative comment and a down vote.
Doing only one of them isn't fun enough…
 
I like to go to the person's house and slap them
 
@Pubby it's our house
 
In the middle of the street?
 
@Pubby yep, house with a street inside of it
 
hmm... I really need to answer more questions...
It seems that every time I make a good answer, I get a vote on one of my top two answers.
so people really do click through to my profile and upvote my posts.
 
4:27 PM
@Mysticial After having read through some of your answers, I have to say that if I ever have a performance question again, I’ll ask you directly …
 
anyways, off to lunch
 
The research-level analyses that you’ve posted e.g. on the question of why two loops perform better than one loop almost merit a paper
 
4:52 PM
Is it OK to have a class only with static methods, just to create a namespace for them?
e.g. class X { public: static void foo(); private: static void step1(); ... stepN(); };
 
What's wrong with namespace X?
As for private functions: put them in a .cpp file…
Also: classes can be instantiated, namespace cannot. You have to explicitly delete the constructors.
And classes can be used as template parameters, namespaces cannot. And classes have RTTI, namespaces have not.
 
well... it looks reasonable to put'em in .cpp, but having a 20 LOC .cpp file with two or four functions, and 5 LOC .h file - I don't feel to like it
so, it's about

struct X
{
    static void foo() {...}
private:
    static void step1() {...}
    ...
    static void stepN() {...}
};

vs

namespace X
{
    namespace details
    {
        inline void step1() {...}
        ...
        inline void stepN() {...}
    }

    inline void foo() {...}
}
 
5:07 PM
@KonradRudolph Or you can just ask it on SO... :P Who knows. It might become the next loop question. :)
which... come to think of it - popular performance questions aren't that rare. There's been at least 4 of them in the last 5 months in just the C/C++ tags.
 
I don't really understand why you don't want to have a .cpp file that has more LOC than the .h file…
Oooooh is it about the inlining of functions?
In that case, ehm… use local functors or lambdas?
 
Is there a way to licence software in a way that means when you sell it, people can have the source code, edit it, and only profit for the edits?
 
@KianMayne sure. Just write an unambiguous document explaining that.
 
I was hoping I wouldn't have to write stuff, but oh well
 
There might be such a license already, but I'm not aware of any.
You could just modify the BSD license or another existing one. It's not very difficult.
Edit summary: "Made the answer more clear."
Actual reason: "Bumped the question to the Top Questions > Interesting page so that I get more upvotes."
 
5:40 PM
You sicken me. There are children dying out there
 
5:55 PM
@KianMayne hi
 
Hey
 
Aloha
 
@LeeChung welcome
@KianMayne wot you doing??
 
thaks
 
@james I'm writing the setting up portion of my timetable program
So like picking what subjects
When I say writing, I'm starting to build the interface
 
5:57 PM
oh he seems dangerous :p
 
@LeeChung why??
 
who are you!
 
@LeeChung i am who..
 
who are you
 
I need a faster machine...
 
6:01 PM
@KianMayne Just a larger timetable, will do :)
 
@sehe Huh? Ahh I get it
It's almost crashing when I ask Visual Studio to do something
 
@KianMayne Specs? I'm running VS2010 on WinXP 32bit in about 1Gb of RAM (of course there is more RAM)
@KianMayne The obvious solution is to ask Visual Studio to shutdown
 
Win 7, 64bit VS is using 131MB/2GB RAM
 
I crash intellesense a lot... not that it ever actually works...
It's only reliable on single module applications.
and fails 90% of the time on multi-module apps.
 
The real problem is the 3.2Ghz Single Core Pentium 4
 
6:04 PM
@KianMayne That's not Visual Studio's fault... :D
 
I never said it was
I'm waiting for someone to get their new i7 board, then I get a good Core 2 Duo board + CPU
 
How does that work? What does Core 2 Duo have anything to do with i7?
trade in? hand-me-downer?
 
@KianMayne That's a good deal. Buy an SSD for that new system and it will be on PAR with most new i3/i5 PCs you can buy
@Mysticial my bet: h-m-d
 
Mmhmm! I'm already using a 1TB hdd from him (my sisters (boy?)friend)
 
Never noticed before but the way gravatars 'fall' out of their ranks when users exit the chat room, can look somewhat dramatic
 
6:08 PM
kinda sad that I keep my Core 2 Xeon off 95% of the time.
Occasionally I'll turn it on to run some code for a few days... then off it goes.
 
@KianMayne You don't know whether he's a boy or a girl? Hehe
 
Also 1.5Gb out of the 2.5 I own was from him
Hahaha
Oh and my DVD writer
But I still need to get that £26 for the new screen
 
@KianMayne He's a good friend, from the looks of it
 
Yeah :) I fixed a netbook of his because he was too drunk and got £10 out of it
 
I do always repurpose my old PC parts in similar ways.
 
6:11 PM
woah, I think my dorm's bandwidth cap isn't working...
 
@KianMayne So, he was too drunk, and still in a hurry to fix it. Amazing
@Mysticial Profit
 
or maybe because I'm confusing them by hiding behind a switch or something...
 
@Mysticial What is the symptom? High download speeds may be due to proxy caches
 
Haha tell me about it, it was like a 3 hour job to be fair, I think he just couldn't be bothered either
 
@sehe Normally when I'm capped (and I haven't been for a year now), it slows all outbound traffic to 32kb/s per connection.
But since then I've added a switch between me and the wall along with several other machines.
 
6:12 PM
E.g. if on our company network I download a largish package (say, a service pack), I can download it a second time at insane speeds, even from a different computer, due the application proxy server
 
I'm way past my 2GB daily cap and it isn't capping my connections.
 
You know the kind of job where USB install isn't working, harddrive looks broken, try creating a partition with Windows install in it, install from that partition
Good trick
 
Normally I stream my downloads through my office which isn't capped - and on-campus traffic doesn't count towards the cap.
 
@Mysticial 32kb/s per connection is fruity. This just invites download managers with many concurrent connections, fragmenting bandwidth and increasing congestion/collision rates
 
But there's one very stubborn torrent which seems to only run fast in my down.
Oh... now it finally kicks in
it usually kicks in 7 min. past the hour
and it just did now...
 
6:14 PM
@Mysticial Awwh, let down
 
There's a 66GB torrent that's going at like 10 kb/s in my office.
But goes at 500kb/s in my dorm...
 
@Mysticial Would it help if I just downloaded it and you could get it via, say, http/ftp/ssh?
 
And I can't seem to trick utorrent into recognizing on campus connections as local peers...
 
I have a variety of servers across US/Europe that can do up to 6Mbyte/s
 
nah, it's good. I'm not in a hurry.
 
6:16 PM
@Mysticial It's probably more like traffic shaping. On Campus, death by torrents is not imaginary
 
They usually shape the dorms (hence the bandwidth cap). They don't usually touch the offices.
 
Time to cook dinner
See you guys in like 15 minutes
 
@KianMayne Fast Food redefined
 
They block incoming connections to the office though. But they don't cap the bandwidth.
So on a good day, I can easily drop in 50GB of torrents and it'll finish over night.
 
@Mysticial Setup a tunnel over ssh. Profit
 
6:18 PM
I just tried that last night by dropping 10GB of torrents. it finished in a couple hours. So it's just that one torrent that's being dick.
 
@Mysticial My home connection can do that in 7.11hrs (2 MByte/s)
 
@sehe Last year my dorm did only 1 MB/s and my office had full 100 Mbit network/internet.
So I used to "sneaker" my downloads back by foot on an ext. drive.
This year, is seems like my dorm got upgraded to full 100 Mbit network/internet as well...
So 10 MB/s transfer between dorm and office... no more "sneakering"
 
@Mysticial hihi. I admit to using snail mail for a new initial backup set for a family member the other week. It was 20Gbs, and I wasn't prepared to wait a week for it to arrive over their uplink
 
Back
@sehe I just put it in the oven :D
 
afk - putting my little ones to bed. They're late (Saturday, woke up at noon :))
 
6:26 PM
@sehe If I were to set up a backup solution I'd do exactly that: all backed up docs on an external drive, then incremental auto syncy thing
 
I keep my backups in different locations.
When hard drive prices come back down, I'm leaving a backup of my stuff at home (in California).
*I'm at school in Illinois.
So that way it'll take more than one nuclear strike to destroy my data - even though it'll take less than one to kill me.
 
Haha
The network technician at my primary school worked in the navy before coming to my primary and he told me about these computers that were so massive and bulky, that if you kicked it hard enough, then rather than break the computer, you would break your foot
 
that's be the case with any rack server
 
and that it would survive a nuclear blast, so the entire crew would be killed, but the computer would be fine
...at the bottom of the ocean (this was on a submarine)
 
6:49 PM
Crap I need to check the food
 
Ell
argghh nothing will compile!
 
What about int main() { return 0; } ;P
 
Ell
okay that will :L
would the compiler complain if it cant find a certain library?
 
Probably
 
Ell
oh no
oh god no
i have two versions of boost isntalled :O one system and one by me
 
6:53 PM
What? :L
Hahahaha
 
Ell
ugh this will be messy -.-
but seriously nothing is linking >.<
 
@Ell that's a blessing.
@KianMayne int main() { return 0; } // ;P (FTFY)
 
Ell
@sehe you can have it if you want :P
 
@sehe Hahaha
 
@Ell Usually not an issue. A judicious -I ~/myboost -L ~/myboost/stage/lib (or similar) would do
 
Ell
7:02 PM
then I really have no idea why my code isn't linking :o
 
Mmm beanburger
I'm no vegetarian but these are nice
 
hiyo
 
@JohnSmith Dude! You might get this a lot, but is that your real name
 
John Smith
Yes
 
Epic
 
7:04 PM
at least it's not Michael Bolton </officespace>
or John Doe
how do i make something recursive iterative
 
Ell
that depends.what is it?
instead of calling the function again
push some values onto an array
 
but how do i know how to do that
 
Ell
then next iteration of the loop, act depending on those values
 
i am not sure how to restructure
 
Post code then (:
and we'll look
If it's long, use ideone
What would be a better way of saying "How many timetable weeks do you have?"
 
Ell
7:12 PM
hmm
not sure really
 
Pray tell, timetable weeks -- how many have you, knave?
idk it sounds fine as is honestly
 
@KianMayne I wish to query your possessed quantity of timetable weeks.
 
Thanks for the wonderful, helpful suggestions :|
I'll change it to timetabled
 
Ell
g++ is giving me errors that contain stuff like this: (.text._ZN5boost4asio6detail13posix_tss_ptrINS1_10call_stackINS1_15task_io_serv‌​iceENS4_11thread_infoEE7contextEED2Ev[_ZN5boost4asio6detail13posix_tss_ptrINS1_10‌​call_stackINS1_15task_io_serviceENS4_11thread_infoEE7contextEED5Ev]+0x15) -how do i get it to not show all this stuff?
 
if it's giving you an error, don't you want to see it?
 
Ell
7:16 PM
Yeah
but not all of the name mangling (is that what this is?)
 
what is the standard way of replacing recursion
 
Is "bananable" a word?
 
replace it with an array?
yes
 
Ell
replace it with one or more loops
 
replacing a recursion is with a loop
dang it, ninja'd
 
Ell
7:18 PM
:D
 
>:(
jk, :D
Ell, can I ask you a question?
 
Ell
of course :)
 
What is a word that describes a syllabus of your test exam, something that describes the range of chapters your test is about to test you with...
?
 
but how
do i literally replace the call with a loop
 
Ell
I would say exam content really :L I don't quite understand what you are asking?
@JohnSmith no, let me find a tutorial for you
 
7:20 PM
Oh
@JohnSmith Protip: Copy/Paste your recursion function, then delete the contents of that function.
 
lol
 
Ell
37
Q: Way to go from recursion to iteration

Gustavo CarrenoI've used recursion quite a lot on my many years of programming to solve simple problems, but I'm fully aware that sometimes you need iteration due to memory/speed problems. So, sometime in the very far past I went to try and find if there existed any "pattern" or text-book way of transforming a...

 
i read this one earlier
and was unable to make sense of it
 
Ell
hmm okay
 
Yay! I don't have to re-invent the WPF wheel for a two handled slider :D
 
7:22 PM
@JohnSmith Another protip: Use a paper, write down what your problem is, use divide-and-conquer, and make sure you iterate (loop) through each step.
Rules of recursion -> iteration (for, while looping): Use divide-and-conquer, then use a counter to count upwards/downwards to remind you of what level (heap) you are in.
New Protip: Ignore my divide-and-conquer. It's a misleading title. :P
 
I mean, if you think that divide and conquer is good for you, go ahead and use it.
But it's not worth it, if your problem is a bit big.
@Ell I'm just asking for a vocabulary that describes the exam content, where the content is testing your knowledge from Chapter X of a book snippet, Chapter Y, section A of some excerpt, etc. It's something that you know the range of your curriculum from beginning of the semester to midterms, from midterms to final exams. (or something)
 
Ell
@tommai78101 sorry I'm tired today I still don't quite get it :P
 
@Ell Ok then. Sorry for asking. :P I guess "content" will have to do.
 
Ell
@tommai78101 no don't be sorry, I mean I am tired which is why I don't understand :L
 
7:31 PM
:/ Off to bed then.
 
can anyone help me change the code to iterative
 
Ell
@JohnSmith give us the code and we will try :)
 
No, not Monty.
 
Ell
@JohnSmith sorry I don't do python :L
 
7:34 PM
Monty :L
 
Yes, it's Monty Python. (for those wondering)
 
Ell
:P
 
Did you know: Java is the most programmed language for back-end development.
/r/TIL
 
nobody has any meaningful statistics on what language is used the most
 
@tom_mai78101 Oh I knew ;)
 
7:39 PM
@DeadMG guess you're right. Sometimes, /r/TIL may not be accurate. :/
Today I also learned that some schools developed "Teaching to the test" curriculums for standardized tests, such as GRE and SAT in USA. (en.wikipedia.org/wiki/Teaching_to_the_test)
 
Xeo
7:59 PM
Damn, now if I only had the confidence to enter that...
 
@Xeo Do it man!
 
8:55 PM
Anyone have a favorite file hashing algorithm (for hash maps, not for cryptographic purposes)?
Using MD5 would be easy enough, but I wonder if there's an obviously better choice
 
SHA-256 is my favorite right now
 
@Mysticial That's a bit heavier than MD5, isn't it? I don't need hashes for security, I just want to get a file hash quickly
 
MD5 is slow and broken.
 
MD5 is about twice as fast as SHA-256, I think
 
SHA-256 actually runs faster than MD5.
 
8:58 PM
@Mysticial I'm aware of that, but as I said, I have no need for security, this is just for building a hash map of files
 
don't take my numbers word-for-word. It's what I remember from seeing some benchmarks.
So if you're think you're correct. Then go for it.
 
heck, I think even CRC32 is slower than SHA-256 if you don't have SSE4.2
 
Not that I wouldn't use SHA-256 - I was just looking to see if anybody knew of a specifically good choice for quickly getting a hash of a file
 
wow, those numbers are significantly different from the ones I've seen.
I guess it's a judgement call. Hash algorithms are probably sensitive to the hardware.
as well as whoever wrote it.
 
9:00 PM
I imagine so, yeah
I don't have much experience with different hashes. I know enough to know that you should use bcrypt for passwords, but I haven't used hashes for much besides storing passwords
 
can anyone help me make my recursion into iterative?
 
I haven't been in the business of superoptimizing hashing algorithms... so I wouldn't know what's the best.
@JohnSmith I'm guessing that means increasing the stack didn't work?
 
different problem
but i have a recursive solution, but i need to make it iterative
because it explodes otherwise
 
Maybe I just want to use a CRC
 
anybody here.
?
 
9:11 PM
No, we're all getting coffee simultaneously
 
oh ok.
 
Haha
 
anybody here solving the google code jam?
 
No
Link?
 
code.google.com/codejam
what i want to know is that, there are 288 recycled numbers between 1111 and 2222 (by algorithm).. but google says that there are 287..
What is the reason for the one less in the number?
Can somebody please explain?
 
9:20 PM
What is meant by the term recycled number
But man, I'm pretty busy
 
got it.. thanks btw..
for ur time..
 
Err
I didn't do anything
But also
> Collaborating with anyone else during the contest is strictly prohibited and will result in your disqualification. This includes discussing or sharing the problem statements or solutions with others.
Perhaps you ought to delete those posts
 
oh. sorry..
i am not able to delete the posts.. can u help me
 
hmm
to work on 3D game.. or to work on language
 
can you help me make my algo iterative
 
9:31 PM
Did you seriously just ask that in front of the puppy?
 
@KianMayne Is ther a way i can delete my earlier post?
 
why would you want to delete it?
 
@Mysticial woof
 
According to the developers of the programming language Julia, this filthy piece of code is an example of how their language is simpler than C++.
 
anyone?
 
9:47 PM
What exactly are you stuck on? Right now your question is too broad.
 
0
Q: Need to make this recursive algorithm iterative due to stack overflow

John SmithBasically I have this huge function in Python (which I've simplified to the bare basics) def rec(a,b): if stoppingCondition==True: return 1 key=(a,b) if key in memo: return memo[key] if b==side condition: memo[key]=rec(a+1,b) #RECURSIVE CALL return memo[key] total=0 ...

a is a number and technically b is a bitmask (in Python, a list of 1's and 0's)
i literally call it from main with rec(0,[0]*w*h)
 
The problem is, not everyone here knows python...
 
@VigneshPT No it's too late
 
at least I don't...
 
it could be in any language
the python bit doesn't matter
it's more a logic/cs problem
 
9:49 PM
I don't know Python either, this is the C++ room after all. :P
 
Well it does, because we don't understand the code
 
...
did you look at the post?
 
Right, in general just use an actual stack data structure instead of the call stack, and voila you're done.
 
or how to build it different
 
it's pseudocode largely
 
9:49 PM
ok
 
Sorry I'm not being very helpful, just I'm feeling really lazy after working really hard all day
 
@GmanNIckG idk why everyone says that like it's so easy... I know it should use a stack/array instead of a call stack but *the problem is that I have no idea how i do that for my case
 
@JohnSmith Which leads us back into the problem of not knowing Python, so I can't show you. :P You should separate the two problems: learn how to use a stack in Python, then reimplement your function. Don't try to do both at the same time, start simpler. Implement factorial with a stack, for example.
 
i took out most of the gory details that were language-specific and tried to make it general to logic structures/loops that are common in most languages
factorials are trivial to do with a stack
i don't know how it's done *in my specific case
has nothing to do with python
 
I tried to understand the code and I struggled
 
9:53 PM
it's not real code
it's pseudocode
recursive vs. iterative is largely one of structure and logic, not specific syntax
 
@JohnSmith: Could you describe, in English, what the code is trying to do?
 
It's counting valid solutions to a problem using memoization
a is an integer, b is a bitmask
 
Ok, fine:

    functon f(x, y, ..., z)
    {
        blah;
        if (blaz)
            f(x', y', ..., z');
        else
            f(x'', y'', ..., z'');
    }

becomes:

    functon f(x, y, ..., z)
    {
        stack<argument_pack> s;
        s.push(argument_pack(x, y, ..., z));

        while (!s.empty())
        {
            argument_pack current = s.pop();

            blah with current;
            if (blaz with current)
                s.push(argument_pack(current.x', current.y', ..., current.z'));
For example.
 

« first day (546 days earlier)      last day (4385 days later) »