Baseline: tree as shared

This commit is contained in:
alexm committed 2026-10-05 03:03:38 +00:00
commit 31f2fb8a5a
1679 files changed
+1024562

No files matched your search

@@ -0,0 +1,19 @@
# Generated by Programming+ from pseudo. Not reviewed for Mojo best practices.
# The position of the highest quality score; the first one, if several tie.
def best_position(q: List[Int]) -> Int:
# REQUIRE LENGTH(Q) >= 1
# ENSURE 0 <= RESULT AND RESULT < LENGTH(Q)
# ENSURE FORALL K IN [0, LENGTH(Q)) : Q[K] <= Q[RESULT]
var best: Int
best = 0
# INVARIANT 0 <= Best AND Best < I
# INVARIANT FORALL K IN [0, I) : Q[K] <= Q[Best]
for i in range(1, len(q)):
if q[i] > q[best]:
best = i
return best
def main():
print(best_position(List[Int](12, 30, 25, 30, 8)))