Project Michael Dings Impressum Login

Bausparen-with-Friends

I am a Graph-of-a-Function, that shows the Concept of a Bausparvertrag, where the avarage Wait-Time can be reduced, when Friends pool their Money.

Bauspar-Vertrag-with-Friends

Observations

The corresponding Background-Story is explained in the Blog-Entry Bauuuspaaarvertrag of the Project-Blog.

Program

The following Python-Program has been used to generate the Function-Graph:

import matplotlib.pyplot as Plt

# Define Constants
COSTS_PER_HOUSE      = 100000 # We can buy a House for 100.000 Coins
MONEY_PER_YEAR       = 10000  # Every Friend can save 10.000 Coins each Year
MAXIMUM_YEAR_COUNT   = 10     # In 10 Years all Houses are built
MAXIMUM_FRIEND_COUNT = 50     # Maximum Number of Friends that pool the Money

# Calculate the Sum of Years to buy all Houses
def Calculate_Wait_Time_Sum(Friends_Count):
        Wait_Time_Sum = 0
        Saved_Money = 0
        Houses = 0
        # Let's see, what we can build in 10 Years
        for Year in range(1, MAXIMUM_YEAR_COUNT + 1):
                # Calculate the saved Money per Year
                Saved_Money += Friends_Count * MONEY_PER_YEAR
                # Buy Houses with the saved Money
                while Saved_Money >= COSTS_PER_HOUSE:
                        Houses += 1
                        Saved_Money -= COSTS_PER_HOUSE
                        Wait_Time_Sum += Year
                        print(f" House %2d bought after %2d Years" % (Houses, Year))
        return Wait_Time_Sum

def Print_Results_Graph():
        # Lists for Data
        Friends_Count_List = []      # X-Axis
        Average_Wait_Years_List = [] # Y-Axis
        # Generate Data
        for Friends_Count in range(1, MAXIMUM_FRIEND_COUNT + 1):
                Friends_Count_List.append(Friends_Count)
                Average_Wait_Years = Calculate_Wait_Time_Sum(Friends_Count) / Friends_Count
                Average_Wait_Years_List.append(Average_Wait_Years)
        # Plot Data
        Plt.plot(Friends_Count_List, Average_Wait_Years_List)
        Plt.xlabel('Number of Friends')
        Plt.ylabel('Average Years to wait')
        Plt.title('Bausparen with Friends')
        Plt.savefig("Bausparen-With-Friends.png", format="png", dpi=300)
        Plt.show()

Print_Results_Graph()