MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / __pretty_data

Method __pretty_data

other/bankers_algorithm.py:197–222  ·  view source on GitHub ↗

Properly align display of the algorithm's solution

(self)

Source from the content-addressed store, hash-verified

195 break
196
197 def __pretty_data(self):
198 """
199 Properly align display of the algorithm's solution
200 """
201 print(" " * 9 + "Allocated Resource Table")
202 for item in self.__allocated_resources_table:
203 print(
204 f"P{self.__allocated_resources_table.index(item) + 1}"
205 + " ".join(f"{it:>8}" for it in item)
206 + "\n"
207 )
208 print(" " * 9 + "System Resource Table")
209 for item in self.__maximum_claim_table:
210 print(
211 f"P{self.__maximum_claim_table.index(item) + 1}"
212 + " ".join(f"{it:>8}" for it in item)
213 + "\n"
214 )
215 print(
216 "Current Usage by Active Processes: "
217 + " ".join(str(x) for x in self.__claim_vector)
218 )
219 print(
220 "Initial Available Resources: "
221 + " ".join(str(x) for x in self.__available_resources())
222 )
223
224
225if __name__ == "__main__":

Callers 1

mainMethod · 0.95

Calls 1

__available_resourcesMethod · 0.95

Tested by

no test coverage detected