Data update
This commit is contained in:
parent
35bcdeebf8
commit
74c69a0df6
2427 changed files with 31826 additions and 3468 deletions
38
Task/Set-consolidation/Quackery/set-consolidation.quackery
Normal file
38
Task/Set-consolidation/Quackery/set-consolidation.quackery
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
[ 0 swap witheach [ bit | ] ] is ->set ( $ --> { )
|
||||
|
||||
[ say "{" 0 swap
|
||||
[ dup 0 != while
|
||||
dup 1 & if [ over emit ]
|
||||
1 >> dip 1+ again ]
|
||||
2drop say "} " ] is echoset ( { --> )
|
||||
|
||||
[ [] swap dup size 1 - times
|
||||
[ behead over witheach
|
||||
[ 2dup & iff
|
||||
[ | swap i^ poke
|
||||
[] conclude ]
|
||||
else drop ]
|
||||
swap dip join ]
|
||||
join ] is consolidate ( [ --> [ )
|
||||
|
||||
[ dup witheach echoset
|
||||
say "--> "
|
||||
consolidate witheach echoset
|
||||
cr ] is task ( [ --> )
|
||||
|
||||
$ "AB" ->set
|
||||
$ "CD" ->set join
|
||||
task
|
||||
$ "AB" ->set
|
||||
$ "BD" ->set join
|
||||
task
|
||||
$ "AB" ->set
|
||||
$ "CD" ->set join
|
||||
$ "DB" ->set join
|
||||
task
|
||||
$ "HIK" ->set
|
||||
$ "AB" ->set join
|
||||
$ "CD" ->set join
|
||||
$ "DB" ->set join
|
||||
$ "FGH" ->set join
|
||||
task
|
||||
26
Task/Set-consolidation/SETL/set-consolidation.setl
Normal file
26
Task/Set-consolidation/SETL/set-consolidation.setl
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
program set_consolidation;
|
||||
tests := [
|
||||
{{'A','B'}, {'C','D'}},
|
||||
{{'A','B'}, {'B','D'}},
|
||||
{{'A','B'}, {'C','D'}, {'D','B'}},
|
||||
{{'H','I','K'}, {'A','B'}, {'C','D'}, {'D','B'}, {'F','G','H'}}
|
||||
];
|
||||
|
||||
loop for t in tests do
|
||||
print(consolidate(t));
|
||||
end loop;
|
||||
|
||||
proc consolidate(sets);
|
||||
outp := {};
|
||||
loop while sets /= {} do
|
||||
set_ from sets;
|
||||
loop until overlap = {} do
|
||||
overlap := {s : s in sets | exists el in s | el in set_};
|
||||
set_ +:= {} +/ overlap;
|
||||
sets -:= overlap;
|
||||
end loop;
|
||||
outp with:= set_;
|
||||
end loop;
|
||||
return outp;
|
||||
end proc;
|
||||
end program;
|
||||
Loading…
Add table
Add a link
Reference in a new issue