Skip to content

Commit 4f8ee06

Browse files
committed
First comparison between Mojo and Python
0 parents  commit 4f8ee06

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

problem-1/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Problem 1
2+
3+
Link:
4+
5+
## Benchmarks
6+
7+
CPU | Mem | Time

problem-1/problem-1.mojo

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from python import Python
2+
def lengthOfLastWord(enterword: String):
3+
let py = Python.import_module("builtins")
4+
count = 0
5+
for i in range(len(enterword)-1, -1, -1):
6+
if enterword[i] != " ":
7+
count += 1
8+
elif count > 0:
9+
break
10+
return count
11+
12+
# Taking input from the user
13+
def main():
14+
let py = Python.import_module("builtins")
15+
enterword = py.input("Enter a string: ")
16+
let result = lengthOfLastWord(enterword)
17+
18+
print("Length of the last word:")
19+
print(result)

problem-1/problem-1.py

Whitespace-only changes.

0 commit comments

Comments
 (0)