Advertisement
Guest User

Untitled

a guest
Apr 19th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.06 KB | None | 0 0
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. namespace Codewars
  5. {
  6. class Program
  7. {
  8. static void Main(string[] args)
  9. {
  10. Hashtable distTable1 = new Hashtable { { "X1", 100.0 }, { "X2", 200.0 }, { "X3", 250.0 }, { "X4", 300.0 } };
  11. string[] friends1 = new string[] { "A1", "A2", "A3", "A4", "A5" };
  12. string[][] fTowns1 = { new string[] { "A1", "X1" }, new string[] { "A2", "X2" }, new string[] { "A3", "X3" }, new string[] { "A4", "X4" } };
  13. tour(friends1, fTowns1, distTable1);
  14. Console.Read();
  15. }
  16.  
  17. public static int tour(string[] arrFriends, string[][] ftwns, Hashtable h)
  18. {
  19.  
  20. List<double> distances = new List<double>();
  21. double b = 0;
  22. double c = 0;
  23. double a = 0;
  24. double total = 0;
  25. foreach (double distance in h.Values)
  26. {
  27. distances.Add(distance);
  28. }
  29. for (int i = 0; i < distances.Count; i++)
  30. {
  31. if (total == 0)
  32. {
  33. total = distances[i];
  34. }
  35. b = distances[i];
  36. Console.WriteLine($"This is b : {b}");
  37. Console.WriteLine($"This is i : {distances[i]}");
  38.  
  39. if (i != distances.Count -1)
  40. {
  41.  
  42. c = distances[i + 1];
  43. Console.WriteLine($"This is c : {c}");
  44. Console.WriteLine($"c*c = {c*c}");
  45. Console.WriteLine($"b*b = {b*b}");
  46. a = (c * c) - (b * b);
  47. Console.WriteLine($"problem aaa? {a}");
  48. a = Math.Sqrt(Math.Sqrt(a*a));
  49. total += a;
  50. }
  51. else
  52. total += b;
  53. }
  54. total = Math.Round(total);
  55. Console.WriteLine($"This is the total : {total}");
  56. return (int)total;
  57. }
  58. }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement