Given name last name objects find the person with shortest name.
names = [{'name': 'huseyin', 'last_name': 'yilmaz'}, {'name': 'sila', 'last_name': 'yilmaz'}] get_shortest(names) >>> {'name': 'sila', 'last_name': 'yilmaz'}
Given dog owner pairs return owner-> dogs pairs
get_dogs({'tommy': 'huseyin', 'oyuncu': 'huseyin', 'kara': 'sila'}) >>> {'huseyin': ['tommy', 'oyuncu'], 'sila': ['kara']}
Given list of dog profiles. write a function that find out which dog needs a spesific shots:
dogs = [{'name': 'tommy': , 'shots': ['a','c']}, {'name': 'oyuncu', 'shots': ['a','b']}, {'name': 'kara', 'shots': ['b','c']}] find_shots(dogs, 'a') -> ['kara'] find_shots(dogs, 'b') -> ['tommy'] find_shots(dogs, 'c') -> ['oyuncu']
remove element at the given index from the list. (return a new list.)
list_remove_idx(['a', 'b', 'c', 'd'], 2) -> ['a', 'b', 'd'] list_remove_idx(['a', 'b', 'c', 'd'], 5) -> ['a', 'b', 'c', 'd']
remove all instances of given element from list.
list_remove_idx(['a', 'b', 'c', 'd', 'a'], 'a') -> ['b', 'c', 'd'] list_remove_idx(['a', 'b', 'c', 'd', 'a'], 'e') -> ['a', 'b', 'c', 'd', 'a']
insert given element on given index. After operation is done, given element has to be on given index.
list_insert_idx(['a', 'b', 'c', 'd'], 'x', 2) -> ['a', 'b', 'x', 'c', 'd']
return the index of an element from given list. if element does not exist in the list return None
find_element(['a', 'b', 'c', 'd'], 'c') -> 2 find_element(['a', 'b', 'c', 'd'], 'd') -> 3 find_element(['a', 'b', 'c', 'd'], 'b') -> 1 find_element(['a', 'b', 'c', 'd'], 'z') -> None
return number of even numbers in a list
even_count([1,2,3,4]) -> 2 even_count([2,3,4,5,6]) -> 3 even_count([2]) -> 1
return true if sum of all elements in a list is positive
even_count([1,2, -4]) -> False even_count([2,3,-3]) -> True even_count([0]) -> False
Add index of the list to values and return new list.
>>> add_distance([5,4,3,9]) [5+0, 4+1, 3+2, 9+3] [5, 5, 5, 12]
Reverse a given list:
>>> rev([1,2,3]) [3,2,1]
get a list and return all element tuples that has sum of 0
>>> two_sum([1,2,3,4,5, -3 , -5]) [(3,-3), (5, -5)]
Write a program that outputs the string representation of numbers from 1 to n.
But for multiples of three it should output “Fizz” instead of the number and for the multiples of five output “Buzz”. For numbers which are multiples of both three and five output “FizzBuzz”.
n = 15, Return: [ "1", "2", "Fizz", "4", "Buzz", "Fizz", "7", "8", "Fizz", "Buzz", "11", "Fizz", "13", "14", "FizzBuzz" ]
You’re given strings J representing the types of stones that are jewels, and S representing the stones you have. Each character in S is a type of stone you have. You want to know how many of the stones you have are also jewels. The letters in J are guaranteed distinct, and all characters in J and S are letters. Letters are case sensitive, so “a” is considered a different type of stone from “A”.
Input: J = "aA", S = "aAAbbbb" Output: 3
Input: J = "z", S = "ZZ" Output: 0
- S and J will consist of letters and have length at most 50.
- The characters in J are distinct.
Initially, there is a Robot at position (0, 0). Given a sequence of its moves, judge if this robot makes a circle, which means it moves back to the original place. The move sequence is represented by a string. And each move is represent by a character. The valid robot moves are R (Right), L (Left), U (Up) and D (down). The output should be true or false representing whether the robot makes a circle.
Input: "UD" Output: true
Input: "LL" Output: false