thedailywtf

Finding the LCM of a range of numbers

I read an interesting DailyWTF post today, "Out of All The Possible Answers..." and it interested me enough to dig up the original forum post where it was submitted. This got me thinking how I would solve this interesting problem - the original question is posed on Project Euler as: 2520 is the smallest number that can be divided by...

How would you implement the pilloried function in the Daily WTF?

The Daily WTF for 2008-11-28 pillories the following code: static char *nice_num(long n) { int neg = 0, d = 3; char *buffer = prtbuf; int bufsize = 20; if (n < 0) { neg = 1; n = -n; } buffer += bufsize; *--buffer = '\0'; do { *--buffer = '0' + (n % 10); n /= 10; ...

Is this a typical work environment, or am I just unlucky?

I've graduated from college last May with a CS degree and have been working for a state-government agency ever since. This place, however, isn't like how I imagined the "real world" would be: I've been put into a small conference room (my bedroom is bigger) with 3 other programmers. The four of us just sit together, all day long, on th...

What's the most ridiculous name you've given to a method?

Rules: You have to be the one who named it. It has to have made it into production. Mine: (the comment is the original comment I added) //WTF?? this should be rethough private static float CalculateFudge(bool isLeft, bool isRight, DesignedRoom r) { ..snip.. } ...

Help with a function I found in a VB.NET 2.0 app I am maintaining

I was going through some reports that were supposed to be displaying 2/1/2009 - 2/28/2009, but instead was displaying 2/1/2009 - 3/1/2009. I have narrowed the bug down to this code, any suggestions? Function GetMonthLastDate(ByVal sDateTime As DateTime) Try Dim strArrMonth() As String = {"", "31", "29", "31", "30", "31", "30...

I don't get this C/C++ Joke

After reading this article on thedailywtf.com, I'm not sure that I really got the joke. It says there that some guy changed the code from int function() { int x; char data_string[15]; ... x = 2; strcpy(data_string,"data data data"); ... } to int function() { int x = 2; char data_string[15] = "data data data"; .....

Unable to locate the Bug

I was recently on The Daily WTF when I came across this old post. In it the author mentions that one of the programmers changed this code: int main (int argc, char **argv) { int x; char data_string[15]; ... x = 2; strcpy(data_string,"data data data"); ... } To this code: int main (int argc, char **argv) { int x = 2;...

IE doesn't apply css loaded through ajax.

As every web developer finds out the hard way sooner or later, IE does not apply css styles loaded via ajax. I know I could just put that css in a more global place, but I'm wondering if there happens to be some "hack" or "trick" to get around this. Perhaps there is some javascript magic? UPDATE WITH EXAMPLE: For example, say you have ...