Transaction isolation conflicts

Write codeEasy18 minOracle and Databricks style

Your task

A database scheduler checks a batch of transactions for conflicts before letting them run together. Each entry of ops is one operation written as "billing|read|cart:12": the transaction name, a pipe, then read or write, then the key it touched. Names and keys hold no pipes, and an operation may repeat. Under read_committed two transactions conflict only when both wrote the same key. Under repeatable_read they also conflict when one wrote a key the other read. Under serializable they also conflict when they read at least one key in common and each wrote at least one key, which is the write skew case. A transaction never conflicts with itself, and isolation is always one of those three names. Return one entry per conflicting pair, each written as the two names joined by a comma with the smaller name first, sorted ascending as text.

Examples

conflicting_txn_pairs(ops: list[str], isolation: str) -> list[str]
Example 1
Inputconflicting_txn_pairs(["billing|read|cart:12", "billing|write|cart:12", "audit|read|cart:12", "sync|write|cart:12"], "read_committed")
Output["billing,sync"]
Example 2
Inputconflicting_txn_pairs(["billing|read|cart:12", "billing|write|cart:12", "audit|read|cart:12", "sync|write|cart:12"], "repeatable_read")
Output["audit,billing", "audit,sync", "billing,sync"]
Example 3
Inputconflicting_txn_pairs(["a|read|k1", "a|write|k9", "b|read|k1", "b|write|k8"], "serializable")
Output["a,b"]