Day 13 (11.MAY.19)
Programs:
Programs:
1.Define a function to convert a binary number to the corresponding decimal number
- binaryToDecimal(1101) -> 12
- binaryToDecimal(1010) -> 10
- binaryToDecimal(111000) -> 56
2.Define a function to convert a decimal number to the corresponding binary number
- decimalToBinary(15) -> 1111
- decimalToBinary(1) -> 1
3.Design a Python script to determine the difference in date for given two dates in YYYY:MM:DD format(0 <= YYYY <= 9999, 1 <= MM <= 12, 1 <= DD <= 31) following the leap year rules. Return the total number of days existing between the two dates.
- dateDifference('2019:05:10', '2019:05:01') -> 9
- dateDifference('0003:03:03', '0003:06:06') -> 95
4.Define a function to print the sequence of spiral pattern elements for a given N x N matrix
- spiralPattern([[1,2,3], [4,5,6], [7,8,9]]) -> 1 2 3 6 9 8 7 4 5
5.Count the number of strings present in the given string
- (StringCount("abccddccc", "cc")) -->2
- (StringCount("1234567891122334455", "3")) -->3
- (StringCount('str','substr')) --> 0
- (StringCount('aaaaaaa', 'aaa')) -->2
6.Define a function to merge the characters of two strings alternatively. The remaining characters of the longer string are printed in the same order at the end.
- mergeString('abcd', 'absd',[]) -> 'aabbcsdd'
- mergeString('abc', '123456',[]) -> 'a1b2c3'
- mergeString('0', '123456',[]) -> 'a102'
All the above problems are solved in Python using Jupyter Notebook and can be accessed here.
All the above problems are solved in Python using Jupyter Notebook and can be accessed here.