Skip to content

Commit a181429

Browse files
authored
Update problem-3.mojo
1 parent 298f1e5 commit a181429

File tree

1 file changed

+17
-25
lines changed

1 file changed

+17
-25
lines changed

problem-3/problem-3.mojo

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,25 @@
11
from python import Python
22

3-
def makeGood():
4-
let py = Python.import_module("builtins")
5-
let enterword = py.input("Enter a string: ")
6-
s = enterword
7-
str1 = str(enterword)
8-
i = 0
9-
result_list = []
3+
def makeGood(s: String):
4+
py = Python.import_module("builtins")
5+
result = str("")
106

11-
while i < len(str1) - 1:
12-
if py.abs(ord(s[i]) - ord(s[i + 1])) == 32:
13-
i += 2
7+
i = 0
8+
while i < len(s):
9+
10+
if i < len(s) - 1 and py.abs(ord(s[i]) - ord(s[i + 1])) == 32:
11+
12+
i += 2
1413
else:
15-
py.result_list.append(s[i])
16-
i += 1
14+
15+
result = result + s[i]
16+
i += 1
1717

18-
if i == len(str1) - 1:
19-
py.result_list.append(s[-1])
18+
print(result)
2019

21-
#result = "".join(result_list)
22-
py.print(result_list)
23-
24-
# Example usage:
25-
26-
# Taking input from the user
2720
def main():
28-
makeGood()
29-
#let py = Python.import_module("builtins")
30-
##let s = py.input("Enter a string: ")
31-
#let input_string = str(input_string_py)
32-
#let result = makeGood(input_string)
21+
22+
input_str = "leEeetcode"
23+
makeGood(input_str)
24+
3325
#print("After making the string good:", result)

0 commit comments

Comments
 (0)