Subject: Re: obfuscated AWK code challenge
It's arguable whether it's appropriate to call code an "AWK code
challenge" that obviously relies on external commands like 'od',
'openssl', and various shell commands _within_ the awk code.
Janis
On 27.12.2021 03:53, RARE Kpop Manifesto wrote:
without actually running this code, can you figure out which prime number has been encoded within the input of ASCII letters
[ Mcb ]
plus the trick that allowed me to achieve such a compression ratio.
* The code works equally well in gawk, mawk-1, mawk2, and nawk.
It is ENTIRELY self-encapsulated.
Enjoy !
= === === === === === === === === === === === === ==
echo; cmd=' echo Mcb | mawk2 '\''function _________(__,_,___) { (___="bc <<< \"obase="(_*=_^=_+=++_)"; "(__)" ;\"")|getline _; close(___); return _ } BEGIN {_____="%c";for(_-=(___-=(_=(_*=_*=_*=_+=++_)))^!_;-""<=_;_--) {__[sprintf(_____,___-+-_)]=_}; for(_ in __) { __[_] } } {____=+""; for(_=_____=length($(____));_;_--) { ___=__[substr($(____),_,!!_)]___ }; ______=___%(_____=((!-"")(-""))^(_____*=(_^=_=-"")^-!-""));_______=int(___/_____);___="%*.f"; ________=sprintf((___"_")___,--_______,!_,--______+-+_______,!___); gsub(/[^_]/,_^!_,________); sub(/[_]/,+"",________); sub(/..$/,"",_____);_____+=_="";_+=_^=_; printf(" log-base-"(_)" :: %."(_^_^_)"g%c%c %c digits in decimal :: %d%c%c 0x %s%c%c",log(_)^(_/-_)*(log((".")(________))+log(_____)*(___=length(________))), _____, _____,_^_*_____-_^-!!_*_____,___,_____,_____, _________(________), _____,_____); system("openssl prime -checks "(_+=_*=(_^=_)*_)" "(________)) }'\'' '; gprintf '\n%s\n\n' "${cmd}" ; echo; eval "${cmd}"
@Janis Papanagnou : if u want a pure awk code challenge, tell me what output comes out of this :
mawk _^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^-_^_^_^_^_^_^_^_^_^_^_^_^_^--_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_
@Janis Papanagnou : if u want a pure awk code challenge, tell me what
output comes out of this :
mawk _^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^-_^_^_^_^_^_^_^_^_^_^_^_^_^--_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_
On Mon, 17 Jan 2022 02:28:27 -0800 (PST), Kpop 2GM
<jason.cy.kwan@gmail.com> wrote:
@Janis Papanagnou : if u want a pure awk code challenge, tell me what
output comes out of this :
mawk
_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^-_^_^_^_^_^_^_^_^_^_^_^_^_^--_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_
Absolutely nothing if you don't supply an input, and even then I doubt it produces any output at all.
On 17.01.2022 11:28, Kpop 2GM wrote:
@Janis Papanagnou : if u want a pure awk code challenge, tell me what output comes out of this :
mawk _^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^-_^_^_^_^_^_^_^_^_^_^_^_^_^--_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_
From a quick glance it seems only half of what is produced by either of
awk 'Doh! Uh - oh, oh no; no! (not again)'
awk 'Doh! Uh - oh, oh no; no! (not again) - Unclear?! then say: "bye"'
Janis
On 17.01.2022 12:03, pk wrote:those cascading 0^0, and one single negation and one single pre-decrement were absolutely intentional.that wasn't a typo.
On Mon, 17 Jan 2022 02:28:27 -0800 (PST), Kpop 2GM
@Janis Papanagnou : if u want a pure awk code challenge, tell me what
output comes out of this :
mawk
_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^-_^_^_^_^_^_^_^_^_^_^_^_^_^--_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_
Absolutely nothing if you don't supply an input, and even then I doubt it produces any output at all.Careful! - You have a variable named _ and it has a value in numeric
context of 0, then you have these cascades of power 0^0 which results
in 1, and some arithmetic in between (- and - -), that effectively
seems to result in 1, meaning an awk condition 'true', and that the
input is therefore just reproduced in the output. (Just an educated
guess, no analysis done.)
Janis
but i also found the absolutely shortest syntax possible to utilize gawk's hex decoder and print out decimals, assuming the input is just rows of 0x….. :need to append my statement - the same code also works for octals-to-decimals. echo 025333523235356512534543125646531264523653261 | gawk -nM '($!_=+$_)~_' 1822980154315230596830091282486207141553
gawk -n '($!_=+$_)~_'
or
gawk -nM '($!_=+$_)~_' (if you need higher than double precision)
On Monday, January 17, 2022 at 5:54:28 AM UTC-5, Janis Papanagnou wrote:
On 17.01.2022 11:28, Kpop 2GM wrote:
From a quick glance it seems only half of what is produced by either of
@Janis Papanagnou : if u want a pure awk code challenge, tell me what output comes out of this :
mawk _^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^-_^_^_^_^_^_^_^_^_^_^_^_^_^--_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_
awk 'Doh! Uh - oh, oh no; no! (not again)'
awk 'Doh! Uh - oh, oh no; no! (not again) - Unclear?! then say: "bye"'
Janis
it's actually really straight forward - that code simply prints everything except first line.
here's another pure awk one for u : what does this perform :
mawk -F= 'BEGIN {_+=(_^=__=_+=++_+_)-_/_} $!!_=$!_=$(__+(_<=+$!_)*NF)'
On Monday, January 17, 2022 at 6:14:48 AM UTC-5, Janis Papanagnou wrote:
On 17.01.2022 12:03, pk wrote:
On Mon, 17 Jan 2022 02:28:27 -0800 (PST), Kpop 2GMCareful! - You have a variable named _ and it has a value in numeric
@Janis Papanagnou : if u want a pure awk code challenge, tell me what >>>> output comes out of this :
mawk
_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^-_^_^_^_^_^_^_^_^_^_^_^_^_^--_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_
Absolutely nothing if you don't supply an input, and even then I doubt it >>> produces any output at all.
context of 0, then you have these cascades of power 0^0 which results
in 1, and some arithmetic in between (- and - -), that effectively
seems to result in 1, meaning an awk condition 'true', and that the
input is therefore just reproduced in the output. (Just an educated
guess, no analysis done.)
Janis
those cascading 0^0, and one single negation and one single pre-decrement were absolutely intentional.that wasn't a typo.
but i also found the absolutely shortest syntax possible to utilize
gawk's hex decoder and print out decimals, assuming the input is just rows of 0x….. :
gawk -n '($!_=+$_)~_'
or
gawk -nM '($!_=+$_)~_' (if you need higher than double precision)
try this one :
echo '0xCAFEBEEFFEED' | gawk -n '($!_=+$_)~_'
223195473903341
BTW, I skip/skipped your many posts from the last two days; I find it inconvenient to get fragmentary thoughts spread over many postings.it's not that i enjoy fragmentation (maybe it's just a manifestation of my ADHD). this, being a good ole' newsgroup, means I couldn't go edit existing posts. the only other option being i copy-over full text of existing to a new post, plus the amendment(s), then deleting the old post (and repeating that cycle numerous times). I'll do it if that's your preference.
(Maybe I read them later or maybe not.)
Sysop: | DaiTengu |
---|---|
Location: | Appleton, WI |
Users: | 793 |
Nodes: | 10 (1 / 9) |
Uptime: | 37:54:46 |
Calls: | 11,106 |
Calls today: | 3 |
Files: | 186,086 |
Messages: | 1,751,432 |