49 lines
601 B
Bash
Executable File

#!/usr/bin/env bash
sum=0
declare -a C
popped=''
function push() {
C[$1]="${C[$1]}${2}"
}
function pop() {
a=${2:-1}
l=$(( ${#C[$1]} - $a ))
popped=${C[$1]:$l:$a}
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--
pop $f $n
push $t $popped
done
out=""
for i in {0..8}; do
pop $i
echo -n "$popped"
done
echo