GLM-5.1 helped develop a new algorithm for analyzing bit strings
A C++ programmer asked GLM-5.1 + OpenCode to develop an algorithm for analyzing bit strings. AI created an original solution from known components. The author shares techniques for getting AI to write reasonable code.
AI-processed from Habr AI; edited by Hamidun News
The author of an article on Habr proposed to GLM-5.1, running through the opencode tool, to devise an algorithm for a specific bit string task — and received not a revolutionary, but an original solution assembled from well-known algorithmic components in a novel combination.
What problem the author solved
The author formulated the problem as follows: given a bit string, find all positions in it where the number of ones minus the number of zeros up to that position equals a given number. He notes that the problem is used in the context of RMQ (Range Minimum Query) and LCA (Lowest Common Ancestor) structures — meaning it is of interest primarily to those working with algorithms and data structures.
How AI devised the solution
The author directly acknowledges that the internet is overflowing with enthusiastic texts about AI, which frustrate many developers — especially C and C++ specialists. He emphasizes that he is not an "AI preacher" but rather calls himself an "active and responsible programmer" who uses AI tools in everyday work. To generate the algorithm, he used precisely the combination of the opencode tool and the GLM-5.1 model.
"This is not a breakthrough algorithm that will make me rich, but it is interesting: assembled from known components, yet still new," the author writes on
Habr.
How to make AI write sensible C++
The article separately discusses what techniques the author uses to make GLM-5.1 write adequate C++ code — this part of the material focuses not on the algorithm itself, but on engineering discipline when working with the model in writing low-level code. It is precisely in C and C++ languages that the quality of AI generation has traditionally caused the most skepticism among professional developers, and the author directly acknowledges this community frustration as his starting point.
The material itself is structured around three themes: how to solve the original bit string problem, what exactly AI proposed as an algorithm, and what techniques the author applies to make GLM-5.1 output working rather than "hallucinating" C++ code. Such a format — analysis of a concrete engineering problem together with honest assessment of the model's role — distinguishes the material from typical enthusiastic posts about AI capabilities, which the author himself complains about at the beginning of the article.
What this means
The story demonstrates a practical use case for large language models: not as a replacement for an algorithmist, but as a tool for quickly iterating through known techniques and assembling them into a working solution for a specific applied task.
Frequently asked questions
What model and tool did the author use?
The author used the GLM-5.1 model, running through the opencode tool, to generate an algorithm for the specific bit string task.
What do RMQ and LCA have to do with this?
The bit string problem itself — finding positions where the number of ones minus the number of zeros equals a given number — is, according to the author, used in the context of RMQ (Range Minimum Query) and LCA (Lowest Common Ancestor) structures.
Is this a breakthrough algorithm?
No — the author describes the result without fanfare: not something that will make him rich, but an interesting and novel combination of already known algorithmic components.
Need AI working inside your business — not just in your newsfeed?
I build production AI for companies — custom CRM, internal tools, autonomous agents, workflow automation. Owned by you, shaped to your process, no per-seat tax. Built by Zhemal Khamidun, CPO of AlpinaGPT (AI platform, 6,000+ users).
The AI world, distilled — once a week
Seven stories that actually mattered, hand-picked. No noise, no reposts, no press releases.
Done! Check your inbox for a confirmation.