Skip to content

sbeginCoveo/MagicTimeAnalysisTool

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

1 Commit
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Magic Time Analysis

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.

What are Magic Times? ๐Ÿ”ฎ

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

Features โœจ

  • 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

Installation

  1. Clone or download the project
  2. Install dependencies:
npm install

Usage

Basic Analysis

Run the complete analysis with default settings:

npm start

Custom Simulation Size

Specify the number of random samples for probability simulation:

npm start -- --samples 50000

Verbose Output

Show detailed listings of all magic times:

npm start -- --verbose

Multiple Simulation Rounds

Run consistency analysis with multiple simulation rounds:

npm start -- --rounds 10 --samples 10000

Skip Simulation

Run only theoretical analysis without simulation:

npm start -- --no-simulation

Custom Confidence Level

Set confidence level for interval estimation:

npm start -- --confidence 0.99

Daily Probability Analysis

Analyze probability of encountering magic times with custom daily check frequency:

npm start -- --daily-checks 20

Sleep Schedule Analysis

Account for your sleep schedule (default: wake at 7:00, sleep at 23:00):

npm start -- --wake-hour 6 --sleep-hour 22

Night Owl Schedule

For people who wake up late and sleep late:

npm start -- --wake-hour 10 --sleep-hour 2

Skip Sleep Schedule

Use full 24-hour analysis ignoring sleep:

npm start -- --no-sleep

Skip Daily Analysis

Run analysis without daily encounter probability:

npm start -- --no-daily

Export to PDF

Export your magic time report to a professional PDF document:

npm run export-pdf

Generate Fresh Report and Export

Create a new analysis and export to PDF in one command:

npm run generate-report

Command Line Options

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

PDF Export

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

Example Output

๐Ÿ”ฎ 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%          โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Project Structure

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

How It Works

1. Time Generation

The application generates all 1,440 possible times in a 24-hour day (00:00 to 23:59).

2. Pattern Detection

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

3. Statistical Analysis

  • 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

4. Advanced Features

  • 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)

Mathematical Background

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)

Requirements

  • Node.js 16.0.0 or higher
  • npm (comes with Node.js)

Dependencies

  • cli-table3: For beautiful CLI table output
  • commander: For command-line interface and option parsing

Development

To modify or extend the application:

  1. Magic Time Patterns: Add new pattern detection functions in src/magicTimes.js
  2. Analysis Logic: Extend the analysis engine in src/timeAnalyzer.js
  3. Statistical Methods: Add new probability calculations in src/probabilityCalculator.js
  4. CLI Interface: Modify the interface and output formatting in src/index.js

License

MIT License - feel free to use and modify for your own projects!

Contributing

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

About

yes

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors