


"""simple docstring"""



from __future__ import annotations

import json

import requests
from bsa import BeautifulSoup
from fake_useragent import UserAgent

UpperCAmelCase      		=			{'''UserAgent''': UserAgent().random}






def       lowerCamelCase					(a_						:int)     ->							str:
       lowercase		:int       							=				script.contents[0]
       lowercase		:List[str]       							=				json.loads(data[data.find('''{\"config\"''') : -1])
       return info["entry_data"]["ProfilePage"][0]["graphql"]["user"]
class 					__magic_name__		:






       def __init__(   self  :    Tuple  ,     snake_case__  :    List[Any]				):

              '''simple docstring'''






              lowercase		:Tuple       							=				f"""https://www.instagram.com/{username}/"""
              lowercase		:Optional[int]       							=				self.get_json()






       def  __snake_case						(   self  :    str				):

              '''simple docstring'''






              lowercase		:Any       							=				requests.get(self.url  ,     headers=snake_case__				).text
              lowercase		:int       							=				BeautifulSoup(snake_case__  ,     '''html.parser'''				).find_all('''script'''				)
              try:
                     return extract_user_profile(scripts[4]				)
              except (json.decoder.JSONDecodeError, KeyError):
                     return extract_user_profile(scripts[3]				)






       def __repr__(   self  :    str				):

              '''simple docstring'''






              return f"""{self.__class__.__name__}(\'{self.username}\')"""






       def __str__(   self  :    Any				):

              '''simple docstring'''






              return f"""{self.fullname} ({self.username}) is {self.biography}"""






       @property
       def  __snake_case						(   self  :    Any				):

              '''simple docstring'''






              return self.user_data["username"]






       @property
       def  __snake_case						(   self  :    str				):

              '''simple docstring'''






              return self.user_data["full_name"]






       @property
       def  __snake_case						(   self  :    Dict				):

              '''simple docstring'''






              return self.user_data["biography"]






       @property
       def  __snake_case						(   self  :    List[Any]				):

              '''simple docstring'''






              return self.user_data["business_email"]






       @property
       def  __snake_case						(   self  :    Any				):

              '''simple docstring'''






              return self.user_data["external_url"]






       @property
       def  __snake_case						(   self  :    Optional[int]				):

              '''simple docstring'''






              return self.user_data["edge_followed_by"]["count"]






       @property
       def  __snake_case						(   self  :    str				):

              '''simple docstring'''






              return self.user_data["edge_follow"]["count"]






       @property
       def  __snake_case						(   self  :    Dict				):

              '''simple docstring'''






              return self.user_data["edge_owner_to_timeline_media"]["count"]






       @property
       def  __snake_case						(   self  :    str				):

              '''simple docstring'''






              return self.user_data["profile_pic_url_hd"]






       @property
       def  __snake_case						(   self  :    Optional[Any]				):

              '''simple docstring'''






              return self.user_data["is_verified"]







       @property
       def  __snake_case						(   self  :    List[Any]				):

              '''simple docstring'''






              return self.user_data["is_private"]






def       lowerCamelCase					(a_						:Tuple = "github")     ->							Any:
       import os

       if os.environ.get('''CI'''):
              return  # test failing on GitHub Actions
       lowercase		:Tuple       							=				InstagramUser(a_)
       assert instagram_user.user_data
       assert isinstance(instagram_user.user_data				,				a_)
       assert instagram_user.username == username
       if username != "github":
              return
       assert instagram_user.fullname == "GitHub"
       assert instagram_user.biography == "Built for developers."
       assert instagram_user.number_of_posts > 150
       assert instagram_user.number_of_followers > 12_0000
       assert instagram_user.number_of_followings > 15
       assert instagram_user.email == "support@github.com"
       assert instagram_user.website == "https://github.com/readme"
       assert instagram_user.profile_picture_url.startswith('''https://instagram.''')
       assert instagram_user.is_verified is True
       assert instagram_user.is_private is False


if __name__ == "__main__":
 import doctest

 doctest.testmod()
 UpperCAmelCase      		=			InstagramUser('''github''')
 print(instagram_user)
 print(F"""{instagram_user.number_of_posts = }""")
 print(F"""{instagram_user.number_of_followers = }""")
 print(F"""{instagram_user.number_of_followings = }""")
 print(F"""{instagram_user.email = }""")
 print(F"""{instagram_user.website = }""")
 print(F"""{instagram_user.profile_picture_url = }""")
 print(F"""{instagram_user.is_verified = }""")
 print(F"""{instagram_user.is_private = }""")





"""simple docstring"""



import argparse
import copy






def       lowerCamelCase					(a_						:Union[str, Any])     ->							Tuple:
       lowercase		:Dict       							=				{}

       with open(a_) as f:
              for line in f:
                     if line.split()[0] not in dict_of_neighbours:
                            lowercase		:List[str]       							=				[]
                            _list.append([line.split()[1], line.split()[2]])
                            lowercase		:Any       							=				_list
                     else:
                            dict_of_neighbours[line.split()[0]].append(
                                [line.split()[1], line.split()[2]])
                     if line.split()[1] not in dict_of_neighbours:
                            lowercase		:List[Any]       							=				[]
                            _list.append([line.split()[0], line.split()[2]])
                            lowercase		:Dict       							=				_list
                     else:
                            dict_of_neighbours[line.split()[1]].append(
                                [line.split()[0], line.split()[2]])

       return dict_of_neighbours






def       lowerCamelCase					(a_						:Any				,				a_						:Dict)     ->							Any:

       with open(a_) as f:
              lowercase		:Any       							=				f.read(1)
       lowercase		:Any       							=				start_node

       lowercase		:Any       							=				[]

       lowercase		:Union[str, Any]       							=				start_node

       lowercase		:int       							=				0
       while visiting not in first_solution:
              lowercase		:int       							=				1_0000
              for k in dict_of_neighbours[visiting]:
                     if int(k[1]) < int(a_) and k[0] not in first_solution:
                            lowercase		:str       							=				k[1]
                            lowercase		:str       							=				k[0]

              first_solution.append(a_)
              lowercase		:int       							=				distance_of_first_solution + int(a_)
              lowercase		:Dict       							=				best_node

       first_solution.append(a_)

       lowercase		:int       							=				0
       for k in dict_of_neighbours[first_solution[-2]]:
              if k[0] == start_node:
                     break
              position += 1

       lowercase		:List[str]       							=				(
           distance_of_first_solution
           + int(dict_of_neighbours[first_solution[-2]][position][1])
           - 1_0000
       )
       return first_solution, distance_of_first_solution






def       lowerCamelCase					(a_						:List[str]				,				a_						:str)     ->							str:
       lowercase		:Any       							=				[]

       for n in solution[1:-1]:
              lowercase		:int       							=				solution.index(a_)
              for kn in solution[1:-1]:
                     lowercase		:Union[str, Any]       							=				solution.index(a_)
                     if n == kn:
                            continue

                     lowercase		:int       							=				copy.deepcopy(a_)
                     lowercase		:str       							=				kn
                     lowercase		:List[Any]       							=				n

                     lowercase		:int       							=				0

                     for k in _tmp[:-1]:
                            lowercase		:Tuple       							=				_tmp[_tmp.index(a_) + 1]
                            for i in dict_of_neighbours[k]:
                                   if i[0] == next_node:
                                          lowercase		:Tuple       							=				distance + int(i[1])
                     _tmp.append(a_)

                     if _tmp not in neighborhood_of_solution:
                            neighborhood_of_solution.append(_tmp)

       lowercase		:Dict       							=				len(neighborhood_of_solution[0]) - 1

       neighborhood_of_solution.sort(key=lambda a_: x[index_of_last_item_in_the_list])
       return neighborhood_of_solution






def       lowerCamelCase					(a_						:int				,				a_						:Optional[int]				,				a_						:List[Any]				,				a_						:Any				,				a_						:Optional[Any])     ->							List[Any]:
       lowercase		:Union[str, Any]       							=				1
       lowercase		:str       							=				first_solution
       lowercase		:int       							=				[]
       lowercase		:int       							=				distance_of_first_solution
       lowercase		:List[str]       							=				solution

       while count <= iters:
              lowercase		:Optional[Any]       							=				find_neighborhood(a_				,				a_)
              lowercase		:Any       							=				0
              lowercase		:Optional[Any]       							=				neighborhood[index_of_best_solution]
              lowercase		:int       							=				len(a_) - 1

              lowercase		:Dict       							=				False
              while not found:
                     lowercase		:List[str]       							=				0
                     while i < len(a_):
                            if best_solution[i] != solution[i]:
                                   lowercase		:Tuple       							=				best_solution[i]
                                   lowercase		:Tuple       							=				solution[i]
                                   break
                            lowercase		:List[str]       							=				i + 1

                     if [first_exchange_node, second_exchange_node] not in tabu_list and [
                         second_exchange_node,
                         first_exchange_node,
                     ] not in tabu_list:
                            tabu_list.append([first_exchange_node, second_exchange_node])
                            lowercase		:Tuple       							=				True
                            lowercase		:Optional[int]       							=				best_solution[:-1]
                            lowercase		:Any       							=				neighborhood[index_of_best_solution][best_cost_index]
                            if cost < best_cost:
                                   lowercase		:Union[str, Any]       							=				cost
                                   lowercase		:Optional[Any]       							=				solution
                     else:
                            lowercase		:Dict       							=				index_of_best_solution + 1
                            lowercase		:int       							=				neighborhood[index_of_best_solution]

              if len(a_) >= size:
                     tabu_list.pop(0)

              lowercase		:int       							=				count + 1

       return best_solution_ever, best_cost






def       lowerCamelCase					(a_						:Tuple=None)     ->							Any:
       lowercase		:Tuple       							=				generate_neighbours(args.File)

       lowercase							,  lowercase		:List[str]       							=				generate_first_solution(
           args.File				,				a_)

       lowercase							,  lowercase		:Union[str, Any]       							=				tabu_search(
           a_				,				a_				,				a_				,				args.Iterations				,				args.Size				,				)

       print(F"""Best solution: {best_sol}, with total distance: {best_cost}.""")


if __name__ == "__main__":
 UpperCAmelCase      		=			argparse.ArgumentParser(description='''Tabu Search''')
 parser.add_argument(
     '''-f''',
     '''--File''',
     type=str,
     help='''Path to the file containing the data''',
     required=True,
 )
 parser.add_argument(
     '''-i''',
     '''--Iterations''',
     type=int,
     help='''How many iterations the algorithm should perform''',
     required=True,
 )
 parser.add_argument(
     '''-s''', '''--Size''', type=int, help='''Size of the tabu list''', required=True
 )

 # Pass the arguments to main method
 main(parser.parse_args())

