Upcoming technologies, programming, problem solving, coding, technology, mobile phones
About us
Get link
Facebook
X
Pinterest
Email
Other Apps
In this blog you will be able to learn python-programming language and problem solving. You can also find solutions for hackerrank problems, google coding problems.
1. Cab and Walk Arun is working in an office which is N blocks away from his house. He wants to minimize the time it takes him to the from his house to the office. He can either take the office cab or he can walk to the office. While walking Arun's velocity is V1 m/s and V2 m/s is the velocity of cab. But when he calls the cab it always starts from the office, covers N blocks, collects Arun and goes back to the office. The cab crosses a total distance of N meters when going from office to Arun's house and vice versa , whereas Arun covers a distance of √2*N while walking. Help Arun to decide whether he has to walk or to take the cab to save the time. Input format : A single line containing three integers N, V1 and V2 separated by space. Output format : Print "Walk" or "Cab" accordingly. Sample input 1 : 5 10 15 Sample output 1 : Cab Sample input 2 : 2 10 14 Sample output 2 : Walk Code : Output : 2. End - Sort Given a list A of ...
Solution for hackerRank problem Lists in python Problem Consider a list (list=[ ]). You can perform the following commands: Insert i e : integer at position. Print : Print the list. Remove e : Delete the first occurrence of integer. Append e : Insert integer at the end of the list. Sort : Sort the list. Pop : Remove the last element from the list. Reverse : Reverse the list. Initialize your list and read in the value of followed by lines of commands where each command will be of the types listed above. Iterate through each command in order and perform the corresponding operation on your list. Example N = 4 Append 1 Append 2 Insert 3 1 print Append 1 : Append to the list, .arr = [1] Append 2 : Append to the list, arr = [1, 2] Insert 3 1 : Insert 3 at index 1, arr = [1, 3, 2]. : Print the array. Output: [1, 3, 2] Input Format The first line contains an integer, n, denoting the number of command...
Solution for hackerRank problem Nested lists in python Problem : Given the names and grades for each student in a class of students, store them in a nested list and print the name(s) of any student(s) having the second-lowest grade. Note: If there are multiple students with the second lowest grade, order their names alphabetically and print each name on a new line. Example records=[ ["chi", 20.0], ["beta", 50.0], ["alpha", 50.0] The ordered list of scores is [20.0, 50.0], so the second lowest score is 50.0 . There are two students with that score: [" beta ", "alpha" ] . Ordered alphabetically, the names are printed as: alpha beta Input Format The first line contains an integer, N, the number of students. The 2N subsequent lines describe each student over 2 lines. - The first line contains a student's name. - The second line contains their grade. Constraints 2<=N<=5 There will always be one or more students having t...
Comments
Post a Comment