GLM-5.1 helped design a new algorithm for analyzing bit strings

In a Habr post, an author describes asking GLM-5.1, running through the opencode tool, to come up with an algorithm for a specific problem: given a bit string, find every position where the number of ones minus the number of zeros from the start equals a target value. The resulting algorithm isn't revolutionary, but it combines well-known components in a new way, and it should be useful to anyone working with RMQ and LCA structures.

AI-processed from Habr AI; edited by Hamidun News
GLM-5.1 helped design a new algorithm for analyzing bit strings
Source: Habr AI. Collage: Hamidun News.
Listen to article

A Habr author asked GLM-5.1, running through the opencode tool, to come up with an algorithm for a specific bit-string problem. The result isn't revolutionary, but it is original: a new combination of well-known algorithmic components.

What problem was the author solving?

The author framed the problem this way: given a bit string, find every position where the number of ones minus the number of zeros up to that position equals a target value. He notes that the problem comes up in the context of RMQ (Range Minimum Query) and LCA (Lowest Common Ancestor) structures, so it mainly matters to people who work on algorithms and data structures.

How the AI came up with the solution

The author openly acknowledges that the internet is flooded with gushing posts about AI, and that many developers, especially C and C++ specialists, find them frustrating. He stresses that he is not an "AI evangelist" and calls himself an "active and responsible programmer" who uses AI tools in his day-to-day work. To generate the algorithm, he used the opencode tool paired with the GLM-5.1 model.

"It's not a breakthrough algorithm that will make me rich, but it is interesting: built from known components, yet still new," the author writes on

Habr.

How to get AI to write sane C++

A separate section of the article covers the techniques the author uses to get GLM-5.1 to write solid C++. This part isn't about the algorithm itself; it's about the engineering discipline of working with a model on low-level code. C and C++ are where professional developers have traditionally been most skeptical of AI-generated code, and the author explicitly cites that community frustration as the starting point for his write-up.

The piece is organized around three topics: how to solve the original bit-string problem, what algorithm the AI actually proposed, and which techniques the author relies on to get GLM-5.1 to produce working C++ rather than "hallucinated" code. This format, a walkthrough of a concrete engineering problem paired with an honest assessment of the model's role, sets the article apart from the typical breathless posts about AI capabilities that the author himself complains about at the start.

What it means

The story illustrates a practical use case for large language models: not replacing the algorithm designer, but serving as a tool to quickly sift through known techniques and assemble them into a working solution for a specific applied problem.

FAQ

Which 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 a specific bit-string problem.

What do RMQ and LCA have to do with it?

According to the author, the bit-string problem itself (finding positions where the number of ones minus the number of zeros equals a target value) is used in the context of RMQ (Range Minimum Query) and LCA (Lowest Common Ancestor) structures.

Is this a breakthrough algorithm?

No. The author himself describes the result without hype: it's not something that will make anyone rich, but it is an interesting and new combination of already-known algorithmic components.

Key Questions Answered

What problem was the author solving?

The author framed the problem this way: given a bit string, find every position where the number of ones minus the number of zeros up to that position equals a target value. He notes that the problem comes up in the context of RMQ (Range Minimum Query) and LCA (Lowest Common Ancestor) structures, so it mainly matters to people who work on algorithms and data structures.

Which 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 a specific bit-string problem.

What do RMQ and LCA have to do with it?

According to the author, the bit-string problem itself (finding positions where the number of ones minus the number of zeros equals a target value) is used in the context of RMQ (Range Minimum Query) and LCA (Lowest Common Ancestor) structures.

Is this a breakthrough algorithm?

No. The author himself describes the result without hype: it's not something that will make anyone rich, but it is an interesting and new combination of already-known algorithmic components.

ZK
Zhemal Khamidun — CPO at Alpina Digital, product manager of AlpinaGPT. Building AI products since 2019. Hamidun News is a pet project that grew into a production aggregator with 6,000+ readers.
✦ Private AI Builders Community · Vibe Club

Ship AI Faster with Founders, Engineers & Weekly Architecture Reviews

Inside Vibe Club (hamidun.com/club) — weekly live masterminds with Zhemal Khamidun, Tech Radar, full LMS access, and 370+ production Claude Code skills.

Join Vibe Club →Explore Hamidun Academy
What do you think?
Loading comments…