Update main.py

This commit is contained in:
Leon² 2023-09-06 14:33:36 +02:00 committed by GitHub
parent 027427ae9e
commit ae2d040c96
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -32,7 +32,7 @@ def generateNetwork():
# to avoid getting too large and too small networks # to avoid getting too large and too small networks
# returns dict: {ip:int, prefix:int} # returns dict: {ip:int, prefix:int}
ip = random.randint(0, 2**32-1) ip = random.randint(0, 2**32-1)
prefix = random.randint(8, 30) prefix = random.randint(8, 31)
ipandprefix = {"ip":ip, "prefix":prefix} ipandprefix = {"ip":ip, "prefix":prefix}
return ipandprefix return ipandprefix
@ -84,16 +84,16 @@ def newSubnetExercises(ip, prefix):
print("Generating new Subnet exercise...") print("Generating new Subnet exercise...")
aufgabentyp = random.randint(0,1) aufgabentyp = random.randint(0,1)
bonusaufgabe = random.randint(0,10) bonusaufgabe = random.randint(0,10)
newprefix = random.randint(prefix, 31) newprefix = random.randint(prefix, 32)
print(printDotted(intToDotted(ip))) print(printDotted(intToDotted(ip)))
print("Prefix: ", prefix) print("Prefix: ", prefix)
if aufgabentyp == 0: if aufgabentyp == 0:
print("You will have to split the subnet into {} subnets".format(random.randint(2,10))) print("You will have to split the subnet into {} subnets".format(random.randint(2,32-prefix-2)))
else: else:
print("Split subnet into subnet with {} Hosts".format(random.randint(8,254))) print("Split subnet into subnet with {} Hosts".format(random.randint(8,2**(32-prefix)/2)))
if bonusaufgabe > 5: if bonusaufgabe > 5:
print("What is the Net ID of the given subnet?") print("What is the Net ID of the given subnet?")