Skip to content

Instantly share code, notes, and snippets.

View satingaux's full-sized avatar
:octocat:
git pull

Sachin Sharma satingaux

:octocat:
git pull
View GitHub Profile
@aasmpro
aasmpro / bankers_algorithm.py
Last active April 10, 2023 03:58
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)]