diff options
author | Jed Barber <jjbarber@y7mail.com> | 2020-05-21 21:24:25 +1000 |
---|---|---|
committer | Jed Barber <jjbarber@y7mail.com> | 2020-05-21 21:24:25 +1000 |
commit | 82a42674ba64c6386152a5910fd7345a92b135e8 (patch) | |
tree | be453540ca12e0679f9ea741f99c592696ce3b96 /test/graph_tests.adb | |
parent | d07979218ea80c58e64148d9638ed3e6195ff6ed (diff) |
Tests complete, minor bugs fixed
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; + + |