0

Do if u can

if a user gives an input of characters then u have to find a maximum no forming in it for ex input °-;℅&72^¢62;*:^£℅ output highest no is 72 2) input -#-6#-2Π¢°`÷°¢i output highest no -2 At least try and keep posting... let us see who will make a best one

12th Jan 2018, 1:44 PM
Arun
7 Answers
+ 5
# Python solution (updated to handle negative numbers): import re inp1 = "°-;℅&72^¢62;*:^£℅" inp2 = "-#-6#-2Π¢°`÷°¢i" rgxp = r"-?\d+" def numbers(txt): num = re.findall(rgxp,txt) num = [int(x) for x in num] return num print(max(numbers(inp1))) print(max(numbers(inp2)))
12th Jan 2018, 4:20 PM
visph
visph - avatar
+ 4
12th Jan 2018, 2:37 PM
Dev
Dev - avatar
+ 2
# Second example shouldn't be 6 rather than 2? # Python solution: import re inp1 = "°-;℅&72^¢62;*:^£℅" inp2 = "-#-6#-2Π¢°`÷°¢i" rgxp = r"\d+" def numbers(txt): num = re.findall(rgxp,txt) num = [int(x) for x in num] return num print(max(numbers(inp1))) print(max(numbers(inp2)))
12th Jan 2018, 2:32 PM
visph
visph - avatar
+ 2
Oh: I doesn't understood that you want negative numbers too ^^ Just use: rgxp = r"-?\d+" instead the previous one ;)
12th Jan 2018, 4:16 PM
visph
visph - avatar
+ 2
full that i can run i am not good at Python now!!
12th Jan 2018, 5:46 PM
Arun
+ 2
Just copy-paste the code and run it ^^
12th Jan 2018, 5:48 PM
visph
visph - avatar
0
no the answer should be -2 only
12th Jan 2018, 4:12 PM
Arun