r/algorithms 3d ago

Discussion What Are You Working On? August 29, 2026

12 Upvotes

This recurring thread will be for general discussion on whatever algorithm-related projects, problems, or topics you have been or will be working on this week. This can be anything, including:

* theoretical computer science and algorithm design,

* books, papers, or articles you are reading,

* coursework or self-study (what you have been learning recently),

* competitive programming or interview prep,

* preparing a talk, presentation, or project demo.

 

All backgrounds and levels of experience are welcome!


r/algorithms 25d ago

[Meta] Which best describes your background/interest in algorithms?

7 Upvotes

Following up on the suggestion to survey the community, please pick the option that best describes you. Feel free to elaborate in the comments.

156 votes, 18d ago
39 Theoretical CS / Algorithms Research
63 Software Engineering / Industry purposes
21 (Undergrad) Student ( CS/Math Coursework)
8 Interview and OA prep
18 General Enthusiast
7 See Results / Other

r/algorithms 20h ago

Help Anyone out there , explain me knapsack problem

0 Upvotes

I have my DAA exam tomorrow , explain asap , in a easy way😭😭đŸ„č

Q: For the given set of items and knapsack capacity = 10 kg, find the optimal solution for

the 0/1 knapsack problem making use of dynamic programming approach

W=(5,4,6,3) and Profits=(10,40,30,50)


r/algorithms 4d ago

Discussion Aquifer: A novel approach to retry storm mitigation

0 Upvotes

Most retry strategies are reactive: exponential backoff, jitter, circuit breakers. They help, but they’re still asking every client to independently guess when it’s safe to send traffic again.

I’ve been experimenting with a different approach: coordinate retries before they hit the backend.
Instead of letting thousands of requests wake up, retry, fail, and back off independently, Aquifer puts them behind bounded queues and dynamically paces their release based on downstream capacity. The goal is to turn a retry storm from a bursty feedback loop into a controlled stream.

The interesting part is that this can sit in front of APIs, databases, inference servers, MCP servers, or basically anything where correlated retries can make an overloaded system even worse.

I’m calling the project Aquifer. It’s open source and still evolving, so I’m curious what failure modes people here think this approach misses.

https://github.com/rjpruitt16/aquifer


r/algorithms 5d ago

Resource Making of QuirkLite: A tool for visualizing quantum circuits

6 Upvotes

I decided to modify the excellent Quirk tool into a more appealing and beginner-friendly version called QuirkLite.

I am building it for a demo I'm preparing, and thought some of you might find it useful too.

You can find the repository here


r/algorithms 6d ago

Resource All quantum computing algorithms can be easily visualized with this interactive method

21 Upvotes

Hi

If you are remotely interested in deep diving how differently quantum computers work compared to our transistor-based and also the algebra behind in a fully interactive way that teach computer science from scratch, oh boy this is for you. I am the Dev behind Quantum Odyssey (AMA! I love taking qs) - worked on it for about 10 years (3+ during PhD, the visual method I developed ended up being my thesis, it is a complete Hilbert space visualizer), the goal was to make a super immersive space for anyone to learn quantum computing through zachlike (open-ended) logic puzzles and compete on leaderboards and lots of community made content on finding the most optimal quantum algorithms. The game has a unique set of visuals capable to represent any sort of quantum dynamics for any number of qubits and this is pretty much what makes it now possible for anybody 12yo+ to actually learn quantum logic without having to worry at all about the mathematics behind.

This is a game super different than what you'd normally expect in a programming/ logic puzzle game, so try it with an open mind.

Stuff you'll play & learn a ton about

  • Boolean Logic – bits, operators (NAND, OR, XOR, AND
), and classical arithmetic (adders). Learn how these can combine to build anything classical. You will learn to port these to a quantum computer.
  • Quantum Logic – qubits, the math behind them (linear algebra, SU(2), complex numbers), all Turing-complete gates (beyond Clifford set), and make tensors to evolve systems. Freely combine or create your own gates to build anything you can imagine using polar or complex numbers.
  • Quantum Phenomena – storing and retrieving information in the X, Y, Z bases; superposition (pure and mixed states), interference, entanglement, the no-cloning rule, reversibility, and how the measurement basis changes what you see.
  • Core Quantum Tricks – phase kickback, amplitude amplification, storing information in phase and retrieving it through interference, build custom gates and tensors, and define any entanglement scenario. (Control logic is handled separately from other gates.)
  • Famous Quantum Algorithms – explore Deutsch–Jozsa, Grover’s search, quantum Fourier transforms, Bernstein–Vazirani, and more.
  • Build & See Quantum Algorithms in Action – instead of just writing/ reading equations, make & watch algorithms unfold step by step so they become clear, visual, and unforgettable. Quantum Odyssey is built to grow into a full universal quantum computing learning platform. If a universal quantum computer can do it, we aim to bring it into the game, so your quantum journey never ends.

Nice to watch:

Khan academy style tutorials in qm/qc: https://www.youtube.com/@MackAttackx

Physics teacher stream with 400hs in https://www.twitch.tv/beardhero


r/algorithms 7d ago

Help Building a constraint-based 2D layout generator for urban plots with an AI agent loop. Looking for libraries/approaches!

0 Upvotes

Hi everyone,

I’m working on a PropTech tool that procedurally generates building layouts for real estate feasibility studies, with the goal of maximizing buildable area.

The Workflow:

  1. The user selects a land plot on a map.
  2. They set high-level parameters (e.g., apartment blocks vs. single-family homes, surface vs. underground parking).
  3. The Engine: Generates multiple 2D site plans (placing roads, footprints, and parking lots) that strictly adhere to the geometric constraints (setbacks, footprint limits, alignments).
  4. The user can manually tweak the layout by dragging polygons around.
  5. The Agentic Loop: An integrated LLM/VLM chatbot that allows the user to iteratively adjust the layout via natural language (e.g., "group the buildings closer to the north edge"). The AI needs to "understand" the current 2D layout and update the constraints to regenerate a new compliant layout.

I already have something 'working', but it is, in my opinion, too static and dependent on the test parcel I'm using. The coming issues are the varying sizes and shapes of the parcels, which can have infinite variations. Given that I am constrained to work within a fixed boundary, I can't use approaches such as Voronoi cells or similar methods.

Where I need your insights: Assuming the rules are already parsed into raw constraints, I’m looking for the state of the art to build the final composition engine:

  • Constraint-based 2D Generation: What are the go-to algorithms or libraries (preferably web-friendly) for 2D packing and layout generation under strict geometric rules?
  • Spatial AI / LLM Integration: Are there any papers, open-source projects, or specific approaches for feeding a 2D spatial topology to a model so it can meaningfully tweak procedural generation parameters?
  • Interactive Frameworks: Any recommended engines or existing tools that handle both procedural layout generation and interactive 2D editing smoothly?

I'm highly open to academic literature, specific algorithms, or existing open-source solvers I could draw inspiration from.

Thanks in advance!


r/algorithms 7d ago

Discussion C++ Solver findet eine Interaktion zwischen zwei Änderungen in 17 Queries

0 Upvotes

Ich experimentiere gerade mit einem C++20 Solver, der bei reproduzierbaren Bugs herausfinden soll, welche CodeĂ€nderungen gemeinsam den Fehler verursachen. Habe ihn jetzt mit einem externen synthetischen Testfall ausprobiert. Zwei Änderungen waren einzeln unauffĂ€llig, zusammen haben sie den Fehler ausgelöst.

Der Solver hat genau diese Kombination gefunden.

17 Queries, 42 echte ProgramlĂ€ufe inklusive zusĂ€tzlicher Verifikation Ich will das jetzt mit schwierigeren FĂ€llen testen, vor allem mit drei beteiligten Änderungen und grĂ¶ĂŸeren SuchrĂ€umen.

Falls jemand Erfahrung mit solchen Debugging oder Causal Testing AnsĂ€tzen hat...welche Baselines oder TestfĂ€lle wĂŒrdet ihr als NĂ€chstes nehmen?


r/algorithms 10d ago

Help Self Sort Algorithm

8 Upvotes

Is there an algorithm where you make each array element an object, provide it with private functions and actions, and then allow it do help with sorting if you broadcast the sort function to all arrays ahead of starting the sort?

For instance, the sort wrapper would just need neighbor information for the cells direct or two steps away and then they could switch in place while a master sorting algorithm verifies end to end sort by just stepping each element and having knowledge of next moves each element is making?

I may be thinking of this more as a Verilog problem than a C++ problem but it seems like it hasn't necessarily been defined or commonly used and I can't imagine why not if the function can be modified for any kind of sorting that is common to each element?​


r/algorithms 10d ago

Resource Implementing arbitary-precision square rooting algorithm using the long division in C++ (with custom BigNumber library)

12 Upvotes

Hello everyone,

Some days ago, I have finished building an algorithm in C++ using only my mobile phone (Termux and Helix), and I want to show it to you!

So, it uses the long division method. Why not the Newton-Rasolph method or use the GMP library? Because this program was built for two reasons:

  1. An educational purpose of learning how to build an algorithm I have an idea of and optimize it as much as I can.

  2. To learn how to implement a mathematical algorithm as a program, and to also learn more about C++.

The performance of this algorithm is following the O(nÂČ), but with a small constant, since I have optimized this algorithm as much as I can. You can see the benchmark in the GitHub link down below. Here is how I optimized it:

This algorithm has a custom BigNumber class that makes a number as a vector, each digit is represented as an element in the vector, and, each digit follows a base 10^17 number instead of a decimal digit! This is the underlying logic behind very famous libraries like BigInt, but since these libraries are so general (they have to deal with very large multiplications, division, negatives and many general cases). This class recognized that the max number is being multiplied to the number is 100 (see the long division method) and implemented base 10^17. Therefore, since 100<10^17 (the base), then the multiplication is just multiplying one digit by the number. You can check the code for more

The way the algorithm predicts the digit is the binary search, it checks a number, and then eliminates half of the domain of search. This way, it is faster by 50-60% than the ordinary linear search.

And more! You can check the README of the project in this repo:

https://github.com/hasan-mazen-darwish/algorithm-square-rooter

I spent more time on this REAMDE than the actual code, so I hope you don't get lost 😅

I'm open for any discussion or any question! Feel free to ask anything or criticize this project or a specific line of code!


r/algorithms 10d ago

Help How to find the row echelon form of a stupid big matrix

6 Upvotes

How to find the row echelon form of a stupid big matrix

I am trying to find an equation that models a fruit in 2D, and I am using Global Polynomial Interpolation to do it, but I have like 2000 points. I am thinking of using Gaussian elimination to do it, but it is impractical by hand. Does anyone have any suggestions?

Also, does anyone have any suggestions for how to model the shape using other methods?


r/algorithms 11d ago

Help Day of Week Calculation

0 Upvotes

I'm aware of Hakamoto's method, Zeller's congruence and the like. But (with the help of AI), I've developed a faster way (literally optimised for speed, nothing else). It's such a niche piece of maths tho, but it feels elegant. I then asked Claude to write it up. It did, as a paper, in LaTeX.

Now I don't know what do with this. It's SUCH a niche example. But it is faster.

I presume this should and could also be applied to other examples. What....what are people doing? Do we just contact maths/CS journals with this? Or go 'meh, our AI overlords will take over soon anyway'.


r/algorithms 12d ago

Resource HVAC coil circuiting used to take me 2 hours

7 Upvotes

A few months ago, I watched a senior CAD draftsman spend nearly two hours on a single AutoCAD drawing. He was not modeling a complex building. He was just connecting dots.

In HVAC coil design, you have a staggered grid of 200+ tube holes. You have to draw balanced fluid circuits across them with zero crossing lines, exact tube counts per circuit, and no trapped holes. One mistake, and you have to erase everything and start over.

I thought, "This is purely math. I can automate this in a weekend." I was wrong.

My first script used standard pathfinding (backtracking). On small test grids, it worked. But the moment we tested a real manufacturing schedule (a dense 19x7 grid with 99% of holes occupied), the algorithm choked and froze.

The turning point came when I stopped trying to "draw lines" from left to right. Instead, I split the problem into two math phases:

  1. Allocate: Pre-calculate exactly how many holes each circuit gets per column.

  2. Stitch: Connect those blocks from bottom to top using Dynamic Programming.

I wrapped it into an AutoCAD C# plugin and hit run. The 2-hour drawing generated in 40 milliseconds. Perfectly packed, zero crossed lines, and 100% compliant with the manufacturing schedule.

The takeaway: If your automation search space explodes, do not brute-force the path. Figure out the mass distribution first, then connect the dots.

Curious if anyone else here builds custom CAD plugins. What is the most tedious drafting task you have automated?

Happy to assist or answer any questions!


r/algorithms 13d ago

Resource If this algorithm runs too long, you can compress randomness

28 Upvotes

Update (21 Aug 2026): Used the feedback provided, I think the exposition is more rigorous now and not jumpy in terms of the logical steps

I wrote a post about a non-trivial analysis technique I was shown in a course that proves why an algorithm terminates.

Link: here

Feedback appreciated!


r/algorithms 12d ago

Resource i created a recomendation code

0 Upvotes

Hi! My name is NicolĂĄs Ochoa Silva, and I've been working on a Python code that calculates a "recommendation" percentage based on factors and weights that you can rate yourself from 1 to 10. The program's logic works like this:

First, choose the number of factors you have and rate them from 1 to 10 (example: money = 7.6).

Then, assign a weight to each factor (money = 7.6, importance of money = 10).

Finally, the code multiplies each factor by its weight and sums them all to then calculate the sigmoid using the equation: sigmoid = 1/(1+Euler^(x)) (at least in the first part).


r/algorithms 14d ago

Discussion The "unreasonable effectiveness" of Linear Programming

122 Upvotes

When I was first learning LP in undergrad (simplex, relaxations for Integer Problems, weak and strong duality and all that jazz), I honestly didn't see where it would be that useful. Now in my research it shows up quite a bit via primal-dual algorithms. These simultaneously keep track of the primal and dual solutions.

To be fair, even in undergrad one usually learns about using LP relaxations and (deterministic or randomized) rounding to get approximation algorithms for problems such as MAXSAT or Set Cover.

I'm curious where else people run into it. Has LP ever popped up in your own research or work?


r/algorithms 15d ago

Research/Papers A Geometric, Best-Improvement Heuristic for the Travelling Salesman Problem

0 Upvotes

I spent six months in 2021 building a TSP solver from geometric first principles, with no prior reading of the literature. Recently turned it into an interactive web app with step-by-step animation of every algorithmic move.

Interesting result: the algorithm independently rediscovered convex hull seeding and 2-opt uncrossing. It also produced a farthest-neighbour strategy I haven't seen documented.

On Berlin52: 7783 vs world optimal 7542 (3.2% above). 14ms on a single CPU core.

Demo: tsp.uncledroid.app
Paper: tsp.uncledroid.app/paper.pdf

Happy to discuss the algorithm — especially if anyone can point me to prior work on farthest-neighbour as a TSP construction heuristic.

video: youtu.be/92z670RTsJg


r/algorithms 16d ago

What Are You Working On? August 16, 2026

13 Upvotes

Inspired by the recurring threads on r/math, we are starting our own weekly discussion thread!

 

This recurring thread will be for general discussion on whatever algorithm-related projects, problems, or topics you have been or will be working on this week. This can be anything, including:

* theoretical computer science and algorithm design,

* books, papers, or articles you are reading,

* coursework or self-study (what you have been learning recently),

* competitive programming or interview prep,

* preparing a talk, presentation, or project demo.

 

All backgrounds and levels of experience are welcomed!


r/algorithms 19d ago

Help Built a combinations algorithm to classify data

6 Upvotes

Does anyone have any advice on where to go from here? The algorithm simply goes through all feature-attribute combinations in a dataset and scores it on purity of the target column. It's very slow, as the number of combinations increases exponentially with the number of input features, and so can only work with 3-4 features at a time. But my goal is to identify <=5 important features with a linear model (statsmodels or PyGam), and then plug in those features to this algorithm to see which subset of the market might be smart to target.

Here's an example with some charts, on the iris dataset.

https://colab.research.google.com/drive/1w3VpDlDATdHwtSk-RmQPMj36cgOfthz1#scrollTo=ZOqeYiMRalj7&uniqifier=1

New to algorithms, so any advice would be welcome. Thanks in advance.


r/algorithms 19d ago

NP-overrated

0 Upvotes

In my experience the concept of NP-hardness is widely misunderstood. Often taken as a problem class that's unsolvable in practice. But they are solved in practice all the time. I wrote a short post about that:

https://gruhn.me/blog/2026-08-13/


r/algorithms 19d ago

Spacing points "evenly" across a gradient

9 Upvotes

Does anyone know an algorithm for "evenly" spacing points across a given space (e.g. a cylinder), where one given point is locked in place and all others are as evenly spaced as possible, but across multiple gradients that weigh less points to be placed at specific positions. For example, a cylinder with aversion points at the top, bottom, and 3D middle, such that some points appear at the top, bottom, and middle, but less than in the middle of the surface where most points would reside. With configurable weights to the aversion points to push points closer or further away from them. Specifically, I'm trying to use such an algorithm to choose a number of sufficiently contrasting colors, but to understand the solution in general would be ideal. Is something like Lloyd's algorithm what I should be reaching for, or is there something simpler?


r/algorithms 20d ago

Built `algomanim` PyPI package for algorithm visualization

9 Upvotes

Check out algomanim — a Python library I built for visualizing classic CS and LeetCode algorithms.All of my visualizations are shared on my YouTube channel.
https://www.youtube.com/@benabub


r/algorithms 21d ago

I made a game about the worst sorting algorithm "Bogosort"

8 Upvotes

r/algorithms 22d ago

Help [Academic] How does your social media feed affect what feels 'real' to you? (4-5 mins, anonymous)

6 Upvotes

Hi! I'm an Msc student, researching how algorithmic personalisation on social media shapes perceptions of authenticity and decision-making.

The survey takes 4-5 minutes, is completely anonymous, and includes a short mock Instagram post to react to.

Would really appreciate your help — every response counts! 🙏

https://qualtricsxmt49bm7j6z.qualtrics.com/jfe/form/SV_248ntuA314RvLKK

Thank you!


r/algorithms 21d ago

Help sorting problem

0 Upvotes

background: i work for a company as a maintenance technician and recently took over the operations of our warehouse from someone that left it a wreck.

i have to get rid of old equipment given to the warehouse to dispose of. there is an unknown quantity of equipment. ~enough to fill a warehouse. each piece needs to be tagged with a type of barcoded document with information about it in order to be received by the disposal facility. a portion of these forms have been made but have not been attached. i will need to make and attach the rest of these documents but do not know how many.

how can i most efficiently sort these items? the goal is that i can tell my boss how much time it will take and then fill enough trucks to have all the materials disposed of.

this is actually the bane of my existence and costing my warehouse greatly. i would greatly appreciate, as the problem could make or break the operation.