Skip to content

Commit 19fe731

Browse files
committed
add .editorconfig with indent_size = 2, indent_style = space
1 parent 9ee8c69 commit 19fe731

File tree

9 files changed

+109
-98
lines changed

9 files changed

+109
-98
lines changed

.editorconfig

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#
2+
# ╭╮╭╮ ╭━╮
3+
# ┃┣╯╰╮ ┃╭╯
4+
# ╭━━┳━╯┣╮╭╋━━┳━┳━━┳━━┳━╮╭╯╰┳┳━━╮
5+
# ┃┃━┫╭╮┣┫┃┃╭╮┃╭┫╭━┫╭╮┃╭╮╋╮╭╋┫╭╮┃
6+
# ╭┫┃━┫╰╯┃┃╰┫╰╯┃┃┃╰━┫╰╯┃┃┃┃┃┃┃┃╰╯┃
7+
# ╰┻━━┻━━┻┻━┻━━┻╯╰━━┻━━┻╯╰╯╰╯╰┻━╮┃
8+
# ╭━╯┃
9+
# ╰━━╯
10+
11+
[*]
12+
charset = utf-8
13+
end_of_line = lf
14+
indent_size = 2
15+
indent_style = space
16+
insert_final_newline = true
17+
trim_trailing_whitespace = true

Classical/DataStructures/Dequeue.sh

+22-22
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,26 @@
22

33
items=()
44
while true ; do
5-
printf "> "
6-
read -r line
7-
args=($line)
8-
case ${args[0]} in
9-
"FADD")
10-
arg_list=(${args[1]})
11-
arg_list+=(${items[@]})
12-
items=(${arg_list[@]})
13-
;;
14-
"RADD")
15-
items+=(${args[1]})
16-
;;
17-
"FPOP")
18-
echo "${items[0]}"
19-
items=(${items[@]:1})
20-
;;
21-
"RPOP")
22-
echo "${items[(( ${#items[@]} - 1))]}"
23-
items=(${items[@]:0:$((${#items[@]} - 1))})
24-
;;
25-
esac
26-
5+
printf "> "
6+
read -r line
7+
args=($line)
8+
case ${args[0]} in
9+
"FADD")
10+
arg_list=(${args[1]})
11+
arg_list+=(${items[@]})
12+
items=(${arg_list[@]})
13+
;;
14+
"RADD")
15+
items+=(${args[1]})
16+
;;
17+
"FPOP")
18+
echo "${items[0]}"
19+
items=(${items[@]:1})
20+
;;
21+
"RPOP")
22+
echo "${items[(( ${#items[@]} - 1))]}"
23+
items=(${items[@]:0:$((${#items[@]} - 1))})
24+
;;
25+
esac
26+
2727
done

Classical/Sorting/BubbleSort.sh

+7-7
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ items=("$@")
44
len=${#items[@]}
55

66
for (( i = len - 1; i > 0 ; i-- )); do
7-
for (( j = 0; j < i; j++ )); do
8-
if (( items[j] > items[$(( j + 1 ))])); then
9-
temp=${items[j]}
10-
items[$j]=${items[$((j + 1))]}
11-
items[$(( j + 1 ))]=${temp}
12-
fi
13-
done
7+
for (( j = 0; j < i; j++ )); do
8+
if (( items[j] > items[$(( j + 1 ))])); then
9+
temp=${items[j]}
10+
items[$j]=${items[$((j + 1))]}
11+
items[$(( j + 1 ))]=${temp}
12+
fi
13+
done
1414
done
1515

1616
echo "${items[@]}"

Classical/Sorting/InsertionSort.sh

+9-9
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ items=("$@")
33
len="${#items[@]}"
44
i=1
55
while [ $i -lt $len ]; do
6-
key="${items[i]}"
7-
j=$((i-1));
8-
while [ $j -ge 0 ] && [ ${items[j]} -gt $key ]; do
9-
items[$((j+1))]=${items[j]}
10-
j=$((j-1))
11-
done
12-
i=$((i+1))
13-
items[$((j+1))]="${key}"
6+
key="${items[i]}"
7+
j=$((i-1));
8+
while [ $j -ge 0 ] && [ ${items[j]} -gt $key ]; do
9+
items[$((j+1))]=${items[j]}
10+
j=$((j-1))
11+
done
12+
i=$((i+1))
13+
items[$((j+1))]="${key}"
1414
done
1515

16-
echo "${items[@]}"
16+
echo "${items[@]}"

Classical/Sorting/SelectionSort.sh

+9-9
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33
items=("$@")
44
len=${#items[@]}
55
for (( i=0; i < $((len - 1)); i+=1)); do
6-
min_index=$i
7-
for (( j=i+1; j < len; j+=1)); do
8-
if (( items[j] < items[min_index])); then
9-
min_index=$j
10-
fi
11-
done
6+
min_index=$i
7+
for (( j=i+1; j < len; j+=1)); do
8+
if (( items[j] < items[min_index])); then
9+
min_index=$j
10+
fi
11+
done
1212

13-
temp=${items[i]}
14-
items[$i]=${items[min_index]}
15-
items[min_index]=$temp
13+
temp=${items[i]}
14+
items[$i]=${items[min_index]}
15+
items[min_index]=$temp
1616
done
1717

1818
echo "${items[@]}"

Classical/Sorting/ShellSort.sh

+17-17
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/bin/bash
22

33
items=("$@")
44
length=${#items[@]}
@@ -7,22 +7,22 @@ major_step_index=$(( length / 2 ))
77

88
echo "Major $major_step_index"
99
while (( major_step_index > 0 )); do
10-
for i in $( seq 0 $major_step_index); do
11-
12-
for j in $( seq $(( i + major_step_index)) $length $major_step_index ); do
13-
current=${items[$j]}
14-
inner_step_index=$j
15-
16-
while (( inner_step_index >= major_step_index && items[$(( inner_step_index - major_step_index ))] > current )); do
17-
items[$inner_step_index]=${items[$(( inner_step_index - manjor_step_index ))]}
18-
inner_step_index=$(( inner_step_index - major_step_index ))
19-
done
20-
21-
items[$inner_step_index]=$current
22-
done
23-
24-
major_slice_index=$(( major_step_index / 2))
25-
done
10+
for i in $( seq 0 $major_step_index); do
11+
12+
for j in $( seq $(( i + major_step_index)) $length $major_step_index ); do
13+
current=${items[$j]}
14+
inner_step_index=$j
15+
16+
while (( inner_step_index >= major_step_index && items[$(( inner_step_index - major_step_index ))] > current )); do
17+
items[$inner_step_index]=${items[$(( inner_step_index - manjor_step_index ))]}
18+
inner_step_index=$(( inner_step_index - major_step_index ))
19+
done
20+
21+
items[$inner_step_index]=$current
22+
done
23+
24+
major_slice_index=$(( major_step_index / 2))
25+
done
2626
done
2727

2828

HackerRank/Implementation/TheGridSearch.sh

+16-21
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,26 @@
22

33
echo "> Insert T"; read T
44
for (( i=0; i < T ; i=$i+1 )); do
5-
echo "> Insert R and C"
6-
read RC
7-
R=($RC)[0]
8-
C=($RC)[1]
5+
echo "> Insert R and C"
6+
read RC
7+
R=($RC)[0]
8+
C=($RC)[1]
99

10-
G=()
10+
G=()
1111

12-
echo "Insert the Grid"
12+
echo "Insert the Grid"
1313

14-
for (( k = 0; k < R; k++ )); do
15-
read line
16-
G=(${G[@]} ${line})
17-
done
14+
for (( k = 0; k < R; k++ )); do
15+
read line
16+
G=(${G[@]} ${line})
17+
done
1818

19-
P=()
20-
echo "Insert the pattern"
21-
22-
for (( k = 0; k < count; k++ )); do
23-
read line
24-
P=(${G[@]} ${line})
25-
done
19+
P=()
20+
echo "Insert the pattern"
2621

22+
for (( k = 0; k < count; k++ )); do
23+
read line
24+
P=(${G[@]} ${line})
25+
done
2726

2827
done
29-
30-
31-
32-

HackerRank/Warmup/Staircase.sh

+10-11
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@
22

33
read -r N
44

5-
for ((i=0; i<N; i++)); do
6-
for ((j=0; j< $(( N - i - 1)); j++ )); do
7-
printf " "
8-
done
9-
10-
for ((j=$(( N - i -1 )); j < $N; j++ )); do
11-
printf "#"
12-
done
13-
14-
printf "\n"
15-
done
5+
for ((i=0; i<N; i++)); do
6+
for ((j=0; j< $(( N - i - 1)); j++ )); do
7+
printf " "
8+
done
9+
10+
for ((j=$(( N - i -1 )); j < $N; j++ )); do
11+
printf "#"
12+
done
1613

14+
printf "\n"
15+
done

HackerRank/Warmup/TimeConversion.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
#!/bin/bash
22

33
pick() {
4-
echo "$time" | cut -d : -f $1
4+
echo "$time" | cut -d : -f $1
55
}
66

77
read -r time
88

99
h=$( pick 1 )
1010
m=$( pick 2 )
1111

12-
s=$( pick 3 )
12+
s=$( pick 3 )
1313
s=${s:0:2}
1414

1515
period=$( pick 3 )

0 commit comments

Comments
 (0)