SwiftIRC
IRC Discussion and Support
 
  Index  •  FAQ  •  Search  

It is currently Tue Jun 18, 2013 6:52 am




Post new topic Reply to topic  [ 13 posts ] 
 [Easy] $mulrep 
Author Message
 Post subject: [Easy] $mulrep
PostPosted: Sat Jul 25, 2009 6:43 pm 
User avatar
User
User

Joined: Tue Jan 01, 2008 7:32 pm
Posts: 714
Location: #mSL
Intro
  • This is my first ever challenge, so i hope it goes pretty good. Goal in short is to take a string and have it apply multiple changes to it. In a sense it will be like replace. Only difference is, you can supply multiple words to be replaced by one.
  • $mulrep(STRING,WORDS;YOU;WANT;TO;REPLACE,SUBSTRING,MORE;WORDS;TO;REPLACE,SUBSTRING2,...)
  • Example:
    • $mulrep(hello there what's up homedawg,dawg;there,guy,what;home,wierd) ==> hello guy wierd's up wierdguy
    • $mulrep(hello there up,there,what's) ==> hello what's up
    • $mulrep(hello,hi) == > hello

Rules
  • This is a shortcode challenge.
  • Must theoretically be able to do an infinite amount of replacements.
  • Must be able to be called multiple times
  • Your delimiter for the multiple tokens being replaced must be ;.
  • No COMs, DLLs, Sockets.

ByteSyzes will be retrieved using Kol's ByteSize Dialog
  • This can be found here
  • No abusing the dialog
  • All comments found being used will be removed then put into the dialog and then re-added before being tested.

End Date
  • July 30th 12:00PM (EST :: GST-500)
  • Entries must be sent VIA PM to myself.

Test Alias

Code:
alias mulrep_test {
  window -e @MulRep_Test
  clear @MulRep_Test
  var %a What what hi there|''|Hello.|So i've got a story to tell.|That story is really going to be good|So i was talking to this guy|and suddenly my $&
    dogs got attacked by my cats|This story is about to make sense|hi|Mr-Jose-Z aren't you mexican?|I'm running out of things to say| $+ $&
    hello there JoshR|Good night SwiftIRC!|Thanks for doing my challenge.
  var %b ;;ha,u,w;;t,h|,hi|He,|i've,have,got,you,.,?|really,$chr(32),is,$chr(44) is it|$null|my,his,dogs;cats,platypus|story;sense;about,really,to,story| $+ $&
    i,ello|aren't;you;mexican?,cut my grass|running;say;to,OBJECTS,out,into|h;e;l;o;t;r;j;s,z|night;SwiftIRC,excellent!|Thanks,You're $&
    welcome!,for;doing;my;challenge;.,$chr(32)
  var %c huh huh hi hhere|'hihihihihihihihihihi'|llo.|So have you a story to tell?|That story $chr(44) is it going to be good|So i was talking to this guy|and suddenly his $&
    platypus got attacked by his platypus|This really is really story make really|hello|Mr-Jose-Z cut my grass cut my grass cut my grass| $+ $&
    I'm OBJECTS into of things OBJECTS OBJECTS|zzzzz zzzzz zzzzz|Good excellent! excellent!!|You're welcome!
  var %n 1,%correct
  while $token(%a,%n,124) {
    if ($mulrep($v1, [ $token(%b,%n,124) ] ) == $token(%c,%n,124)) {
      echo 3 @MulRep_Test $!mulrep( $token(%a,%n,124) , $token(%b,%n,124) ) == $v1
      inc %correct
    }
    else {
      echo 4 @MulRep_Test $!mulrep( $token(%a,%n,124) , $token(%b,%n,124) ) != $v2 (returned: $v1 $+ )
    }
    inc %n
  }
  echo 12 @MulRep_Test $+($iif(%correct,$v1,0),/,$token(%a,0,124)) passed ( $+ $calc(%correct / $token(%a,0,124) * 100) $+ % $+ )
}


Valid Entries
  • ImK0tter
  • Chid
  • A Noniem (Ano)
  • Mr-own (Mr-Jose-Z/Jose)
  • jaytea
  • WorldDMT

Invalid Entries

    _________________
    Image


    Last edited by JoshR on Thu Jul 30, 2009 12:16 pm, edited 11 times in total.

    Offline
     Profile  
     
     Post subject: Re: [Easy] $mulrep
    PostPosted: Sun Jul 26, 2009 7:15 am 
    User
    User

    Joined: Thu Mar 08, 2007 4:45 am
    Posts: 236
    will you be testing spaces?

    ex: $mulrep(this is a test,a test;is,this)

    _________________
    Image


    Offline
     Profile  
     
     Post subject: Re: [Easy] $mulrep
    PostPosted: Sun Jul 26, 2009 7:30 am 
    User avatar
    User
    User

    Joined: Mon Jun 18, 2007 4:39 am
    Posts: 1594
    So... alias must be clean? Loaded in remotes or aliases? What is the range of characters you will be testing?

    _________________
    Image

    Sig by Steve| (edited by Pat <3), avatar by camerawn


    Offline
     Profile  
     
     Post subject: Re: [Easy] $mulrep
    PostPosted: Sun Jul 26, 2009 4:58 pm 
    User avatar
    User
    User

    Joined: Tue Jan 01, 2008 7:32 pm
    Posts: 714
    Location: #mSL
    Imk0tter wrote:
    will you be testing spaces?

    ex: $mulrep(this is a test,a test;is,this)


    Yes, i will :).

    Kol wrote:
    So... alias must be clean? Loaded in remotes or aliases? What is the range of characters you will be testing?


    Alias will be loaded in aliases.

    Should expect to replace any range of characters.

    It is indeed being tested on a clean mIRC, so i shouldn't find traces of it afterwards.

    _________________
    Image


    Offline
     Profile  
     
     Post subject: Re: [Easy] $mulrep
    PostPosted: Mon Jul 27, 2009 12:00 am 
    User avatar
    User
    User

    Joined: Tue Jan 01, 2008 7:32 pm
    Posts: 714
    Location: #mSL
    Test alias updated, fixed a $chr(44) problem that ImK0tter brought to my attention.

    Also added a few more tests.

    _________________
    Image


    Offline
     Profile  
     
     Post subject: Re: [Easy] $mulrep
    PostPosted: Thu Jul 30, 2009 3:37 pm 
    User avatar
    User
    User

    Joined: Tue Jan 01, 2008 7:32 pm
    Posts: 714
    Location: #mSL
    Lucky for anyone who still wishes to enter. I'm not at home at the moment, so i will have to extend to finish time to later this afternoon till i can test the latest entries.

    So i will post the results then and i apologize for this inconvenience.

    EDIT


    Jaytea: 120 bytes. WINNER

    Code:
    mulrep {
      var %a
      while $(,$ $+ %a) {
        inc %a
        var %b ,$ $+ %a ,,%c %c $replace($v1 ;,;,%b)
        inc %a
      }
      return $replace($1, [ %c ] ,)
    }


    Jose: 132 bytes.

    Code:
    mulrep {
      var %y 1,%c ,,
      while %y < $0 {
        inc %y 2
        var %x %x $replace($(,$ $+ $(},%y)) ;,;,%c $ $+ %y %c)
      }
      return $replace($1, [ %x %c ] )
    }


    Ano: 139 bytes.

    Code:
    mulrep {
      %t = $1
      a $*
      if %t {
      }
      unsetall
      return $v1
    }
    a {
      inc %a
      %r = $1-
      tokenize 59 %y
      if (2 \\ %a) scon 0 set -u $(%t,) $!replace(%t, $* ,%r)
      %y = %r


    Kylar (Mr_K_13): 144 bytes.

    Code:
    mulrep {
      var %i,%t $1
      while $(,$ $+ %i) {
        var %s $v1,%j 1
        inc %i
        while $gettok(%s,%j,59) {
          var %t $replace(%t,$v1,$(,$ $+ %i))
          inc %j
        }
        inc %i
      }
      return %t
    }


    Kol: 149 bytes.

    Code:
    mulrep {
      var %x 3,%o $1
      while %x <= $0 {
        var %y 1
        while $gettok($(,$ $+ $({,%x)),%y,59) > $z {
          %o = $replace(%o,$v1,$(,$ $+ %x))
          inc %y
        }
        inc %x 2
      }
      return %o
    }


    Imk0tter: 160 bytes.

    Code:
    mulrep {
      var %x 3,%y $1
      while $0 >= %x {
        var %n $(,$ $+ $(},%x)),%z $numtok(%n,59)
        while %z {
          %y = $replace(%y,$token(%n,%z,59),$(,$ $+ %x))
          dec %z
        }
        inc %x 2
      }
      return %y


    chid: 210 bytes.

    Code:
    mulrep {
      var %m 2,%s,%r $1
      while (%m <= $iif($calc($0 % 2),$0,$calc($0 - 1))) {
        %s = %m + 1
        %c = 1
        %1 = [ $ $+ [ %m ] ]
        %2 = [ $ $+ [ %s ] ]

        while ($token(%1,%c,59)) {
          %r = $replace(%r,$v1,%2)
          inc %c
        }
        inc %m 2
      }
      return %r
    }


    WorldDMT: 372 bytes.

    Code:
    mulrep {
      var %t $0,%r $1,%i 2,%l 3,%x $regsubex($str(.,$(%t,2)),/./g,$chr(32) $+($,\n) •),%x $left($replace($(%x,2),;,|,$+($chr(32),•,$chr(32)),•),-1)
      while ($gettok(%x,%i,149)) var %v $replace($iif($replace($v1,||,|) != $+(|,$remove($v1,|)),$v1,$remove($v1,|)),.,\.,?,\?),%r $regsubex($(%r,2),/ $+ %v $+ /ig,$gettok($(%x,2),$(%l,2),149)),%i %i + 2,%l %l + 2
      return %r
    }



    Thanks everyone who submitted for this challenge, and congratulations to jaytea for winning :D. Hopefully we will have another one soon.

    _________________
    Image


    Offline
     Profile  
     
     Post subject: Re: [Easy] $mulrep
    PostPosted: Thu Jul 30, 2009 10:39 pm 
    User
    User

    Joined: Thu Mar 08, 2007 4:45 am
    Posts: 236
    Jose, loved the %c ,, trick ;)

    _________________
    Image


    Offline
     Profile  
     
     Post subject: Re: [Easy] $mulrep
    PostPosted: Thu Jul 30, 2009 10:56 pm 
    User
    User

    Joined: Tue Dec 11, 2007 4:10 pm
    Posts: 339
    Location: #msl
    Surprised i'm the only one who used $*. Couldn't get it working without (well didn't put much time in that part :lol: )
    But overall, 3rd place isn't that bad.

    _________________
    Image


    Offline
     Profile  
     
     Post subject: Re: [Easy] $mulrep
    PostPosted: Thu Jul 30, 2009 11:00 pm 
    User avatar
    User
    User

    Joined: Tue Jan 01, 2008 7:32 pm
    Posts: 714
    Location: #mSL
    Ano, you're actually second.

    ;).

    Unfortunately, I was blind and missed this. but jayteas/kols/kylars/chids entries are all invalid.

    they all happen to fail when replacing the number 0.

    Code:
    $mulrep(Hell0,0,o) ==> Hell0


    As unfortunate as it may be that i come to discover this after the challenge has ended. it's more a shame on me situation for not noticing. Not giving them a chance to resubmit an entry that was working. and i'm sorry for this. If you gus happen to come up with a fixed entry, please do post it here. as we would like to see the finished product :).

    _________________
    Image


    Offline
     Profile  
     
     Post subject: Re: [Easy] $mulrep
    PostPosted: Fri Jul 31, 2009 6:59 am 
    User
    User

    Joined: Tue Dec 11, 2007 4:10 pm
    Posts: 339
    Location: #msl
    Roflmao :mrgreen:

    _________________
    Image


    Offline
     Profile  
     
     Post subject: Re: [Easy] $mulrep
    PostPosted: Mon Aug 03, 2009 5:30 am 
    Newbie
    Newbie

    Joined: Sat Apr 26, 2008 2:25 am
    Posts: 8
    anyway, final product
    Code:
    alias mulrep {
      %m = 1
      %r = $1
      while %m < $0 {
        inc %m
        var %1 %2,%c 1,%2 $($ $+ %m,2)
        while $calc(%m % 2) && $token(%1,%c,59) != $null {
          %r = $replace(%r,$v1,%2)
          inc %c
        }
      }
      return %r


    edit. : 169 bytes!


    Offline
     Profile  
     
     Post subject: Re: [Easy] $mulrep
    PostPosted: Mon Aug 03, 2009 10:05 pm 
    User
    User

    Joined: Tue Dec 11, 2007 4:10 pm
    Posts: 339
    Location: #msl
    chid wrote:
    anyway, final product
    Code:
    alias mulrep {
      %m = 1
      %r = $1
      while %m < $0 {
        inc %m
        var %1 %2,%c 1,%2 $($ $+ %m,2)
        while $calc(%m % 2) && $token(%1,%c,59) != $null {
          %r = $replace(%r,$v1,%2)
          inc %c
        }
      }
      return %r


    edit. : 169 bytes!


    That alias isn't valid since it doesn't run clean.

    _________________
    Image


    Offline
     Profile  
     
     Post subject: Re: [Easy] $mulrep
    PostPosted: Wed Aug 05, 2009 7:18 am 
    Newbie
    Newbie

    Joined: Sat Apr 26, 2008 2:25 am
    Posts: 8
    Oh. I don't usually read posts in the challenge topic ;P

    Code:
    alias mulrep {
      var %m 1,%r $1
      while %m < $0 {
        inc %m
        var %1 %2,%c 1,%2 $($ $+ %m,2)
        while $calc(%m % 2) && $token(%1,%c,59) != $null {
          %r = $replace(%r,$v1,%2)
          inc %c
        }
      }
      return %r


    fixed. even though you probably don't care :D


    Offline
     Profile  
     
    Display posts from previous:  Sort by  
    Post new topic Reply to topic  [ 13 posts ] 


     Who is online 

    Users browsing this forum: No registered users and 1 guest


    You cannot post new topics in this forum
    You cannot reply to topics in this forum
    You cannot edit your posts in this forum
    You cannot delete your posts in this forum

    Search for:
    Jump to:  

     
    Index  |  FAQ  |  Search

    phpBB skin developed by: John Olson
    Protected by Anti-Spam ACP
    Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group