mIRC Homepage
Posted By: FroggieDaFrog Challenge(Short-Code): $skip - 25/07/17 05:16 PM
Overview
Starts: Tuesday, July 25, 2017
Ends: Monday, August 7, 2017 @ 12:00pm EDT
Description: Return only characters of an input that aren't to be skipped over
Type: Short-Code


Explanation
  • Create an identifier alias named skip that returns only characters from an input("input-text") that have not been skipped due to designated skip inputs("skip-input")
  • The alias should account for a .invert prop that results in the characters that were skipped being returned
  • The input-text will always be at least one character in length
  • The input-text will consist of only letters and/or numbers: a-z, A-Z, 0-9
  • A skip-input indicates the number of characters of the input-text to skip.
  • After characters have been skipped, the next character in the input-text - if any are left - should be consumed and added to the output.
  • Subsequent skip-inputs are to start counting directly after the character consumed for output.
  • A skip-input will be a whole number equal to or greater than zero.
  • A skip-input may be larger than the amount of characters left to process in the input-text.
  • A variable number of skip-inputs will be specified but there will always be at least one.
  • If the end of the skip-input list has been reached, cycle back to the first skip-input until the entire input-text has been gone over.



Examples
Code:
$skip(ab,1)
    Skips 1 character: a
    Stores: "b"
    Reaches the end of the input so returns: b
  
$skip(a, 0)
    Skips 0 characters
    Stores: a
    Reaches end of input so returns: a

$skip(abcdefg, 2, 1)
    Skips 2 characters: ab
    Stores: c
    Skips 1 character: d
    Stores: e
    Skips 2 characters: fg
    Reached the end of the input so returns: ce
  
$skip(abcdefghij, 2, 1)
    Skips 2 characters: ab
    Stores: c
    Skips 1 character: d
    Stores: e
    Reached end of skip-inputs so cycles back to the first skip-input
    Skips 2 characters: fg
    Stores: h
    Skips 1 characters: i
    Stores: j
    Reaches end of input so returns: cehj

$skip(abcdefghi, 2, 1).invert
    Stores 2 characters: ab
    Skips the next character: c
    Stores 1 character: d
    Skips the next character: e
    Reached end of skip-inputs so cycles back to the first skip-input
    Stores 2 characters: fg
    Skips the next character: h
    Stores 1 character character: i
    Reaches end of input so returns: abdfgi



Categories
There are two categories for this challenge of which can be entered. You may submit to either or both categories. That is you may submit an entry for one of the categories and make another submission for the other. The categories are
  • Non-regex: The submission does not make use of regex
  • Regex: The submission makes use of regex



Rules
  • Submissions will be saved as skip.mrc
  • Submissions will be loaded into a fresh offline mIRC v7.49 instance's fresh remote section
  • Submissions length will be determined by the "byte" value from https://mothereff.in/byte-counter AFTER leading spaces(chr 32) are removed from each line
  • Submissions may contain supporting alias
  • Submissions do NOT have to run cleanly but must be able to be re-ran indefinitely
  • No mismatched brackets`{}` or parentheses`()`
  • No use of external-inputs such as $?, $input, etc
  • No File-System access, COMs, DLLs, Sockets or tools outside of mIRC
  • Do not abuse the rules, byte counter or test alias



Submitting
  • Send entries to me via Forum Private Message with the topic of "Challenge: $skip Entry"
  • I will also accept entries through IRC query messages in the form of pastebin links but there is no guarantee I will receive it
  • In your entry post, specify if it uses regex or not
  • You may submit as many times as you like, only your last entry for each category at the end of the challenge will be evaluated
  • I will check the forums at least once a day for new entries, evaluate them and tell you if the entry is valid



Questions
If something is unclear feel free to ask as a reply to this post or, if the question would give your methodology away, ask via PM
Posted By: FroggieDaFrog Re: Challenge(Short-Code): $skip - 26/07/17 05:51 PM
Clarification

There is no need for prop validation. If a prop is specified, it will always be .invert
Posted By: Asterix_UO Re: Challenge(Short-Code): $skip - 30/07/17 11:45 AM
the before spaces will be counted?
may I ommit then in skip.mrc?
Posted By: FroggieDaFrog Re: Challenge(Short-Code): $skip - 30/07/17 02:05 PM
The before spaces will NOT be counted. I do not wish to punish participants for mIRC's auto formatting.

Code:
alias thing {
  cmd 1
  cmd 2
  cmd 3
}
will be counted as:
Code:
alias thing {
cmd1
cmd2
cmd3
}
Posted By: FroggieDaFrog Re: Challenge(Short-Code): $skip - 30/07/17 05:28 PM
$sha256(skip.mrc,2) for my entry:
Code:
a872c1f99807134be01364426d0982e61e5a773478ad111ee56f1b9cbd7c2a31
Posted By: FroggieDaFrog Re: Challenge(Short-Code): $skip - 01/08/17 08:13 PM
Test alias

/skiptest
Code:
alias -l skiptests {
  goto $1
  :1 | return a,1 0
  :2 | return a,1 1 a
  :3 | return ab,1 0 b
  :4 | return ab,1 1 a
  :5 | return abcdef,1 0 bdf
  :6 | return abcdef,1 1 ace
  :7 | return abcdef,2 0 cf
  :8 | return abcdef,2 1 abde
  :9 | return abcdef,1,2 0 be
  :10 | return abcdef,1,2 1 acdf
  :11 | return Dq6nV3Klx4GusXtadgrmL6R5ANS1u59yzfv17l9f5j1QvgW9gnsQMtYSDDJrhqoLVYwGOXOvuq2jZib33oMqqeY89wRqNZAriaB3S3Src79jggKGEzyEcuI9PKJcD0IULcqpUkFuL8aH6d9KJa7u5bZ0SA5mTz5bEfBleJBY8AYhllp4MtHRqFxkLcCpR2fadlVhhu29,2,1,4,5,3,5,3 0 6V4amN5zvfgnSroVXj3ewNA37gE9JDcuHabS5bJA4RxL2h9
  :12 | return Dq6nV3Klx4GusXtadgrmL6R5ANS1u59yzfv17l9f5j1QvgW9gnsQMtYSDDJrhqoLVYwGOXOvuq2jZib33oMqqeY89wRqNZAriaB3S3Src79jggKGEzyEcuI9PKJcD0IULcqpUkFuL8aH6d9KJa7u5bZ0SA5mTz5bEfBleJBY8AYhllp4MtHRqFxkLcCpR2fadlVhhu29,2,1,4,5,3,5,3 1 Dqn3KlxGusXtdgrL6R5AS1u9yf17l95j1QvW9gsQMtYDDJhqLYwGOOvuq2Zib3oMqqY89RqZriaBS3Src9jgKGEzycuIPKc0IULqpUkFL8a6d9KJ7u5Z0AmTz5EfBleBY8YhllpMtHqFkcCpRfadlVhu2
  :error
  reseterror
  return
}

alias skiptest {
  var %x 1
  while ($skiptests(%x)) {
    tokenize 32 $v1
    var %res = $!skip( $+ $1 $+ ) $+ $iif($2,.invert)
    if ($(%res,2) !== $3) {
      echo 04 -a [SkipTest# $+ %x] %res - Expected: $v2 - Result: $v1
      return
    }
    else {
      echo 03 -a [SkipTest# $+ %x $+ ] Passed
    }
    inc %x
  }
  echo 12 -a [SkipTest] All tests passed
  return
  :error
  echo 04 -a [SkipTest# $+ %x $+ ] mIRC error: $error
  reseterror
}
Posted By: FroggieDaFrog Re: Challenge(Short-Code): $skip - 03/08/17 08:54 AM
Added tests:"0" as a non-first skip-input:
Code:
:13 | return abcdef,1,0 0 bcef
:14 | return abcdef,1,0 1 ad


Posted By: Asterix_UO Re: Challenge(Short-Code): $skip - 05/08/17 01:36 PM
line break will be counted too?
Posted By: FroggieDaFrog Re: Challenge(Short-Code): $skip - 05/08/17 01:44 PM
line breaks are counted as 1 character as per how the linked byte counter functions
Posted By: FroggieDaFrog Re: Challenge(Short-Code): $skip - 05/08/17 02:59 PM
New Tests
"0" related inputs
Code:
:15 | return 0,1 0
:16 | return 0,1 1 0
:17 | return 00,1 0 0
:18 | return 00,1 1 0
:19 | return 00000000,1,2,1 0 000
:20 | return 00000000,1,2,1 1 00000


Unless I've sent you a reply PM, entries have been retested and passed these new tests.


Note
Only the test cases in this post & above will be used to test validness from this point onward; no new test cases will be added. I do not want an instance of last minute tests invalidating entries.
Posted By: FroggieDaFrog Re: Challenge(Short-Code): $skip - 07/08/17 04:22 PM
Results

Congrats to Sat for the non-regex catagory and to jaytea for the regex category. Thanks everyone for participating. laugh


Non Regex

Sat - Forums - 178 bytes (Non Regex)
Code:
alias skip %i = $1 | while (%i > !) var %p $($ $+ $calc(%n % (1-$0)+2),2),%q %p + 4,%o %o $+ $iif($prop,$left(%i,%p),$mid(!! %i,%q,1)),%i $mid(! %i,%q),%n $calc(1+%n) | return %o


Degausser - Forums - 184 bytes (Non Regex)
Code:
alias skip {
  var %x,%n,%i
  ::
  inc %x
  if ($(,$ $+ $calc($len(%n)% ($0 -1)+2))) %i = %i $+ $mid($1,%x,$v1)
  inc %x $v1
  if $mid($1,%x,1) < + return $iif($prop,%i,%n)
  %n = %n $+ $v1
  goto :
}


SReject - Self - 187 bytes (Non Regex)
Code:
alias skip {
  var %i $1,%n 1 
  while $len(%i) {
    inc %n
    if (%n > $0) %n = 2
    var %z $(,$ $+ %n),%o %o $+ $iif($prop,$left(%i,%z),$mid(%i,$calc(%z +1),1)),%z %z + 2,%i $mid(%i,%z)
  }
  return %o
}


rockcavera - Forums - 201 bytes (Non Regex)
Code:
alias skip {
  var %a 2,%b 1,%r
  while %b <= $len($1) {
    %c = $($ $+ %a,2)
    %r = %r $+ $iif($prop,$iif(%c,$mid($1,%b,%c)),$mid($1,$calc(%b + %c),1))
    inc %b %c
    inc %b
    inc %a
    if (%a > $0) %a = 2
  }
  return %r
}



Regex

jaytea - Forums - 111 bytes (Regex)
Code:
alias skip return $(,$regsubex($1,m $regsubex($2-,/(\d+)/g,$iif($prop,(.{0,\t}).?,(?:.|){\t}(.?))) gx,\A $!/)))


Sat - Forums - 175 bytes (Regex)
Code:
alias skip var %i $1,%n 2 | while ($regex(%i,(?=.)(.{0, $+ $($ $+ %n,2) $+ })(.?)(.*))) var %o %o $+ $regml($iif($prop,1,2)),%i $regml(3),%n $iif(%n < $0,%n,1) + 1 | return %o


Loki12583 - Forums - 187 bytes (Regex)
Code:
alias skip var %a $iif($prop,1,0),%b 1 - %a,%l $regsubex($2-,/(\d+)/g,$str(%a $+ $chr(32),\t) %b) | return $regsubex($1,/(.)/g,$iif($gettok(%l,$calc((\n -1)% $numtok(%l,32)+1),32),\t))



Note
I have another creative-type challenge planned to start this coming Friday(and run for a month) so stay tuned
Posted By: Sat Re: Challenge(Short-Code): $skip - 07/08/17 04:38 PM
Damn, jaytea. Amazing. I'm glad you left one category to us mere mortals :P

Once again, thanks so much SReject for organizing the challenge!
Posted By: FroggieDaFrog Re: Challenge(Short-Code): $skip - 07/08/17 04:39 PM
Fix
I made a tracking error in the post above that had Degausser with a stale submission. This has been fixed to his last submission before the deadline.
Posted By: Degausser Re: Challenge(Short-Code): $skip - 07/08/17 04:40 PM
Thanks for this, was quite fun. Congrats to both winners!
Posted By: FroggieDaFrog Re: Challenge(Short-Code): $skip - 07/08/17 04:45 PM
Originally Posted By: Sat
Once again, thanks so much SReject for organizing the challenge!

Originally Posted By: Degausser
Thanks for this, was quite fun. Congrats to both winners!


You all are welcome, hope everyone that participated enjoyed it.
Posted By: jaytea Re: Challenge(Short-Code): $skip - 07/08/17 06:47 PM
thanks SReject for hosting this challenge so capably, and for giving me a great excuse to fire up mIRC and tinker around with it again! i almost forgot how much I enjoyed this fun lil scripting language laugh

Originally Posted By: Sat
Damn, jaytea. Amazing. I'm glad you left one category to us mere mortals :P


oh, first challenge in a long time.. I thought it wise not to push my luck!

also, wow, I don't think it ever occurred to me that $calc(A % B) = $calc(A % -B)! I'm sure that's cost me a char in at least one challenge in the past...
Posted By: FroggieDaFrog Challenge(Short-Code): $skip - 07/08/17 11:33 PM
Fix
I missed one entry in the above results:

Asterix_UO - Forums - 190 bytes (Non-Regex)
Code:
alias skip {
  %@ =
  %x = $iif($prop,0,1)
  while (%x <= $len($1)) {
    %t = $iif($prop,$2,1)
    inc %x $iif($prop,1,$2)
    %@ = %@ $+ $iif(%t,$mid($1,%x,%t))
    inc %x %t
    tokenize 32 $1 $3- $2
  }
  return %@
}
© mIRC Discussion Forums