Sorry, I should have explicitly specified a Bourne-type shell. I’ve tried it with bash, dash and zsh, all of which behave the same AFAICT. The sequence should begin: 3, 7, 37, 973, 642493; which is probably as far as you can get experimentally. Cheers, Robin On Tue, 25 Aug 2020 at 16:44, Christopher Landauer <topcycal@gmail.com> wrote:
robin - which unix shell? sh, bash, ksh, csh tcsh, zsh, lotsa choices - i do know that sh barfs on it more later, chris
On Tue, Aug 25, 2020 at 8:01 AM Robin Houston <robin.houston@gmail.com> wrote:
I posted the below puzzle to Twitter, where no one has solved it. I think it’s too hard. Although it’s a silly question, the method of solution is quite interesting IMHO.
(The computation would be doable by hand, if one were patient and careful, but can be done more easily and reliably by a computer.)
I know some of you are aware of a related problem I solved a few years ago. The method of solution of this one is related, but not identical.
Cheers, Robin
A Unix shell puzzle. If you were to run this script – which I don’t recommend doing – how many occurrences of $x would appear in the output?
x=\"\'\$x\'\"\$x\'\"\$x\"\' eval x=$x eval x=$x eval x=$x eval x=$x eval x=$x eval x=$x eval x=$x eval x=$x eval x=$x eval x=$x echo "$x" _______________________________________________ math-fun mailing list math-fun@mailman.xmission.com https://mailman.xmission.com/cgi-bin/mailman/listinfo/math-fun
-- dr. christopher landauer topcy house consulting thousand oaks, california _______________________________________________ math-fun mailing list math-fun@mailman.xmission.com https://mailman.xmission.com/cgi-bin/mailman/listinfo/math-fun