File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed
src/hackerrank/interview_preparation_kit/sorting Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change 5
5
import logging
6
6
7
7
LOGGER = logging .getLogger (__name__ )
8
+ SEPARATOR = "\n "
8
9
9
10
10
11
# pylint: disable=R0903:too-few-public-methods
@@ -46,9 +47,10 @@ def count_swaps(group: list[int]) -> str:
46
47
sortable_group = SortableGroup (group )
47
48
sortable_group .bubble_sort ()
48
49
49
- nl = "\n "
50
- output = f'Array is sorted in { sortable_group .count } swaps.{ nl } ' + \
51
- f'First Element: { sortable_group .group [0 ]} { nl } ' + \
52
- f'Last Element: { sortable_group .group [len (sortable_group .group )- 1 ]} { nl } '
50
+ last = len (sortable_group .group ) - 1
51
+
52
+ output = f'Array is sorted in { sortable_group .count } swaps.{ SEPARATOR } ' + \
53
+ f'First Element: { sortable_group .group [0 ]} { SEPARATOR } ' + \
54
+ f'Last Element: { sortable_group .group [last ]} { SEPARATOR } '
53
55
54
56
return output
You can’t perform that action at this time.
0 commit comments