Description:
In this challenge you are asked to create an alias that will compress a string of characters that are in alphabetical order.
Syntax
$reduce(<a-z characters to compress>)
Input:
- $1 will only contain a-z characters in lowercase
- $len($1) will be <= 200
- no validation is needed -- asume the correct input is always passed
Output:
- your alias must return the output where there are 3 or more characters in alphabetical order and convert it into a range i.e. $reduce(abc) = a-c
- characters can go "backwards" which must be reduced too i.e. $reduce(cba) = c-a
- must work for a using more than one range set i.e.: $reduce(abcba) = a-c-a
Examples
simple examples:
$reduce(abcd) = a-d
$reduce(hijlbcd) = h-jlb-d
$reduce(ihdlkioabcihgfe) = ihdlkioa-ci-e
going backwards:
$reduce(cba) = c-a
$reduce(zyx) = z-x
using more than one range:
$reduce(abcdcba) = a-d-a
$reduce(abcddcba) = a-dd-a
$reduce(abcba) = a-c-a
$reduce(abcbabcdefgfec) =a-c-a-g-ec
Example:
$reduce(cba) = c-a
$reduce(abcddcba) = a-dd-a
$reduce(abcd) = a-d
$reduce(hijlbcd) = h-jlb-d
$reduce(abcdefghijklmnopqrstuvwxyz) = a-z
$reduce(abhijklmnopqrstucdefgvwxyz) = abh-uc-gv-z
$reduce(ihdlkioabcihgfe) = ihdlkioa-ci-e
$reduce(aaabcd) = aaa-d
$reduce(zzzyxqrstuv) = zzz-xq-v
$reduce(abcdcba) = a-d-a
$reduce(abcbabcdefgfec) =a-c-a-g-ec
Rules:
Alias name must be 'reduce'
No dlls, coms, sockets, jaytea
One submission per user per entry type.
Script must give correct results after consecutive runs.
Testing conditions:
Alias will be run on mIRC v6.35 and loaded into the alias section i.e. NO alias { }.
Must have balanced brackets
Your code will be taken for EXACTLY as-is.
Alias will be run on a mIRC with no variables set - a clean mIRC.