read X; read Y; read Z
if (( X == Y && Y == Z )); then echo "EQUILATERAL"
elif (( X == Y || Y == Z || X == Z )); then echo "ISOSCELES"
else echo "SCALENE"
fi
c=$(cat | tr ' ' "\n" | sort -n -u | wc -l)
[ $c -eq 1 ] && echo EQUILATERAL
[ $c -eq 2 ] && echo ISOSCELES
[ $c -eq 3 ] && echo SCALENE
read n;
readarray -t a_num
printf "%.3f" $({
echo -n "(";
{ IFS=+; echo -n "${a_num[*]}"; };
echo -n ") / $n"; } | bc -l)
Too long, I passed !
declare -A arr
initialize(){
for r in {0..62}; do
for c in {0..99}; do
arr[$r,$c]="_"
done
done
}
print(){
for r in {0..62}; do
for c in {0..99}; do
echo -n ${arr[$r,$c]}
done
echo
done
}
draw(){
local cnt=$1
local r=$2
local c=$3
for ((i=0; i<cnt; i++ )); do
arr[$r,$c]=1
(( r -= 1 ))
done
for ((i=0; i<cnt; i++ )); do
arr[$r,$((c-i-1))]=1
arr[$r,$((c+i+1))]=1
(( r -= 1 ))
done
if [[ $4 -gt 1 ]]; then
draw $(($cnt>>1)) $r $(($c-cnt)) $(($4-1))
draw $(($cnt>>1)) $r $(($c+cnt)) $(($4-1))
fi
}
initialize
read x
draw 16 62 49 x
print
branch() {
if (( $1 == 0 )); then
exit;
fi
let inc=int=ext=rows=$(( 64 / 2**$1 ))
for ((i=1;i<=rows;i++)) do
x=$((buffer))
for ((j=0;j<100;j++)) do
if (( $1 > N )) || (( j >= (100 - buffer) )) || (( j != x )); then
printf "_"
else
printf "1"
if (( i <= rows/2 )); then
if (( inc == int )); then
inc=$((ext))
else
inc=$((int))
fi
fi
x=$((x+inc))
fi
done
printf "\n"
if ((i <= rows/2 )); then
buffer=$((buffer+1))
int=$((int-2))
inc=ext=$((ext+2))
fi
done
branch $(($1-1))
}
printf "%0.s_" {1..100}
printf "\n"
buffer=18
read N
branch 5
#!/bin/bash
declare -A m
StartLegLength=16
maxrows=63
maxcols=100
iter=$(cat)
function Y {
typeset -i row=$1 col=$2 len=$3 iter=$4
typeset -i r=$row x=$len cl=$col cr=$col l=$((len/2))
# leg
while (( x-- > 0 ))
do m[$((r--)),$col]=1
done
# fork
x=$len
while (( x-- > 0 ))
do m[$r,$((--cl))]=1
m[$r,$((++cr))]=1
((r--))
done
# subs
if (( --iter > 0 ))
then Y $r $cl $l $iter
Y $r $cr $l $iter
fi
}
# initialize
for (( row=0; row<maxrows; row++ ))
do for (( col=0; col<maxcols; col++))
do m[$row,$col]=_
done
done
# recurse
Y $(( maxrows-1 )) $(( (maxcols-1)/2 )) $StartLegLength $iter
# show the result
for (( r=0; r<maxrows; r++ ))
do for (( c=0; c<maxcols; c++))
do printf "%s" ${m[$r,$c]}
done
printf "\n"
done
-n
option sorts the file on the basis of the numeric fields available if the first word or column in the file is a number.-r
option reverses the sorting order to either the reverse of the usual lexicographical ordering or descending order while sorting in numerical mode.-k
option is useful while sorting a table of data (tsv, csv etc.) based on a specified column (or columns).-t
option is used while specifying a delimiter in a particular file where columns are separated by tabs, spaces, pipes etc.-c
count: prefix with the number of lines collaspsed-d
duplicate: only print duplicate lines-u
uniqque: only print unique lines-w
word: Limit comparison only to the first characters-s
paSS: Avoid comparing the first characters-i
ignore case: Ignore variations in case between lines-f
field: Avoid comparing the first fields-s
serial-d";"
delimiter separated by ;${A[@]:3:5}
: From 3 (0 indexed) with 5 elementsread
arr=($(cat))
arr=${arr[*]}
# render a new variable of type string from the merging of the array arr delimited by space, i.e., from [1,2,2,2,1] to "1 2 2 2 1"
echo $((${arr// /^}))
# replaces all spaces ' ' in the string variable with ^ (bitwise-XOR operator),
# read the input values
read n
read -a A
#echo -e "The size of the array is '${#A[*]}', and the array is:\n${A[*]}"
x=${A[0]}
#echo "A[0] = ${A[0]}, x = $x"
for (( i = 1; i < ${
#A[*]}; i++ )); do
#for (( i = 1; i < n; i++ )); do
$((x ^= ${A[i]} ))
#x=$((x ^ ${A[i]} ))
#echo "A[$i] = ${A[i]}, x = $x"
done
echo $x
|
()
NF
Number of Fieldsawk '{if ($4 == "") print "Not all scores are available for",$1;}'
awk '{if(NF < 4) print "Not all scores are available for",$1;}'
awk '{if (NF < 4){print "Not all scores are available for "$1}}'
# Removed coma
awk '$4=="" {print "Not all scores are available for " $1} '
awk '{printf $1" : "; if ($2+$3+$4 >= 150) {print "Pass"} else {print "Fail"}}'
# Wrong but I got lucky
awk '{print $1,":", ($2<50||$3<50||$4<50) ? "Fail" : "Pass"}'
awk '{
printf $0" : ";
sum=$2+$3+$4;
if (sum >= 240) {print "A"}
else if (sum >= 180) {print "B"}
else if (sum >= 150) {print "C"}
else {print "FAIL"}
}'
awk '{avg=($2+$3+$4)/3; print $0, ":", (avg<50)?"FAIL":(avg<80)?"B":"A"}'
paste -d";" - -
awk 'ORS=NR%2?";":"\n"'
awk 'NR%2{printf$0";"}1-NR%2'
awk '{
if ( NR % 2 == 1 )
printf "%s;", $0
else
printf "%s\n", $0
}'