Mangkubumi1 = ("tugu", "pantiwilosoprojo", "hotelarjuna" )
Mangkubumi2 = ("klinikmediksa", "bcapusat", "gkiwongsodirjan")
Malioboro = ("grandina", "malioboromall", "bappeda", "smpn3", "ramaimall", "malioboro")
Sudirman1 = ("uiversitaskristendutawacana", "klitren", "bethesda", "galeria",'ukdw')
Sudirman2 = ("ojk", "tugu", "gramedia")
AhmadYani = ("museumbenteng", "ramayana", "bringharjo", "alunalun")
Senopati = ("tamanpintar", "titiknol", "smapangudiluhur")
TamanPintar = ("tamanpintar", "titiknol", "smapangudiluhur")
Katamso2 = ("smpmariaimakulata", "xiaomiservice", "brikatamso")
Katamso1 = ("arenasport", "dinaskomunikasiinformasi", "bnnp", "kantorpertanahan")
YosSudarso = ("kridosono", "kotabaru", "rssoetarto", "smpn5")
MandalaKrida = ("universitasahmaddahlan", "dinaskebudayaan","pengadilannegriyogya")
KHADahlan2 = ("bniahmaddahlan", "moneychanger", "jlahmaddahlan")
MTHaryono1 = ("sman7", "gerejahatikudus", "pasarsepeda")
MTHaryono2 = ("sman7", "opposervicecenter", "pasarsepeda")
Tejoklusuman = MTHaryono1
kusumanegara3 = ("bpnjogja","universitassarjanawiyatatamansiswa","masjidalbadar")
kusumanegara4 = ("bpnjogja","universitassarjanawiyatatamansiswa","masjidalbadar")
kusumanegara = ("gembiraloka","masjidbaitulhamdi","sdngedongkuning")
lempuyangan = ("stasiunlempuyangan","pasarlempuyangan","kantorsicepatlempuyangan")
apmd1 = ("sekolahtinggipembangunanmasyarakatdesa","ciclektimoho29b","timohopetsshop")
apmd2 = ("sekolahtinggipembangunanmasyarakatdesa","messkotemtimoho","gmahktimohojogja")
debrito = ("smadebrito","administrasiuin","wismapu")
gedungwanita = ("smadebrito", "administrasiuin","mandalabhaktiwanitatama")
soloambarukmo = ("grandambarukmoplaza", "ambarukmoplaza", "masjidjamialiman")
JantiBawah = ("flyoverjanti","gorlanudadisucipto","masjidalmukhlishun")
janti = ("mirotakampurbabarsari","upnvybabarsari","jnebabarsari")
maguwotrasmart = ("grandorchidhotel","transmartmaguwo","lionparcel")
Maguwoharjo = ("maguwolama","bungabangsamedika","kesehatanpelabuhanjogja")
AdiSucipto = ("imigrasikelasitpijogja","spbupertaminaadisucipto","bankbnikalasan", "adisucipto")
Samirono = ("sanatadharma","samirono","uny")
sanatadharma = ("uny", "samirono", "sanatadharma")
santren =  ("depok","dazzlegejayan","hartonomall")
CondongCatur = ("vivoapartemensenturanjogja","pelayananpajakpratamasleman","condongcatur")
kusumanegara2 = ("balaikerajinandanbatik","smksmtijogja","gedungkeuangannegarajogja")
kusumanegara1 = ("balaikerajinandanbatik","makampahlawannasionalkusumanegara","gedungkeuangannegarajogja")
pakualaman = ("museumsasmitalokapanglimabesarjendralsudirman","pasarsentuljogja","bebadanpuropakualaman")
museumbiologi = ("museumsasmitalokapanglimabesarjendralsudirman","superindosultanagung","gerejakatoliksantoyusuf")
Ngabean= ("khususibudananakrachmi","univesitasaisyiyahjogja","klinikprismadiagnostika")
upy = ("universitaspgri","universitaspgriunit2","universitaspgriunit3")
kotabaru = ("mueseumsandi","balaibahasa","ramintenkitchen")
UIN = ("uin", "bniuin", "maxmarastoretimoho")
GedongKuning = ("jec", "grandrohan", "grhapradipta")
Babarsari = ("dinasperhubungan", "universitasatmajaya", "upnveteran")
KopmaUGM = ("mirotakampus", "kfcugm", "smkbopkri")
RRU = ("upnveteran", "amikom", "ringroadutara", "banksinarmas")
UNY = ("tokomerah", "sanatadharma", "uny")
Giwangan = ("pasargiwangan", "terminalgiwangan", "dinasperhubunganyogya")
Monjali = ("asuransijiwakresna", "tamanpelangi", "terminalmonjali", "monumenjogja")
Samsat = ("vivobike", "samsatkota", "smpn14")
Tegalgendu = ("bnikotagede", "planetban", "sdmuhamadiyahkleco")
SGM = ("smkn5", "smkydppmm52", "masjidalislah")
AtmaJaya = ("universitasatmajaya", "babarsari", "bcajwalkmall")

Halte = { 
    'Mangkubumi1': Mangkubumi1,
    'Mangkubumi2': Mangkubumi2,
    'Malioboro': Malioboro,
    'Katamso1': Katamso1, 
    'Katamso2': Katamso2,
    'kusumanegara': kusumanegara,
    'kusumanegara1': kusumanegara1,
    'kusumanegara2': kusumanegara2,
    'kusumanegara3': kusumanegara3, 
    'kusumanegara4': kusumanegara4,
    'kotabaru': kotabaru,
    'KopmaUGM': KopmaUGM,
    'SGM': SGM,
    'AtmaJaya': AtmaJaya,
    'UIN': UIN,
    'UNY': UNY,
    'CondongCatur': CondongCatur,
    'pakualaman': pakualaman,
    'Samirono': Samirono,
    'santren': santren,
    'sanatadharma': sanatadharma,
    'AdiSucipto': AdiSucipto,
    'Maguwoharjo': Maguwoharjo,
    'maguwotrasmart': maguwotrasmart,
    'janti': janti,
    'JantiBawah': JantiBawah,
    'soloambarukmo': soloambarukmo,
    'gedungwanita': gedungwanita,
    'museumbiologi': museumbiologi,
    'Ngabean':Ngabean,
    'upy': upy,
    'GedongKuning': GedongKuning,
    'KHADahlan2': KHADahlan2,
    'MTHaryono1': MTHaryono1,
    'MTHaryono2': MTHaryono2,
    'AhmadYani': AhmadYani,
    'Senopati': Senopati,
    'Sudirman1': Sudirman1,
    'Sudirman2': Sudirman2,
    'TamanPintar': TamanPintar,
    'YosSudarso': YosSudarso,
    'MandalaKrida': MandalaKrida,
    'Tejoklusuman': Tejoklusuman,
    'lempuyangan': lempuyangan,
    'apmd1': apmd1,
    'apmd2': apmd2,
    'debrito': debrito,
    'RRU': RRU,
    'Monjali': Monjali,
    'soloambarukmo': soloambarukmo,
    'Babarsari': Babarsari,
    'Giwangan': Giwangan,
    'Samsat': Samsat
}


a1= ('AdiSucipto', 'Maguwoharjo', 'JantiBawah', 'UIN', 'Sudirman2', 'Mangkubumi1', 'Mangkubumi2', 'Malioboro', 'AhmadYani', 'TamanPintar', 'pakualaman', 'SGM','kusumanegara', 'GedongKuning', 'janti')

b1= ('AdiSucipto','Maguwoharjo', 'Babarsari', 'JantiBawah', 'GedongKuning','kusumanegara', 'SGM', 'pakualaman', 'TamanPintar', 'AhmadYani','KHADahlan2', 'Malioboro', 'Samsat', 'Mangkubumi1', 'Sudirman2', 'Samirono', 'gedungwanita', 'CondongCatur', 'UIN')

a2 = ('Mangkubumi1', 'Mangkubumi2', 'Malioboro', 'AhmadYani', 'Senopati', 'GedongKuning', 'kusumanegara', 'SGM', 'MandalaKrida', 'santren', 'lempuyangan', 'YosSudarso','ukdw', 'Sudirman1', 'Sudirman2', 'tugu','Samirono', 'CondongCatur', 'RRU', 'Monjali', 'malioboro')

b2 = ('RRU', 'CondongCatur', 'Samirono', 'Sudirman2', 'YosSudarso', 'JantiBawah','Katamso2',  'MandalaKrida', 'SGM', 'kusumanegara', 'GedongKuning', 'Senopati', 'AhmadYani', 'KHADahlan2', 'Ngabean', 'KHADahlan2', 'Samsat', 'Monjali')    

a3 = ('Giwangan', 'Tegalgendu','janti', 'AdiSucipto', 'Maguwoharjo', 'CondongCatur', 'RRU', 'KopmaUGM', 'Samsat', 'Malioboro', 'Ngabean')

b3 = ('Giwangan', 'Tegalgendu', 'Ngabean', 'KHADahlan2', 'Samsat', 'Mangkubumi1', 'Sudirman2', 'KopmaUGM', 'RRU', 'CondongCatur', 'Maguwoharjo', 'AdiSucipto', 'janti', 'GedongKuning', 'Tegalgendu')

a4 = ('Giwangan', 'lempuyangan', 'KopmaUGM', 'UNY','KopmaUGM', 'UNY', 'gedungwanita', 'UIN', 'SGM', 'kusumanegara3')

b4 = ('Giwangan', 'kusumanegara1', 'SGM', 'kusumanegara4', 'UIN', 'Sudirman1', 'KopmaUGM', 'UNY', 'Sudirman2', 'lempuyangan', 'kusumanegara1', 'KHADahlan2')

a5 = ('RRU', 'Samirono', 'gedungwanita', 'RRU', 'CondongCatur', 'RRU', 'Monjali')

b5 = ('RRU', 'Monjali', 'RRU', 'CondongCatur', 'RRU', 'janti', 'gedungwanita', 'Samirono', 'YosSudarso', 'KopmaUGM', 'lempuyangan')

a6 = ('Ngabean', 'Tejoklusuman', 'RRU', 'lempuyangan')

b6 = ('Ngabean', 'Tejoklusuman', 'lempuyangan', 'RRU', 'MTHaryono2')

a7 = ('Giwangan', 'KHADahlan2', 'GedongKuning', 'janti', 'Babarsari', 'AtmaJaya', 'janti', 'KHADahlan2')

a8 = ('RRU', 'KopmaUGM', 'Malioboro', 'Ngabean', 'MTHaryono2', 'Ngabean', 'KHADahlan2', 'Malioboro')

a9 = ('Giwangan',  'Ngabean', 'Samsat', 'RRU', 'Samsat', 'Ngabean')

a10 = ('Giwangan', 'Tegalgendu', 'SGM', 'apmd1', 'Katamso2', 'Katamso1', 'Ngabean','Katamso1', 'Mangkubumi2', 'Samirono', 'JantiBawah', 'apmd2', 'SGM', 'Tegalgendu')

a11 = ('Giwangan', 'MTHaryono2', 'Ngabean', 'Samsat', 'Sudirman1', 'KopmaUGM', 'Samirono', 'CondongCatur','Samirono', 'Samirono', 'Sudirman2', 'Samsat', 'Ngabean', 'MTHaryono2')

Jalur = {"1A":a1, "1B":b1, "2A":a2, "2B":b2, "3A": a3, "3B":b3, "4A":a4, "4B":b4, "5A": a5, "5B":b5, "6A":a6, "6B":b6, "7":a7, "8":a8, "9":a9, "10":a10, "11":a11}

depature = input("Keberangkatan: ")
destination = input("Tujuan       : ")


departure = depature.lower()
destination = destination.lower()
dept = "".join(departure.split())
dest = "".join(destination.split())

def BusStop(x):
    for key, value in Halte.items():
        if x in value:
            return key

def iter(tup, x, y):
    x_index = tup.index(x)
    y_index = tup.index(y)
    if x_index<y_index:
        return y_index-x_index
    elif x_index>y_index:
        return x_index+y_index

def Find(x, y):
    start = BusStop(x)
    stop = BusStop(y)
    short = 100
    track = ""
    for key, value in Jalur.items():
        if (start in value) and (stop in value):
                count = iter(value, start, stop)
                if short>count:
                    short = count
                    track = key
                
    return [start, stop, track]

result= Find(dept, dest)

print("naik halte ", result[0])
print("turun halte ", result[1])
print("jalur ", result[2])

print(Find(dept, dest))
