Results:
Second of the returning challenges on mircscripts.org and it was another success. Thanks to all those who participated and I welcome those new to participating in challenges... hope you find it a rewarding experience. :)
The Challenge: Explained
The challenge was one of an unusual one that I came up with. You were given code to de-obfuscate. As quite a few have pointed out across the forum and in private messages - The code did give strange results if it was spread across multiple lines. You needed to analyse why it did this and what it was doing instead. In actual fact what was happening was a mIRC parser error between the two while loops that was on the same line. The while loop effectively turns into an if statement and only iterated once and it never actually 'looped' – To understand this, I’ve created an alias that will simulate the parser error:
| alias parser-error var %a 1,%i 500 | while %i { while %a { echo -a %i | dec %a } | %a = 1 | dec %i } |
Looking at this code you would expect it to echo from 500 to 1 on the screen. Instead, it only displays 500. If you were to spread this across multiple lines – It would execute as expected.
Hint
Some of you might have found the hint:
| V2hpbGUgdGhlcmUgaXMgYSBtaXJjIHBhcnNlciBlcnJvciB5b3VyIGNvZGUgd2lsbCByZW1haW4gdmFsaWQu |
Not much of a hint? In the rules was another 'secret' hint in which said '$decode is allowed.' Once you $decode(hint,m) you received the message:
| While there is a mirc parser error your code will remain valid. |
I'm not sure how many people found this out - It would be interesting to know in the forums after the results are posted. :)
Results
Out of the 20 entries - 9 were invalid and 11 were valid entries. Congratulations to the winner jaytea with 142 bytes and in second place E_TarDeD with 145 bytes. Due to the huge volume of tests upon the new $obs alias - Only the first failed test pattern will be shown.
I once again invite all those to participate in the next challenge. As always, suggestions for challenges are welcomed in private message to me.
Winner:
jaytea 142 bytes!
Top Entries
Invalid Entries
| zzattack | 145 bytes | $obs(tel4) returns $null instead of 81 |
| Lam4o | 155 bytes | $obs(Ty5QH0) returns 8D instead of 9E |
| xinion | 159 bytes | $obs(TDID0ZFzPm) returns 4 instead of 118 |
| LimonE | 172 bytes | $obs(W) returns 3 instead of $null |
| foobar | 223 bytes | $obs(6NtaWPyVcnx) returns 169 instead of 3 |
| Mpdz | 232 bytes | $obs(F) returns 3 instead of 2 |
| [Znork] | 244 bytes | $obs(1ypIQqG3S) returns $null instead of 104 |
| hixxy | 267 bytes | $obs(X9) returns 32 instead of $null |
| blink | 325 bytes | $obs(D) returns 232032 instead of 2 |
Description:
new challenges as of 2006!
In this challenge you are asked to take the obfuscated code below and shorten it as much as possible.
The code has been deliberately made longer than necessary. You will need to understand what the code does in order to shorten it substantially. The code MUST return the same output as the code below.
Here is the code:
alias obs {
var %=, %$ 1,%%,%:,%:.,%l $len($1-) | while %$ <= %l { %= = $calc($asc($mid($1-,%$,1))/2.9+%=) | %$ = %$ + 1 } | %= = $left(%=,$pos(%=,.)) | %l = $iif(*0 iswm %l,9,$right(%l,1)) | %$ = 1 | while %$ <= $len(%=) { %: = $mid(%=,%$,%l)
while %: { %:. = $iif($calc(%: % ($asc(%)-21)) > 9,$chr($calc(5*11+$v1)),$v1) $+ %:. | %: = $int($calc(%: /($asc(/:.)-31))) } | %% = %% $+ $iif(%:.,$v1,0) | %$ = %$ + %l } | return %% }
Example:
$obs(z) = 4
$obs(123456) = 6A
$obs(?:@~0-+) = 9A
$obs('';,,.,//??///##=-2990425//:!::::!@#s]/) = 2AD
Hint: V2hpbGUgdGhlcmUgaXMgYSBtaXJjIHBhcnNlciBlcnJvciB5b3VyIGNvZGUgd2lsbCByZW1haW4gdmFsaWQu
Rules:
Alias name must remain 'obs'
No dlls, coms, sockets or regular expressions
One submission per user
Your code will be taken for EXACTLY as submitted. Nothing will be changed in your submitted code - even if a subtle mistake is found.
Alias will be run on mirc v6.16 $decode is allowed.
Script must give correct results after consecutive runs.
File will be loaded into the remotes section
Code will sometimes return nothing ($null) - This is intentional.
File we will be using to count the code: countcode.mrc
Alias will be run on a mirc with no variables set - a clean mirc.
Alias MUST return the same output as the alias above - your code will be tested against input values of different character sets and lengths of up to 900 chars against the original 'obs'.
Entries will be judged on code size and whether they return the same output as the original 'obs' alias.