File tree 3 files changed +90
-0
lines changed
3 files changed +90
-0
lines changed Original file line number Diff line number Diff line change
1
+ def isOrder (a ):
2
+ b = []
3
+ n = len (a )
4
+ for i in range (n ):
5
+ if len (a )> 0 :
6
+ b .append (a .pop (0 ))
7
+ if len (a )> 0 :
8
+ b .append (a .pop (- 1 ))
9
+ flag = True
10
+ print (b )
11
+ for i in range (n - 1 ):
12
+ if b [i ] > b [i + 1 ]:
13
+ flag = False
14
+ break
15
+ print (flag )
16
+
17
+
18
+
19
+ c = [1 , 3 , 5 , 6 , 4 , 2 ]
20
+ isOrder (c )
21
+ isOrder ([1 , 4 , 5 , 6 , 3 ])
Original file line number Diff line number Diff line change
1
+ #!/bin/python3
2
+
3
+ import math
4
+ import os
5
+ import random
6
+ import re
7
+ import sys
8
+
9
+ #
10
+ # Complete the 'miniMaxSum' function below.
11
+ #
12
+ # The function accepts INTEGER_ARRAY arr as parameter.
13
+ #
14
+
15
+ def miniMaxSum (arr ):
16
+ # Write your code here
17
+ array_sum = sum (arr )
18
+ minNum = math .inf
19
+ maxNum = - math .inf
20
+ for i in arr :
21
+ temp = array_sum - i
22
+ minNum = min (temp , minNum )
23
+ maxNum = max (temp , maxNum )
24
+
25
+ print (minNum , maxNum )
26
+
27
+
28
+ if __name__ == '__main__' :
29
+
30
+ arr = list (map (int , input ().rstrip ().split ()))
31
+
32
+ miniMaxSum (arr )
Original file line number Diff line number Diff line change
1
+ #!/bin/python3
2
+
3
+ import math
4
+ import os
5
+ import random
6
+ import re
7
+ import sys
8
+
9
+ #
10
+ # Complete the 'plusMinus' function below.
11
+ #
12
+ # The function accepts INTEGER_ARRAY arr as parameter.
13
+ #
14
+
15
+ def plusMinus (arr ):
16
+ # Write your code here
17
+ plus = 0
18
+ minus = 0
19
+ zero = 0
20
+ n = len (arr )
21
+ for i in arr :
22
+ if i > 0 :
23
+ plus += 1
24
+ elif i < 0 :
25
+ minus += 1
26
+ else :
27
+ zero += 1
28
+ print ("{:.6f}" .format (plus / n ))
29
+ print ("{:.6f}" .format (minus / n ))
30
+ print ("{:.6f}" .format (zero / n ))
31
+
32
+ if __name__ == '__main__' :
33
+ n = int (input ().strip ())
34
+
35
+ arr = list (map (int , input ().rstrip ().split ()))
36
+
37
+ plusMinus (arr )
You can’t perform that action at this time.
0 commit comments