Skip to content

Instantly share code, notes, and snippets.

View zaxboy24's full-sized avatar
🎯
Focusing

Shao D Vorgz zaxboy24

🎯
Focusing
  • Gefura Inc.
View GitHub Profile
@zaxboy24
zaxboy24 / bankers_algorithm.py
Created December 4, 2019 10:34 — forked from aasmpro/bankers_algorithm.py
Python implementation of Banker's algorithm, written in Python 3
def main():
processes = int(input("number of processes : "))
resources = int(input("number of resources : "))
max_resources = [int(i) for i in input("maximum resources : ").split()]
print("\n-- allocated resources for each process --")
currently_allocated = [[int(i) for i in input(f"process {j + 1} : ").split()] for j in range(processes)]
print("\n-- maximum resources for each process --")
max_need = [[int(i) for i in input(f"process {j + 1} : ").split()] for j in range(processes)]
@zaxboy24
zaxboy24 / bankers_algorithm.py
Created December 4, 2019 10:34 — forked from aasmpro/bankers_algorithm.py
Python implementation of Banker's algorithm, written in Python 3
def main():
processes = int(input("number of processes : "))
resources = int(input("number of resources : "))
max_resources = [int(i) for i in input("maximum resources : ").split()]
print("\n-- allocated resources for each process --")
currently_allocated = [[int(i) for i in input(f"process {j + 1} : ").split()] for j in range(processes)]
print("\n-- maximum resources for each process --")
max_need = [[int(i) for i in input(f"process {j + 1} : ").split()] for j in range(processes)]