Question

In: Computer Science

Python language!!!!! №1 The translation from the Berland language into the Birland language is not an...

Python language!!!!!

№1

The translation from the Berland language into the Birland language is not an easy task. Those languages are very similar: a berlandish word differs from a birlandish word with the same meaning a little: it is spelled (and pronounced) reversely. For example, a Berlandish word code corresponds to a Birlandish word edoc. However, it's easy to make a mistake during the «translation». Vasya translated word s from Berlandish into Birlandish as t. Help him: find out if he translated the word correctly.

Input

The first line contains word s, the second line contains word t. The words consist of lowercase Latin letters. The input data do not consist unnecessary spaces. The words are not empty and their lengths do not exceed 100 symbols.

Output

If the word t is a word s, written reversely, print YES, otherwise print NO.

Examples

input

code
edoc

output

YES

№2

Anton likes to play chess, and so does his friend Danik.

Once they have played n games in a row. For each game it's known who was the winner — Anton or Danik. None of the games ended with a tie.

Now Anton wonders, who won more games, he or Danik? Help him determine this.

Input

The first line of the input contains a single integer n (1 ≤ n ≤ 100 000) — the number of games played.

The second line contains a string s, consisting of n uppercase English letters 'A' and 'D' — the outcome of each of the games. The i-th character of the string is equal to 'A' if the Anton won the i-th game and 'D' if Danik won the i-th game.

Output

If Anton won more games than Danik, print "Anton" (without quotes) in the only line of the output.

If Danik won more games than Anton, print "Danik" (without quotes) in the only line of the output.

If Anton and Danik won the same number of games, print "Friendship" (without quotes).

Examples

input

6
ADAAAA

output

Anton

№3

You can not just take the file and send it. When Polycarp trying to send a file in the social network "Codehorses", he encountered an unexpected problem. If the name of the file contains three or more "x" (lowercase Latin letters "x") in a row, the system considers that the file content does not correspond to the social network topic. In this case, the file is not sent and an error message is displayed.

Determine the minimum number of characters to remove from the file name so after that the name does not contain "xxx" as a substring. Print 0 if the file name does not initially contain a forbidden substring "xxx".

You can delete characters in arbitrary positions (not necessarily consecutive). If you delete a character, then the length of a string is reduced by 11. For example, if you delete the character in the position 22 from the string "exxxii", then the resulting string is "exxii".

Input

The first line contains integer nn (3≤n≤100)(3≤n≤100) — the length of the file name.

The second line contains a string of length nn consisting of lowercase Latin letters only — the file name.

Output

Print the minimum number of characters to remove from the file name so after that the name does not contain "xxx" as a substring. If initially the file name dost not contain a forbidden substring "xxx", print 0.

Examples

input

6
xxxiii

output

1

Solutions

Expert Solution

======== NO1 =========

def translation(string1,string2):

    if string1 == string2[::-1]: # reverse the second string and check same are not

        return 1

    else:

        return 0

if __name__ == "__main__":

    Berland = input()

    Birland = input()

    if len(Berland) < 1 or len(Birland) < 1 or len(Birland) > 100 or len(Berland) > 100: # if string is not valid

        print("Invalid Input")

    else:

        if translation(Berland,Birland):   

            print("YES")

        else:

            print("NO")

    

======= NO2 ========

def who_won_more_games(string1):   

if string1.count('A') > string1.count('D'): # Count the number of A and D and return 1 if greater else 2

        return 1

    elif string1.count('A') < string1.count('D'):

        return 2

    else:

        return 0

if __name__ == "__main__":

    number_of_games  = int(input())

    s = input()

    if len(s) < 1 or len(s) > 1000000:

        print("Invalid Input")

    else:

s.upper() # Convert to upper letter   

        if who_won_more_games(s) == 1: # If return value is 1 print Anton or if it is 2 print Danik else Friendship

            print("Anton")

        elif who_won_more_games(s) == 2:

            print("Danik")

        else:

            print("Friendship")

    

======= NO3 ======

if __name__ == "__main__":

    number_of_games  = int(input())

    s = input()

    if len(s) < 1 or len(s) > 1000000:

        print("Invalid Input")

    else:

        result,s1 = 0,0

        for i in range(len(s)):

            if s[i] ==  'x':

                s1 += 1

                if s1 > 2: # Check if consecutive 'x' are greater than 2 then add 1 to result

                    result += 1

            else:

                s1 = 0

        print(result)


Related Solutions

Python Language Only! Python Language Only! Python Language Only! Python 3 is used. When doing this...
Python Language Only! Python Language Only! Python Language Only! Python 3 is used. When doing this try to use a level one skill python, like as if you just learned this don't use anything advanced if you can please. If not then do it as you can. Assume you have a file on your disk named floatnumbers.txt containing float numbers. Write a Python code that reads all the numbers in the file and display their average. Your code must handle...
In the C programming language, implement the translation from regular English to Euroglish. If the letters...
In the C programming language, implement the translation from regular English to Euroglish. If the letters were uppercase, keep them uppercase in the replacement. 1. Remove one“e”from the end of words that are more than three characters long, if they happen to end in “e”. 2. Change all double letters to a single letter (including double spaces). Do not remove double line spacing (i.e. “\n”). 3. When a word ends in “ed”, change that to just “d”. Text: The cat...
Python Language: Similar to Project 3, write a program that loops a number from 1 to...
Python Language: Similar to Project 3, write a program that loops a number from 1 to 10 thousand and keeps updating a count variable according to these rules: if the number is divisible by n1, increase count by 1 if the number is divisible by n2, increase count by 2 if the number is divisible by n3, increase count by 3 if none of the above conditions match for the number, increase count by the number. Before the loop begins,...
Add the result envidented by the python compiler. use python language. 1(a) A Give the output...
Add the result envidented by the python compiler. use python language. 1(a) A Give the output for the array([ 0, 1, 8, 27, 64, 125, 216, 343, 512, 729]) a. a[:6:2] = -1000 (ii) a[ : :-1] ) b. Display the values of 1D array using for loop?
 c. Write a code to print a 3D array?
 d. How to print the transpose of a 2D array?
 e Write a function to sort the array row and coloumn wise ?...
how to extract references and citing sentences from PDF in python language?
how to extract references and citing sentences from PDF in python language?
Solve the following question by using python language In range of 1-10000 if the numbers are...
Solve the following question by using python language In range of 1-10000 if the numbers are divisible by n1 increase count by 1 , if the number is divisible by n2 increase count by 2, and if the number are divisible by n3 increase the count by 3 if none of the above conditions match for the number, increase count by the number. n1=10 +17 n2=50 +21 n3=100 +9
language python use a functions and write a python of a computer with three power operations:...
language python use a functions and write a python of a computer with three power operations: power by two, power by three, and power by four. input a number and operation (^2,^3,or^4). output: the result of the power operation
Using python programming language, compare the four tasks. 1. For the following exercises you will be...
Using python programming language, compare the four tasks. 1. For the following exercises you will be writing a program that implements Euler’s method (pronounced ‘oy-ler’). It may be the case that you have not yet encountered Euler’s method in the course. Euler’s method can be found in Chapter 10.2 of your notes, which gives a good description of why this algorithm works. But for our purposes, we only need to know the algorithm itself - so there’s no need to...
1. Explain the transcription and translation mechanism of protein and the role of GTP in translation...
1. Explain the transcription and translation mechanism of protein and the role of GTP in translation process I want to know the answer of this question less than one page
(20 pts) Using your programming language of choice (from C++, Java, or Python) , also drawing...
(20 pts) Using your programming language of choice (from C++, Java, or Python) , also drawing on your experience from program 1, read an integer, n from keyboard (standard input). This integer represents the number of integers under consideration. After reading that initial integer in, read n integers in, and print the minimum and maximum of all the integers that are read in. Example: Input Output 7 1 5 3 6 9 22 2 Min: 1 Max: 22 C++ preferred
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT