diff --git a/.vs/comivoyar/v15/.suo b/.vs/comivoyar/v15/.suo index 58183ba..9c724f2 100644 Binary files a/.vs/comivoyar/v15/.suo and b/.vs/comivoyar/v15/.suo differ diff --git a/.vs/comivoyar/v15/Server/sqlite3/storage.ide b/.vs/comivoyar/v15/Server/sqlite3/storage.ide index 36a165d..43bdfea 100644 Binary files a/.vs/comivoyar/v15/Server/sqlite3/storage.ide and b/.vs/comivoyar/v15/Server/sqlite3/storage.ide differ diff --git a/.vs/comivoyar/v15/Server/sqlite3/storage.ide-shm b/.vs/comivoyar/v15/Server/sqlite3/storage.ide-shm index 7272348..533549f 100644 Binary files a/.vs/comivoyar/v15/Server/sqlite3/storage.ide-shm and b/.vs/comivoyar/v15/Server/sqlite3/storage.ide-shm differ diff --git a/.vs/comivoyar/v15/Server/sqlite3/storage.ide-wal b/.vs/comivoyar/v15/Server/sqlite3/storage.ide-wal index 6a1f690..43864b5 100644 Binary files a/.vs/comivoyar/v15/Server/sqlite3/storage.ide-wal and b/.vs/comivoyar/v15/Server/sqlite3/storage.ide-wal differ diff --git a/comivoyar/App.config b/comivoyar/App.config index 731f6de..daf6772 100644 --- a/comivoyar/App.config +++ b/comivoyar/App.config @@ -1,6 +1,22 @@ - + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/comivoyar/Program.cs b/comivoyar/Program.cs index edc844c..a664daf 100644 --- a/comivoyar/Program.cs +++ b/comivoyar/Program.cs @@ -1,7 +1,8 @@ using System; -using System.Collections.Generic; -using System.Diagnostics; using System.IO; +using System.Diagnostics; +using Combinatorics.Collections; +using System.Collections.Generic; using static System.Console; namespace komvo @@ -44,21 +45,29 @@ namespace komvo WriteLine(); } - string formP = string.Empty; - for (int i = 2; i <= Points.Count; i++) formP += i.ToString(); + int[] toSwap = new int[Points.Count]; + for (int i = 0; i < toSwap.Length; i++) toSwap[i] = i + 2; + + + for (int i = 0; i < toSwap.Length; i++) WriteLine(toSwap[i]); int fct = Fact(Points.Count - 1); - WriteLine("\n{0} {1}\n\n\n", formP, fct); - int[] routes = new int[fct]; - double[] leng = new double[fct]; + int[] routes = new int[Fact(Points.Count)]; + double[] leng = new double[Fact(Points.Count)]; - int waves = fct / 6; double optim = leng[0]; int oIndex = 0; - string inf = formP; - Swapper(0, inf, ref routes, waves); + Permutations perm = new Permutations(toSwap); + int index = 0; + foreach(IList p in perm) + { + string res = string.Empty; + for (int i = 0; i < toSwap.Length; i++) res += p[i].ToString(); + routes[index++] = int.Parse(res); + } + CountLen(ref leng, Matrix, routes); SearchBest(ref optim, ref oIndex, routes, leng); Debug(routes); @@ -71,28 +80,6 @@ namespace komvo ReadKey(); } - public static string Swap(string value, int first, int second) - { - char[] res = value.ToCharArray(); - res[first] = value[second]; - res[second] = value[first]; - value = new string(res); - - return value; - } - - public static string Swap(string value, int first, int second, int debug) - { - int d = debug; - char[] res = value.ToCharArray(); - res[first] = value[second]; - res[second] = value[first]; - value = new string(res); - - return value; - } - - public static void CountLen (ref double[] result, double[,] mtr, int[] rts) { for (int i = 0; i < rts.Length; i++) @@ -101,74 +88,23 @@ namespace komvo char[] ch = rts[i].ToString().ToCharArray(); for (int j = 0; j < ch.Length; j++) { - int db = int.Parse(ch[j].ToString()) - 1; //debug + int db = int.Parse(ch[j].ToString()) - 2; //debug string db1 = rts[i].ToString(); //debug - if (j == 0) res += mtr[0, int.Parse(ch[j].ToString()) - 1]; + if (j == 0) res += mtr[0, int.Parse(ch[j].ToString()) - 2]; else if (j == ch.Length - 1) { - res += mtr[int.Parse(ch[j - 1].ToString()) - 1, int.Parse(ch[j].ToString()) - 1]; - res += mtr[0, int.Parse(ch[j].ToString()) - 1]; + res += mtr[int.Parse(ch[j - 1].ToString()) - 2, int.Parse(ch[j].ToString()) - 2]; + res += mtr[0, int.Parse(ch[j].ToString()) - 2]; } else { - res += mtr[int.Parse(ch[j - 1].ToString()) - 1, int.Parse(ch[j].ToString()) - 1]; + res += mtr[int.Parse(ch[j - 1].ToString()) - 2, int.Parse(ch[j].ToString()) - 2]; } } result[i] = res; } } - - public static void Swapper(int counter, string inf, ref int[] routes, int waves) - { - string formP = inf; - if (counter >= waves) WriteLine("\nEnd"); - else - { - if (counter == 0) - { - Infinitives.Add(inf); - formP = Infinitives[0]; - } - else if (counter % 4 == 0) - { - Infinitives.Add(Swap(inf, counter / 4 - 1, inf.Length - 1, counter)); - formP = Infinitives[counter / 4]; - } - else if (waves > 1) - { - formP = Swap(Infinitives[counter / 4], counter % 4 - 1, 3); - } - - BlockOfSix(formP, ref routes, counter); - - Swapper(counter + 1, inf, ref routes, waves); - } - } - - - public static void BlockOfSix(string formP, ref int[] routes, int start) - { - for (int j = 0; j < 6; j++) - { - if (j == 0) - { - routes[j + start * 6] = int.Parse(formP); - WriteLine(routes[j + start * 6]); - } - else if (j % 2 == 0) - { - routes[j + start * 6] = int.Parse(formP = Swap(formP, 0, j / 2)); - WriteLine(routes[j + start * 6]); - } - else - { - routes[j + start * 6] = int.Parse(Swap(formP, 1, 2)); - WriteLine(routes[j + start * 6]); - } - } - } - public static void SearchBest(ref double optim, ref int oIndex, int[] routes, double[] leng) { optim = leng[0]; @@ -193,16 +129,12 @@ namespace komvo } } - - - public partial struct Point { public int X { get; set; } public int Y { get; set; } } - static int Fact(int a) => a <= 1 ? 1 : a * Fact(a - 1); } } \ No newline at end of file diff --git a/comivoyar/bin/Debug/comivoyar.exe b/comivoyar/bin/Debug/comivoyar.exe index bbb731d..7668129 100644 Binary files a/comivoyar/bin/Debug/comivoyar.exe and b/comivoyar/bin/Debug/comivoyar.exe differ diff --git a/comivoyar/bin/Debug/comivoyar.exe.config b/comivoyar/bin/Debug/comivoyar.exe.config index 731f6de..daf6772 100644 --- a/comivoyar/bin/Debug/comivoyar.exe.config +++ b/comivoyar/bin/Debug/comivoyar.exe.config @@ -1,6 +1,22 @@ - + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/comivoyar/bin/Debug/comivoyar.pdb b/comivoyar/bin/Debug/comivoyar.pdb index 44c1a8b..df10e14 100644 Binary files a/comivoyar/bin/Debug/comivoyar.pdb and b/comivoyar/bin/Debug/comivoyar.pdb differ diff --git a/comivoyar/bin/Debug/coord.txt b/comivoyar/bin/Debug/coord.txt index d0211c8..f0b2693 100644 --- a/comivoyar/bin/Debug/coord.txt +++ b/comivoyar/bin/Debug/coord.txt @@ -1,6 +1,4 @@ 0 0 -0 20 +10 10 20 20 -20 0 -40 40 -30 30 +30 30 \ No newline at end of file diff --git a/comivoyar/comivoyar.csproj b/comivoyar/comivoyar.csproj index c3b400e..2a88594 100644 --- a/comivoyar/comivoyar.csproj +++ b/comivoyar/comivoyar.csproj @@ -32,13 +32,66 @@ 4 + + ..\packages\Combinatorics.1.1.0.19\lib\netstandard1.2\Combinatorics.dll + + + ..\packages\Microsoft.Win32.Primitives.4.0.1\lib\net46\Microsoft.Win32.Primitives.dll + + + ..\packages\System.AppContext.4.1.0\lib\net46\System.AppContext.dll + + + + ..\packages\System.Console.4.0.0\lib\net46\System.Console.dll + + + ..\packages\System.Diagnostics.DiagnosticSource.4.0.0\lib\net46\System.Diagnostics.DiagnosticSource.dll + + + ..\packages\System.Globalization.Calendars.4.0.1\lib\net46\System.Globalization.Calendars.dll + + + ..\packages\System.IO.Compression.4.1.0\lib\net46\System.IO.Compression.dll + + + + ..\packages\System.IO.Compression.ZipFile.4.0.1\lib\net46\System.IO.Compression.ZipFile.dll + + + ..\packages\System.IO.FileSystem.4.0.1\lib\net46\System.IO.FileSystem.dll + + + ..\packages\System.IO.FileSystem.Primitives.4.0.1\lib\net46\System.IO.FileSystem.Primitives.dll + + + ..\packages\System.Net.Http.4.1.0\lib\net46\System.Net.Http.dll + + + ..\packages\System.Net.Sockets.4.1.0\lib\net46\System.Net.Sockets.dll + + + + ..\packages\System.Runtime.InteropServices.RuntimeInformation.4.0.0\lib\net45\System.Runtime.InteropServices.RuntimeInformation.dll + + + ..\packages\System.Security.Cryptography.Algorithms.4.2.0\lib\net461\System.Security.Cryptography.Algorithms.dll + + + ..\packages\System.Security.Cryptography.Encoding.4.0.0\lib\net46\System.Security.Cryptography.Encoding.dll + + + ..\packages\System.Security.Cryptography.Primitives.4.0.0\lib\net46\System.Security.Cryptography.Primitives.dll + + + ..\packages\System.Security.Cryptography.X509Certificates.4.1.0\lib\net461\System.Security.Cryptography.X509Certificates.dll + - @@ -47,6 +100,7 @@ + \ No newline at end of file diff --git a/comivoyar/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/comivoyar/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache index 1ba01cc..45d9c4c 100644 Binary files a/comivoyar/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache and b/comivoyar/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/comivoyar/obj/Debug/comivoyar.csproj.CoreCompileInputs.cache b/comivoyar/obj/Debug/comivoyar.csproj.CoreCompileInputs.cache index e4c5453..aa00d1d 100644 --- a/comivoyar/obj/Debug/comivoyar.csproj.CoreCompileInputs.cache +++ b/comivoyar/obj/Debug/comivoyar.csproj.CoreCompileInputs.cache @@ -1 +1 @@ -6eed873852f8ce9c50ebe974dac1f20cc4ef270e +47ece507326a3ff73baa3b75434a7d03f71dc86d diff --git a/comivoyar/obj/Debug/comivoyar.csproj.FileListAbsolute.txt b/comivoyar/obj/Debug/comivoyar.csproj.FileListAbsolute.txt index 87e761f..4f9f63b 100644 --- a/comivoyar/obj/Debug/comivoyar.csproj.FileListAbsolute.txt +++ b/comivoyar/obj/Debug/comivoyar.csproj.FileListAbsolute.txt @@ -12,3 +12,23 @@ D:\Git\comvo\comivoyar\obj\Debug\comivoyar.csprojAssemblyReference.cache D:\Git\comvo\comivoyar\obj\Debug\comivoyar.csproj.CoreCompileInputs.cache D:\Git\comvo\comivoyar\obj\Debug\comivoyar.exe D:\Git\comvo\comivoyar\obj\Debug\comivoyar.pdb +E:\кк\прог\comivoyar\comivoyar\bin\Debug\Combinatorics.dll +E:\кк\прог\comivoyar\comivoyar\bin\Debug\Microsoft.Win32.Primitives.dll +E:\кк\прог\comivoyar\comivoyar\bin\Debug\System.AppContext.dll +E:\кк\прог\comivoyar\comivoyar\bin\Debug\System.Console.dll +E:\кк\прог\comivoyar\comivoyar\bin\Debug\System.Diagnostics.DiagnosticSource.dll +E:\кк\прог\comivoyar\comivoyar\bin\Debug\System.Globalization.Calendars.dll +E:\кк\прог\comivoyar\comivoyar\bin\Debug\System.IO.Compression.dll +E:\кк\прог\comivoyar\comivoyar\bin\Debug\System.IO.Compression.ZipFile.dll +E:\кк\прог\comivoyar\comivoyar\bin\Debug\System.IO.FileSystem.dll +E:\кк\прог\comivoyar\comivoyar\bin\Debug\System.IO.FileSystem.Primitives.dll +E:\кк\прог\comivoyar\comivoyar\bin\Debug\System.Net.Http.dll +E:\кк\прог\comivoyar\comivoyar\bin\Debug\System.Net.Sockets.dll +E:\кк\прог\comivoyar\comivoyar\bin\Debug\System.Runtime.InteropServices.RuntimeInformation.dll +E:\кк\прог\comivoyar\comivoyar\bin\Debug\System.Security.Cryptography.Algorithms.dll +E:\кк\прог\comivoyar\comivoyar\bin\Debug\System.Security.Cryptography.Encoding.dll +E:\кк\прог\comivoyar\comivoyar\bin\Debug\System.Security.Cryptography.Primitives.dll +E:\кк\прог\comivoyar\comivoyar\bin\Debug\System.Security.Cryptography.X509Certificates.dll +E:\кк\прог\comivoyar\comivoyar\bin\Debug\Combinatorics.xml +E:\кк\прог\comivoyar\comivoyar\bin\Debug\System.Diagnostics.DiagnosticSource.xml +E:\кк\прог\comivoyar\comivoyar\obj\Debug\comivoyar.csproj.CopyComplete diff --git a/comivoyar/obj/Debug/comivoyar.csprojAssemblyReference.cache b/comivoyar/obj/Debug/comivoyar.csprojAssemblyReference.cache index 51e185e..6e0c1c9 100644 Binary files a/comivoyar/obj/Debug/comivoyar.csprojAssemblyReference.cache and b/comivoyar/obj/Debug/comivoyar.csprojAssemblyReference.cache differ diff --git a/comivoyar/obj/Debug/comivoyar.exe b/comivoyar/obj/Debug/comivoyar.exe index bbb731d..7668129 100644 Binary files a/comivoyar/obj/Debug/comivoyar.exe and b/comivoyar/obj/Debug/comivoyar.exe differ diff --git a/comivoyar/obj/Debug/comivoyar.pdb b/comivoyar/obj/Debug/comivoyar.pdb index 44c1a8b..df10e14 100644 Binary files a/comivoyar/obj/Debug/comivoyar.pdb and b/comivoyar/obj/Debug/comivoyar.pdb differ diff --git a/comivoyar/packages.config b/comivoyar/packages.config new file mode 100644 index 0000000..40d60f8 --- /dev/null +++ b/comivoyar/packages.config @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file