calculations for life | This does not include vacation days since I was 14 and moved away from Ohio. Maybe 1 week every 3 years average | Cell 2 | Search

This JavaScript script calculates and logs various statistics related to life, including the percentage of life spent sleeping and masturbating, based on assumptions of 7 hours of sleep per night and 1 hour of masturbation per day. The output includes the percentage of life spent sleeping, the percentage of the year spent masturbating, and the percentage of life spent masturbating.

Cell 1

// calculate exact age based on current date
var _daysUntilBirthday = (_currentDate.getMonth() + 1) / 11 * 365.25 + (_currentDate.getDate() - 12);
var _daysLifeOfBrian = (_currentDate.getFullYear() - 1986) * 365.25 - _daysUntilBirthday;
var _32exactYearsLifeOfBrian = _daysLifeOfBrian / 365.25;

var _7hoursPerNight = 7;
var _1hourPerDay = 1;

// percent of life spent sleeping (verification of methodology)
var _daysPerYearSleeping = _7hoursPerNight / 24 * 365.25;
var _percentOfYearSleeping = _daysPerYearSleeping / 365.25;
var _percentOfYearSleepingFormatted = Math.round(_percentOfYearSleeping * 10000) / 100 + '%';

console.log('Percent of life spent sleeping (1/3 of life): ' + _percentOfYearSleepingFormatted)

// percent of life spent masturbating
var _daysPerYearJerking = _1hourPerDay / 24 * 365.25;
var _percentOfYearJerking = _daysPerYearJerking / 365.25;
var _percentOfYearJerkingFormatted = Math.round(_percentOfYearJerking * 10000) / 100 + '%';
var _percentOfLifeJerking = _percentOfYearJerking * (_32exactYearsLifeOfBrian - 12) / _32exactYearsLifeOfBrian; // Since age 12
var _percentOfLifeJerkingFormatted = Math.round(_percentOfLifeJerking * 10000) / 100 + '%';

console.log('Percent of year spent masturbating: ' + _percentOfYearJerkingFormatted);
console.log('Percent of life spent masturbating: ' + _percentOfLifeJerkingFormatted);

// percent of life spent not working


// percent of life spent watching movies


What the code could have been:

// Date constants
const BIRTH_YEAR = 1986;
const CURRENT_DATE = new Date();

// Calculate exact age
function calculateDaysUntilBirthday(currentDate) {
  return currentDate.getDate() - 12;
}

function calculateDaysLifeOfBrian(currentYear) {
  const daysUntilBirthday = calculateDaysUntilBirthday(CURRENT_DATE);
  return (currentYear - BIRTH_YEAR) * 365.25 - daysUntilBirthday;
}

function calculateExactYearsLifeOfBrian(daysLifeOfBrian) {
  return daysLifeOfBrian / 365.25;
}

// Calculate sleep data
function calculateDaysPerYearSleeping(hoursPerNight) {
  return (hoursPerNight / 24) * 365.25;
}

function calculatePercentOfYearSleeping(daysPerYearSleeping) {
  return daysPerYearSleeping / 365.25;
}

function calculatePercentOfYearSleepingFormatted(percentOfYearSleeping) {
  return Math.round(percentOfYearSleeping * 10000) / 100 + '%';
}

const SLEEP_HOURS_PER_NIGHT = 7;
const SLEEP_PERCENTAGE = calculatePercentOfYearSleeping(calculateDaysPerYearSleeping(SLEEP_HOURS_PER_NIGHT));

// Calculate masturbation data
function calculateDaysPerYearJerking(hoursPerDay) {
  return (hoursPerDay / 24) * 365.25;
}

function calculatePercentOfYearJerking(daysPerYearJerking) {
  return daysPerYearJerking / 365.25;
}

function calculatePercentOfYearJerkingFormatted(percentOfYearJerking) {
  return Math.round(percentOfYearJerking * 10000) / 100 + '%';
}

function calculatePercentOfLifeJerking(percentOfYearJerking, exactYearsLifeOfBrian) {
  const age = 12; // Since age 12
  return percentOfYearJerking * (exactYearsLifeOfBrian - age) / exactYearsLifeOfBrian;
}

function calculatePercentOfLifeJerkingFormatted(percentOfLifeJerking) {
  return Math.round(percentOfLifeJerking * 10000) / 100 + '%';
}

const JERKING_HOURS_PER_DAY = 1;
const JERKING_PERCENTAGE = calculatePercentOfYearJerking(calculateDaysPerYearJerking(JERKING_HOURS_PER_DAY));
const JERKING_PERCENTAGE_OF_LIFE = calculatePercentOfLifeJerking(JERKING_PERCENTAGE, calculateExactYearsLifeOfBrian(calculateDaysLifeOfBrian(CURRENT_DATE.getFullYear())));

// Log results
console.log('Percent of life spent sleeping:'+ calculatePercentOfYearSleepingFormatted(SLEEP_PERCENTAGE));
console.log('Percent of year spent masturbating:'+ calculatePercentOfYearJerkingFormatted(JERKING_PERCENTAGE));
console.log('Percent of life spent masturbating:'+ calculatePercentOfLifeJerkingFormatted(JERKING_PERCENTAGE_OF_LIFE));

Overview

The provided code is a JavaScript script that calculates various statistics related to life, including the percentage of life spent sleeping and masturbating.

Variables

The code defines the following variables:

Calculations

The code performs the following calculations:

  1. Calculates the number of days until the current day's birthday
  2. Calculates the number of days since 1986
  3. Calculates the exact age of "Life of Brian" (based on 1986 birth year)
  4. Calculates the number of days per year spent sleeping and masturbating
  5. Calculates the percentage of the year and life spent sleeping and masturbating
  6. Formats the percentages as strings with two decimal places

Output

The code logs the following output to the console:

  1. Percent of life spent sleeping (1/3 of life)
  2. Percent of year spent masturbating
  3. Percent of life spent masturbating