
from timeit import timeit

__lowerCAmelCase					:			Tuple			      =		{
    "MALAYALAM": True,
    "String": False,
    "rotor": True,
    "level": True,
    "A": True,
    "BB": True,
    "ABC": False,
    "amanaplanacanalpanama": True,  # "a man a plan a canal panama"
}
# Ensure our test data is valid
assert all((key == key[::-1]) is value for key, value in test_data.items())


def     UpperCAmelCase_  (						__lowerCAmelCase	) ->						bool:
    __lowercase		:			Dict	    =       0
    __lowercase		:			str	    =       len(__lowerCAmelCase	) - 1
    while start_i < end_i:
        if s[start_i] == s[end_i]:
            start_i += 1
            end_i -= 1
        else:
            return False
    return True


def     UpperCAmelCase_  (						__lowerCAmelCase	) ->						bool:
    __lowercase		:			int	    =       len(__lowerCAmelCase	) // 2
    __lowercase		:			int	    =       len(__lowerCAmelCase	)

    # We need to traverse till half of the length of string
    # as we can get access of the i'th last element from
    # i'th index.
    # eg: [0,1,2,3,4,5] => 4th index can be accessed
    # with the help of 1st index (i==n-i-1)
    # where n is length of string
    return all(s[i] == s[n - i - 1] for i in range(__lowerCAmelCase	)	)


def     UpperCAmelCase_  (						__lowerCAmelCase	) ->						bool:
    if len(__lowerCAmelCase	) <= 2:
        return True
    if s[0] == s[len(__lowerCAmelCase	) - 1]:
        return is_palindrome_recursive(s[1:-1]	)
    else:
        return False


def     UpperCAmelCase_  (						__lowerCAmelCase	) ->						bool:
    return s == s[::-1]


def     UpperCAmelCase_  (						__lowerCAmelCase	) ->						None:
    __lowercase		:			Dict	    =       F'all({name}(key) is value for key, value in test_data.items())'
    __lowercase		:			Optional[int]	    =       F'from __main__ import test_data, {name}'
    __lowercase		:			Optional[int]	    =       500_000
    __lowercase		:			str	    =       timeit(stmt=__lowerCAmelCase	,					setup=__lowerCAmelCase	,					number=__lowerCAmelCase	)
    print(F'{name:<35} finished {number:,} runs in {result:.5f} seconds'	)


if __name__ == "__main__":
 for key, value in test_data.items():
  assert is_palindrome(key) is is_palindrome_recursive(key)
  assert is_palindrome(key) is is_palindrome_slice(key)
  print(F'{key:21} {value}')
 print("a man a plan a canal panama")

 # finished 500,000 runs in 0.46793 seconds
 benchmark_function("is_palindrome_slice")
 # finished 500,000 runs in 0.85234 seconds
 benchmark_function("is_palindrome")
 # finished 500,000 runs in 1.32028 seconds
 benchmark_function("is_palindrome_recursive")
 # finished 500,000 runs in 2.08679 seconds
 benchmark_function("is_palindrome_traversal")




import csv

import tweepy

# Twitter API credentials
__lowerCAmelCase					:			str			      =		""
__lowerCAmelCase					:			Any			      =		""
__lowerCAmelCase					:			Any			      =		""
__lowerCAmelCase					:			Optional[int]			      =		""


def     UpperCAmelCase_  (						__lowerCAmelCase	) ->						None:
    # authorize twitter, initialize tweepy
    __lowercase		:			List[Any]	    =       tweepy.OAuthHandler(__lowerCAmelCase	,					__lowerCAmelCase	)
    auth.set_access_token(__lowerCAmelCase	,					__lowerCAmelCase	)
    __lowercase		:			str	    =       tweepy.API(__lowerCAmelCase	)

    # initialize a list to hold all the tweepy Tweets
    __lowercase		:			Union[str, Any]	    =       []

    # make initial request for most recent tweets (200 is the maximum allowed count)
    __lowercase		:			List[Any]	    =       api.user_timeline(screen_name=__lowerCAmelCase	,					count=200	)

    # save most recent tweets
    alltweets.extend(__lowerCAmelCase	)

    # save the id of the oldest tweet less one
    __lowercase		:			Any	    =       alltweets[-1].id - 1

    # keep grabbing tweets until there are no tweets left to grab
    while len(__lowerCAmelCase	) > 0:
        print(F'getting tweets before {oldest}'	)

        # all subsequent requests use the max_id param to prevent duplicates
        __lowercase		:			Tuple	    =       api.user_timeline(
            screen_name=__lowerCAmelCase	,					count=200	,					max_id=__lowerCAmelCase	)

        # save most recent tweets
        alltweets.extend(__lowerCAmelCase	)

        # update the id of the oldest tweet less one
        __lowercase		:			Any	    =       alltweets[-1].id - 1

        print(F'...{len(__lowerCAmelCase	)} tweets downloaded so far'	)

    # transform the tweepy tweets into a 2D array that will populate the csv
    __lowercase		:			Optional[int]	    =       [[tweet.id_str, tweet.created_at, tweet.text] for tweet in alltweets]

    # write the csv
    with open(F'new_{screen_name}_tweets.csv'	,					'''w'''	) as f:
        __lowercase		:			int	    =       csv.writer(__lowerCAmelCase	)
        writer.writerow(['''id''', '''created_at''', '''text''']	)
        writer.writerows(__lowerCAmelCase	)


if __name__ == "__main__":
 # pass in the username of the account you want to download
 get_all_tweets("FirePing32")


