r/algorithms • u/Phytor_c • 20h ago
News No polynomial-time 7/8-approximation algorithm for MAX SAT, assuming UGC and P ̸= NP
arxiv.orgWas scrolling through arxiv and found this paper, I think it’s a very cool result.
r/algorithms • u/Phytor_c • 20h ago
Was scrolling through arxiv and found this paper, I think it’s a very cool result.
r/algorithms • u/ClickOk5811 • 20h ago
Given a set of line segments, report all intersection points. Standard sweep-line: sort events by x, then y; maintain an active set ordered by y at the sweep line; check neighbors when segments enter or leave.
The part that rarely gets emphasized is the event tie-break. When two segments share the same left endpoint x, you order them by y. But when the sweep line reaches an endpoint shared by multiple segments, the order you process endpoints at that exact x determines which pairs are “adjacent” in the active set at that moment, and a wrong tie-break can make you miss an intersection entirely.
I put together a minimal reproducible example in Python (shapely only for ground truth, the sweep is pure Python). I have not run the numbers myself, so treat the expected output as a hypothesis, not a measurement:
from shapely.geometry import LineString, MultiPoint
from sortedcontainers import SortedList
def sweep_intersections(segments):
"""
segments: list of ((x1,y1),(x2,y2)) with x1 <= x2.
Returns list of intersection points.
"""
events = []
for i, ((x1, y1), (x2, y2)) in enumerate(segments):
events.append((x1, y1, 'L', i))
events.append((x2, y2, 'R', i))
# Sort by x, then y, then type (L before R at same point)
events.sort(key=lambda e: (e[0], e[1], 0 if e[2] == 'L' else 1))
active = SortedList(key=lambda i: y_at(segments[i], current_x))
intersections = set()
def y_at(seg, x):
(x1, y1), (x2, y2) = seg
if x1 == x2:
return y1
return y1 + (y2 - y1) * (x - x1) / (x2 - x1)
def check_pair(i, j, x):
if i is None or j is None:
return
# compute intersection of segments i and j near sweep line x
...
for x, y, typ, i in events:
if typ == 'L':
pos = active.add(i) # conceptual
neighbors = active.neighbors(i)
check_pair(i, neighbors.left, x)
check_pair(i, neighbors.right, x)
else:
neighbors = active.neighbors(i)
check_pair(neighbors.left, neighbors.right, x)
active.remove(i)
return intersectionsThe subtle point: at a shared left endpoint, should you insert segments in order of slope (steepest first), or by y at x+ε? If you insert by y at the endpoint itself, two segments starting at the same point compare equal, and the tie-break in your sorted container becomes arbitrary — which changes which pairs you test for intersection.
Questions:
I haven’t tested this with real coordinates yet, if someone wants to run it, I’d love to see whether the naive tie-break actually drops an intersection on a concrete case.
r/algorithms • u/xain1999 • 1d ago
Hey everyone!
Back in 2024, I started working on LearnGraphTheory.org as a personal project with a simple goal: to make graph theory, algorithms, and mathematical optimization easier to learn through interactive visualizations.
As someone with a background in mathematics and operations research, I've always felt that these subjects could be taught in a more intuitive and interactive way.
What started as a small project has gradually grown into an educational platform that now receives 10,000 monthly visitors from around the world, mainly through organic growth.
Over the past two years, I've continuously worked on improving the platform and adding new features, including:
- 80+ interactive algorithms with step-by-step visualizations.
- 70+ educational articles and tutorials.
- 20 video lessons.
- Interactive 2D and 3D graph visualizations.
- Built-in Python and JavaScript code editors.
- 8 mathematical optimization calculators.
- Operations research tools for vehicle routing, project scheduling, linear programming, and more.
- Real-world map-based algorithm visualizations.
- Cloud saving and synchronization.
- Support for six different languages.
It's been really rewarding to see people from different countries using the platform, whether they're students, teachers, researchers, or developers.
One of my main goals is to keep the platform's interactive learning resources freely accessible to everyone. I'm also exploring ways to make the project financially sustainable without putting these resources behind a paywall.
There's still a lot I want to add, including more advanced algorithms, optimization tools, educational content, and additional languages.
I would love to hear your thoughts, especially from people studying or working in mathematics, computer science, and operations research.
Are there any particular algorithms, tools, or features you'd like to see added to the platform?
You can check it out here: https://learngraphtheory.org/
Thanks to everyone who has supported the project so far!
r/algorithms • u/Opengangs • 2d ago
https://eccc.weizmann.ac.il/report/2026/353/
Based on the talk Dana gave a little while back but we finally have the first human-readable proof of the Unique Games Conjecture which is huge (would have to find some time myself to read it!).
EDIT: We also have a human-digestible refutation of ETH as well (https://eccc.weizmann.ac.il/report/2026/347/)
r/algorithms • u/himanshu_parat • 3d ago
I've been building Parat, a SAT solver with special engines next to a CDCL core. v1.5 is out, one program per OS (Windows, Linux, macOS; x64 and ARM): https://github.com/himanshu161106-crypto/parat/releases/tag/v1.5
What it does:- Proves a 2048×2048-bit Wallace multiplier (42M AND gates) correct in ~3.5 min on one core with 8 GB RAM. A wrong gate gives INCORRECT with a counterexample.
- Writes PAC certificates you can check yourself. A 1024×1024-bit certificate (13 GB, 3.1M steps) was checked piece by piece with pacheck (JKU Linz), the independent checker. The checker script builds the gate polynomials from the AIGER file itself, so it doesn't trust Parat's output. - SAT Competition 2026: it solves 10 main-track files that no competition solver solved within 300 s. 3 of them (minimum-disagreement-parity) were not solved by any solver.
- UNSAT answers on CNF come with DRAT proofs (checked with drat-trim).
Where it's weak: on general industrial CNF, Kissat is clearly ahead (61 files at 120 s: Kissat 37, Parat 25). The macOS/Windows-ARM builds haven't been run on real hardware yet.
Benchmarks and logs: results/ and benchmarks/v1.5/ in the repo. Feedback welcome, especially anyone who can run the Mac build.
r/algorithms • u/Dishant-1211 • 3d ago
I'm currently practicing DSA and solving LeetCode problems. Sometimes, I start with a recursive or memoization-based DP solution, only to realize later that the problem can be solved using a much simpler greedy approach.
My question is: How do you identify whether a problem requires DP or can be solved using greedy?
Are there any specific patterns or clues to look for?
How do you prove that a greedy approach will always give the optimal answer?
Is there a systematic way to convert a DP solution into a greedy solution?
I'd love to know how experienced competitive programmers approach this decision. Any examples or resources would be helpful!
r/algorithms • u/Both-Extreme-8609 • 4d ago
This December will be my 4th Advent of Code. I solve it in Kotlin, and before AoC I took part in ICPC. For 3 years I wrote the same code again and again. Every grid began with a table of 4 offsets and a bounds check, and every maze began with a queue and a visited array.
Last year, before AoC 2025, I published the first part of my helpers as a library, kodvent. It had gcd and lcm, a disjoint set union, a segment tree and binary search, but not the code for maps and shortest paths, which I need most often. Now version 0.4.0 is out. It is the largest update so far, and it adds this code: grids, bfs and dijkstra, and a heap.
val maze = input.toGrid() // input: List<String>
val start = maze.positionOf('S')
// The fewest steps from the start to every cell that can be reached
val steps = bfs(start) { p -> maze.neighbors(p).filter { maze[it] != '#' } }
// Dijkstra's algorithm, when entering a cell costs its digit
val risk = levels.toGrid { it.digitToInt() } // levels: lines of digits
val costs = dijkstra(Position(0, 0)) { p -> risk.neighbors(p).map { it to risk[it] } }A state of a search does not have to be a cell. It can be a cell with a direction, a bitmask or any data class.
To check that the library really helps, I rewrote 3 of my old solutions with it:
The documentation shows both versions of each solution. It has spoilers for these 3 puzzles and for part 1 of 2025 day 10.
The library is Kotlin Multiplatform, has no dependencies and is published on Maven Central. It needs Kotlin 2.4.0 or newer:
implementation("io.github.dmitrynekrasov:kodvent:0.4.0")I would like to know what you write again every December and what is missing in the library.
r/algorithms • u/Valdemar216 • 4d ago
8 channels prime harvesting. Takes only O(sqrt(n)) of space instead of regular O(n). 2-3 times faster than Atkin and Sundaram. To see live: https://primeprism.replit.app
r/algorithms • u/emmynoether • 5d ago
One of the common refrains here is that "P=NP might not have any practical effect if the algorithm found is galactic in terms of polynomial exponents I.e. O(n^1000)"
Do we have an example of a natural problem solvable in polynomial time, but with large exponents? More strongly, do we have any problem where the large exponent polynomial is proven optimal?
r/algorithms • u/nxvr443 • 5d ago
I wrote a CDCL solver for SHA-256 from scratch (C++17, F2 Gauss-Jordan elimination, 12-thread lemma sharing) and I'm stuck on how far it can go with round-reduced versions.
At 18 rounds it finds a preimage in about 4.5 s (11,451 conflicts). Caveat: that's one benchmark target, the 18-round digest of the padded "abc" block, not a random one. I fix the six registers A..F at step 16 to values derived algebraically from the digest, and absorb the last two rounds backwards against W16/W17. No external hints.
At 19 rounds it just dies. 241M conflicts over 11.75 h, no solution. My guess is nested Ch multiplexers and carry chains, but I haven't tested that, so take it as a guess.
For comparison I also implemented a simplified 18-step version of Wain/Basra's algebraic method (dropped the third Q-inversion, set a4 = a3). After an ~11 s table build it handles arbitrary 18-round targets in under 0.1 s. The 19-20 step results are Wain's (arXiv:2611.00512), and I re-verified his 46 witnesses.
So has anyone seen a similar cliff between 18 and 19 rounds with other encodings? And is there a better way to encode Ch and the carries for CDCL? Code:
r/algorithms • u/Phytor_c • 6d ago
https://scottaaronson.blog/?p=10379
"I now feel in my bones, for the first time ever, that a proof of P ≠ NP is not far."
r/algorithms • u/pastroc • 7d ago
I apologise for the loaded title.
One aspect I particularly like about research in mathematics, specifically theoretical computer science, is the culmination of observations and understandings that humans generate. When I read a paper, I mainly witness the fruits of months, years of dedication, motivation and obsession of humans. And these papers tend to be written in ways that are relatable and unique.
Nowadays, major companies like Anthropic and OpenAI seem to be throwing out a low massive claims (such as VP vs VNP) with massive, hard-to-grasp technical papers that would require months to fully examine. A lot of papers in the last few months have been heavily written and guided by AI.
I am afraid of a future where research is mainly about generating papers via AI tools and getting humans the chore to understand all the AI-generated nonsense from scratch. I fear a future where clarity and the quality of exposition are no longer valued.
r/algorithms • u/IEEENaN0S • 7d ago
Hi all, posting a closed proof I just finished, with full certificates so you don't have to trust me.
Theorem: lic_lifted_halting_equivalence in formal/utm/MinskyLeftInfiniteClockRun.v
source left-infinite machine halts
<->
exists K t, K >= t /\
c_halted (run t
(if lic_halted c then dispatch_halt_at_y [] []
else lic_q5_encode (lic_head c - Z.of_nat K - 2)
(lic_lift_cfg c)
(lic_book_rows (lic_lift_rows rows)) [])) = true
For nonempty well-formed rows and well-formed source configurations. The existential left-window K is essential — I do not claim a total runtime-independent encode, because wall-halt and lookup-failure halt frames can collide. Empty program is explicitly outside the sentinel encoding's domain.
This closes the host-side obligation for Minsky's published 23×8 universal table — the concrete table, not an abstract fixed UTM — for the left-infinite source model.
How it closed:
• lic_forward_clock — computable recursive native clock • lic_forward_clock_lo_ind — clock is independent of left-window depth • lic_forward_clock_run — clock really reaches native halt, by induction over the source run using the right/left/none/wall macros • Branch alignments: lic_step_cost_none_eq, lic_step_cost_right_eq, lic_step_cost_left_eq, lic_boundary_clock_of_eq • Source/augmented first-match bridge: lic_book_rows_first_match_hit_app_bridge, lic_book_rows_first_match_hit_snoc • Backward direction: lic_lifted_native_halt_to_source with n = t, lic_left_ok_window, lic_bounded_clock_at_least_steps_general
Verification:
• coqc succeeds • coqchk reports “Modules were successfully checked” • Print Assumptions lic_lifted_halting_equivalence → “Closed under the global context” • No Admitted, Axiom, or Parameter in the new proof files • Full-chain rebuild running as final reproducibility check, critical module already passed standalone coqc`/coqchk`
Certificates — commit f4f2e2a on main, formal/utm/certificates/:
• lic_lifted_halting_equivalence.assumptions.txt — Closed under the global context • lic_lifted_halting_equivalence.statement.txt — exact Set Printing All statement • lic_lifted_halting_equivalence.proofterm.txt — full printed proof term, 46 KB • lic_lifted_halting_equivalence.coqchk.txt.gz — complete raw coqchk -o transcript, 2.9 MB uncompressed • lic_lifted_halting_equivalence.coqchk.summary.txt • lic_lifted_halting_equivalence.certificate.json — manifest with statement, assumption list, Coq version, source/.vo hashes, and 62 project dependency hashes
Anchor hashes:
3a2f7c1da821c71e5e58871e4694150a6e4f2ecbbed87384601b4d00270e3a92 MinskyLeftInfiniteClockRun.v
1400472a72cc1f293b0a28d6157e9ad5575efcf37ee71d65d2efb8c70245a385 MinskyLeftInfiniteClockRun.vo
4c2adc7d081414756e2807079f71f37c9f7a28ddbcc8b72f5d8e899f20278dd7 [STRIPPED 73 bytes] assumptions
9f4cf150845cf46cd400a66a2837b3f0708c41cd021a3f35e52b759204465306 proof term
Important caveat, stated up front:
The coqchk -o module-cone summary lists Coq.Logic.FunctionalExtensionality.functional_extensionality_dep.
That is because MinskyLeftInfinite.v uses it in an unrelated theorem. It is not an assumption of lic_lifted_halting_equivalence: • Print Assumptions for this theorem is closed • The 46 KB proof term contains zero occurrences of functional_extensionality • The dependency is in the loaded module cone, not in this theorem's proof Scope, stated honestly:
This is a certificate for the Coq model of the fixed 23×8 table. It is not a certificate for a Coq ↔ NaN0S refinement.
The native NaN16 .nas Minsky fixtures and the nan16.c core are still linked to the Coq table by executable conformance, not by a semantics-preserving proof. No such certificate exists yet. RAW NaN ↔ Coq is the next track.
Repo: https://shemshallah.github.io/nan0s/ Certificates: formal/utm/certificates/ @ f4f2e2a
r/algorithms • u/Opengangs • 8d ago
https://eccc.weizmann.ac.il/report/2026/339/
It looks like the main idea is in showing that a linear number of edge-weight comparisons is sufficient for finding an MST, after which applying Pettie-Ramachandran (2002) gives a linear-time algorithm. Very cool!
r/algorithms • u/Phytor_c • 8d ago
This is crazy... I guess working through this will keep me busy for a while...
r/algorithms • u/cruelCalita • 9d ago
Hey everyone, I hope this isn’t a question that’s been asked a million times already, but I’ve been scratching my head over it and haven’t found a clear explanation. I’ve seen topics about this before in this sub, which encouraged me to bring it up here! I’d really appreciate it if someone could clear up any misunderstandings I might have.
So, my confusion centers around why hash tables are labeled as O(1) in terms of time complexity. I get that the number of buckets is limited, and that resolving hash collisions can take O(n*log(n)) at worst. With data sets getting larger, doesn’t that make hashing just a big constant improvement on the collision resolution method?
If my thinking is on point, how can we still categorize hash tables as O(1) time complexity instead of just calling them high-performing for smaller data sets? Thanks a ton for any clarification!
r/algorithms • u/The_Moth__Guy • 9d ago
I was too bored to search on google similar algorithms, so i wrote one myself
Plese help me find how good i wrote it.
def similarity(a, b) -> float:
# Choose the biggest
if len(a) > len(b):
A = a
B = b
else:
A = b
B = a
perc = 50 / len(A)
total = 0 # total percentage
List = list(B)
Found = []
# algorithm to found similar letters
for i in A:
if i in List:
List.remove(i)
total += perc
Found.append(i)
#alghoritm to found sequence
A1 = list(A)
B1 = list(B)
Bbreak = False
c = 0
for countA in range(len(A1)):
if c != 0:
c -= 1
continue
for countB in range(len(B1)):
if Bbreak:
Bbreak = False
break
if A1[countA] == B1[countB]:
c = 1
a = True
try:
t = A1[countA + 1]
t = B1[countB + 1]
except:
continue
if A1[countA + 1] == B1[countB + 1]:
while a:
try:
t = A1[countA + c]
t = B1[countB + c]
except:
total = total + perc * c
Bbreak = True
break
if A1[countA + c] == B1[countB + c]:
c += 1
else:
a = False
total = total + perc * c
Bbreak = True
return totaldef similarity(a, b) -> float:
# Choose the biggest
if len(a) > len(b):
A = a
B = b
else:
A = b
B = a
perc = 50 / len(A)
total = 0 # total percentage
List = list(B)
Found = []
# algorithm to found similar letters
for i in A:
if i in List:
List.remove(i)
total += perc
Found.append(i)
#alghoritm to found sequence
A1 = list(A)
B1 = list(B)
Bbreak = False
c = 0
for countA in range(len(A1)):
if c != 0:
c -= 1
continue
for countB in range(len(B1)):
if Bbreak:
Bbreak = False
break
if A1[countA] == B1[countB]:
c = 1
a = True
try:
t = A1[countA + 1]
t = B1[countB + 1]
except:
continue
if A1[countA + 1] == B1[countB + 1]:
while a:
try:
t = A1[countA + c]
t = B1[countB + c]
except:
total = total + perc * c
Bbreak = True
break
if A1[countA + c] == B1[countB + c]:
c += 1
else:
a = False
total = total + perc * c
Bbreak = True
return totalr/algorithms • u/Max_Arbuzov • 11d ago
It can be used as a building block for insertion-only (write-optimized) data structures composed of multiple sorted arrays.
Properties:
The task: Array should allow deletion, and search should be always performed in O(log N).
It is simple to do with numbers – just use bit mask to mark deleted items. If a number is deleted, it can still be compared with another items.
But in case of objects, comparing a deleted object might be tricky or impossible. The idea is to avoid any comparison of deleted items.
The idea: Empty and non-empty items should be placed in a specific way. If some item is empty (deleted) and its index divides by 2^k, it is assumed that all 2^k items are empty. This approach allows that search will remain in O(log N) complexity.
Data organizing.
Items in the array are considered as blocks of size 2^k. Blocks are composed of 2 smaller blocks – left and right.
The array is fit into one larger block. For example, an array of length 375 is considered to be placed into block of length 512. It can be also considered as placed into larger block of length 4096.
If a block contains any data, its first item must be non-empty. If first item of the block is empty, entire block considered empty. If a block contains data and its first item is empty, such block is inconsistent.
Searching. It is done recursively.
At the beginning we have a single block, for example its size is 512 for an array of 375 items.
We call a function SearchItemInBlock(item, block_512). The function checks if a block can contain the item; if not then return not_found. If the block can contain the item, then the block is split into 2 smaller blocks – left block_256 and right block_256, the function checks which one can contain searched item and recursively calls SearchItemInBlock(item, block_256) one or two times.
And so on. The complexity is O(log N).
Deletion.
An item is replaced with delete_marker, for example MIN_INT, -INF, default(T) or null_ptr.
After such deletion some block may become inconsistent. To restore consistency (rebuilding) one non-empty item should be moved to the beginning of the block. Any move is performed only inside the block. Finding the next non-empty item is O(log N) in worst-case.
After moving an item another block may become inconsistent. That block will be twice smaller then the previous one. Restoring its consistency requires O(log N). And so on, up to O(log N) blocks.
Totally, restoring consistency requires up to O(log N) searches per O(log N) blocks, that gives compexity O((log N)^2) for worst-case.
Packing/compressing/compaction.
It is optional, not necessary. It might increase the performance of searching and deletion.
After deletion of an item up to O(log N) items moved to more left position. I don't know if it helps in worst-case.
Worst scenario is deleting the items from the very beginning of the array each time, as I understand. It will definetely cause worst-case at least once, I believe.
r/algorithms • u/Phytor_c • 11d ago
Hi all, the guy from Anthropic claims to have a proof of GRH. Of course it's just a claim and no human has read the lean stuff etc. and it might very well be complete nonsense.
The reason why I'm posting this here is cause it's known that if GRH and VP = VNP over the complex numbers, then the Polynomial Hierarchy PH collapses and in particular P/Poly = NP/Poly. VP vs VNP is still open and we believe they're not the same.
Edit: The above was apparently true under the Quasi-RH too
The GRH also imples the Miller-Rabin primality test is determinstic (as pointed out here).
I am not sure if there are other links to complexity theory and (G)RH. Thoughts?
r/algorithms • u/smocialsmedia • 12d ago
I’ve been working on the sliding 8-puzzle. You’ve got eight tiles, one empty square, and the goal is to solve the board in as few moves as possible.
I ran incremental IDA* against compiled A* with pattern databases on 62 boards. IDA* was 7.77× faster with the tables already built and 2.34× faster when table construction was included. Both batch timings exclude startup, imports, and input loading.
I also replayed 3,906 paths from the timed trials. Every path reached the goal and matched the shortest reference distance.
The setup cost is the bit I want to dig into next. If you were running this, how would you pick the boards and batch sizes to show when building the tables pays off?
[Primitive’s public GitHub](https://github.com/Primitivelabai/primitive-open)
r/algorithms • u/ClickOk5811 • 14d ago
The naive shuffle swaps each position with a random position from the whole array:
def naive_shuffle(a):
n = len(a)
for i in range(n):
j = random.randrange(n) # j anywhere in [0, n-1]
a[i], a[j] = a[j], a[i]It looks fine, but it can’t be uniform, and you can see it by counting, no randomness needed.
The counting argument. There are n^n equally likely sequences of random choices, here 3^3 = 27. A uniform shuffle needs each of the 3! = 6 permutations to be reached the same number of times, but 27 isn’t divisible by 6. So at least some permutations must be more likely than others.
Enumerating all 27 outcomes (I did this exhaustively in a script) for the array [0, 1, 2]:
| Permutation | Count out of 27 |
|---|---|
| (0, 1, 2) | 4 |
| (0, 2, 1) | 5 |
| (1, 0, 2) | 5 |
| (1, 2, 0) | 5 |
| (2, 0, 1) | 4 |
| (2, 1, 0) | 4 |
So some orderings come up 5/27 of the time and others 4/27. For n = 4, the same enumeration gives 256 outcomes over 24 permutations (uniform would be about 10.7 each), with counts ranging from 8 to 15.
Fisher–Yates avoids this by shrinking the range:
def fisher_yates(a):
for i in range(len(a) - 1, 0, -1):
j = random.randrange(i + 1) # j in [0, i]
a[i], a[j] = a[j], a[i]Here the number of choice sequences is 3 * 2 * 1 = 6 for n = 3 (n! in general), and each permutation is produced by exactly one sequence. Enumerating them gave 1 outcome per permutation, 1/6 each. That’s the key property: the number of equally likely paths equals the number of permutations, and the mapping between them is one-to-one.
Why it matters in practice: biased shuffles can matter for things like card games, randomized tests, or sampling, although the bias for large n is small per permutation and is easy to overlook. Most standard libraries already provide a correct shuffle, so the usual advice is to use that and not hand-roll one.
Limits: this shows the naive version is non-uniform, not how large the effect is for big n, and it assumes the underlying randrange is itself uniform. I haven’t looked at the quality of any specific random number generator.
Do you have a favorite counting argument for showing an algorithm is biased or incorrect without sampling?
r/algorithms • u/No_Development865 • 15d ago
The Blind-Spot Sweep Constant (\(\Sigma _{s}\)) is a search-and-rescue and robotics constant equal to approximately 1.705035. It tells you the exact optimal spacing between parallel search lanes to cover the largest possible area in a single pass without leaving dangerous blind spots between paths.
The Real-World Problem It Solves
Imagine you are programming a search-and-rescue drone, an autonomous lawnmower, or a sonar boat to sweep a field for a missing object. Your sensor's detection probability fades smoothly with distance following a standard Gaussian falloff:
\(p(d)=e^{-(d/R)^{2}}\)
where \(d\) is the distance from your path and \(R\) is your sensor's characteristic range.
If you fly your parallel grid lines too close together, you waste battery overlapping areas you already checked. If you space them too far apart, the blindest spot—the midpoint exactly halfway between two adjacent lanes—drops to near-zero detection.
Mathematical Definition
To maximize the guaranteed effective sweep width (lane spacing multiplied by the worst-case detection probability at the midpoint), you maximize:
\(W(s)=s\left[1-\prod _{k=0}^{\infty }\left(1-e^{-\left(\frac{(2k+1)s}{2}\right)^{2}}\right)^{2}\right]\)
The unique peak of this curve occurs at \(s = \Sigma_s \approx 1.7050352709\).
r/algorithms • u/atomU235_3113 • 16d ago
Hi everyone. I would like to share Lustro, a 256-bit engine I created.
One of the main ideas behind Lustro is treating randomness as a tree, not a sequence of rigid values. I personally see it as a wave function. I'm a chemist by education. The basic problem is familiar: with a conventional sequential RNG the output you get depends on how many values have already been consumed. Adding one random operation can shift the sequence.
Lustro allows to derive streams from a seed and a path of identifiers. It can switch between single lane and batch processing.
It allows giving every object its own stream and can change how one of them is generated without affecting others. Full snapshot support is built in. The parent stream is not affected by forking and each child starts its own trajectory. Each branch has its own state and can be advanced independently.
The result is a tree-like structure of deterministic streams. Each branch can be advanced independently and you can reproduce a particular branch directly from its path.
Some specs. A unified stream engine combining hash, prng and xof. All based on one internal transformation mechanism. Scalar/AVX2. Written natively in Rust, it also comes with python and C layers.
The main repo contains all the test results. The generator is currently considered non-cryptographic.
github main repo
https://github.com/Ligatum/Lustro_API
cargo
https://crates.io/crates/lustro_api
pypi
https://pypi.org/project/lustro-api/
It's an independent project. I'd appreciate constructive feedback. I'm planning to improve on the API with time, ideas and feedback are welcome. Thanks.
r/algorithms • u/Phytor_c • 17d ago
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!