- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
boog is an ass, but at least he's funny, you just throw a tantrum...
Admin
Admin
Admin
Here. I'm done.
http://www.dreamincode.net/code/snippet6172.htm
Admin
Hint: Time travel is necessary.
Admin
What does this have to do with your code? This is valid and working code, as far as I see. Yours is not. If you don't see the difference between this code and yours, then I hope you're trolling. I'd lose faith in humanity if I found out that someone can be as retarded as you appear to be.
Admin
True, we are asses. Apparently we're also both hypocritical about throwing tantrums.
Admin
IHBT apparently. That's were I got the idea. I tried to edit it for some reason. Then were was alot of talking to you that I regret.
Admin
Admin
Admin
Admin
Yes, I'm quite sure I'd like to think that.
Admin
I always thought there wes a big deal of exaggeration in these stories. I guess, being in academia for a long time really changed my opinion about people.
Admin
Admin
Allow me to rephrase: boog can be an ass... :)
Admin
Admin
The donkey is a miscarriaged freeze-dried FEMALE fetus with eye sockets emptied and enlarged. Thank you very much.
Admin
Admin
How can you guys stand to take[color=white] it in the ass yourselves so seriously?
Admin
There's two parts to the answer:
Since this is Java, the solution should use the 'StringBuilder' class as 'String's are immutable when created. So each time the given solution recurses, at least another copy of the supplied String is created. This makes the supplied solution O(n^2) in memory.
Using StringBuilder allows the adjustment of individual characters in-place, so you could create a for loop that travels along 1/2 of the string, swapping the character at the current position with the character at [total string length minus the current position]
Admin
Of course, one could always be boring and just use StringBuilder.reverse().
Admin
Yeah, but you can at least just write an extension method in C#
Admin
I once assisted our Manager of the Support Division in evaluating candidates' technical skills. While the manager was present at the interviews, I'd ask all sorts of questions. Quite often, the manager ignored my recommendations, even though I could pinpoint all the candidate's errors. Equally often, he sacked the hired candidate after 3 months for not being good enough. Sigh. Once, they hired a guy without the necessary skills just because he'd been a sharpshooter in the Army. The HR manager was an ex army guy, too.
Admin
I remember being a part of a German start-up because it was the only company with an English environment which was still hiring. The English was with such a strong German accent, that I could barely understand. What's worse, all tasks were specified in Mantis using grammatically illogical and incomplete sentences. The boss hated explaining anything that was clear to him, and the rest of the stuff was my job to find out. You cannot imagine how bad their codebase was. I refused to work with their code and offered working on new modules and new CMS only. That way I got immediately 20% lower salary for refusing to work with their code. Never minds, it was still 100% more than the average salary in my country. One of the pearls they were so proud about was exactly the same stupid thing as described in this article; database tables stored as ordinary data inside a MyISAM DB. Their code was so bad that with every request for new functionality, the company would rewrite the whole CMS module. The code was simply write-only. No matter how many times they rewrote it, it never came to their mind this is now how you develop software. I've seen so many bad start-ups, and only one which was a good one.
Admin
s/this is now how you develop software/this is NOT how you develop software
Admin
I once failed to bag a sweet internal promotion because I'm not a soccer fan. After everything went tits-up in that department I discussed this with the guy whose responsibility it had been to make that decision. He had to agree with me that it had been the worst mistake of his career.
Sometimes management skills are things you have to learn through trial and error. Wisdom comes with age. And it takes a particularly cool head to deliberately not select a person to whom you've (unwisely, perhaps even drunkenly) promised a position when encountering him in a social situation.
Apparently most positions are filled via the "network" rather than the formal interview process. Whether this is on the whole a good or a bad thing is debatable, but it may be more worthwhile cultivating social contacts than relying on job adverts and agencies.
Admin
I know I'm days late on this thread, but this thread is full of posts talking about the memory usage here incorrectly...
substring in Java shares the char[] buffer from the parent string, so there's no copying involved. In fact, that's one of the reasons that the strings are immutable.
Yes, this solution uses a bunch of memory, but it uses it coming up out of the recursion, not going down it. The + operator is the issue, not the substring call.
Admin
The real WTF: Calling that Java method a function on a senior Java developer test.
Admin
Admin
Admin
Hm, so how come after Tim had been rejected that guy got to have 2 more free lunches? It was clear the other two would be hired no matter what.
Admin
and it sounds like were using the "I'm-not-going-to-ask-which-number,-maybe-it-is-47" approach
Admin
See, I usually had recursion explained through the use of factorials. That's a pretty simple example of recursion.
Admin
Thanks for pointing that out, I missed it as well and came to the comments for an explanation because I only saw it as an endless loop :-)
Admin
I always find it amusing that people test on recursion, when recursion has very little place in the real world. I worked a lot in SCHEME when I was younger, and SCHEME is very friendly to recursion. And recursion is so fricking pretty. It's very elegant.
But usually you have to document it so thoroughly that it's not worth not doing it iteratively. It also hogs memory dramatically compared to iteration, and even seasoned coders have to stop and scratch their heads for a minute.
The last time I seriously used recursion was in school. I wrote a program on an exam. The paper provided was almost two pages, and my recursion worked in 3 lines. I was so proud of myself when I turned it in. I got full credit, but the prof took the opportunity provided to write a massive diatribe about it in the remaining space. Told me that if he'd seen it in the real world, he'd have fired me, and that if he saw it on another exam, I'd only get half credit.
It's a lesson I took to heart, and to this day, I can count the number of legitimate uses of recursion I've seen in other peoples code on one hand. On the other hand, I can't count the number of times I've seen it used for obfuscation.
That being the case, I'd recommend you make harder, less recursive tests.
Admin
Sorry, the divide by 2 at the end also needs to be power of n:
Alternatively, it can be merged into termOne and termTwo:
I don't understand why others choose to endlessly bicker rather than pointing out this simple fact.
Admin
Retail software package I am building uses plenty of recursion to optimize tree like data structures in memory, before they are cached and reused.
Admin
They may HAVE implemented the solution from "Wrong Answer." I was at a Code Camp recently where a speaker gave a presentation about doing EXACTLY this. He'd apparently built a library to do it.
Admin
To the interview question: Would have said that it's cool, a recursive function. basically, it takes a string as parameter and return it unchanged if null or less then 2 characters or shuffles thing around and well could create an infinite loop. Im a PHB
Admin
Admin
they had fired the QA group for repeatedly rejecting Charles' and Terry's high quality work. Talk about firing the messenger!
Hey! I had that happen! I was the entire QA group for UPMC ISG.
Norman Kulinski (sp? I don't remember) is a moron project manager.
Admin
The CMS eZpublish uses this kind of antipattern : http://doc.ez.no/schemadoc-450/tables/ezcontentclass_attribute.html
Easier to upgrade (structure never change) ? but a nightmare for DBA and programmers...
Admin