Ejemplo n.º 1
0
    def test_short_case(self):
        ticket_1 = Ticket("NONE", "PDX")
        ticket_2 = Ticket("PDX", "DCA")
        ticket_3 = Ticket("DCA", "NONE")

        tickets = [ticket_1, ticket_2, ticket_3]

        expected = ["PDX", "DCA"]
        result = reconstruct_trip(tickets, 3)

        self.assertTrue(expected, result)
Ejemplo n.º 2
0
    def test_short_case(self):
        ticket_1 = Ticket("NONE", "PDX")
        ticket_2 = Ticket("PDX", "DCA")
        ticket_3 = Ticket("DCA", "NONE")

        tickets = [ticket_1, ticket_2, ticket_3]

        expected = ["PDX", "DCA", "NONE"]
        result = reconstruct_trip(tickets, 3)
        print("EXPECTED", expected)
        print("RESULT", expected)
        self.assertTrue(expected == result)
    def test_long_case(self):
        ticket_1 = Ticket("PIT", "ORD")
        ticket_2 = Ticket("XNA", "SAP")
        ticket_3 = Ticket("SFO", "BHM")
        ticket_4 = Ticket("FLG", "XNA")
        ticket_5 = Ticket("NONE", "LAX")
        ticket_6 = Ticket("LAX", "SFO")
        ticket_7 = Ticket("SAP", "SLC")
        ticket_8 = Ticket("ORD", "NONE")
        ticket_9 = Ticket("SLC", "PIT")
        ticket_10 = Ticket("BHM", "FLG")

        tickets = [ticket_1, ticket_2, ticket_3, ticket_4, ticket_5,
                   ticket_6, ticket_7, ticket_8, ticket_9, ticket_10]

        expected = ["LAX", "SFO", "BHM", "FLG", "XNA", "SAP",
                    "SLC", "PIT", "ORD", "NONE"]
        result = reconstruct_trip(tickets, 10)
Ejemplo n.º 4
0
from ex2 import Ticket

ticket_1 = Ticket("NONE", "PDX")
ticket_2 = Ticket("PDX", "DCA")
ticket_3 = Ticket("DCA", "NONE")
tickets = [ticket_1, ticket_2, ticket_3]

# source / destination

# dictionary = {}
# for i in range(3):
#     dictionary[tickets[i].source] = i

# print(dictionary)


def reconstruct_trip(tickets, length):
    """
    YOUR CODE HERE
    """
    # Your code here
    source = {}
    # destination = {}
    # Slist = []
    # Dlist = []

    for t in range(length):
        source[tickets[t].source] = tickets[t].destination
        # destination[tickets[t].destination] = t
        # Slist[t] = tickets[t].source
        # Dlist[t] = tickets[t].destination