Abstract
Recent advancements in AI for competitive programming have primarily focused on generating exact algorithms for standard problems. However, combinatorial competitive programming, which involves NP-hard optimization tasks, presents a different challenge: finding the best possible heuristic solution for visible inputs. This paper explores a human-AI synergy where researchers from Google DeepMind use FunSearch to evolve complex scoring functions within human-designed "backbone" algorithms. By automating the fine-tuning of these heuristics, the system outperformed top-tier human teams in several Google Hash Code competitions and achieved elite rankings in recent AtCoder contests.
Introduction
While systems like AlphaCode have demonstrated proficiency in standard competitive programming, reaching the "Grandmaster" level remains difficult. Standard contests require writing exact, efficient code for hidden test cases. In contrast, combinatorial competitive programming (e.g., Google Hash Code) focuses on NP-hard problems where finding an optimal solution is computationally intractable. The goal is to design heuristics that produce high-quality solutions for a set of provided inputs.
Humans are adept at designing high-level logic—the "backbone"—of a heuristic but often struggle to fine-tune the complex, non-intuitive scoring functions that guide greedy decision-making. This "tuning gap" represents a significant bottleneck in human performance.
Methods: The Human-AI Loop
The proposed approach bridges this gap through a collaborative loop between a human programmer and an AI system.
- The Backbone: A human writes a basic Python skeleton including an input parser, a greedy algorithm, and a local evaluator.
- FunSearch: This system utilizes a large language model (LLM), specifically Gemini 1.5 Flash 002, integrated with a systematic evaluator.
- Evolutionary Search: The LLM is prompted to "evolve" the scoring function used by the greedy backbone. Through "best-shot prompting," the LLM proposes modifications, the evaluator tests them, and the best-performing code is fed back for further refinement.
- Switching Variables: To handle multi-faceted decisions, a switching variable allows the AI to evolve different logic branches within a single function.
Crucially, the AI does not replace the human; it optimizes the critical "brain" of the heuristic while the human-designed "body" remains fixed.
Results
The researchers evaluated this method across eight years of Google Hash Code (2015–2022) and a "held-out" AtCoder Heuristic Contest (AHC 039) held in late 2024.
Hash Code Performance
The evolved solutions consistently reached the top 1% of all participants across all tested years. In 5 out of 8 years (2015, 2018, 2020, 2021, and 2022), the AI-augmented backbone outperformed the Rank-1 human team on the qualification leaderboard.
A notable example is the 2018 "Self-driving rides" task. The initial human-written backbone performed below the 20th percentile. After FunSearch evolution, the performance jumped to Rank 1.
AtCoder Validation
To ensure the results were not due to the LLM memorizing solutions from its training data, the system was tested on AtCoder Heuristic Contest 039, which occurred after the model's release. The method achieved a score that would have ranked between 9th and 17th place out of hundreds of elite competitors, validating its ability to discover new strategies for novel problems.
Discussion and Conclusion
The success of this approach highlights a powerful human-AI synergy. By delegating the "black magic" of fine-tuning complex heuristics to an AI, humans can focus on high-level algorithmic design. The evolved functions often contain non-intuitive algebraic expressions that a human would likely never write, yet they consistently extract superior performance from the same backbone.
While the method currently depends on a human-written "working and complete" backbone and involves significant computational costs for thousands of evaluations, it demonstrates that generalist LLMs, when wrapped in an evolutionary loop, can significantly amplify human problem-solving capabilities in complex reasoning tasks.
Summary updated