+ 5
[CHALLENGE]: Otimizing String by removing all 0,0 pairs and merging previous and next pairs into a new single one!
I added challenge body to pastebin, seems are too many characters in message body and SL doesn't accept it. Check it here: https://pastebin.com/50aGaJtb -------------------------------------------- This challenges was a problem that a faced a time and I loved solved it in JAVA then I'm sharing it with you all. All languages are welcome, anyway java is more apreciated. Good luck!
6 Réponses
+ 4
Python:
import re
string = "3/0,0,1+2-3,0,0/1+4"
regEx = re.compile(r'0,0')
answer = re.sub(regEx, "", string)
print(answer)
+ 3
Why even answer then?
+ 1
Look this example:
Input: -2,3/5,-4/6,0/0,0/-3,0/-5,-5/
Output: -2,3/5,-4/3,0/-5,-5/
The 0,0 group was removed and the previous and following groups was merged into a new one using the rules I described.
Other Example:
Input: a,b/0,0/c,d
Output: a+c,b+d/
Considering a,b,c,d as 1,2,3,4 respectively, we have:
Output: a+c,b+d/
Output: 1+3,2+4/
Output: 4,6/
This means that the sequence [4,6/] is equivalent to [1,2/0,0/3,4].
0
bro i can do this
but there is no use of this thing and i dont code useless things
0
ok i will send you the code in java by tommorrow
0
after read all your challenge i didnt get what you want to print ,it is bit confusing