Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections;
- using System.Collections.Generic;
- namespace Codewars
- {
- class Program
- {
- static void Main(string[] args)
- {
- Hashtable distTable1 = new Hashtable { { "X1", 100.0 }, { "X2", 200.0 }, { "X3", 250.0 }, { "X4", 300.0 } };
- string[] friends1 = new string[] { "A1", "A2", "A3", "A4", "A5" };
- string[][] fTowns1 = { new string[] { "A1", "X1" }, new string[] { "A2", "X2" }, new string[] { "A3", "X3" }, new string[] { "A4", "X4" } };
- tour(friends1, fTowns1, distTable1);
- Console.Read();
- }
- public static int tour(string[] arrFriends, string[][] ftwns, Hashtable h)
- {
- List<double> distances = new List<double>();
- double b = 0;
- double c = 0;
- double a = 0;
- double total = 0;
- foreach (double distance in h.Values)
- {
- distances.Add(distance);
- }
- for (int i = 0; i < distances.Count; i++)
- {
- if (total == 0)
- {
- total = distances[i];
- }
- b = distances[i];
- Console.WriteLine($"This is b : {b}");
- Console.WriteLine($"This is i : {distances[i]}");
- if (i != distances.Count -1)
- {
- c = distances[i + 1];
- Console.WriteLine($"This is c : {c}");
- Console.WriteLine($"c*c = {c*c}");
- Console.WriteLine($"b*b = {b*b}");
- a = (c * c) - (b * b);
- Console.WriteLine($"problem aaa? {a}");
- a = Math.Sqrt(Math.Sqrt(a*a));
- total += a;
- }
- else
- total += b;
- }
- total = Math.Round(total);
- Console.WriteLine($"This is the total : {total}");
- return (int)total;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement