TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

SEPA: A Simple, Efficient Permutation Algorithm

55 pointsby navigaidover 6 years ago

4 comments

mauriciocover 6 years ago
According to Donald Knuth, "This algorithm goes back to Nārāyaṇa Paṇḍita in 14th-century India; it also appeared in C. F. Hindenburg's preface to _Specimen Analyticum de Lineis Curvis Secundi Ordinis_ by C. F. Rudiger (Leipzig: 1784), xlvi--xlvii, and it has been frequently rediscovered ever since". (Volume 4A, Section 7.2.1.2, Algorithm L)
评论 #18053694 未加载
mattnewportover 6 years ago
This sounds like what next_permutation does in the C++ STL. <a href="https:&#x2F;&#x2F;en.cppreference.com&#x2F;w&#x2F;cpp&#x2F;algorithm&#x2F;next_permutation" rel="nofollow">https:&#x2F;&#x2F;en.cppreference.com&#x2F;w&#x2F;cpp&#x2F;algorithm&#x2F;next_permutation</a>
swingline-747over 6 years ago
Btw, XOR swap... probably slower than register-aliased swap, but it swaps two registers without using a third:<p><pre><code> void swap(char *s, int a, int b) { s[b] ^= s[a]; s[a] ^= s[b]; s[b] ^= s[a]; }</code></pre>
评论 #18054229 未加载
评论 #18053565 未加载
ur-whaleover 6 years ago
While this is very cool, I&#x27;m having a hard time believing it is a new development.
评论 #18053653 未加载