Saturday, December 24, 2016

Day 24, Java Holiday Calendar 2016, How many Santas are there - Really?

Day 24, Java Holiday Calendar 2016, How many Santas are there - Really?

Today we are going to do some nonsense calculations. Is there a Santa and if yes, how many Stantas can we expect to find in the world?

The Assumptions

Let us start with some assumptions. When this article was written there was an estimate of 7,472,085,518 humans on Earth. Let us disregard the guys that lives on the International Space Station, because presumably, Santa's reindeers cannot operate in near-earth-orbit. Luckily for those guys, Elon Musk can deliver their presents via Space X's delivery rocket instead.

A large number of the remaining people are not visited by Santa at all including people of various religious affiliations or beliefs and people that are very poor. We assume that only one third of the remaining persons are visited. We further assume that in average, there are three persons per household (this is not unreasonable taking the vast number of single-person-households into account). Furthermore, we assume that each person gets four presents in average (some rich ones get much more, some poor just get one if they are lucky).

Additionally we estimate that there is an average distance of 500 m (i.e. 0.5 km or 0.3 miles) between each household and that Santa's average sleigh speed is 4 m/s (i.e. 14 km/h or 9 mph) and that it takes Santa 1 second to drop of each present. It should be noted that the actual procedure of handing over presents differs from country to country. In the US, Santa is more likely to drop the packages down the chimney and curve the packages so that they always backspin and land in socks that are hanged near the beginning of the chimney whereas in some European countries, he is more likely to deliver the packages in person. This is note covered in the model though.

Because the speed of the sleigh is not so high, Santa cannot take advantage of the fact that the Earth is rotating and the different time zones. So, Santa can only work 24 hours.

The Java Code 

In Java we can model the problem like this:

public class NumberOfSantas {

    private static final long NUMBER_OF_PERSONS = 7_472_085_518L / 3;
    private static final int PERSONS_PER_HOUSHOLD = 3;
    private static final int PRESENTS_PER_PERSON = 4;

    private static final int AVERAGE_DISTANCE_BETWEEN_HOUSHOLDS = 500; // m (i.e. 0.5 km or 0.3 miles)
    private static final int AVERAGE_SLEIGH_SPEED = 4; // 4 m/s (i.e. 14 km/h or 9 mph)
    private static final int TIME_TO_DELIVER_PRESENTS = 1; // 1 s 

    private static final int WORKING_HOURS = 24;

    public static void main(String[] args) {

        long totalTimeS = NUMBER_OF_HOUSHOLDS

        long noSantas = totalTimeS / (WORKING_HOURS * 3600);

        System.out.format("There are %,d Santas in the world", noSantas);



Evidently, there is a large number of Santas out there because the program above outputs the following:

There are 1,316,455 Santas in the world

(Ho, ho)^1.3 M...

Follow the Java Holiday Calendar 2016 with small tips and tricks all the way through the winter holiday season. I am contributing to open-source Speedment, a stream based ORM tool and runtime. Please check it out on GitHub.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.