PY
py
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
#sscanf challenge
#by baptiste prunier
#input format : 2 lines, s and p such as described bellow
"""
*DAILY CHALLENGE* : Write a sscanf like function.
The function gets a string s and a string p (pattern) and returns an array of variables.
The pattern can contain:
- %d for integer AND double
- %s for string
- %c for character
- any normal asci-char
example 1:
p = "%c'am %d"
s = "I'am 25"
result = sscanf(s,p) = ['I',25]
example 2:
p = "good %s!"
s = "good night!"
result = sscanf(s,p) = ["night"]
info:
- If s doesn't match p -> return an empty array
- If you can't return arrays with different types store the values as strings and return a string array!
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run