50 lines
621 B
Bash
Executable File

#!/usr/bin/env bash
sum=0
declare -a C
popped=''
function push() {
C[$1]="${C[$1]}${2}"
}
function pop() {
l=$(( ${#C[$1]} - 1 ))
popped=${C[$1]:$l:1}
C[$1]="${C[$1]:0:$l}"
}
while read a; do
if [[ "$a" == "1 2 3 4 5 6 7 8 9" ]]; then
break
fi
for i in {0..8}; do
c=${a:$(( 4 * $i + 1)):1}
if [[ "$c" == ' ' ]]; then
c=''
fi
C[$i]="${c}${C[$i]}"
done
done
read
while read x1 n x2 f x3 t; do
let f--
let t--
for i in `seq 1 $n`; do
pop $f
push $t $popped
done
done
out=""
for i in {0..8}; do
pop $i
echo -n "$popped"
done
echo