Data update
This commit is contained in:
parent
4bb20c9b71
commit
cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions
22
Task/Power-set/Ada/power-set.adb
Normal file
22
Task/Power-set/Ada/power-set.adb
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
with Ada.Text_IO, Ada.Command_Line;
|
||||
use Ada.Text_IO, Ada.Command_Line;
|
||||
|
||||
procedure powerset is
|
||||
begin
|
||||
for set in 0..2**Argument_Count-1 loop
|
||||
Put ("{");
|
||||
declare
|
||||
k : natural := set;
|
||||
first : boolean := true;
|
||||
begin
|
||||
for i in 1..Argument_Count loop
|
||||
if k mod 2 = 1 then
|
||||
Put ((if first then "" else ",") & Argument (i));
|
||||
first := false;
|
||||
end if;
|
||||
k := k / 2; -- we go to the next bit of "set"
|
||||
end loop;
|
||||
end;
|
||||
Put_Line("}");
|
||||
end loop;
|
||||
end powerset;
|
||||
34
Task/Power-set/PowerShell/power-set.ps1
Normal file
34
Task/Power-set/PowerShell/power-set.ps1
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
function power-set ($array) {
|
||||
if($array) {
|
||||
$n = $array.Count
|
||||
function state($set, $i){
|
||||
if($i -gt -1) {
|
||||
state $set ($i-1)
|
||||
state ($set+@($array[$i])) ($i-1)
|
||||
} else {
|
||||
"$($set | sort)"
|
||||
}
|
||||
}
|
||||
$set = state @() ($n-1)
|
||||
$power = 0..($set.Count-1) | foreach{@(0)}
|
||||
$i = 0
|
||||
$set | sort | foreach{$power[$i++] = $_.Split()}
|
||||
$power | sort {$_.Count}
|
||||
} else {@()}
|
||||
|
||||
}
|
||||
$OFS = " "
|
||||
$setA = power-set @(1,2,3,4)
|
||||
"number of sets in setA: $($setA.Count)"
|
||||
"sets in setA:"
|
||||
$OFS = ", "
|
||||
$setA | foreach{"{"+"$_"+"}"}
|
||||
$setB = @()
|
||||
"number of sets in setB: $($setB.Count)"
|
||||
"sets in setB:"
|
||||
$setB | foreach{"{"+"$_"+"}"}
|
||||
$setC = @(@(), @(@()))
|
||||
"number of sets in setC: $($setC.Count)"
|
||||
"sets in setC:"
|
||||
$setC | foreach{"{"+"$_"+"}"}
|
||||
$OFS = " "
|
||||
4
Task/Power-set/Uiua/power-set-1.uiua
Normal file
4
Task/Power-set/Uiua/power-set-1.uiua
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
[1 2 3 4] # Input array
|
||||
⇡+1⊸⧻ # Window sizes for permutations
|
||||
≡⌟(□≡□⧅<) # Iterate through permutation sizes and box the results
|
||||
/◇⊂ # Flatten each permutation size
|
||||
1
Task/Power-set/Uiua/power-set-2.uiua
Normal file
1
Task/Power-set/Uiua/power-set-2.uiua
Normal file
|
|
@ -0,0 +1 @@
|
|||
[[]│1│2│3│4│1 2│1 3│1 4│2 3│2 4│3 4│1 2 3│1 2 4│1 3 4│2 3 4│1 2 3 4]
|
||||
1
Task/Power-set/Uiua/power-set-3.uiua
Normal file
1
Task/Power-set/Uiua/power-set-3.uiua
Normal file
|
|
@ -0,0 +1 @@
|
|||
[1 2 3 4] # Input array
|
||||
1
Task/Power-set/Uiua/power-set-4.uiua
Normal file
1
Task/Power-set/Uiua/power-set-4.uiua
Normal file
|
|
@ -0,0 +1 @@
|
|||
⇡+1⊸⧻ # Window sizes for permutations
|
||||
4
Task/Power-set/Uiua/power-set-5.uiua
Normal file
4
Task/Power-set/Uiua/power-set-5.uiua
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
⧅< # Get the permutations for a fixed size
|
||||
≡□ # Box each individual permutation
|
||||
□ # Box the array of permutations for combination
|
||||
≡⌟(□≡□⧅<) # Iterate through permutation sizes and box the results
|
||||
1
Task/Power-set/Uiua/power-set-6.uiua
Normal file
1
Task/Power-set/Uiua/power-set-6.uiua
Normal file
|
|
@ -0,0 +1 @@
|
|||
/◇⊂ # Flatten each permutation size
|
||||
1
Task/Power-set/Uiua/power-set-7.uiua
Normal file
1
Task/Power-set/Uiua/power-set-7.uiua
Normal file
|
|
@ -0,0 +1 @@
|
|||
[""│"H"│"e"│"l"│"l"│"o"│"He"│"Hl"│"Hl"│"Ho"│"el"│"el"│"eo"│"ll"│"lo"│"lo"│"Hel"│"Hel"│"Heo"│"Hll"│"Hlo"│"Hlo"│"ell"│"elo"│"elo"│"llo"│"Hell"│"Helo"│"Helo"│"Hllo"│"ello"│"Hello"]
|
||||
1
Task/Power-set/Uiua/power-set-8.uiua
Normal file
1
Task/Power-set/Uiua/power-set-8.uiua
Normal file
|
|
@ -0,0 +1 @@
|
|||
[[]│]
|
||||
1
Task/Power-set/Uiua/power-set-9.uiua
Normal file
1
Task/Power-set/Uiua/power-set-9.uiua
Normal file
|
|
@ -0,0 +1 @@
|
|||
[0×0 ℝ│¤1×0 ℝ]
|
||||
33
Task/Power-set/VBScript/power-set.vbs
Normal file
33
Task/Power-set/VBScript/power-set.vbs
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
Function Dec2Bin(n)
|
||||
q = n
|
||||
Dec2Bin = ""
|
||||
Do Until q = 0
|
||||
Dec2Bin = CStr(q Mod 2) & Dec2Bin
|
||||
q = Int(q / 2)
|
||||
Loop
|
||||
Dec2Bin = Right("00000" & Dec2Bin,6)
|
||||
End Function
|
||||
|
||||
Function PowerSet(s)
|
||||
arrS = Split(s,",")
|
||||
PowerSet = "{"
|
||||
For i = 0 To 2^(UBound(arrS)+1)-1
|
||||
If i = 0 Then
|
||||
PowerSet = PowerSet & "{},"
|
||||
Else
|
||||
binS = Dec2Bin(i)
|
||||
PowerSet = PowerSet & "{"
|
||||
c = 0
|
||||
For j = Len(binS) To 1 Step -1
|
||||
If CInt(Mid(binS,j,1)) = 1 Then
|
||||
PowerSet = PowerSet & arrS(c) & ","
|
||||
End If
|
||||
c = c + 1
|
||||
Next
|
||||
PowerSet = Mid(PowerSet,1,Len(PowerSet)-1) & "},"
|
||||
End If
|
||||
Next
|
||||
PowerSet = Mid(PowerSet,1,Len(PowerSet)-1) & "}"
|
||||
End Function
|
||||
|
||||
WScript.StdOut.Write PowerSet("1,2,3,4")
|
||||
Loading…
Add table
Add a link
Reference in a new issue