Lewis University SP23-CPSC-46000-LT1-Programming Languages
Programming-Assignment-2
Write a Python program to display a string’s index 0, 1, 2, 6, 7, 8, 12, 13, 14, 18, 19, 20, … (3 on and 3 off pattern) location characters for any string given. Sample Input String: “abcdefghijklmnopqrstuvwxyz”
Sample Output : abcghimnostuyz
Write a Python program to find out all index locations that has a certain pattern a string. (return a list, return [] if no such pattern in the string.)
Sample String : “abaaababbbbaaabbabababababbbaaaaabababababbbbb”
Pattern: “abb”
Sample Output :
[6, 13, 24, 40]
Check if an expression is balanced by its parentheses or not. Sample expression: ((a+b)
Sample Output: False
Sample expression: (((a+b)+c)+d)+e
Sample Output: True
Write a program to print out tower(n), Sample Output:
tower(1)
/\
**
**
tower(2)
/\
**
**
/ \
* *
* *
tower(3)
/\
**
**
/ \
* *
* *
/ \
* *
* *
Given a list of number from 1 to N. The list has only one missing number. (within 1 to N). Please find out which number is missing. (Sorting not allowed. O(n) algorithm required) Sample Input Sequence: [3, 5, 2, 1] # missing 4
Sample Output: 4