Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-rosetta/blob/main/tasks/recamans-sequence/oracle.py # omega-rosetta aien-dev/omega-rosetta Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-rosetta / tasks / recamans-sequence / oracle.py` 17 lines ยท 610 bytes Raw Blame History 1 # Independent reference for "Recaman's sequence" (Python 3, standard library only). 2 # expected.txt is this program's stdout; omc never produced it. 3 a, seen, terms, dup = [0], {0}, [0], None 4 need = set(range(1, 1001)) 5 n = 0 6 while need: 7 n += 1 8 b = a[-1] - n 9 v = b if b > 0 and b not in seen else a[-1] + n 10 if v in seen and dup is None: 11 dup = (n, v) 12 seen.add(v) 13 need.discard(v) 14 a.append(v) 15 print("first 15 terms: " + " ".join(map(str, a[:15]))) 16 print(f"first term already seen: a({dup[0]}) = {dup[1]}") 17 print(f"terms a(0)..a(n) first contain every integer 0..1000 at n = {n}")