(mIRC) Code Contest: $byte()

By raccoon on Jan 16, 2015

This challenge is simple:

Write a function $byte(N) that emulates the behavior of $bytes(N).suf.

$bytes(N).suf converts the value N as bytes of a file size into a human readable format along with the suffix B, KB, MB, GB or TB. Your function simply copies this one behavior of the $bytes() identifier and nothing else. No $bytes(N,3) or anything. You should compare multiple values of $bytes(N).suf against your own $byte(N) to make sure they match. There are 1024 bytes in a kilobyte and so on.

Output must be an EXACT match of $bytes().suf for all values of N: 1 thru 999999999999999

Shortest function wins! Code submissions will be scored by total script length, excluding indentation.

Your script should be written in the Aliases section and not the Remotes section. There should be no "alias " or "/" prefix included in your submission. Here are some example templates for your code:

byte {
  return stuff

or just

byte return stuff

You may not use $bytes() in your submission or any obfuscated derivative that calls $bytes(), and you may not use external libraries, processes or network requests.

Your function will only be tested for input values 1 thru 999999999999999. Validating input is not required.

You can use this alias to test the functionality of your code. This is only a practice test function and its behavior or misbehavior does not influence the nature of the rules above.

byteTest {
  var %a = $bytes($$1).suf, %b = $byte($$1)
  echo -ga * byteTest: $1 : %a , %b : $iif(%a === %b,$chr(3) $+ 3PASS,$chr(3) $+ 4FAIL)
  editbox -ap /byteTest

Again, this is a shortcode challenge, so the submission with the shortest number of characters (excluding indentation) will be declared the winner. Generally speaking, pipes will add 3 characters per line to your script so avoiding using them, and instead break your code into multiple lines or use more creative methods than pipes to reduce the size of your submission.

All submissions must be made no later than Friday, 23 Jan 2015 somewhere in the world. Code may be submitted via Hawkee Messages or somewhere on IRC. I have already written a couple variations of this function myself which I'll be willing to share at the conclusion of this contest, but I shall exclude myself as a contestant.

Have fun!

The idea for this challenge was originally thought up by Talon but he changed his mind.


Sign in to comment.
raccoon   -  Jan 17, 2015

Click LIke if you think you're going to enter a submission so I know people are playing.

Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.