Skip to main content
Commonmark migration
Source Link

#Bash, 94 86 bytes (saved eight bytes thanks to Digital Trauma)

Bash, 94 86 bytes (saved eight bytes thanks to Digital Trauma)

p=equal;q=than;(($1>$2))&&p=greater&&[ ]||(($1<$2))&&p=less||q=to;echo $1 is $p $q $2

Test (on Linux):

echo 'p=equal;q=than;(($1>$2))&&p=greater&&[ ]||(($1<$2))&&p=less||q=to;echo $1 is $p $q $2' > cmp.sh
chmod +x cmp.sh
./cmp.sh 10 12
10 is less than 12

The use of [ ] after p=greater is to prevent || operator from being evaluated before = in the expression ...&&p=greater||(($1<$2))... (the operator precedence!).

The alternative would be using brackets around (($1>$2))&&p=greater and (($1<$2))&&p=less , but brackets make inner scope for variables, so p would be left unaltered.

#Bash, 94 86 bytes (saved eight bytes thanks to Digital Trauma)

p=equal;q=than;(($1>$2))&&p=greater&&[ ]||(($1<$2))&&p=less||q=to;echo $1 is $p $q $2

Test (on Linux):

echo 'p=equal;q=than;(($1>$2))&&p=greater&&[ ]||(($1<$2))&&p=less||q=to;echo $1 is $p $q $2' > cmp.sh
chmod +x cmp.sh
./cmp.sh 10 12
10 is less than 12

The use of [ ] after p=greater is to prevent || operator from being evaluated before = in the expression ...&&p=greater||(($1<$2))... (the operator precedence!).

The alternative would be using brackets around (($1>$2))&&p=greater and (($1<$2))&&p=less , but brackets make inner scope for variables, so p would be left unaltered.

Bash, 94 86 bytes (saved eight bytes thanks to Digital Trauma)

p=equal;q=than;(($1>$2))&&p=greater&&[ ]||(($1<$2))&&p=less||q=to;echo $1 is $p $q $2

Test (on Linux):

echo 'p=equal;q=than;(($1>$2))&&p=greater&&[ ]||(($1<$2))&&p=less||q=to;echo $1 is $p $q $2' > cmp.sh
chmod +x cmp.sh
./cmp.sh 10 12
10 is less than 12

The use of [ ] after p=greater is to prevent || operator from being evaluated before = in the expression ...&&p=greater||(($1<$2))... (the operator precedence!).

The alternative would be using brackets around (($1>$2))&&p=greater and (($1<$2))&&p=less , but brackets make inner scope for variables, so p would be left unaltered.

Just title edit to not confuse the leaderboard ;)
Source Link

#Bash, 94 86 bytes (saved 8eight bytes thanks to Digital Trauma)

p=equal;q=than;(($1>$2))&&p=greater&&[ ]||(($1<$2))&&p=less||q=to;echo $1 is $p $q $2

Test (on Linux):

echo 'p=equal;q=than;(($1>$2))&&p=greater&&[ ]||(($1<$2))&&p=less||q=to;echo $1 is $p $q $2' > cmp.sh
chmod +x cmp.sh
./cmp.sh 10 12
10 is less than 12

The use of [ ] after p=greater is to prevent || operator from being evaluated before = in the expression ...&&p=greater||(($1<$2))... (the operator precedence!).

The alternative would be using brackets around (($1>$2))&&p=greater and (($1<$2))&&p=less , but brackets make inner scope for variables, so p would be left unaltered.

#Bash, 94 86 bytes (saved 8 bytes thanks to Digital Trauma)

p=equal;q=than;(($1>$2))&&p=greater&&[ ]||(($1<$2))&&p=less||q=to;echo $1 is $p $q $2

Test (on Linux):

echo 'p=equal;q=than;(($1>$2))&&p=greater&&[ ]||(($1<$2))&&p=less||q=to;echo $1 is $p $q $2' > cmp.sh
chmod +x cmp.sh
./cmp.sh 10 12
10 is less than 12

The use of [ ] after p=greater is to prevent || operator from being evaluated before = in the expression ...&&p=greater||(($1<$2))... (the operator precedence!).

The alternative would be using brackets around (($1>$2))&&p=greater and (($1<$2))&&p=less , but brackets make inner scope for variables, so p would be left unaltered.

#Bash, 94 86 bytes (saved eight bytes thanks to Digital Trauma)

p=equal;q=than;(($1>$2))&&p=greater&&[ ]||(($1<$2))&&p=less||q=to;echo $1 is $p $q $2

Test (on Linux):

echo 'p=equal;q=than;(($1>$2))&&p=greater&&[ ]||(($1<$2))&&p=less||q=to;echo $1 is $p $q $2' > cmp.sh
chmod +x cmp.sh
./cmp.sh 10 12
10 is less than 12

The use of [ ] after p=greater is to prevent || operator from being evaluated before = in the expression ...&&p=greater||(($1<$2))... (the operator precedence!).

The alternative would be using brackets around (($1>$2))&&p=greater and (($1<$2))&&p=less , but brackets make inner scope for variables, so p would be left unaltered.

added 46 characters in body
Source Link

#Bash, 9494 86 bytes (saved 8 bytes thanks to Digital Trauma)

p=equal;q=than;[ $1 -gt $2 ]&&p=greater&&[ ]||[ $1 -lt $2p=equal;q=than;(($1>$2))&&p=greater&&[ ]&&p=less||q=to;echo]||(($1<$2))&&p=less||q=to;echo $1 is $p $q $2

Test (on Linux):

echo 'p=equal;q=than;[ $1 -gt $2 ]&&p=greater&&[ ]||[ $1 -lt $2'p=equal;q=than;(($1>$2))&&p=greater&&[ ]&&p=less||q=to;echo]||(($1<$2))&&p=less||q=to;echo $1 is $p $q $2' > cmp.sh
chmod +x cmp.sh
./cmp.sh 10 12
10 is less than 12

The use of [ ] after p=greater is to prevent || operator to befrom being evaluated before = in the expression ...&&p=greater||[ $1 &&p=greater||(($1<$2))... (the operator precedence!).

The alternative would be using brackets around [ $1 -gt $2 ]&&p=greater(($1>$2))&&p=greater and [ $1 -lt $2 ]&&p=less(($1<$2))&&p=less , but brackets make inner scope for variables, so p would be left unaltered.

#Bash, 94 bytes

p=equal;q=than;[ $1 -gt $2 ]&&p=greater&&[ ]||[ $1 -lt $2 ]&&p=less||q=to;echo $1 is $p $q $2

Test (on Linux):

echo 'p=equal;q=than;[ $1 -gt $2 ]&&p=greater&&[ ]||[ $1 -lt $2 ]&&p=less||q=to;echo $1 is $p $q $2' > cmp.sh
chmod +x cmp.sh
./cmp.sh 10 12
10 is less than 12

The use of [ ] after p=greater is to prevent || operator to be evaluated before = in the expression ...&&p=greater||[ $1 ... (the operator precedence!).

The alternative would be using brackets around [ $1 -gt $2 ]&&p=greater and [ $1 -lt $2 ]&&p=less , but brackets make inner scope for variables, so p would be left unaltered.

#Bash, 94 86 bytes (saved 8 bytes thanks to Digital Trauma)

p=equal;q=than;(($1>$2))&&p=greater&&[ ]||(($1<$2))&&p=less||q=to;echo $1 is $p $q $2

Test (on Linux):

echo 'p=equal;q=than;(($1>$2))&&p=greater&&[ ]||(($1<$2))&&p=less||q=to;echo $1 is $p $q $2' > cmp.sh
chmod +x cmp.sh
./cmp.sh 10 12
10 is less than 12

The use of [ ] after p=greater is to prevent || operator from being evaluated before = in the expression ...&&p=greater||(($1<$2))... (the operator precedence!).

The alternative would be using brackets around (($1>$2))&&p=greater and (($1<$2))&&p=less , but brackets make inner scope for variables, so p would be left unaltered.

Source Link
Loading