\u003Cfigcaption>Jacob Plachta\u003C/figcaption>\u003C/figure>\u003C/div>\u003C/center>\n\u003C!-- /wp:image -->\n\n\u003C!-- wp:heading -->\n\u003Ch2>\u003Cstrong>Striking the right balance\u003C/strong>\u003Cbr>\u003C/h2>\n\u003C!-- /wp:heading -->\n\n\u003C!-- wp:paragraph -->\n\u003Cp>The challenge of crafting a great Hacker Cup problem set, say May and Plachta, is managing problem difficulty, variety, and originality. The goals of every round are to narrow the field for the next round, and to ensure that everybody has an enjoyable and educational experience.\u003Cbr>\u003C/p>\n\u003C!-- /wp:paragraph -->\n\n\u003C!-- wp:paragraph -->\n\u003Cp>“In the final round, it’s ideal if every problem gets solved, everybody solves at least one problem, but nobody solves every problem,” says May. “In earlier rounds we want the overall difficulty to be such that everybody who solves every problem advances, but you don’t need to solve every problem to advance.”\u003Cbr>\u003C/p>\n\u003C!-- /wp:paragraph -->\n\n\u003C!-- wp:paragraph -->\n\u003Cp>Problems need to have variety while remaining within the scope of the contest. The solution to every problem should be attainable from first principles or combinations of well-known algorithms. No one should be stumped by a question because it relies on some unusually specialized knowledge. That said, nobody wants to solve the same problems every contest, so the problems also need to be original.\u003Cbr>\u003C/p>\n\u003C!-- /wp:paragraph -->\n\n\u003C!-- wp:paragraph -->\n\u003Cp>Plachta thinks of there being two general approaches to creating problems. The first involves starting with some aspect of the solution then working backwards to come up with a problem. “This approach can work, but it can also easily lead to problems that end up feeling more standard, less original,” says Plachta. The second approach, which Plachta uses more often today, starts with a problem where the solution is unknown.\u003Cbr>\u003C/p>\n\u003C!-- /wp:paragraph -->\n\n\u003C!-- wp:paragraph -->\n\u003Cp>“I basically spend a lot of time sitting around thinking of rough ideas which could possibly turn into problems,” says Plachta. \"Any given idea is very unlikely to work out, definitely less than a 10% chance. Maybe it'll feel uninteresting after all, or maybe upon trying to solve the resulting problem, it'll turn out too easy, too cumbersome, or unsolvable. Unfortunately, you often can't tell until you've thought it through much of the way. But, upon trying enough different ideas or variations of them, I'll happen across one that actually turns into a great problem. That's always really exciting!\"\u003C/p>\n\u003C!-- /wp:paragraph -->\n\n\u003C!-- wp:heading -->\n\u003Ch2>\u003Cstrong>Finding Inspiration From The Everyday World\u003C/strong>\u003Cbr>\u003C/h2>\n\u003C!-- /wp:heading -->\n\n\u003C!-- wp:paragraph -->\n\u003Cp>Sometimes a problem comes out of experiences in the real world. May and Plachta run across something that gets them thinking, then slowly find a way to form those ideas into a coding problem. “I helped write a problem for the third round of the 2015 season called \u003Ca href=\"https://www.facebook.com/hackercup/problem/1775684812755999/\">Broken Bits\u003C/a>,” says May. “It was based on my actual observations of a digital clock that was broken, meaning some of the LED segments just didn’t work. I remember staring at that for a while and thinking, well, you can look at this clock, and maybe you can't tell what time it is because some of the segments are missing, and that makes it ambiguous. But if you watch this clock for long enough, eventually you may have enough information to figure out what time it must have actually been.”\u003Cbr>\u003C/p>\n\u003C!-- /wp:paragraph -->\n\n\u003C!-- wp:paragraph -->\n\u003Cp>Problem ideas can also arise from games. “I was playing a bunch of Pathfinder Adventure Card Game with friends,” recalls May. “You get to choose different items for your attacks, which means using different dice to determine how much damage you'll do. Maybe I have one attack that has a higher average damage, but I might prefer a different one that has a lower average yet higher variance. That turned into a problem called \u003Ca href=\"https://www.facebook.com/hackercup/problem/326053454264498/\">Fighting the Zombie\u003C/a>, which appeared in the qualification round for 2017.”\u003Cbr>\u003C/p>\n\u003C!-- /wp:paragraph -->\n\n\u003C!-- wp:paragraph -->\n\u003Cp>“Sometimes we’ll use the same characters and themes across multiple problems each year. The problems can feel like thematically they ought to be similar even though they might be very different,” says May. “Last year we had a series of problems about a struggling computer science student who’s never quite able to code things correctly.” Once they have a theme in mind, Plachta and May try to develop it further to see what other problems might come out of it.\u003Cbr>\u003C/p>\n\u003C!-- /wp:paragraph -->\n\n\u003C!-- wp:paragraph -->\n\u003Cp>This is a computer programming challenge, but sometimes inspiration comes from nature, for example watching \u003Ca href=\"https://www.youtube.com/watch?v=9KKjqXxxp-Q\">a tuskfish smash clams against rocks\u003C/a> on \u003Cem>Planet Earth\u003C/em>. “This concept seemed cool, so I thought about how to expand on it. Maybe there could be multiple clams and rocks with different hardnesses, such that clams would need to be smashed against harder rocks,” says Plachta. “I considered a bunch of variations, including what context to place these clams and rocks in and what the goal should be. As it turned out, the simple concept of arranging them on a number line and asking for the minimum travel distance to go around opening all of the clams worked out just right, resulting in the final problem in the 2019's second round, \u003Ca href=\"https://www.facebook.com/hackercup/problem/404425766835121/\">Seafood\u003C/a>.\"\u003Cbr>\u003C/p>\n\u003C!-- /wp:paragraph -->\n\n\u003C!-- wp:paragraph -->\n\u003Cp>“It's the sort of problem which might seem infeasible at first, given the exponential number of possible routes the tuskfish might take, which is ideal. It's only upon further thought that you can narrow down the possibly-optimal routes to a more manageable set of patterns. From there, it boils down to a problem solvable using dynamic programming -- that's a general approach for efficiently solving optimization problems by recursively solving smaller subproblems, which is often useful in contests. Though in this case, a further, more advanced technique often called the 'convex hull trick' was required to arrive at an efficient-enough time complexity.”\u003Cbr>\u003C/p>\n\u003C!-- /wp:paragraph -->\n\n\u003C!-- wp:paragraph -->\n\u003Cp>Regardless of inspiration, they make a problem interesting by wrapping it in a narrative. “There's a layer of varnish at the end which is the story. Like you certainly don't have to have this, but it's a lot more fun.” A problem about placing blocks on a grid is presented as a rivalry between two pizza delivery guys. A problem about moving around the nodes on a tree becomes a tale of marital strife for a family of moles. \u003Cbr>\u003C/p>\n\u003C!-- /wp:paragraph -->\n\n\u003C!-- wp:image {\"id\":13891,\"align\":\"center\"} -->\n\u003Ccenter>\u003Cdiv class=\"wp-block-image\">\u003Cfigure class=\"aligncenter\">\u003Cimg src=\"https://stackoverflow.blog/wp-content/uploads/2019/10/Wesley-Hacker-Cup-840x630.jpg\" alt=\"\" class=\"wp-image-13891\"/>\u003Cfigcaption>Wesley May\u003C/figcaption>\u003C/figure>\u003C/div>\u003C/center>\n\u003C!-- /wp:image -->\n\n\u003C!-- wp:heading -->\n\u003Ch2>\u003Cstrong>Ever-Evolving Complexity\u003C/strong>\u003C/h2>\n\u003C!-- /wp:heading -->\n\n\u003C!-- wp:paragraph -->\n\u003Cp>If you look at the winning routines from Olympic gymnasts a few decades ago, they seem incredibly simplistic when compared with the complexity of top performances today. The same is true for the kind of problems completed during the Hacker Cup, which has been running since 2011, and comes out of a much older lineage of competitions like the ICPC, which has been active since the 1970s. The problems have only gotten harder since the days when May started. “If I look at World Finals problems from ICPC back in like 2008, I can knock out quite a lot of those problems now. Whereas if I look at a problem set from today, on my own, I’m probably solving at most three of 11 problems.”\u003Cbr>\u003C/p>\n\u003C!-- /wp:paragraph -->\n\n\u003C!-- wp:paragraph -->\n\u003Cp>The final rounds from the 1970s and 80s would be considered middling difficulty today. “Earlier problems were pretty explicit about what you had to do, and most of the challenge was in the implementation and not the actual problem solving. These sorts of problems are generally considered trivial and tedious nowadays,” says May. “The focus has shifted towards finding interesting applications of core algorithms and data structures. So for example, figuring out which tools are best for the situation -- binary search, depth first search, segment trees, dynamic programming, etc. and putting those to work.”\u003Cbr>\u003C/p>\n\u003C!-- /wp:paragraph -->\n\n\u003C!-- wp:paragraph -->\n\u003Cp>Because many of the contestants have been solving these sorts of problems throughout high school and college, and come armed with pre-written algorithms, Hacker Cup problems need to be about more than just identifying the right tools. “What we try to get into our problems nowadays are interesting transformations,” says May. “Maybe you get some game that's not explicitly played on a graph, but if you think about it in the right way you can see that is actually has some graph structure abstractly. A hard problem should be hard because it takes a series of interesting insights to come up with a feasible solution, not because the actual coding work is long and finicky.”\u003Cbr>\u003C/p>\n\u003C!-- /wp:paragraph -->\n\n\u003C!-- wp:paragraph -->\n\u003Cp>As the ability of contestants improves, it’s sometimes the contestants that surprise the problem authors. “Contestants' submissions can sometimes turn out more elegant than what we could come up with ourselves,” explains Plachta. “A good example was with a problem called \u003Ca href=\"https://www.facebook.com/hackercup/problem/367172063898266/\">Integers as a Service\u003C/a> in this year's third round. I intended for the solution to involve prime factorization and handling different primes independently, a pretty typical way of dealing with \u003Ca href=\"https://en.wikipedia.org/wiki/Greatest_common_divisor\">GCDs \u003C/a>and \u003Ca href=\"https://en.wikipedia.org/wiki/Least_common_multiple\">LCMs\u003C/a>, as was required in this problem. And, that is how many people went about it. But some top contestants came up with a simpler approach taking advantage of how GCDs and LCMs interact with one another and using them more directly. It's really cool and impressive seeing these kinds of thought processes materialize even in the short timespan of a contest!”\u003Cbr>\u003C/p>\n\u003C!-- /wp:paragraph -->\n\n\u003C!-- wp:paragraph -->\n\u003Cp>While the broader world of competitive programming has evolved, so has Hacker Cup. For the first few years, every round had three problems including the finals. Now every online round has four problems and the final has gone from three hours for three problems to four hours for six problems. “Not only have we added problems, we’ve also strived to keep improving the quality and originality. We want every year to be better than the last,” says May. Some aspects of the overall philosophy have also changed over time. “We used to be meaner regarding the example test cases that are given for each problem. Because you only get one chance to submit each problem in Hacker Cup, we try to be more generous nowadays. If you’re correct on the sample data, chances are you have the right solution. We’re trying to test your ability to solve interesting problems, and not trying to catch you on an off-by-one error.”\u003Cbr>\u003C/p>\n\u003C!-- /wp:paragraph -->\n\n\u003C!-- wp:heading -->\n\u003Ch2>\u003Cstrong>By Hackers, for Hackers, Open to All\u003C/strong>\u003Cbr>\u003C/h2>\n\u003C!-- /wp:heading -->\n\n\u003C!-- wp:paragraph -->\n\u003Cp>Both May and Plachta are former ICPC World Final competitors. They originally met in 2011 at the tryouts for the University of Toronto ICPC team, and they ended up going to the World Finals together. The next year, May could no longer compete in the ICPC as there’s a two-appearance limit in the World Finals, so he took over coaching duties at U of T while Plachta and his team made another World Finals run. Since then, they have written problems for a variety of contests, including high school-level ones such as the Canadian Computing Olympiad and Woburn Challenge.\u003Cbr>\u003C/p>\n\u003C!-- /wp:paragraph -->\n\n\u003C!-- wp:paragraph -->\n\u003Cp>More remarkably, while May became a competitive programmer while studying CS, Plachta was studying music. “My first World Finals team had a statistics major who did most of the problem solving while the other two of us did all the coding,” says May. “You don’t need to be doing a traditional ‘tech’ subject to enjoy and be successful at algorithmic competitions. Neither of my two best teammates were focused on CS or engineering.”\u003Cbr>\u003C/p>\n\u003C!-- /wp:paragraph -->\n\n\u003C!-- wp:paragraph -->\n\u003Cp>Over the years, Hacker Cup participants have gone on to work at Facebook, many of whom were still in college or high school when they took part. “While competitive programming tests only a very specific subset of skills, taking part shows a certain level of enthusiasm for coding,” says May. “I did my undergrad at Simon Fraser University which isn’t particularly well-known in the States. My competitive programming activities are what put me on Facebook’s radar in the first place.”\u003Cbr>\u003C/p>\n\u003C!-- /wp:paragraph -->\n\n\u003C!-- wp:paragraph -->\n\u003Cp>During the early years, Facebook always held the final phase of the tournament at their headquarters in Menlo Park. As part of trying to expand the reach and accessibility of the contest, Facebook began choosing new locations from around the globe to host the live event. This year the Hacker Cup is taking place in Dublin, and you can catch a live stream of the finals beginning at 8:30am EST. And if you want to read more about Plachta, check out a \u003Ca href=\"https://www.facebook.com/1633466236940064/posts/2522842978002381?sfns=mo\">profile here\u003C/a>. Last but not least, if you feel like some puzzling this morning, don’t forget to check out the question the Hacker Cup team shared on Code Golf. \u003Cbr>\u003C/p>\n\u003C!-- /wp:paragraph -->\n\n\u003C!-- wp:block {\"ref\":13752} /-->\n\n\u003C!-- wp:paragraph -->\n\u003Cp>\u003Cem>The Stack Overflow blog is committed to publishing interesting articles by developers, for developers. From time to time that means working with companies that are also clients of Stack Overflow’s through our advertising, talent, or teams business. When we publish work from clients, we’ll identify it as Partner Content with tags and by including this disclaimer at the bottom.\u003C/em>\u003C/p>\n\u003C!-- /wp:paragraph -->","html","2019-10-25T14:30:44.000Z",{"current":478},"the-puzzle-masters-behind-facebooks-hacker-cup-explain-how-they-craft-questions",[480,488,490,495,499,504,508,513],{"_createdAt":481,"_id":482,"_rev":483,"_type":484,"_updatedAt":481,"slug":485,"title":487},"2023-05-23T16:43:21Z","wp-tagcat-bulletin","9HpbCsT2tq0xwozQfkc4ih","blogTag",{"current":486},"bulletin","Bulletin",{"_createdAt":481,"_id":482,"_rev":483,"_type":484,"_updatedAt":481,"slug":489,"title":487},{"current":486},{"_createdAt":481,"_id":491,"_rev":483,"_type":484,"_updatedAt":481,"slug":492,"title":494},"wp-tagcat-code-for-a-living",{"current":493},"code-for-a-living","Code for a Living",{"_createdAt":481,"_id":496,"_rev":483,"_type":484,"_updatedAt":481,"slug":497,"title":498},"wp-tagcat-facebook",{"current":498},"facebook",{"_createdAt":481,"_id":500,"_rev":483,"_type":484,"_updatedAt":481,"slug":501,"title":503},"wp-tagcat-partner-content",{"current":502},"partner-content","Partner Content",{"_createdAt":481,"_id":505,"_rev":483,"_type":484,"_updatedAt":481,"slug":506,"title":507},"wp-tagcat-partnercontent",{"current":507},"partnercontent",{"_createdAt":481,"_id":509,"_rev":483,"_type":484,"_updatedAt":481,"slug":510,"title":512},"wp-tagcat-stackoverflow",{"current":511},"stackoverflow","Stackoverflow",{"_createdAt":481,"_id":509,"_rev":483,"_type":484,"_updatedAt":481,"slug":514,"title":512},{"current":511},"The puzzle masters behind Facebook's Hacker Cup explain how they craft questions",[517,523,528,533],{"_id":518,"publishedAt":519,"slug":520,"sponsored":12,"title":522},"1d082483-6dc6-424b-8b09-9c84b54779da","2025-09-02T17:00:00.000Z",{"_type":10,"current":521},"back-to-school-developers-at-stack-overflow-have-some-advice-for-you","Back to school? Developers at Stack Overflow have some advice for you",{"_id":524,"publishedAt":519,"slug":525,"sponsored":12,"title":527},"5cd91820-9515-4be5-87ae-e919fd443c18",{"_type":10,"current":526},"getting-started-on-stack-overflow-a-step-by-step-guide-for-students","Getting started on Stack Overflow: a step-by-step guide for students",{"_id":529,"publishedAt":519,"slug":530,"sponsored":12,"title":532},"614538a9-c352-4024-adf1-fa44a9f911b6",{"_type":10,"current":531},"stack-overflow-is-helping-you-learn-to-code-with-new-resources","Stack Overflow is helping you learn to code with new resources",{"_id":534,"publishedAt":519,"slug":535,"sponsored":12,"title":537},"763b1d36-83d8-4178-9c2d-32d705ea1d7b",{"_type":10,"current":536},"introducing-your-newest-study-buddy-stackoverflow-ai","Introducing your newest study buddy: stackoverflow.ai",{"count":539,"lastTimestamp":540},3,"2023-05-25T09:46:51Z",["Reactive",542],{"$sarticleModal":543},false,["Set"],["ShallowReactive",546],{"sanity-1L_ufZco8xFZVQbtd6DsqTwBkBpAa-i-YYs5mEUkenc":-1,"sanity-comment-wp-post-13869-1756862832488":-1},"/2019/10/25/the-puzzle-masters-behind-facebooks-hacker-cup-explain-how-they-craft-questions/?cb=1"]