Data update
This commit is contained in:
parent
35bcdeebf8
commit
74c69a0df6
2427 changed files with 31826 additions and 3468 deletions
|
|
@ -0,0 +1,14 @@
|
|||
#include <basico.h>
|
||||
|
||||
algoritmo
|
||||
|
||||
matrices (A, B)
|
||||
"John", "Bob", "Mary", "Serena", enlistar en 'A'
|
||||
"Jim", "Mary", "John", "Bob", enlistar en 'B'
|
||||
|
||||
" A XOR B: {", diferencia simétrica(A,B), "}\n"
|
||||
" A \ B: {", diferencia(A,B), "}\n"
|
||||
" B \ A: {", diferencia(B,A), "}\n"
|
||||
imprimir
|
||||
|
||||
terminar
|
||||
|
|
@ -1,21 +1,16 @@
|
|||
a$[] = [ "John" "Bob" "Mary" "Serena" ]
|
||||
b$[] = [ "Jim" "Mary" "John" "Bob" ]
|
||||
#
|
||||
for i to 2
|
||||
for a$ in a$[]
|
||||
for b$ in b$[]
|
||||
if a$ = b$
|
||||
a$ = ""
|
||||
break 1
|
||||
.
|
||||
.
|
||||
if a$ <> b$
|
||||
for c$ in c$[]
|
||||
if c$ = a$
|
||||
break 1
|
||||
.
|
||||
.
|
||||
if c$ <> a$
|
||||
c$[] &= a$
|
||||
.
|
||||
if a$ <> ""
|
||||
c$[] &= a$
|
||||
.
|
||||
.
|
||||
swap a$[] b$[]
|
||||
|
|
|
|||
|
|
@ -0,0 +1,53 @@
|
|||
Set = new map
|
||||
Set["set"] = {}
|
||||
|
||||
Set.init = function(items)
|
||||
set = new Set
|
||||
set.set = {}
|
||||
for item in items
|
||||
set.add(item)
|
||||
end for
|
||||
return set
|
||||
end function
|
||||
|
||||
Set.contains = function(item)
|
||||
return self.set.hasIndex(item)
|
||||
end function
|
||||
|
||||
Set.items = function
|
||||
return self.set.indexes
|
||||
end function
|
||||
|
||||
Set.add = function(item)
|
||||
self.set[item] = true
|
||||
end function
|
||||
|
||||
Set.union = function(other)
|
||||
result = Set.init
|
||||
result.set = self.set + other.set
|
||||
return result
|
||||
end function
|
||||
|
||||
Set.difference = function(other)
|
||||
result = Set.init
|
||||
for item in self.items
|
||||
if not other.contains(item) then result.add(item)
|
||||
end for
|
||||
return result
|
||||
end function
|
||||
|
||||
Set.symmetricDifference = function(other)
|
||||
diff1 = self.difference(other)
|
||||
diff2 = other.difference(self)
|
||||
return diff1.union(diff2)
|
||||
end function
|
||||
|
||||
a = ["John", "Serena", "Bob", "Mary", "Serena"]
|
||||
b = ["Jim", "Mary", "John", "Jim", "Bob"]
|
||||
|
||||
A1 = Set.init(a)
|
||||
B1 = Set.init(b)
|
||||
|
||||
print "A XOR B " + A1.symmetricDifference(B1).items
|
||||
print "A - B " + A1.difference(B1).items
|
||||
print "B - A " + B1.difference(A1).items
|
||||
8
Task/Symmetric-difference/SETL/symmetric-difference.setl
Normal file
8
Task/Symmetric-difference/SETL/symmetric-difference.setl
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
program symmetric_difference;
|
||||
A := {"John", "Bob", "Mary", "Serena"};
|
||||
B := {"Jim", "Mary", "John", "Bob"};
|
||||
|
||||
print("A - B:", A - B);
|
||||
print("B - A:", B - A);
|
||||
print("Symmetric difference:", (A-B) + (B-A));
|
||||
end program;
|
||||
Loading…
Add table
Add a link
Reference in a new issue