day 5, part 2
parent
5e5a92d0e7
commit
11c9fba2c4
|
@ -0,0 +1,46 @@
|
|||
#!/bin/bash
|
||||
|
||||
# still Paula fronting! i think!
|
||||
data="$(cat /tmp/05 | sed 's/ / _ /g;s/\[//g;s/\]//g')"
|
||||
|
||||
x=0
|
||||
IFS=$'\n'
|
||||
(
|
||||
while read line; do
|
||||
[[ "$line" == '1 '* ]] && break
|
||||
|
||||
IFS=' '
|
||||
uwu=($line)
|
||||
for (( i=0; i<${#uwu[@]}; i++ )); do
|
||||
[[ "${uwu[$i]}" != _ ]] && meow[$i]="${meow[$i]} ${uwu[$i]}"
|
||||
done
|
||||
done
|
||||
read line;
|
||||
while read line; do
|
||||
ins=($line)
|
||||
from=$((${ins[3]}-1))
|
||||
to=$((${ins[5]}-1))
|
||||
|
||||
asd=(${meow[$from]})
|
||||
|
||||
echo "moving ${ins[1]} things from ${ins[3]} to ${ins[5]}"
|
||||
echo "from, initial: ${meow[$from]}"
|
||||
echo "what? ${asd[@]:0:${ins[1]}}"
|
||||
echo "to, initial: ${meow[$to]}"
|
||||
meow[$from]=${asd[@]:${ins[1]}:${#asd[@]}}
|
||||
meow[$to]="${asd[@]:0:${ins[1]}} ${meow[$to]}"
|
||||
echo "from, after: ${meow[$from]}"
|
||||
echo "to, after: ${meow[$to]}"
|
||||
echo ---
|
||||
done
|
||||
|
||||
IFS=' '
|
||||
x=''
|
||||
for (( i=0; i<${#meow[@]}; i++ )); do
|
||||
a=(${meow[$i]})
|
||||
echo "$i: ${meow[$i]}"
|
||||
x="$x${a[0]}"
|
||||
done
|
||||
echo "$x"
|
||||
) <<< "$data"
|
||||
|
|
@ -15,3 +15,10 @@ the header separately from the rest of the code - probably wouldn't
|
|||
be needed if Tulip was fronting and writing the code, she likes to
|
||||
accept input from stdin (whereas I (Paula?) like to accept input
|
||||
from argv)
|
||||
|
||||
## part 2
|
||||
|
||||
... remember L31?
|
||||
|
||||
so I removed that `| rev`, and that did the trick for the 2nd part.
|
||||
BOORIIIIING
|
||||
|
|
Loading…
Reference in New Issue