Skip to main content

The Billion Pi Challenge

探讨如何在π的十亿位小数中高效查找特定数字序列的方法,采用空间换时间的策略建立滑动窗口索引来优化搜索速度。

Utilities & Web Tools#search-algorithm#data-processing#pi-digits

https://nullprogram.com/blog/2014/09/18/The Billion Pi Challenge:如何高效的在 pi 的十亿位小数中查找特定的数字序列?文中的假设:不要求完全精确(例如某个序列出现了一万次,可以只返回其中的一千次)文中的解法:- 空间换时间,用固定长度的滑动窗口建立索引(长度为n的序列 -> 出现位置的列表)- 为了优化速度,整个索引存储在内存中,且可以用不同的滑窗长度多次建立索引(3,6,8...);- 如果用户输入的序列长度和已有的索引长度不匹配,过短的填充(12345 -> 123450~123459),过长的先截取符合最长滑窗长度的前n位,缩小可能出现的位置数量,再回到原始的小数文件中逐个确认

More in Utilities & Web Tools

China Parcels

Track and manage all your online orders from China and worldwide

Utilities ·

OpenDocScan

Scan documents to searchable PDF in your browser without uploading

Utilities ·

LensUp Scanner

Browser-based document scanner that turns phone photos into printable PDFs

Utilities ·

Intertakt

An interval timer that runs with the screen off, with voice cues and beeps over

Utilities ·

Intertakt

Interval timer with voice cues and beeps that runs with the screen off

Utilities ·