File tree Expand file tree Collapse file tree 6 files changed +35
-71
lines changed Expand file tree Collapse file tree 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
99 cd " $dir "
1010 echo " Benchmarking $dir "
1111 $COMPILE
12- $BENCH " ${COMMANDS[@]} "
12+ $BENCH " ${COMMANDS[@]} "
1313 cd ..
1414 fi
1515done
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
83 for i in range (len (enterword)- 1 , - 1 , - 1 ):
94 if enterword[i] != " " :
105 count += 1
116 elif count > 0 :
127 break
13-
14- print (" Length of the last word:" )
15- print (count)
16-
178
18- def main ():
19- input_string = " Hello World"
20- lengthOfLastWord(input_string)
9+ print (" Length of the last word:" , count)
2110
2211
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
23
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
96
107 for i in range (len (attendance_record_str)):
11-
8+
129 if attendance_record_str[i] == ' A' :
1310 absent_count += 1
1411 late_count = 0
@@ -25,8 +22,5 @@ def checkRecord(attendance_record: String):
2522 return True
2623
2724
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
22
3- def makeGood (s : String):
4- py = Python.import_module(" builtins" )
5- result = str (" " )
3+ fn makeGood (s : String):
4+ var result = str (" " )
65
7- i = 0
6+ var i = 0
87 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+
1211 i += 2
1312 else :
14-
13+
1514 result = result + s[i]
1615 i += 1
1716
1817 print (result)
1918
20- def main ():
21-
22- input_str = " leEeetcode"
19+ fn main ():
20+ var input_str = " leEeetcode"
2321 makeGood(input_str)
24-
22+
2523 # 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
23
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
95 for i in range (len (uinput)):
10- letter = uinput[i]
6+ var letter = uinput[i]
117 if ord (letter) < 97 :
128 number_of_capital_letters += 1
139
14- number_of_small_letters = len (uinput) - number_of_capital_letters
10+ var number_of_small_letters = len (uinput) - number_of_capital_letters
1511
1612 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 ):
1713 return True
1814 else :
1915 return False
2016
21- def main ():
22- result = detectCapitalUse(" USA" )
17+ fn main ():
18+ var result = detectCapitalUse(" USA" )
2319 print (" Result:" )
2420 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):
62 for i in range (len (t)):
73 if s[i] != t[i]:
8- result = t[i]
4+ var result = t[i]
95 print (" The difference is:" )
106 print (result)
117 break
128
13- def main ():
9+ fn main ():
1410 findTheDifference(" abcd" , " abced" )
You can’t perform that action at this time.
0 commit comments