# 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([12, 30, 25, 30, 8]))