Skip to main content
added 11 characters in body
Source Link

Bash + Unix utilities, 28 bytes

dc<<<`grep -c [13579]$`d2-*p

Try it online!

Input is on stdin: one number per line.

Output is on stdout: 0 is truthy, any non-zero value is falsy.

How it works:

  • grep counts the number n of lines ending with an odd digit;
  • dc then computes and prints n*(n-2), which is 0 iff n equals 0 or 2.

Bash + Unix utilities, 28 bytes

dc<<<`grep -c [13579]$`d2-*p

Try it online!

Input is on stdin: one number per line.

Output is on stdout: 0 is truthy, any non-zero value is falsy.

How it works:

  • grep counts the number n of lines ending with an odd digit;
  • dc then computes n*(n-2), which is 0 iff n equals 0 or 2.

Bash + Unix utilities, 28 bytes

dc<<<`grep -c [13579]$`d2-*p

Try it online!

Input is on stdin: one number per line.

Output is on stdout: 0 is truthy, any non-zero value is falsy.

How it works:

  • grep counts the number n of lines ending with an odd digit;
  • dc then computes and prints n*(n-2), which is 0 iff n equals 0 or 2.
added 8 characters in body
Source Link

Bash + Unix utilities, 28 bytes

dc<<<`grep -c [13579]$`d2-*p

Try it online!

Input is on stdin: one number per line.

Output is on stdout: 0 is truthy, any non-zero value is falsy.

How it works:

  • grep counts the number nn of lines ending with an odd digit;
  • dc then computes n*n*(nn-2), which is 0 iff nn equals 0 or 2.

Bash + Unix utilities, 28 bytes

dc<<<`grep -c [13579]$`d2-*p

Try it online!

Input is on stdin: one number per line.

Output is on stdout: 0 is truthy, any non-zero value is falsy.

How it works:

  • grep counts the number n of lines ending with an odd digit;
  • dc then computes n*(n-2), which is 0 iff n equals 0 or 2.

Bash + Unix utilities, 28 bytes

dc<<<`grep -c [13579]$`d2-*p

Try it online!

Input is on stdin: one number per line.

Output is on stdout: 0 is truthy, any non-zero value is falsy.

How it works:

  • grep counts the number n of lines ending with an odd digit;
  • dc then computes n*(n-2), which is 0 iff n equals 0 or 2.
Source Link

Bash + Unix utilities, 28 bytes

dc<<<`grep -c [13579]$`d2-*p

Try it online!

Input is on stdin: one number per line.

Output is on stdout: 0 is truthy, any non-zero value is falsy.

How it works:

  • grep counts the number n of lines ending with an odd digit;
  • dc then computes n*(n-2), which is 0 iff n equals 0 or 2.