On 22.01.2022 11:07, Janis Papanagnou wrote:
Just for recreational purposes here's yet another obfuscated Awk code.
func ___(_) { return __(_,x^x,x^x^x) }
func __(_,_x,x_) { return --_?__(_,x_,_x+x_):_x+x_ }
{ print ___($_) }
Solutions, guesses, comments, improvements, fixes, requests for hints,
etc. are all welcome.
Janis
On 22.01.2022 19:11, Kpop 2GM wrote:
it's not even limited by 2^-1023 or 2^-1074. since once you're past
-2^53, unitary pre-decrementing a number keeps it stuck there, since
it lacks the ability to accumulate your non-representable odd numbers
in double precision, and will go on for quite some time until the
either input position 2 or 3 in the two-underscore function reaches
2^1024 infinity
just my random uneducated guess
as for function called by print, the 3-underscore one, all of those
are pure distractions, since those reduce to calling two-underscore
function with
__( original-input, 1, 0)
wait … then that's Fibonacci then not Lucas …. i'm confused
You've identified it!
A couple notes. Since numbers grow extremely there's some limit as
you noticed. I admit it was unfair that I didn't define the domain
of the function, but you got it anyway. I could of course have had
a condition added to make life easier, e.g. $_&&!/[^0-9]/ { ... }
or, to obfuscate it a bit, even _=int(sqrt(-($_*-$_))) { ... } .
The two constant parameters are indeed 1 and 0 (not the values you
assumed in an earlier post). I used a reduced pattern of what I saw
in your other thread's post (_^_^_^...^_) for these constants (with
my observation that the reduced subexpression toggles between 0 and
1). The function is the one you suspected, and (in obfuscated form)
simpler written as just
# defined for integer args>0
func __(_) { return _>2?__(--_)+__(--_):1 } { print __($_) }
I like this form even more (with those nasty --_ side effects) and
the underlying mathematical function is more obvious, but the time
complexity is extremely bad since we have a cascading recursion in
that simple form. There's a transformation of the function possible
to generate an equivalent linear recursion with good (linear) time
complexity (and no supporting arrays and the like), and that is
func ___(_) { return __(_,x^x,x^x^x) }
func __(_,_x,x_) { return --_?__(_,x_,_x+x_):_x+x_ }
$_&&!/[^0-9]/ { print ___($_) }
And where the first version is rarely usable for arguments >35 the
second one runs smoothly for large arguments in no time.
Janis
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)