diff options
Diffstat (limited to 'test/graph_tests.adb')
-rw-r--r-- | test/graph_tests.adb | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/test/graph_tests.adb b/test/graph_tests.adb new file mode 100644 index 0000000..321313f --- /dev/null +++ b/test/graph_tests.adb @@ -0,0 +1,34 @@ + + +package body Graph_Tests is + + + function Is_Permutation + (Left, Right : in Array_Type) + return Boolean + is + Marked_Off : array (Right'Range) of Boolean := (others => False); + Same_Count : Natural := 0; + begin + if Left'Length = 0 and Right'Length = 0 then + return True; + end if; + if Left'Length /= Right'Length then + return False; + end if; + for L in Left'Range loop + for R in Right'Range loop + if Left (L) = Right (R) and not Marked_Off (R) then + Marked_Off (R) := True; + Same_Count := Same_Count + 1; + exit; + end if; + end loop; + end loop; + return Same_Count = Left'Length; + end Is_Permutation; + + +end Graph_Tests; + + |