TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

SEPA: A Simple, Efficient Permutation Algorithm

55 点作者 navigaid超过 6 年前

4 条评论

mauricioc超过 6 年前
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 未加载
mattnewport超过 6 年前
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-747超过 6 年前
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-whale超过 6 年前
While this is very cool, I&#x27;m having a hard time believing it is a new development.
评论 #18053653 未加载