Skip to main content
no need to set $m
Source Link
roblogic
  • 4k
  • 18
  • 23

Zsh --force_float, 141 136 109 10196 bytes

Try it online!Try it online!  109bytes109bytes  136bytes  141bytes

m=$1 n=$1
forn=$1;for x ((t+=x,m=x>m?x:m,n=x<n?x:n,s=2*(#>2?(t-m-n)/(#-2):t/#)))
<<<$[(s^0+(s-s^0>.5?1:0))/2]

Solution follows latest spec, except for the unclear second test case. Saved a few bytes using implicit ($@). Saved more by moving most calculations into the (( )) statement.

We implicitly iterate over the arguments with for x, and build a running total t, and also find maxima, minima m, n. If the number of arguments # is greater than 2, we discard m and n from the average. s is 2x the resulting average. If the mantissa of s is greater than 0.5, round s up, otherwise truncate with s^0. Finally, divide by 2 and output.

Zsh --force_float, 141 136 109 101 bytes

Try it online!  109bytes  136bytes  141bytes

m=$1 n=$1
for x ((t+=x,m=x>m?x:m,n=x<n?x:n,s=2*(#>2?(t-m-n)/(#-2):t/#)))
<<<$[(s^0+(s-s^0>.5?1:0))/2]

Solution follows latest spec, except for the unclear second test case. Saved a few bytes using implicit ($@). Saved more by moving most calculations into the (( )) statement.

We implicitly iterate over the arguments with for x, and build a running total t, and also find maxima, minima m, n. If the number of arguments # is greater than 2, we discard m and n from the average. s is 2x the resulting average. If the mantissa of s is greater than 0.5, round s up, otherwise truncate with s^0. Finally, divide by 2 and output.

Zsh --force_float, 141 136 109 96 bytes

Try it online!  109bytes  136bytes  141bytes

n=$1;for x ((t+=x,m=x>m?x:m,n=x<n?x:n,s=2*(#>2?(t-m-n)/(#-2):t/#)))
<<<$[(s^0+(s-s^0>.5?1:0))/2]

Solution follows latest spec, except for the unclear second test case. Saved a few bytes using implicit ($@). Saved more by moving most calculations into the (( )) statement.

We implicitly iterate over the arguments with for x, and build a running total t, and also find maxima, minima m, n. If the number of arguments # is greater than 2, we discard m and n from the average. s is 2x the resulting average. If the mantissa of s is greater than 0.5, round s up, otherwise truncate with s^0. Finally, divide by 2 and output.

-8 more
Source Link
roblogic
  • 4k
  • 18
  • 23

Zsh --force_float, 141 136 109109 101 bytes

Try it online!Try it online!  109bytes  136bytes  141bytes

m=$1 n=$1 a=$#;for x ((t+=x,m=x>m?x:m,n=x<n?x:n))
s=$[2*(a>2?(t-m-n)/(a-2):t/a)];<<<$[(s^0+(s-s^0>.5?1:0))/2]
m=$1 n=$1
for x ((t+=x,m=x>m?x:m,n=x<n?x:n,s=2*(#>2?(t-m-n)/(#-2):t/#)))
<<<$[(s^0+(s-s^0>.5?1:0))/2]

Solution follows latest spec, except for the unclear second test case. Saved a few bytes using implicit ($@). Saved more by moving most calculations into the (( )) statement.

We implicitly iterate over the arguments with for x, and build a running total t, and also find maxima, minima m, n. If the number of arguments a# is greater than 2, we discard m and n from the average. s is 2x the resulting average. If the mantissa of s is greater than 0.5, round s up, otherwise truncate with s^0. Finally, divide by 2 and output.

Zsh --force_float, 141 136 109 bytes

Try it online!  136bytes  141bytes

m=$1 n=$1 a=$#;for x ((t+=x,m=x>m?x:m,n=x<n?x:n))
s=$[2*(a>2?(t-m-n)/(a-2):t/a)];<<<$[(s^0+(s-s^0>.5?1:0))/2]

Solution follows latest spec. Saved a few bytes using implicit ($@).

We implicitly iterate over the arguments with for x, and build a running total t, and also find maxima, minima m, n. If the number of arguments a is greater than 2, we discard m and n from the average. s is 2x the resulting average. If the mantissa of s is greater than 0.5, round s up, otherwise truncate with s^0. Finally, divide by 2 and output.

Zsh --force_float, 141 136 109 101 bytes

Try it online!  109bytes  136bytes  141bytes

m=$1 n=$1
for x ((t+=x,m=x>m?x:m,n=x<n?x:n,s=2*(#>2?(t-m-n)/(#-2):t/#)))
<<<$[(s^0+(s-s^0>.5?1:0))/2]

Solution follows latest spec, except for the unclear second test case. Saved a few bytes using implicit ($@). Saved more by moving most calculations into the (( )) statement.

We implicitly iterate over the arguments with for x, and build a running total t, and also find maxima, minima m, n. If the number of arguments # is greater than 2, we discard m and n from the average. s is 2x the resulting average. If the mantissa of s is greater than 0.5, round s up, otherwise truncate with s^0. Finally, divide by 2 and output.

-27
Source Link
roblogic
  • 4k
  • 18
  • 23

Zsh --force_float, 141 136136 109 bytes

try it online!   Try it online!  136bytes  141bytes

setopt FORCE_FLOAT
m=$1 n=$1 a=$#
fora=$#;for x ((t+=x))&&m=$[x>m,m=x>m?x:m]&&n=$[x<nm,n=x<n?x:n]n))
s=$[2*(a>2?(t-m-n)/(a-2):t/a)]
<<<$[];<<<$[(s^0+(s-s^0>.5?1:0))/2]

Solution follows latest spec. Saved a few bytes using implicit ($@).

We implicitly iterate over the arguments with for x, and build a running total t, and also find maxima, minima m, n. If the number of arguments a is greater than 2, we discard m and n from the average. s is 2x the resulting average. If the mantissa of s is greater than 0.5, round s up, otherwise truncate with s^0. Finally, divide by 2 and output.

Zsh, 141 136 bytes

try it online!   141bytes

setopt FORCE_FLOAT
m=$1 n=$1 a=$#
for x ((t+=x))&&m=$[x>m?x:m]&&n=$[x<n?x:n]
s=$[2*(a>2?(t-m-n)/(a-2):t/a)]
<<<$[(s^0+(s-s^0>.5?1:0))/2]

Solution follows latest spec. Saved a few bytes using implicit ($@).

We implicitly iterate over the arguments with for x, and build a running total t, and also find maxima, minima m, n. If the number of arguments a is greater than 2, we discard m and n from the average. s is 2x the resulting average. If the mantissa of s is greater than 0.5, round s up, otherwise truncate with s^0. Finally, divide by 2 and output.

Zsh --force_float, 141 136 109 bytes

Try it online!  136bytes  141bytes

m=$1 n=$1 a=$#;for x ((t+=x,m=x>m?x:m,n=x<n?x:n))
s=$[2*(a>2?(t-m-n)/(a-2):t/a)];<<<$[(s^0+(s-s^0>.5?1:0))/2]

Solution follows latest spec. Saved a few bytes using implicit ($@).

We implicitly iterate over the arguments with for x, and build a running total t, and also find maxima, minima m, n. If the number of arguments a is greater than 2, we discard m and n from the average. s is 2x the resulting average. If the mantissa of s is greater than 0.5, round s up, otherwise truncate with s^0. Finally, divide by 2 and output.

explain
Source Link
roblogic
  • 4k
  • 18
  • 23
Loading
save 5
Source Link
roblogic
  • 4k
  • 18
  • 23
Loading
Source Link
roblogic
  • 4k
  • 18
  • 23
Loading