mIRC Home    About    Download    Register    News    Help

Topic Options
#264030 - 21/10/18 07:21 AM New Challenge! $palicount() - a palindrome counter
jaytea Offline

Fjord artisan

Registered: 23/02/06
Posts: 542
Please see the below replies for extra clarification and important updates to the rules!

I would like to share an old tradition with you, one that inspired myself and many of my fellow scripters over the years to cultivate our knowledge of mIRC's fun and quirky syntax. It's a tradition that bred generations of avid scripters, sparked valuable discussion, and provided many hours of satisfying thought to all those who partook.

I'm talking, of course, about mIRCscripting challenges.

I have one for you. It's easily stated, maybe even easily coded, but I hope and estimate it will be tricky to fashion a winning entry.

Name: $palicount() - a palindrome counter!
Difficulty: Easy
Criteria: Shortcode
Deadline: Wed 21 Nov 10:00 (10am) GMT

Description:

Your challenge is to create a custom identifier that returns the total number of palindromes in the input. This includes palindromes that are part of other, larger palindromes. Ignore palindromes less than 3 characters in length.

Examples:

$palicount(abcc) = 0

$palicount(abcdcb) = 2
The palindromes here are "bcdcb" and "cdc".

$palicount(racecarac) = 5
The palindromes here are "racecar", "aceca", "cec", "carac", and "ara".

$palicount(aaaaa) = 6
The palindromes here are "aaaaa", two occurrences in different positions of "aaaa", and three of "aaa".

$palicount(babbab) = 4
The palindromes here are "babbab", "bab", "bab", and "abba".

Input:

The input will be a single argument consisting of an alphanumeric string less than 100 characters.

Output:

A single integer N representing the number of palindromes found.

Judging:

Your alias will be judged based on its codesize as measured by the following link: https://jay-tea.github.io/mirc/countcode.html

Regex related functions in mIRC have come a long way over the years, and now provide scripters with a set of tools so powerful that it is no longer fair to allow them to compete with other methods.

So, there will be two winning categories: regex and non-regex. One scripter may compete in both of these categories with separate entries if they wish.

Rules:

- Your alias should be case sensitive, ie. $palicount(abA) = 0
- Your code will be loaded into the remote section of a clean mIRC instance.
- Additional code, such as an auxiliary remote alias, is allowed.
- No sockets.
- COM Object are permitted, but no calls that involve network communication.
- Your alias must run "cleanly", ie. not leave behind any hash tables, global variables, @windows, etc.
- Your alias must be able to run consecutively and return correct values if called more than once in the same line of code.
- This is not a lateral thinking exercise. I won't accept any exploitation of the rules or countcode script, no matter how creative.
- Similarly, your alias needs to terminate before I die.

Submitting:

Entries should be submitted to me through PM on these forums, or on IRC if you don't have an account.

Test alias:

To be made! Check back later.

By the way, I would be interested and greatly amused to see an entry from you, Khaled, if you happen to be reading this laugh


Edited by Khaled (23/10/18 10:27 AM)
_________________________
"The only excuse for making a useless script is that one admires it intensely" - Oscar Wilde

Top
#264035 - 21/10/18 07:48 PM Re: New Challenge! $palicount() - a palindrome counter [Re: jaytea]
Raccoon Offline
Hoopy frood

Registered: 18/02/03
Posts: 2476
> This is not a lateral thinking exercise. I won't accept any exploitation of the rules or countcode script, no matter how creative.

I always found the creative 'honorable mentions' a fulfilling part of these contests, and wouldn't mind seeing those rule-broke approaches as well, especially when they don't follow an expected path or reveal an interesting quark in the language. smile
_________________________
doiní things a particle can

Top
#264039 - 22/10/18 02:29 AM Re: New Challenge! $palicount() - a palindrome counter [Re: jaytea]
FroggieDaFrog Online
Hoopy frood

Registered: 16/04/10
Posts: 904
Loc: USA
For COMs, is requiring a non-native library allowed? If not, then I'd suggest going with COMs not being allowed.

The reason is that what is native to my machine may not be native to yours. Not that its allowed, but a decent example is windows native MSXML. Some machines have v2, later versions have v3, win10 has v7. Each has different interfaces, quirks, etc.


And could you clarify requirements on brackets, as you made no mention of them. Are we allowed to have unclosed brackets?
Code:
alias example {
  ; ....


Edited by FroggieDaFrog (22/10/18 02:31 AM)
_________________________
I am SReject
My Stuff

Top
#264042 - 23/10/18 08:45 AM Re: New Challenge! $palicount() - a palindrome counter [Re: FroggieDaFrog]
jaytea Offline

Fjord artisan

Registered: 23/02/06
Posts: 542
IMPORTANT: RULE CLARIFICATION AND TEST ALIAS

I'd like to clarify a few of the rules and also use this opportunity to give you a test alias:

Code:
alias test_palicount {

  var %+ = scon 1 $(%test = %test, 0), %i = 1, %test, %time, %tot, %fail

  %+ jaytea 0
  %+ a 0
  %+ aa 0
  %+ aaA 0
  %+ 000 1
  %+ 0x00 1
  %+ 0x000 2
  %+ abcc 0
  %+ abcdcb 2
  %+ racecarac 5
  %+ aaaaa 6
  %+ aaAaa 2 
  %+ aaAAAaa 3
  %+ babbab 4
  %+ babbabbab 10
  %+ madamadam 8
  %+ madammadam 8
  %+ madamracecar 5
  %+ donaldtrump 0
  %+ amanaplanacanalpanama 16
  %+ 00000000000000000000000000000000000000000000000000 1176
  %+ 01010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101 2352
  %+ aAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaA 2352
  %+ 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 4753
  %+ aaasdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfbbb 2
  %+ qlgapbhfcdyjkygrodepkwypocggteqvxpjgajvbcuvkltflpjbsmbwirysgqejsgtverbapiqvvjyolzyvsbwgqcsjxrpqccno 0

  echo 3 -eag Starting test:
  %time = $ticks

  while ($gettok(%test, %i, 32) != $null) {
    var %in = $v1, %out = $gettok(%test, $calc(1 + %i), 32)
    if ($palicount(%in) != %out) {
      echo 4 -ag Failed on $!palicount( $+ %in $+ ) (returned $v1 instead of %out $+ )
      inc %fail
    }
    inc %tot
    inc %i 2  
  }
  %time = $calc($ticks - %time)

  echo $iif(%fail, 4 -eag Failed. Only passed, 3 -eag Success! Passed) $calc(%tot - %fail) out of %tot tests in %time $+ ms

}


Just load and use /test_palicount to test out your alias

Now, rules.. some of you have made some good points and raised interesting questions so I'll attempt to clarify them all here:

1. Code will be tested on mIRC 7.52 (thanks Ouims :P)

2. COM: let us now say COM is now entirely disallowed. The rule in my post comes from a time when various scripters were learning and playing around with COM objects, and so I wanted to grant them the freedom to pursue methods that were almost certainly not going to be conducive to winning.

3. {} Braces: please include the final trailing brace. It's only 1 byte, everyone knows the trick by now, and I'll be adding it to your code if you omit it :P

4. Identifier warning will be disabled. Go nuts :P

I think that's it, but stay tuned to this topic in case there are any further updates. Have fun!
_________________________
"The only excuse for making a useless script is that one admires it intensely" - Oscar Wilde

Top
#264216 - 10/11/18 05:31 AM Re: New Challenge! $palicount() - a palindrome counter [Re: jaytea]
jaytea Offline

Fjord artisan

Registered: 23/02/06
Posts: 542
Less than two weeks to go - get your entries in!
_________________________
"The only excuse for making a useless script is that one admires it intensely" - Oscar Wilde

Top