Skip to content

Instantly share code, notes, and snippets.

@cyingfan
Last active December 29, 2017 06:50
Show Gist options
  • Save cyingfan/06ad98e14596ab91ff8bde6d5f32dfe8 to your computer and use it in GitHub Desktop.
Save cyingfan/06ad98e14596ab91ff8bde6d5f32dfe8 to your computer and use it in GitHub Desktop.
Deep Thought Simulator
<?php
class DeepThoughtSimulator
{
public function getAnswerToTheUltimateQuestionOfLifeTheUniverseAndEverything()
{
sleep(7500000 * 365.24219 * 24 * 60 * 60);
return 42;
}
public function __call($name, $arguments)
{
return $this->getAnswerToTheUltimateQuestionOfLifeTheUniverseAndEverything();
}
public function __get($name)
{
return $this->getAnswerToTheUltimateQuestionOfLifeTheUniverseAndEverything();
}
public function __invoke()
{
return $this->getAnswerToTheUltimateQuestionOfLifeTheUniverseAndEverything();
}
}
import time
class DeepThoughtSimulator(object):
def getAnswerToTheUltimateQuestionOfLifeTheUniverseAndEverything(self):
try:
time.sleep(7500000 * 365.24219 * 24 * 60 * 60)
except KeyboardInterrupt:
print("Okay, it doesn't have to take so long")
return 42
def __getattr__(self, name):
return self.getAnswerToTheUltimateQuestionOfLifeTheUniverseAndEverything()
def __call__(self, *args, **kwargs):
return self.getAnswerToTheUltimateQuestionOfLifeTheUniverseAndEverything()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment