File tree 6 files changed +35
-71
lines changed
6 files changed +35
-71
lines changed Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ for dir in *; do
9
9
cd " $dir "
10
10
echo " Benchmarking $dir "
11
11
$COMPILE
12
- $BENCH " ${COMMANDS[@]} "
12
+ $BENCH " ${COMMANDS[@]} "
13
13
cd ..
14
14
fi
15
15
done
Original file line number Diff line number Diff line change 1
- from python import Python
2
-
3
- def lengthOfLastWord (enterword : String):
4
-
5
- py = Python.import_module(" builtins" )
6
-
7
- count = 0
1
+ fn lengthOfLastWord (enterword : String):
2
+ var count : Int = 0
8
3
for i in range (len (enterword)- 1 , - 1 , - 1 ):
9
4
if enterword[i] != " " :
10
5
count += 1
11
6
elif count > 0 :
12
7
break
13
-
14
- print (" Length of the last word:" )
15
- print (count)
16
-
17
8
18
- def main ():
19
- input_string = " Hello World"
20
- lengthOfLastWord(input_string)
9
+ print (" Length of the last word:" , count)
21
10
22
11
12
+ fn main ():
13
+ var input_string = " Hello World"
14
+ lengthOfLastWord(input_string)
Original file line number Diff line number Diff line change 1
- from python import Python
1
+ fn checkRecord (attendance_record : String) -> Bool:
2
+ var attendance_record_str = attendance_record
2
3
3
- def checkRecord (attendance_record : String):
4
- py = Python.import_module(" builtins" )
5
- attendance_record_str = attendance_record
6
-
7
- absent_count = 0
8
- late_count = 0
4
+ var absent_count = 0
5
+ var late_count = 0
9
6
10
7
for i in range (len (attendance_record_str)):
11
-
8
+
12
9
if attendance_record_str[i] == ' A' :
13
10
absent_count += 1
14
11
late_count = 0
@@ -25,8 +22,5 @@ def checkRecord(attendance_record: String):
25
22
return True
26
23
27
24
28
- def main ():
29
- checkRecord(" PAALP" )
30
-
31
-
32
-
25
+ fn main ():
26
+ var value = checkRecord(" PAALP" )
Original file line number Diff line number Diff line change 1
- from python import Python
1
+ import math
2
2
3
- def makeGood (s : String):
4
- py = Python.import_module(" builtins" )
5
- result = str (" " )
3
+ fn makeGood (s : String):
4
+ var result = str (" " )
6
5
7
- i = 0
6
+ var i = 0
8
7
while i < len (s):
9
-
10
- if i < len (s) - 1 and py .abs(ord (s[i]) - ord (s[i + 1 ])) == 32 :
11
-
8
+
9
+ if i < len (s) - 1 and math .abs(ord (s[i]) - ord (s[i + 1 ])) == 32 :
10
+
12
11
i += 2
13
12
else :
14
-
13
+
15
14
result = result + s[i]
16
15
i += 1
17
16
18
17
print (result)
19
18
20
- def main ():
21
-
22
- input_str = " leEeetcode"
19
+ fn main ():
20
+ var input_str = " leEeetcode"
23
21
makeGood(input_str)
24
-
22
+
25
23
# print("After making the string good:", result)
Original file line number Diff line number Diff line change 1
- from python import Python
1
+ fn detectCapitalUse (word : String) -> Bool:
2
+ var uinput = word
2
3
3
- def detectCapitalUse (word : String):
4
- py = Python.import_module(" builtins" )
5
-
6
- uinput = word
7
-
8
- number_of_capital_letters = 0
4
+ var number_of_capital_letters = 0
9
5
for i in range (len (uinput)):
10
- letter = uinput[i]
6
+ var letter = uinput[i]
11
7
if ord (letter) < 97 :
12
8
number_of_capital_letters += 1
13
9
14
- number_of_small_letters = len (uinput) - number_of_capital_letters
10
+ var number_of_small_letters = len (uinput) - number_of_capital_letters
15
11
16
12
if number_of_capital_letters == len (uinput) or number_of_small_letters == len (uinput) or (ord (word[0 ]) < 97 and number_of_capital_letters == 1 ):
17
13
return True
18
14
else :
19
15
return False
20
16
21
- def main ():
22
- result = detectCapitalUse(" USA" )
17
+ fn main ():
18
+ var result = detectCapitalUse(" USA" )
23
19
print (" Result:" )
24
20
print (result)
25
-
26
-
27
-
28
-
29
-
30
-
31
-
32
-
33
-
34
-
35
-
36
-
Original file line number Diff line number Diff line change 1
- from python import Python
2
-
3
- def findTheDifference (s :String, t :String):
4
- py = Python.import_module(" builtins" )
5
-
1
+ fn findTheDifference (s :String, t :String):
6
2
for i in range (len (t)):
7
3
if s[i] != t[i]:
8
- result = t[i]
4
+ var result = t[i]
9
5
print (" The difference is:" )
10
6
print (result)
11
7
break
12
8
13
- def main ():
9
+ fn main ():
14
10
findTheDifference(" abcd" , " abced" )
You can’t perform that action at this time.
0 commit comments