Make the dc command available in Bash

I don’t know if I’m the only one, but when I use Bash for Clash of Code, especially in the Shortest mode, I often find myself needing the dc command to do various calculations. I know the bc command is available and while both programs are powerful, dc has a very compact syntax!

I think it can be added with a minimum of effort, dc is I presume default in many Linux distributions, it’s actually one of the oldest programs. Please consider putting it in the bash environment. Thank you.

Some example treats to convince you how awesome dc can be:

  • sum the numbers in the sequence 1,2,3,…,N (with N read from input): dc -e’?d1+*2/p’

  • calculate sqrt((12+(-3)^4)/11): dc -e’3kC_3 4^+B/vp’

  • entire CoC challenges can be solved with just dc. The one with calculating the steps for a number to reach 1 in the Collatz sequence is solved (non-optimally) by: dc -e’?[2/2Q]sE[dd2%[0=E3*1+]xd1<L]dsLxkzp’