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/drafts/rosettacode/determine-if-a-string-has-all-unique-characters.wiki # 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 / drafts / rosettacode / determine-if-a-string-has-all-unique-characters.wiki` 91 lines ยท 1842 bytes Raw Blame History 1 =={{header|Omegese}}== 2 {{works with|omc|sha256 `2c824805`, aien-dev/omega-mv `e5b32567`, Linux AArch64}} 3 Omega has no imports, so the small output helpers (emit and friends) are part of the program. 4 5 om2 6 text nl "\n" 7 text lq "<<<" 8 text rq ">>>" 9 text tlen " length " 10 text tuni ": all unique\n" 11 text tdup ": duplicate '" 12 text tat "' at " 13 text tand " and " 14 text u0 "." 15 text u1 "abcABC" 16 text u2 "XYZ ZYX" 17 text u3 "1234567890ABCDEFGHIJKLMN0PQRSTUVWXYZ" 18 note emit writes every byte of a to stdout; a short write is retried, an error exits 1 19 fn emit a view uchar * to void 20 o = ulong 0 21 while lt o len a bound 4096 22 k = write 1 a o sub len a o 23 if le k 0 24 exit 1 25 end 26 o = add o ulong k 27 end 28 end 29 note emitu writes n in decimal; 20 digits hold every ulong 30 fn emitu n ulong to void 31 d = new uchar 20 0 32 i = ulong 20 33 v = n 34 while true bound 20 35 i = sub i 1 36 put d i uchar add rem v 10 48 37 v = div v 10 38 if eq v 0 39 break 40 end 41 end 42 emit part d i sub 20 i 43 end 44 note emitc writes one byte 45 fn emitc c uchar to void 46 b = new uchar 1 0 47 put b 0 c 48 emit b 49 end 50 note the first byte (smallest i) that occurs again later, with the place j of its next occurrence 51 fn show a view uchar * to void 52 emit lq 53 emit a 54 emit rq 55 emit tlen 56 emitu len a 57 for i ulong len a 58 for j ulong sub sub len a i 1 59 k = add add i j 1 60 if eq get a i get a k 61 emit tdup 62 emitc get a i 63 emit tat 64 emitu i 65 emit tand 66 emitu k 67 emit nl 68 ret 69 end 70 end 71 end 72 emit tuni 73 end 74 fn main to int 75 note the empty string, as a slice of length 0 76 show part u0 0 0 77 show u0 78 show u1 79 show u2 80 show u3 81 ret 0 82 end 83 84 {{out}} 85

86 <<<>>> length 0: all unique

87 <<<.>>> length 1: all unique

88 <<<abcABC>>> length 6: all unique

89 <<<XYZ ZYX>>> length 7: duplicate 'X' at 0 and 6

90 <<<1234567890ABCDEFGHIJKLMN0PQRSTUVWXYZ>>> length 36: duplicate '0' at 9 and 24

91