A Node.js application that analyzes "magic times" in a 24-hour day and calculates the probability of encountering them when looking at the time randomly.
Magic times are times that display interesting patterns in their digits when shown in HH:MM format:
- Palindromic Times: Read the same forwards and backwards (e.g.,
12:21,10:01,23:32) - Repeated Digits: Contains repeated digit patterns (e.g.,
11:11,12:12,22:22) - Sequential Times: Digits follow consecutive sequences
- Ascending:
12:34,01:23 - Descending:
43:21,32:10
- Ascending:
- Complete Analysis: Analyzes all 1,440 possible times in a 24-hour period
- Pattern Detection: Identifies palindromic, repeated digit, and sequential patterns
- Probability Simulation: Monte Carlo simulation to empirically estimate encounter rates
- Statistical Analysis: Compares theoretical vs empirical probabilities with confidence intervals
- Overlap Detection: Finds times that belong to multiple magic categories
- Beautiful CLI Output: Clean, tabular presentation of results
- Configurable Options: Customize simulation parameters and output verbosity
- Clone or download the project
- Install dependencies:
npm installRun the complete analysis with default settings:
npm startSpecify the number of random samples for probability simulation:
npm start -- --samples 50000Show detailed listings of all magic times:
npm start -- --verboseRun consistency analysis with multiple simulation rounds:
npm start -- --rounds 10 --samples 10000Run only theoretical analysis without simulation:
npm start -- --no-simulationSet confidence level for interval estimation:
npm start -- --confidence 0.99Analyze probability of encountering magic times with custom daily check frequency:
npm start -- --daily-checks 20Account for your sleep schedule (default: wake at 7:00, sleep at 23:00):
npm start -- --wake-hour 6 --sleep-hour 22For people who wake up late and sleep late:
npm start -- --wake-hour 10 --sleep-hour 2Use full 24-hour analysis ignoring sleep:
npm start -- --no-sleepRun analysis without daily encounter probability:
npm start -- --no-dailyExport your magic time report to a professional PDF document:
npm run export-pdfCreate a new analysis and export to PDF in one command:
npm run generate-report| Option | Description | Default |
|---|---|---|
-s, --samples <number> |
Number of random samples for simulation | 10000 |
-v, --verbose |
Show detailed output including all magic times | false |
-r, --rounds <number> |
Number of simulation rounds for consistency analysis | 1 |
-c, --confidence <number> |
Confidence level (0.90, 0.95, 0.99) | 0.95 |
-d, --daily-checks <number> |
Times checking clock per day for daily probability | 15 |
-w, --wake-hour <number> |
Hour when you wake up (0-23) | 7 |
-z, --sleep-hour <number> |
Hour when you go to sleep (0-23) | 23 |
--no-simulation |
Skip probability simulation | false |
--no-daily |
Skip daily encounter probability analysis | false |
--no-sleep |
Ignore sleep schedule (use full 24-hour analysis) | false |
The application includes professional PDF export functionality:
| Command | Description |
|---|---|
npm run export-pdf |
Export existing report.md to PDF |
npm run generate-report |
Generate fresh analysis and export to PDF |
--help |
Show help information |
--version |
Show version number |
๐ฎ Magic Time Analysis
Analyzing all possible times in 24-hour format...
โโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโฌโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Magic Time Type โ Count โ Percentage โ Example Times โ
โโโโโโโโโโโโโโโโโโโโผโโโโโโโโโผโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Palindromic โ 64 โ 4.44% โ 00:00, 01:10, 02:20 โ
โ Repeated Digits โ 156 โ 10.83% โ 00:00, 01:01, 01:10 โ
โ Sequential (โ) โ 48 โ 3.33% โ 01:23, 12:34 โ
โ Sequential (โ) โ 48 โ 3.33% โ 43:21, 32:10 โ
โโโโโโโโโโโโโโโโโโโโผโโโโโโโโโผโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Total Unique โ 225 โ 15.63% โ 1440 total times โ
โโโโโโโโโโโโโโโโโโโโดโโโโโโโโโดโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ Probability Simulation
โโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโ
โ Metric โ Value โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโค
โ Samples Generated โ 10,000 โ
โ Magic Times Found โ 1,547 โ
โ Theoretical Probability โ 15.63% โ
โ Empirical Probability โ 15.47% โ
โ Absolute Difference โ -0.16% โ
โ Relative Error โ 1.02% โ
โ Convergence Quality โ Good โ
โ โ โ
โ 95% Confidence Interval โ 14.76% - 16.18% โ
โ Margin of Error โ ยฑ0.71% โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโ
magic-time/
โโโ PLAN.md # Original project planning document
โโโ README.md # This file
โโโ package.json # Node.js project configuration
โโโ src/
โโโ index.js # Main CLI entry point
โโโ magicTimes.js # Magic time pattern detection
โโโ timeAnalyzer.js # Time generation and analysis
โโโ probabilityCalculator.js # Simulation and statistics
The application generates all 1,440 possible times in a 24-hour day (00:00 to 23:59).
Each time is analyzed for magic patterns:
- Palindromic: Time digits read the same forwards and backwards
- Repeated Digits: Various repetition patterns in the digits
- Sequential: Consecutive ascending or descending digit sequences
- Calculates exact theoretical probabilities from complete enumeration
- Runs Monte Carlo simulation with configurable sample sizes
- Compares theoretical vs empirical results
- Provides confidence intervals and convergence analysis
- Overlap Detection: Identifies times belonging to multiple categories
- Consistency Analysis: Multiple simulation rounds to assess stability
- Detailed Listings: Complete lists of times in each category (with --verbose)
The theoretical probability is calculated as:
P(Magic Time) = Number of Unique Magic Times / Total Possible Times
P(Magic Time) = Unique Magic Times / 1,440
The empirical probability is estimated through Monte Carlo simulation:
Pฬ(Magic Time) = Magic Time Hits / Total Samples
Confidence intervals use the normal approximation to the binomial distribution:
CI = pฬ ยฑ z_(ฮฑ/2) ร โ(pฬ(1-pฬ)/n)
- Node.js 16.0.0 or higher
- npm (comes with Node.js)
cli-table3: For beautiful CLI table outputcommander: For command-line interface and option parsing
To modify or extend the application:
- Magic Time Patterns: Add new pattern detection functions in
src/magicTimes.js - Analysis Logic: Extend the analysis engine in
src/timeAnalyzer.js - Statistical Methods: Add new probability calculations in
src/probabilityCalculator.js - CLI Interface: Modify the interface and output formatting in
src/index.js
MIT License - feel free to use and modify for your own projects!
Contributions are welcome! Some ideas for enhancements:
- Support for 12-hour format analysis
- Include seconds in the time analysis
- Additional magic time pattern types
- Export results to JSON/CSV formats
- Web interface for visualization
- Historical time pattern analysis