@mtf/

CC - Boreless Tourist

Python

No description

fork
loading
Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
from datetime import datetime

destinations = [
  "Paris, France",
  "Shanghai, China",
  "Los Angeles, USA",
  "So Paulo, Brazil",
  "Cairo, Egypt"
]
test_traveler = [
  'Erin Wilkes',
  'Shanghai, China',
  ['historical site', 'art']
]
attractions = [[] for x in destinations]

def get_destination_index(destination):
  return destinations.index(destination)

#print (get_destination_index("Los Angeles, USA"))
#print (get_destination_index("Paris, France"))
#print (get_destination_index("Hyderabad, India"))
def get_traveler_location(traveler):
  return get_destination_index(traveler[1])
test_destination_index = get_traveler_location(test_traveler)
#print (test_destination_index)
#print (attractions)
def add_attraction(destination, attraction):
  try:
    attractions[get_destination_index(destination)] += [attraction]
    return True
  except:
    return False
add_attraction("Los Angeles, USA", ['Venice Beach', ['beach']])
#print (attractions)
add_attraction("Paris, France", ["the Louvre", ["art", "museum"]])
add_attraction("Paris, France", ["Arc de Triomphe", ["historical site", "monument"]])
add_attraction("Shanghai, China", ["Yu Garden", ["garden", "historcical site"]])
add_attraction("Shanghai, China", ["Yuz Museum", ["art", "museum"]])
add_attraction("Shanghai, China", ["Oriental Pearl Tower", ["skyscraper", "viewing deck"]])
add_attraction("Los Angeles, USA", ["LACMA", ["art", "museum"]])
add_attraction("So Paulo, Brazil", ["So Paulo Zoo", ["zoo"]])
add_attraction("So Paulo, Brazil", ["Ptio do Colgio", ["historical site"]])
add_attraction("Cairo, Egypt", ["Pyramids of Giza", ["monument", "historical site"]])
add_attraction("Cairo, Egypt", ["Egyptian Museum", ["museum"]])
#print (attractions)
def find_attractions(destination, interests):
  destination_index = get_destination_index(destination)
  attractions_in_city = attractions[destination_index]
  attractions_with_interest = []
  for attraction in attractions_in_city:
    possible_attraction = attraction
    attraction_tags = attraction[1]
    for interest in interests:
      if interest in attraction_tags:
        attractions_with_interest.append(possible_attraction[0])
  return attractions_with_interest

la_arts = find_attractions("Los Angeles, USA", ['art'])
print (la_arts)

print (find_attractions("Shanghai, China", ['historical site']))
'''
  possible_attraction = [x for x in attractions_in_city]
  attraction_tags = [x[1] for x in possible_attraction]
  #print (possible_attraction)
  #print (attraction_tags)
  for i, x in enumerate(attraction_tags):
    if x in interests:
      attractions_with_interest += [attractions_in_city[i][0],possible_attraction[i]]
  return attractions_with_interest
'''
'''
def get_attractions_for_traveler(traveler):
  traveler_destination = traveler[1]
  traveler_interests = traveler[2]
  traveler_attractions = find_attractions(traveler_destination, traveler_interests)
  interests_string = "Hi " + traveler[0] + ", we think you'll like these places around " + traveler[1] + ": "
  n = len(traveler_attractions)
  m = n - 1
  for x in range(n):
    interests_string += '{}{}'.format(traveler_attractions[x], "." if x == m else ", ")
  return interests_string
  '''

def get_attractions_for_(traveler):
  name, destination, interests = traveler
  attractions = find_attractions(destination, interests)
  recommendations = "Hi " + name + ", we think you'll like these places around " + destination + ": "
  n = len(attractions)
  m = n - 1
  for x in range(n):
    recommendations += '{}{}'.format(attractions[x], "." if x == m else ", ")
  return recommendations
  '''
  for x in traveler_attractions:
    interests_string += '{}, '.format(x)
  interests_string += chr(8) + chr(8) + "."
  return interests_string
'''
def particulars(name, destination, *interests):
  #interests = list(interests)
  return list((name, destination, interests))
print (particulars('Dereck Smill', 'Paris, France', 'monument', 'art'))
print (get_attractions_for_(['Dereck Smill', 'Paris, France', ['monument']]))
#print (smills_france)
print (get_attractions_for_(test_traveler))
'''
traveler = {}
name = input("Name: ")
destination = input("Destination: ")
interests = input("Interests: ")
id = "{}{}".format(name.split()[1].lower(), datetime.now().microsecond)
traveler[id] = particulars(name, destination, interests)
print (traveler[id])
# ['Cris Cringle', 'Paris, France', ['monument, art']]
'''