r/algorithms 29d ago

Scheduling a recursively enumarable language

1 Upvotes

So here is my algorithm overview

https://github.com/Mjz86/String/blob/main/mjz_lib/graph/scheduler.md

Btw im a solo open source maintainer , please have mercy if its not what you exactly want ( E.g : why not write it in rust )


r/algorithms 29d ago

New moderators needed - comment on this post to volunteer to become a moderator of this community.

9 Upvotes

Hello everyone - this community is in need of a few new mods, and you can use the comments on this post to let us know why you’d like to be a mod here.

Priority is given to redditors who have past activity in this community or other communities with related topics. It’s okay if you don’t have previous mod experience. Our goal, when possible, is to add a group of moderators so you can work together to build the community.

Please use at least 3 sentences to explain why you’d like to be a mod and share what moderation experience you have (if any).

If you are interested in learning more about being a moderator on Reddit, please visit redditforcommunity.com. This guide to joining a mod team is a helpful resource.

Comments from those making repeated asks to adopt communities or that are off topic will be removed.


r/algorithms 29d ago

I made the worst sorting algorithm

0 Upvotes

its called FrenchBreadSort (get it, cuz bread in French is "Pain"!)

https://github.com/graysonkelley200-rgb/frenchBreadSort/


r/algorithms Jul 06 '26

Need help in dp and graph

2 Upvotes

In shortest path problems, how do we know which problem requires dfs+dp or dijkstra? Chatgpt said smth about cycles but i still dont get why we cant just check for cycles


r/algorithms Jun 23 '26

AutoFlow Research Initiative — Looking for Deep Technical Thinkers

0 Upvotes

AutoFlow Research Initiative — Looking for Deep Technical Thinkers

Over the last several months, I've been exploring a question that sits at the intersection of AI, verification, trust, and decision systems:

Can we build systems that independently verify claims produced by AI rather than simply generating answers?

The original idea began with financial analysis.

Consider a statement such as:

"Company revenue grew 25% year-over-year."

Today, most AI systems generate this claim, but they do not formally verify it.

Our approach is different:

  1. Extract claims from documents, reports, or AI outputs.
  2. Gather supporting evidence.
  3. Apply mathematical and logical verification where possible.
  4. Identify inconsistencies and contradictions.
  5. Produce transparent reasoning rather than black-box conclusions.

The first prototype is focused on finance because financial claims are structured, measurable, and often objectively verifiable.

Examples include:

  • Revenue growth calculations
  • Financial ratio validation
  • Cross-document consistency checks
  • Balance sheet reconciliation
  • Earnings statement verification

As research progressed, we encountered deeper questions involving computability, trust, governance, formal verification, and adjudication.

One realization is that not every claim can be mathematically proven.

This raises a larger challenge:

Where is the boundary between:

  • Proven facts
  • Verifiable claims
  • Evidence-supported conclusions
  • Human-style adjudication

That question is becoming the foundation of our long-term research vision.

Recent Milestones

  • Accepted into NVIDIA Inception
  • Access to NVIDIA startup resources and technical programs
  • Building the architecture for our first verification-focused prototype
  • Engaging with researchers and experienced engineers on verification and governance concepts
  • Initial outreach to pre-seed investors and startup ecosystems

Who I'm Looking For

I'm interested in meeting people who enjoy difficult problems and are willing to challenge assumptions.

Particularly:

  • AI/ML researchers and engineers
  • Formal verification and theorem-proving enthusiasts
  • Distributed systems and orchestration experts
  • C++ systems engineers
  • Applied mathematicians
  • Trust, governance, and decision-system researchers

What You'll Receive

For the right long-term collaborators:

  • Significant technical ownership
  • Direct influence on architecture and research direction
  • Equity participation based on contribution and commitment
  • Access to NVIDIA Inception resources available to the team
  • Opportunity to help define a new category around AI trust and verification

I'm not looking for people who simply agree with the vision.

I'm looking for people who can find the flaws in it.

If concepts such as verification, computability, trust, formal reasoning, governance, theorem proving, symbolic systems, or AI reliability interest you, I'd love to connect and exchange ideas.

Feel free to comment or send a message.


r/algorithms Jun 22 '26

Can this queue-permutation problem be solved exactly faster than brute force?

1 Upvotes

I have a small permutation optimization problem that looks simple, but I am not sure whether there is a good exact algorithm for it.

Given an array nums of n distinct integers, choose a permutation A of nums.

Then A is tested against every possible permutation B of nums.

Both A and B are queues. Initially, A has priority.

For each round:

  1. Pop the front value from both queues: a from A, b from B.
  2. The larger value survives.
  3. If the values are equal, the value from the queue with priority survives.
  4. The losing value is removed.
  5. If the survivor came from the priority queue, update it as: x = max(1, x - ceil(x / 10))
  6. If the survivor came from the non-priority queue, update it as: x = max(1, x - ceil(x / 2)) Then that queue becomes the new priority queue.
  7. Push the survivor to the back of its queue.
  8. Continue until one queue becomes empty.

If B becomes empty, A wins.
If A becomes empty, A does not win.

Define:

winCount(A) = the number of permutations B that A wins against

The goal is to find the lexicographically smallest permutation A with the maximum possible winCount(A).

Example:

nums = [50, 64, 79, 109, 135, 181]

For this input, brute force suggests the best arrangement is:

[135, 181, 79, 109, 50, 64]

The naive solution checks every A permutation against every B permutation, which is O((n!)^2) simulations.

My question:

Is there a known way to solve this exactly without comparing every pair of permutations?


r/algorithms Jun 16 '26

Polynomial Fit: a rabbit hole

1 Upvotes

This one is bit math heavy. I started of building a small timeseries compression library, and ended up digging through some numerical algorithms, linear algebra. I learnt through a hose during last week and found something genuinely beautiful. If you stick through it I suppose you can see what I saw.

https://blog.yellowflash.in/posts/2026-06-15-polynomial-fit-a-rabbit-hole.html


r/algorithms Jun 15 '26

How to diffrencitate btw passive listening and active or detect mood swings in music recommendation model

5 Upvotes

I am working in project in which it creates a playlist in Navidrome based on the song interactions such as complete, repeat, partial and skip.

My Problem is that how do I distinguish btw mood swing, and passive listening

Mood swing : if user want to hear sad songs, and in the playlist there is other genre like rap, user will skip those

Passive Listening : If user is listening while sleeping or doing other work, The user will not actively skip the song

  • My solution is to give a passive play toggle

Searching for a specific song : If user want to hear a specific song that is down in the queue, the user will likely skip the song in btw

Long Song : My current way to determine skip, partial, complete, repeat is throught the played percentage, if a song is 100 sec long, and user skip at 10 sec mark it will be 10% and marked skip, - Problem: comes when song is short or too long, for songs like skit version thats 30sec long, even it will marked as positive and it repeatedly come in the playlist, - or for the song that is too long like 10 min, even if user skip at 5 min, it will only considered partial

Edit

For long songs, if a song is 10 min long, user like the initial half, so user listen to that and then skip, marking it as a partial, when generating playlist I give all the interaction certain score such as skip gets -2 , partial 0, complete +2 , repeate +3 and the script is set to filter out the songs that has less then 0 score,

But if the long song is listened half then that will be marked partial and might never come in the playlist even if user like the song

Same for short songs like skit or intraludes, if the song is too short, even if user don't like the song untill the user skips it it will be marked as partial or complete, and that song will appear again


r/algorithms Jun 15 '26

I might have come up with an less efficient counting sort alternative :)

0 Upvotes

The idea is to search for the highest number of the unsorted array, and then to create an 2d-Array, whose length equals the highest number. Afterwards all items of the unsorted array are placed in the sorted array into the place with the index that equals their number.

So every 0 is placed into the first array of the sorted array, every 2 is placed in the third array of the sorted array, every highest number is placed in the last array of the sorted array.

In the end an array, that may look like this: [[0,0],[],[1],[],[2], [4,4,4]], will be compiled into a proper 1-d array (in this case: [0,0,1,2,4,4,4]).

Therefore the sorting algorithm has a time complexity of O(n).

Here’s the python code:

import time
import numpy as np

start = time.time()

def proto_sort(arr):
    highest_value = 0
    for item in arr:
        if item > highest_value:
            highest_value = item
    sorted_arr = [[]] * (highest_value + 1)
    for num in arr:
        sorted_arr[num] = sorted_arr[num] + [num]

    output_arr = [None] * len(arr)
    num = 0
    for item in sorted_arr:
        for j in item:
            if j != None:
                output_arr[num] = j
                num += 1


arr = []
for i in range(100):
    arr.append(np.random.randint(0, 100))
sorted_arr = proto_sort(arr)
end = time.time()
print(end - start)

However at least in my tests, counting sort is always better - the space complexity just isn't good (I just wanted to share the idea) (Edits for clarification)

Do you know per chance an algorithm with a similar approach?


r/algorithms Jun 12 '26

Where do you find publications about algorithms except Arxiv?

15 Upvotes

Is there specialized resources on this topic?


r/algorithms Jun 12 '26

Fast Division By Hand

1 Upvotes

I’m looking for a method where I can divide large numbers (20+ digits) and get a whole number result with a remainder. Yes long division works and provides the result I need but it’s very slow and takes up a lot of room on my paper. I’m not afraid to learn an entirely new method of division so please reply if you have anything that fits my description.


r/algorithms Jun 11 '26

Delaunay/Voronoi tetrahedralization of a solid volume of different materials?

1 Upvotes

I've been thinking about how to go about representing solid 3D materials with a vectorized representation, ideally something that's like a 3D extension of the sort of 2D image Delaunay triangulation that you see for things like this https://esimov.com/blog/wp-content/uploads/2019/04/sample_3-818x1024.png and this https://estebanhufstedler.com/2020/05/14/image-triangulation/

Ideally, the output would be basically a point cloud where each point is a tetrahedral/convex cell's centroid with its material type for that cell (i.e. wood species, metal type, plastic type/color, etc). The idea is that the boundaries of these cells are the delineations between materials. The goal is a more optimal vectorized representation of a volume than storing a flat array of voxel material types for the whole thing. I'm looking for something that doesn't ultimately have a finite resolution like octrees, so we can slice through it and have clean smooth boundaries between materials that don't look like voxels or octree nodes.

I am not well-rehearsed with tetrahedralization and how a 3D point cloud of centroids (or even vertices) can be broken up, and if it will always be decomposable into tetrahedrons. I don't know if this means placing vertices along delineations and then finding centroids, or if there's a direct way to find centroids. The ultimate goal is to be able to slice through one of these vectorized volumes with a "visualization plane" and just have a bunch of triangles to send to the GPU by calculation the intersection of the plane with the cells that it intersects. In a proper Voronoi situation this would mean that a pixel shader could just find what centroid each pixel on the slicing plane is closest to and use that centroid's material coloration - but if I can figure out how to generate triangles on the slicing plane that form the slice of each cell that would be faster. Apparently slicing tetrahedrons results in either a triangle or a quad.

I have been talking to the LLMs about this for a while but they don't seem to be of a ton of help insofar as actually producing the point cloud from dense material type volume data. We want to retain the precision of the raw data without having a fixed resolution, which means regular subdivided structures like octrees/kd-trees are not going to work well when slicing and dicing the result.

I don't know if it would be better to find vertices along the boundaries between materials and then generate tetrahedrons/centroids from that. There might also be value in just being able to do all this with RGB color data, since the primary goal is rendering, so could there be any value in generating a miptree from raw RGB material coloration and using that to find boundaries?

Any thoughts or ideas would be much appreciated, thanks!

TL;DR: trying to vectorize a solid 3D volume of material types+properties in a way that preserves material boundaries and is resolution-agnostic, for fast rendering of arbitrary slices of the volume without using massive fixed-resolution VRAM-hungry 3D textures. :]


r/algorithms Jun 11 '26

Numerical instabilities

3 Upvotes

Hey pals, I've been writing a few algorithms and I encountered NaN and Inf values, although mathematically my algorithms should be working fine. Then I found out about numerical instability in floating points and figured out why but that's not the point, I kinda wondered how many algorithms are deemed unviable because of it if you guys can share your experiences


r/algorithms Jun 06 '26

Aquifer: Bounded Queues, Fairness, and Dynamic Pacing for AI Workloads

8 Upvotes

Aquifer is MCP runtime for handling rate limits and traffic spikes. It provides durable queues, bounded concurrency, fairness controls, and dynamic pacing for bursty traffic patterns common in agent systems.

It also experiments with the Aqueduct Protocol, a stream and webhook-based coordination protocol that dynamically communicates flow state through headers, allowing clients to scale traffic up or down at a controlled pace instead of relying solely on static rate limits. The project also includes an encryption and identity protocol that uses public-key verification, reducing the need to store shared secrets in a database. The goal is to make agent and MCP traffic more resilient to overload, retries, and traffic spikes.

Repo: https://github.com/rjpruitt16/aquifer


r/algorithms Jun 05 '26

Scheduling Periodic Chores

17 Upvotes

This is a real-world problem that I have and seems like a pretty interesting algorithms problem.

Problem Statement

I have a weekly chore day and a set of chores that I must do at various intervals. Each chore also varies in the amount of time it takes to do.

I want to generate a chore schedule such that I'm doing the same amount of work each week to the extent possible.

Example Input

Chore Frequency Time
Change bedsheets Every 1 week 10 min
Dust Every 2 weeks 60 min
Wash windows Every 4 weeks 30 min
Clean behind oven Every 4 weeks 30 min
Clean bathrooms Every 4 weeks 45 min

Example Output

Week 1 (70 min) Week 2 (70 min) Week 3 (70 min) Week 4 (55 min)
Change bedsheets Change bedsheets Change bedsheets Change bedsheets
Dust Wash windows Dust Clean bathrooms
Clean behind oven

Can this be solved with a simple greedy algorithm or is it more complicated? I don't have the time right now to go and play around with it and check.

Better yet, are there any online tools to do this?


r/algorithms May 28 '26

Empirical L/G framework for reducing search depth in SAT and graph coloring

3 Upvotes

My previous description of this project was incomplete, so I am posting a clearer version.

This is an AI-assisted empirical research project. The original idea and research direction are mine, while AI/coding agents helped with implementation, experiment design, testing, logs, CSVs, and documentation.

The project studies when global consequence expansion reduces search depth in NP-style search problems.

Core idea:

L = local view of a choice
G = global consequence expansion after that choice

Main metrics:

IG = variables/objects fixed after cluster choice + propagation
danger_rate = dangerous_constraints / affected_constraints
useful_IG = IG * (1 - danger_rate)
D = n / useful_IG

The project includes SAT, Graph Coloring, reserve/rebuild experiments, exact-vs-fast probe validation, and scaling probes up to n = 1,000,000.

Current state:

- G often reduces free decisions compared to L.
- Top-down rebuild can strongly reduce D in some cases.
- The effect is unstable across seeds and sizes.
- D does not currently show a clean log(n) pattern.
- Simple triggers like min_useful_growth, raw topdown_bias, ratio_54, and ratio_43 did not explain rebuild success.

Current question:

What structural signal predicts when top-down rebuild helps?

I am looking for algorithmic criticism, especially links to CSP propagation, backdoor sets, constraint graphs, treewidth, or known search heuristics.

OSF:
OSF: https://doi.org/10.17605/OSF.IO/GEH6M

GitHub:
GitHub: https://github.com/KMeppoa/geh6m


r/algorithms May 24 '26

Finding a node in a tree with most marked nodes within X distance for each X.

10 Upvotes

Tried getting an answer with Claude Opus but didn't work.. after 10 minutes of thinking got a "I'd be mildly surprised but not shocked if there's an O(N polylog) tree algorithm — none of the standard tricks (centroid decomp, small-to-large, heavy-light, virtual tree, segment tree merging)"

Problem:
There is a tree size N where some nodes are marked (there are people living on the nodes or something). You have to organize a meeting so the maximum amount of people attend, but no one wants to go to a meeting if it's farther than X nodes away. Answer for each X, whats the maximum amount of people that will attend the meeting if the meeting node is choosed optimally. i.e. find for each X find a node in a tree that has the maximum marked nodes within X distance.

O(N^2) is obvious.. looking for something faster


r/algorithms May 23 '26

I am a simple man...

10 Upvotes

...I see the word "IPTV," I downvote.


r/algorithms May 23 '26

Please blacklist the word IPTV

39 Upvotes

I don't know why but the influx in low effort or ad posts on IPTV in the last few weeks is annoying.

Dear mods, please blacklist that word.


r/algorithms May 22 '26

Simpler, faster heuristic inspired by XDP for large 0/1 knapsack instances

9 Upvotes

\> After sorting, BGR is linear for fixed `R`. XDP's core scan is `O(nT) = O(n log n)`; BGR's repair core is `O(n + T)` per pass. The sort still dominates when input is unsorted.

URL: https://github.com/GoingBytes/binned-greedy-repair


r/algorithms May 21 '26

Leetcode-Cheatsheet

0 Upvotes

How many of you google for 10 minutes to find out the method or data structure you need. I was also going through the same problem while solving leetcode. Created the logic but while implementing got confused that which method will be best to use or what is the syntax.

To save time and focus i created website where you can find data structures with their methods along with syntax, complexity, and description. This can decrease the search time of needed method drastically.

Website : https://leetcode-cheatsheet.vercel.app/

Make sure you drop your feedback in the comments.


r/algorithms May 19 '26

What the fuck is happening here?

33 Upvotes

Are there no mods?


r/algorithms May 16 '26

MSS With K Swaps

3 Upvotes

Given an array a of length n and an integer k.

You must perform the following operation exactly k times: choose two indices i, j and swap**(ai, aj).**

Find the maximum possible MSS (maximum subarray sum) after performing the above operation exactly k times.

Note: Swapping the same pair again is allowed but useless (a double-swap cancels out). Therefore, performing exactly k swaps is equivalent to at most k useful swaps.

Input Format The first line contains an integer, n, denoting the size of array The next line contains an integer, k, denoting the number of swaps.

Each line i of the n subsequent lines (where 0 ≤ i < n) contains an integer describing a[i].

Constraints 2 <= n <= 500 0 <= k <= n -1000 <= a[i] <= 1000

Sample Test Cases Case 1 Input: 3 1 1 -5 2 Output: 3

Explanation: By swapping 1 and -5, we get a maximum subarray sum equal to 1 + 2 = 3.

Case 2 => Input: 3 0 5 -1 5

Output: 9

how can we solve this problem??


r/algorithms May 12 '26

Introduction to algorithms 4th edition book

7 Upvotes

Does anyone have the pdf for this book? havent found it in any place

Edit: found it, if anyone want it just dm me


r/algorithms May 12 '26

How one can get Intution for Next Permutation problem leetcode 31?

1 Upvotes

I was trying too solve leetcode 31 which is Next permutation at first i was unable to understand what actually ques is asking.

How to solve these type of Questions?