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-mv/blob/main/si/rosetta/exercises/largest-series-product/.meta/example.om # omega-mv Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance. Brought by drakestapleton Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / si / rosetta / exercises / largest-series-product / .meta / example.om` 43 lines ยท 940 bytes Raw Blame History 1 note Exercism-style exercise "largest-series-product": https://exercism.org/tracks/python/exercises/largest-series-product 2 note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 3 note largestproduct is the largest product of span adjacent decimal digits of s (1 for span 0); or 4 note -1 when span is negative, -2 when span is longer than s, -3 when s holds a non-digit. 5 note Check it with: sh exercise.sh exercises/largest-series-product 6 om2 7 fn alldigits s view uchar * to bool 8 for i ulong len s 9 c = get s i 10 if or lt c 48 gt c 57 11 ret false 12 end 13 end 14 ret true 15 end 16 fn window s view uchar * k ulong w ulong to long 17 p = long 1 18 for j ulong w 19 p = mul p long sub get s add k j 48 20 end 21 ret p 22 end 23 fn largestproduct s view uchar * span long to long 24 if lt span 0 25 ret -1 26 end 27 w = ulong span 28 n = len s 29 if gt w n 30 ret -2 31 end 32 if not alldigits s 33 ret -3 34 end 35 best = long 0 36 for k ulong add sub n w 1 37 p = window s k w 38 if gt p best 39 best = p 40 end 41 end 42 ret best 43 end