Last active
October 5, 2016 18:34
-
-
Save chopmo/654d8112b48585f929eae21650b3bd9a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns Player | |
(:require [clojure.set :as s]) | |
(:gen-class)) | |
(defn node-filter [nodes] | |
(fn [link] | |
(not-empty | |
(s/intersection | |
(set link) | |
(set nodes))))) | |
(defn -main [& args] | |
(let [num-nodes (read) | |
num-links (read) | |
num-gateways (read) | |
links (doall (repeatedly num-links (fn [] [(read) (read)]))) | |
gateways (doall (repeatedly num-gateways read))] | |
(while true | |
(let [si (read) | |
si-links (filter (node-filter [si]) links) | |
si-gw-links (filter (node-filter gateways) si-links) | |
link-to-sever (first (concat si-gw-links si-links))] | |
(apply println link-to-sever))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment