June 2018 Update
This commit is contained in:
parent
ba8067c3b7
commit
22f33d4004
5278 changed files with 84726 additions and 14379 deletions
|
|
@ -1,57 +1,39 @@
|
|||
integer
|
||||
ordered(text s)
|
||||
ordered(data s)
|
||||
{
|
||||
integer a, i, l;
|
||||
integer a, c, p;
|
||||
|
||||
a = 1;
|
||||
|
||||
l = length(s);
|
||||
if (l) {
|
||||
l -= 1;
|
||||
i = 0;
|
||||
while (i < l) {
|
||||
if (character(s, i + 1) < character(s, i)) {
|
||||
a = 0;
|
||||
break;
|
||||
}
|
||||
i += 1;
|
||||
p = -1;
|
||||
for (, c in s) {
|
||||
if (c < p) {
|
||||
a = 0;
|
||||
break;
|
||||
} else {
|
||||
p = c;
|
||||
}
|
||||
}
|
||||
|
||||
return a;
|
||||
a;
|
||||
}
|
||||
|
||||
integer
|
||||
main(void)
|
||||
{
|
||||
integer l, m;
|
||||
file f;
|
||||
list w;
|
||||
text s;
|
||||
index x;
|
||||
|
||||
f_affix(f, "unixdict.txt");
|
||||
f.affix("unixdict.txt");
|
||||
|
||||
m = 0;
|
||||
|
||||
while ((l = f_line(f, s)) != -1) {
|
||||
if (m <= l) {
|
||||
if (ordered(s)) {
|
||||
if (m < l) {
|
||||
m = l;
|
||||
l_clear(w);
|
||||
}
|
||||
l_append(w, s);
|
||||
}
|
||||
while (f.line(s) != -1) {
|
||||
if (ordered(s)) {
|
||||
x.v_list(~s).append(s);
|
||||
}
|
||||
}
|
||||
|
||||
l = l_length(w);
|
||||
m = 0;
|
||||
while (m < l) {
|
||||
o_text(l_q_text(w, m));
|
||||
o_byte('\n');
|
||||
m += 1;
|
||||
}
|
||||
l_ucall(x.back, o_, 0, "\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1 @@
|
|||
function isordered{T<:String}(w::T)
|
||||
p = '\0'
|
||||
for c in w
|
||||
p <= c || return false
|
||||
p = c
|
||||
end
|
||||
return true
|
||||
end
|
||||
issorted("abc") # true
|
||||
|
|
|
|||
|
|
@ -1,20 +1,4 @@
|
|||
maxlen = 0
|
||||
wlst = String[]
|
||||
WL = open("ordered_words.txt", "r")
|
||||
|
||||
for w in eachline(WL)
|
||||
w = chomp(w)
|
||||
wlen = length(w)
|
||||
wlen>=maxlen && isordered(w) || continue
|
||||
if wlen > maxlen
|
||||
maxlen = wlen
|
||||
wlst = [w]
|
||||
else
|
||||
push!(wlst, w)
|
||||
end
|
||||
end
|
||||
close(WL)
|
||||
|
||||
for w in wlst
|
||||
println(" ", w)
|
||||
end
|
||||
lst = readlines("data/unixdict.txt")
|
||||
filter!(issorted, lst)
|
||||
filter!(x -> length(x) == maximum(length, lst), lst)
|
||||
println.(lst)
|
||||
|
|
|
|||
19
Task/Ordered-words/Maple/ordered-words.maple
Normal file
19
Task/Ordered-words/Maple/ordered-words.maple
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
lst := StringTools:-Split(Import("http://www.puzzlers.org/pub/wordlists/unixdict.txt"), "\n"):
|
||||
longest := 0:
|
||||
words := Array():
|
||||
i := 1:
|
||||
for word in lst do
|
||||
if StringTools:-IsSorted(word) then
|
||||
len := StringTools:-Length(word):
|
||||
if len > longest then
|
||||
longest := len:
|
||||
words := Array():
|
||||
words(1) := word:
|
||||
i := 2:
|
||||
elif len = longest then
|
||||
words(i) := word:
|
||||
i++:
|
||||
end if;
|
||||
end if;
|
||||
end do;
|
||||
for word in words do print(word); end do;
|
||||
15
Task/Ordered-words/Red/ordered-words.red
Normal file
15
Task/Ordered-words/Red/ordered-words.red
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
Red []
|
||||
;; code to read url and save to local file:
|
||||
;;data: read/binary http://www.puzzlers.org/pub/wordlists/unixdict.txt
|
||||
;;write %unixdict.txt data
|
||||
|
||||
max: [ "" ] ;; init array with one empty string (length 0 )
|
||||
|
||||
foreach word read/lines %unixdict.txt [ ;; read local file
|
||||
len: either word = sort copy word [ length? word ] [ -1 ] ;; check if ordered and get length
|
||||
case [
|
||||
len > length? first max [ max: reduce [ word ]] ;; init new block
|
||||
len = length? first max [ append max word ]
|
||||
]
|
||||
]
|
||||
probe max
|
||||
Loading…
Add table
Add a link
Reference in a new issue