public static void SkynetFinalPart1() { string[] inputs = Console.ReadLine().Split(' '); int numberOfNodes = int.Parse(inputs[0]); // the total number of nodes in the level, including the gateways int numberOfLinks = int.Parse(inputs[1]); // the number of links int numberOfExitGateways = int.Parse(inputs[2]); // the number of exit gateways Console.Error.WriteLine("Number of nodes: {0}", numberOfNodes); Console.Error.WriteLine("Number of links: {0}", numberOfLinks); Console.Error.WriteLine("Number of exit gateways: {0}", numberOfExitGateways); List <Node> nodes = new List <Node>(numberOfNodes); AllLinks links = new AllLinks(); for (int i = 0; i < numberOfLinks; i++) { inputs = Console.ReadLine().Split(' '); int linkBetweenNodes1 = int.Parse(inputs[0]); // N1 and N2 defines a link between these nodes int linkBetweenNodes2 = int.Parse(inputs[1]); Node nodeA = new Node(linkBetweenNodes1); nodes.Add(nodeA); Node nodeB = new Node(linkBetweenNodes2); nodes.Add(nodeB); Link currentLink = new Link(nodeA, nodeB); links.Add(currentLink); Console.Error.WriteLine("Link Number #{0}", i); Console.Error.WriteLine("#1 Link between nodes: {0}", linkBetweenNodes1); Console.Error.WriteLine("#2 Link between nodes: {0}", linkBetweenNodes2); Console.Error.WriteLine(); } for (int i = 0; i < numberOfExitGateways; i++) { int indexOfGatewayNode = int.Parse(Console.ReadLine()); // the index of a gateway node Console.Error.WriteLine("Index of #{0} gateway node: {1}", i, indexOfGatewayNode); Console.Error.WriteLine(); nodes.First(n => n.Index == indexOfGatewayNode).IsGateway = true; } // game loop while (true) { int indexOfSkynetAgentNode = int.Parse(Console.ReadLine()); // The index of the node on which the Skynet agent is positioned this turn Console.Error.WriteLine("Index of skynet agent node: {0}", indexOfSkynetAgentNode); Node skynetNode = nodes.First(n => n.Index == indexOfSkynetAgentNode); Link linkToBlock = CalculateLinkToBlock(links, nodes, skynetNode); Console.WriteLine(linkToBlock.ToString()); // Example: 0 1 are the indices of the nodes you wish to sever the link between } }
public void OnTestStarted() { driver = new ChromeDriver(); driver.Manage().Window.Maximize(); All_Pages = new AllLinks(driver); Page_StatusCode = new PageStatusCode(); Helper_Title = new HelperTitle(driver); Helper_H1 = new HelperH1(driver); Canonical_Helper = new CanonicalHelper(driver); https_www_URLs = new https_wwwURLs(); Get_StatusCode301 = new GetStatusCode301(); http_URLs = new httpURLs(); http_www_URLs = new http_wwwURLs(); slash_helper = new SlashHelper(); mixed_ContentHelper = new MixedContentHelper(driver); W3C_hel_per = new W3C_helper(); }
public void GetRankingFilmLinks(string url) { AllLinks.Clear(); System.Console.WriteLine("***********************************"); System.Console.WriteLine("Pobieram linki filmow z rankingow\n" + url); System.Console.WriteLine("***********************************"); // e.g. http://www.filmweb.pl/rankings/film/country/genre/ Document = HtmlWeb.Load(url); Prepare_links = Document.DocumentNode.Descendants("a"); foreach (var link in Prepare_links) { if (link.GetAttributeValue("class", "test") == "s-20") { string Link = "http://filmweb.pl" + link.Attributes["href"].Value; AllLinks.Add(Link); } } System.Console.WriteLine("Pobrano linki."); }
private static Link CalculateLinkToBlock(AllLinks links, IEnumerable <Node> nodes, Node skynetNode) { IEnumerable <Node> enumerable = nodes as IList <Node> ?? nodes.ToList(); IEnumerable <Node> gatewayNodes = enumerable.Where(n => n.IsGateway); Node nodeLinkedToSkynetNode = gatewayNodes.FirstOrDefault(n => links.GetConnectedLink(n, skynetNode) != null); Link returnedLink; if (nodeLinkedToSkynetNode != null) { returnedLink = links.GetConnectedLink(skynetNode, nodeLinkedToSkynetNode); } else { returnedLink = links.FirstOrDefault(l => l.IsConnected); } returnedLink.IsConnected = false; return(returnedLink); }
public void FindAllUrlStringII() { int i = 0; int c = 0; while ( i < 100 & c != AllLinks.Count) { var ll = AddUrlString(AllLinks[c]); foreach (var l in ll) { if (AllLinks.Find(u => u == (l)) == null) { AllLinks.Add(l); i++; } } c++; // MessageBox.Show(AllLinks.Count.ToString()); } MessageBox.Show("All links II" + AllLinks.Count.ToString()); }
// Initializes the proper context for each of the steps onTabActivate private void tabInterface_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (e.OriginalSource is TabControl) { if (tabInterface.SelectedIndex > 0 && System.IO.File.Exists(ioPathLinkList) == false) { tabInterface.SelectedIndex = 0; } else if (tabInterface.SelectedIndex > 1 && System.IO.File.Exists(ioPathLinkObjects) == false) { tabInterface.SelectedIndex = 1; } else if (tabInterface.SelectedIndex == 4 && System.IO.File.Exists(ioPathHelpAbstraction) == false) { tabInterface.SelectedIndex = 3; } else { switch (tabInterface.SelectedIndex + 1) { case 1: // Step 1: Extracting Navigation Links navURL = urlHelpers.getHelpURL("4CEE5072-8817-4920-8A2D-7060F5E16547"); break; case 2: // Step 2: Classify the extracted links AllLinks.Clear(); var html = System.IO.File.ReadAllText(ioPathLinkList); HAP.HtmlDocument doc = new HAP.HtmlDocument(); doc.LoadHtml(html); var anchors = doc.DocumentNode.SelectNodes("//a").ToList(); foreach (var a in anchors) { var href = a.GetAttributeValue("href", "").ToUpper().Trim(' ', '?').Replace("GUID-", "").Replace("GUID=", "").Trim(); var title = a.InnerText.Replace("\n", "").Replace("\r", "").Replace(">", ">").Replace("<", "<").Trim(); AllLinks.Add(new LinkObject(title, href)); } navURL = ioPathLinkList; lbxInitNavLinks.ItemsSource = AllLinks; break; case 3: // Download the classified link conent isIdle = true; InitializeDownloadVariables(); break; case 4: // Parse of web help document content InitializeDownloadVariables(); break; case 5: // possibly some kind of rule system CurrentLib = ioPathHelpAbstraction.UnPack <WebObjectLibrary>(); AllOverrides.Clear(); Filter = ""; if (System.IO.File.Exists(ioPathRuleOverrides) == true) { foreach (OverrideRule item in ioPathRuleOverrides.UnPack <List <OverrideRule> >()) { AllOverrides.Add(item); } } tvApplyOverrides.DataContext = CurrentLib; break; } } } }