RosettaCodeData/Task/Abbreviations-automatic/Yabasic/abbreviations-automatic.basic
2023-07-01 13:44:08 -04:00

28 lines
547 B
Text

a = open("days_of_week.txt", "r")
while(not eof(#a))
line input #a s$
print buscar(s$), " ", s$
wend
close #a
sub buscar(s$)
local n, d, i, j, s, a$, b$, r$(1)
n = token(s$, r$())
d = 1
repeat
s = true
for i = 1 to n
for j = i + 1 to n
a$ = left$(r$(i), d)
b$ = left$(r$(j), d)
if a$ = "" or b$ = "" s = true : break 2
if a$ = b$ s = false : d = d + 1 : break 2
next
next
until(s)
return d
end sub