Since there's just a single instance, you can find the optimal solution manually and write a 29-line program that specifies the 29 rectangles in the optimal solution.
The general version of this problem can be termed "the minimum dissection of a rectilinear region" and can be solved optimally using a sweep-line and computing the maximal independent set in a bipartite graph as described in section 7.1 of [1].
Now if you'll excuse me, I'm gonna have some fun implementing this result in JavaScript.
(Offtopic rant) Guess, I'm not really suited for programming. When I read I remembered I've heard about an algorithm for such tasks, Googled the details up to freshen my memory, and things instantly became boring. :(
I came up with a general O(n^2) algorithm that yields 30 rectangles, which is one off from the optimal answer according to you. Actually, it's only O(n^2) because I'm exhaustively searching an array instead of indexing by xy coordinates in nested hashes, which would yield O(n).
Basically, it just fills the spaces with rectangles, expanding horizontally. Then I look for "stacks" of vertical adjacent rectangles and combine them.
(EDIT: Goes to show that you can get pretty good though non-optimal results by taking the low hanging fruit and optimizing a bit.)
This is a good point. Traditional recruiters have different ways of knowing how good you are at programming (often they don't). By starting with your Gridmancer competency, we can potentially find and qualify you for opportunities that traditional credentials couldn't. (And we're not going to send candidates who aren't good enough to higher-skill positions.)
One weakness is that we don't have a good way of measuring how much software development (as opposed to core programming skill) you have. In this sense, we don't yet have an advantage over traditional recruiters.
Traditional recruiters do have better connections, for now, but we are going really high-hustle for this initial batch of players, so it's not like we're just sending off resumes.
Is there a problem with recruiters working harder to find the best candidate/job fit? It's a nice change from having to compete (or work with!) people rammed into the wrong sorts of jobs.
Worst case you can have fun with the levels and just not worry about the job bits.
Only the very darkest realm would deprive its wizards of the mighty printf spell! To what Silicon demon legion did you pledge fealty to summon this coding abomination upon an unsuspecting land? Winter is truly coming at last.
I know, I know. Try this.say() for a poor man's replacement.
We haven't improved it much because we are going to make an awesome timeless debugger, where you just hover over the variables to see their values at any point in time as well as scrubbing forward and backward through your entire program's execution (like jsdares does), all without any breakpoints, but haven't quite got it yet.
To those playing: if you want to be able to find your code again later, go to the CodeCombat home page and sign up for a free account! Sorry, we derped out and didn't put any signup form accessible from the Gridmancer level.
Also, we're sorry that we left you without good debugging tools: https://news.ycombinator.com/item?id=6976883 -- this is the #1 problem uncovered today. We will retreat in tearful shame to our code lairs until we can blow your minds with our timeless debugger.
You are amazing players--so many good solutions here. Thanks for playing! To those who sent in solutions and are looking for dev opportunities, we'll be in touch this weekend to see what we can do and learn about what you're looking for.
Also, we're sorry that we left you without good debugging tools
I just thought that was part of the challenge. (See if you can get by with scientific method and printf debugging.) The biggest problem I had was that the environment kept freezing. However, copy-pasting into the window from emacs worked fine.
This seems pretty incredible that CodeCombat has already reached the point where they're placing people into jobs. It's supposed to be Codecademy's goal [1] to do that eventually but they've been around much longer.
There's a pretty big difference in audience in these two examples. Codecademy is targeting people who have no, or nearly no, experience programming and trying to turn them into programmers. CodeCombat's normal stuff appears to be in the same vein, but this specific challenge is something only a fairly experienced programmer is likely to solve. It's easy to place great programmers. Not so easy to take someone, make them a good programmer, and then get them a job.
We are doing it in a way that won't scale: George is just going to hustle to make the placements. Codecademy might have a different problem to solve, too: the players we're placing through this level are mostly people with existing skills who like a fun challenge, not players who have gotten there from scratch through the site's content (like all Codecademy users). It'll be a while before we have enough content to take raw beginners to the required skill levels.
A better way to look at the object's structure/values would help a lot. Seems like the first step would be to generate a list of vertices from the 2d array of tiles.
Just curious - would anyone here currently hiring consider the winning candidates any more than they would from a (reputable) recruiter?
I'm not trying to be a cynic - I really hope this works and solves a real problem. This is honest feedback from someone has and will continue to evaluate talent for technical teams - proof of algorithmic ability is only one tick mark of the dozens needed.
We're not sure ourselves; we're testing the waters with this level to find out exactly that. And if it looks like this monetization strategy has legs, we'll aim to expand what we can provide to companies so we can be more compelling.
We'll be interested to hear what others think about this too!
Clever! In an ideal world, we'd have logic to prevent incorrect configurations so rectangles couldn't touch walls. There would also be ogres dying and explosions and battle music and such related to the efficiency of your algorithm--you know, actual gameplay mechanics, like our other levels. Didn't have time to get those in yet, though.
We could try doing placements outside of California later, but for now we don't have much of a network outside of the SF Bay Area. (We're quite young as a startup.)
Hi. I took this challenge, asked for help in finding a job, and heard nothing back.
I could really use help as my resume is mostly Flash/Actionscript related work, which is not in demand, and it's difficult to convince the "filtering" HR reps that my skills are applicable to other languages. So if this proves that I can code, then I should be able to get a job?
This was a great way for me to get back into programming after the holiday break. Your optimal number seems off, though; I ended up with a solution in 27 rects:
[+] [-] rav|12 years ago|reply
The general version of this problem can be termed "the minimum dissection of a rectilinear region" and can be solved optimally using a sweep-line and computing the maximal independent set in a bipartite graph as described in section 7.1 of [1].
Now if you'll excuse me, I'm gonna have some fun implementing this result in JavaScript.
[1] Hiroshi Imai, Takao Asano: Efficient algorithms for geometric graph search problems (1986) https://dl.acm.org/citation.cfm?id=14098 http://epubs.siam.org/doi/pdf/10.1137/0215033
[+] [-] drdaeman|12 years ago|reply
(Offtopic rant) Guess, I'm not really suited for programming. When I read I remembered I've heard about an algorithm for such tasks, Googled the details up to freshen my memory, and things instantly became boring. :(
[+] [-] thomasfedb|12 years ago|reply
Sadly, JavaScript.
[+] [-] stcredzero|12 years ago|reply
Basically, it just fills the spaces with rectangles, expanding horizontally. Then I look for "stacks" of vertical adjacent rectangles and combine them.
(EDIT: Goes to show that you can get pretty good though non-optimal results by taking the low hanging fruit and optimizing a bit.)
[+] [-] funky_vodka|12 years ago|reply
[+] [-] unreal37|12 years ago|reply
Beat this level, and we'll send your resume to some companies that are hiring. And those companies will pay us a hefty commission.
[+] [-] nwinter|12 years ago|reply
One weakness is that we don't have a good way of measuring how much software development (as opposed to core programming skill) you have. In this sense, we don't yet have an advantage over traditional recruiters.
Traditional recruiters do have better connections, for now, but we are going really high-hustle for this initial batch of players, so it's not like we're just sending off resumes.
[+] [-] ENGNR|12 years ago|reply
Worst case you can have fun with the levels and just not worry about the job bits.
[+] [-] varelse|12 years ago|reply
(Otherwise pretty neat)
[+] [-] nwinter|12 years ago|reply
We haven't improved it much because we are going to make an awesome timeless debugger, where you just hover over the variables to see their values at any point in time as well as scrubbing forward and backward through your entire program's execution (like jsdares does), all without any breakpoints, but haven't quite got it yet.
[+] [-] nwinter|12 years ago|reply
Also, we're sorry that we left you without good debugging tools: https://news.ycombinator.com/item?id=6976883 -- this is the #1 problem uncovered today. We will retreat in tearful shame to our code lairs until we can blow your minds with our timeless debugger.
You are amazing players--so many good solutions here. Thanks for playing! To those who sent in solutions and are looking for dev opportunities, we'll be in touch this weekend to see what we can do and learn about what you're looking for.
[+] [-] stcredzero|12 years ago|reply
I just thought that was part of the challenge. (See if you can get by with scientific method and printf debugging.) The biggest problem I had was that the environment kept freezing. However, copy-pasting into the window from emacs worked fine.
[+] [-] negamax|12 years ago|reply
[+] [-] jacobbudin|12 years ago|reply
User agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_1) AppleWebKit/537.73.11 (KHTML, like Gecko) Version/7.0.1 Safari/537.73.11
[+] [-] nwinter|12 years ago|reply
[+] [-] abus|12 years ago|reply
There aren't enough good programmers to meet the demand for low paid programmers.
[+] [-] natebrennand|12 years ago|reply
1. http://bits.blogs.nytimes.com/2011/09/14/codecademy-offers-f...
[+] [-] ibdknox|12 years ago|reply
[+] [-] nwinter|12 years ago|reply
[+] [-] foxly|12 years ago|reply
-29 rectangles
-O(N) worst-case complexity
-Under 200 lines
https://gist.github.com/foxly/8168624 http://imgur.com/PXcUEHz
[+] [-] shawndrost|12 years ago|reply
[+] [-] sbuccini|12 years ago|reply
[+] [-] daemonk|12 years ago|reply
[+] [-] acgourley|12 years ago|reply
I'm not trying to be a cynic - I really hope this works and solves a real problem. This is honest feedback from someone has and will continue to evaluate talent for technical teams - proof of algorithmic ability is only one tick mark of the dozens needed.
[+] [-] serickson|12 years ago|reply
We'll be interested to hear what others think about this too!
[+] [-] Danieru|12 years ago|reply
This second requirement is much simpler. One only needs to merge a single two rects into one rect to fulfil it. I assume this is a bug?
Edit: Sorry I didn't read the original post well enough the first time. It gives the more practical goal of 40 rects or less.
[+] [-] nwinter|12 years ago|reply
[+] [-] jffry|12 years ago|reply
[+] [-] nwinter|12 years ago|reply
[+] [-] emeraldd|12 years ago|reply
Also, any chances of expanding beyond California?
[+] [-] nwinter|12 years ago|reply
We could try doing placements outside of California later, but for now we don't have much of a network outside of the SF Bay Area. (We're quite young as a startup.)
[+] [-] adamredwoods|12 years ago|reply
I could really use help as my resume is mostly Flash/Actionscript related work, which is not in demand, and it's difficult to convince the "filtering" HR reps that my skills are applicable to other languages. So if this proves that I can code, then I should be able to get a job?
[+] [-] tokipin|12 years ago|reply
[+] [-] kd5bjo|12 years ago|reply
http://imgur.com/hAOLUaD
[+] [-] swframe|12 years ago|reply
[+] [-] Zarathust|12 years ago|reply
[+] [-] gorhill|12 years ago|reply
[+] [-] nwinter|12 years ago|reply
[+] [-] chrismcb|12 years ago|reply