-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathexercises.json
127 lines (127 loc) · 7.93 KB
/
exercises.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
{
"1": {
"exercise": "Write a function that displays the argument it receives surrounded by `'{` and `}'`. For example, if the argument is `5`, the function will print `'{5}'`.",
"e_file": "fstring_braces.py",
"exp_op": "'{5}'\n'{hello world}'\n'{[1, 2]}'\n"
},
"2": {
"exercise": "Write a function that returns:\n\n\u2022 `Good` for numbers divisible by 7\n\u2022 `Food` for numbers divisible by 6\n\u2022 `Universe` for numbers divisible by 42\n\u2022 `Oops` for all other numbers\n\nOnly one output is expected, with 'divisible by 42' taking precedence. This question is based on the popular FizzBuzz test for programmers.",
"e_file": "6by7.py",
"exp_op": "all tests passed\n"
},
"3": {
"exercise": "Check if two strings are the same irrespective of case. Assume that the strings can only have ASCII letters.",
"e_file": "str_comparison.py",
"exp_op": "all tests passed\n"
},
"4": {
"exercise": "Check if two strings are anagrams. Assume that the input strings can contain only English alphabets. Differences due to case should be ignored.",
"e_file": "str_same_letters.py",
"exp_op": "all tests passed\n"
},
"5": {
"exercise": "Write a function that adds two time strings of the format HH:MM:SS (hours, minutes, seconds). Assume that the input can be `0` to `99` for each of the three time components. The output format should be DD-HH:MM:SS where DD stands for number of days. The output should be normalized to not exceed `59` for minutes/seconds and `23` for hours.",
"e_file": "add_time_strings.py",
"exp_op": "all tests passed\n"
},
"6": {
"exercise": "Write a function that prints a styled version of the string argument it receives. Expected output is shown below inside a triple quoted string.",
"e_file": "string_styling.py",
"exp_op": "--------\n hi \n--------\n***********\n///hello///\n***********\n----------------------------\n good day \n----------------------------\n=-==-==-==-==-==-\n pomegranate \n=-==-==-==-==-==-\n:::::\n=fig=\n:::::\n"
},
"7": {
"exercise": "Return a list of integers from a given range (inclusive) which reads the same in reversed form in both binary and decimal formats. For example, `33` in decimal is `100001` in binary and both of these are palindromic. The function should accept two keyword arguments `start=1` and `stop=10000`.",
"e_file": "numeric_palindrome.py",
"exp_op": "all tests passed\n"
},
"8": {
"exercise": "Write a function that returns both the minimum and maximum values from an iterable input. Assume that there will be at least one element in the input. Do not use the built-in `min()` and `max()` functions.",
"e_file": "min_max_iter.py",
"exp_op": "all tests passed\n"
},
"9": {
"exercise": "Write a function that sums up zero or more numeric arguments passed to it. The function should also accept a default valued argument `initial` which should be added to the final total. For example, `sum_nums(3, -8)` should give `-5` and `sum_nums(1, 2, 3, 4, 5, initial=5)` should give `20`.",
"e_file": "sum_numbers.py",
"exp_op": "all tests passed\n"
},
"10": {
"exercise": "Write a function that returns the sum of product of corresponding elements of two sequences. For example, the result should be `44` for `(1, 3, 5)` and `(2, 4, 6)`.",
"e_file": "inner_product.py",
"exp_op": "all tests passed\n"
},
"11": {
"exercise": "Sort a sequence of numbers in such a way that the even numbers are all placed before the odd ones. The even and odd numbers should further be sorted in descending order.",
"e_file": "sort_even_odd.py",
"exp_op": "all tests passed\n"
},
"12": {
"exercise": "Write a function that returns a list of first occurrences of an element from a sequence without changing the order.",
"e_file": "first_occurrence.py",
"exp_op": "all tests passed\n"
},
"13": {
"exercise": "Write a function that checks whether an iterable has duplicate values or not. Assume that the iterable will not have any unhashable element.",
"e_file": "iterable_duplicates.py",
"exp_op": "all tests passed\n"
},
"14": {
"exercise": "Write a function that sorts a dictionary by value in ascending order.",
"e_file": "dictionary_sort.py",
"exp_op": "all tests passed\n"
},
"15": {
"exercise": "Write a function that returns a list of string slices as per the following rules:\n\n\u2022 return the input string as the only element if its length is less than 3 characters\n\u2022 otherwise, return slices that have 2 or more characters as shown below\n\nAssume that the input string will contain only English alphabets.",
"e_file": "string_slices.py",
"exp_op": "all tests passed\n"
},
"16": {
"exercise": "Square even numbers and cube odd numbers. For example, `[321, 1, -4, 0, 5, 2]` should give `[33076161, 1, 16, 0, 125, 4]` as the output.",
"e_file": "square_cube.py",
"exp_op": "all tests passed\n"
},
"17": {
"exercise": "Write a function that returns a list of words present in the input string. A word here is defined as a sequence of English alphabets.",
"e_file": "list_of_words.py",
"exp_op": "all tests passed\n"
},
"18": {
"exercise": "Write a function that checks if two words differ at most by a single character, irrespective of case. The length of both the words should be same and the characters should be in the same order for a positive match.",
"e_file": "character_diff.py",
"exp_op": "all tests passed\n"
},
"19": {
"exercise": "Write a function that checks if a word is in alphabetic order, irrespective of case. Order can be either ascending or descending. Write another function that uses the first function to check if all the words in a sentence are alphabetically ordered. Assume that the sentence can only have alphabets and whitespace characters.",
"e_file": "alphabetic_ordering.py",
"exp_op": "all tests passed\n"
},
"20": {
"exercise": "The file `nums.txt` (in the current working directory) contains a single column of integer and floating-point numbers. Calculate the sum of these numbers.",
"e_file": "sum_column.py",
"exp_op": "10485.14\n"
},
"21": {
"exercise": "Write a function that returns a set of longest words from a file passed to it. Assume that the input file can only have whitespace separated words. Also assume that the input file is small enough to fit within the available memory. If the input file doesn't have any alphabets, the return value should be an empty set.",
"e_file": "longest_words.py",
"exp_op": "all tests passed\n"
},
"22": {
"exercise": "Write a function that accepts a file argument and returns the sum of all integers present in the file. If the keyword argument `floating` (default `False`) is set to True, floating-point numbers should also be counted. Assume whitespace as the separator between numbers and other words in the input file. Only decimal format is allowed as a valid integer \u2014 Octal, Binary and Hexadecimal values shouldn't be counted. Scientific notation is valid for floating-point values.",
"e_file": "sum_file_numbers.py",
"exp_op": "all tests passed\n"
},
"23": {
"exercise": "Write a function that returns the maximum nested depth of curly braces in a string. For example, `'{{a+2}*{{b+{c*d}}+e*d}}'` should give `4`. Unbalanced or wrongly ordered braces like `'{a}*b{'` and `'}a+b{'` should return `-1`.",
"e_file": "count_nested_braces.py",
"exp_op": "all tests passed\n"
},
"24": {
"exercise": "The function `len_int()` should return the length of integer numbers. For non-integer inputs, it should raise an exception as shown below.",
"e_file": "int_length.py",
"exp_op": "all tests passed\n"
},
"25": {
"exercise": "Write a function that returns the product of numbers from an iterable. Empty sequence or non-numerical values should raise an exception as shown below.",
"e_file": "product_of_nums.py",
"exp_op": "all tests passed\n"
}
}