Over a million developers have joined DZone.

Java Holiday Calendar 2016 (Day 24): How Many Santas Are There, Really?

DZone's Guide to

Java Holiday Calendar 2016 (Day 24): How Many Santas Are There, Really?

Yes, Virginia, there really is a Santa Claus. In fact, there might be a lot of them. Let's do some Java math to see how many Santas it takes to deliver presents around the world.

· Java Zone ·
Free Resource

Delivering modern software? Atomist automates your software delivery experience.

Image title

Today, we are going to do some nonsense calculations. Is there a Santa, and if yes, how many Santas 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 who live on the International Space Station, because presumably, Santa's reindeer 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 who are very poor. We assume that only one-third of the remaining persons are visited. We further assume that, on 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 on 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 hung up near the fireplace, whereas in some European countries, he is more likely to deliver the packages in person. This is not covered in the model, though.

Because the speed of the sleigh is not extreme, Santa cannot take advantage of the fact that the Earth is rotating and that there 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.

Start automating your delivery right there on your own laptop, today! Get the open source Atomist Software Delivery Machine.

java ,java math ,tutorial ,data model

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}