SwiftIRC
IRC Discussion and Support
 
  Index  •  FAQ  •  Search  

It is currently Fri Sep 03, 2010 8:11 am




Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next
 [Intermediate] /clone and $clone 
Author Message
 Post subject: [Intermediate] /clone and $clone
PostPosted: Sat Jul 11, 2009 12:32 pm 
User
User

Joined: Mon Aug 13, 2007 7:33 am
Posts: 47
Location: Sydney, Australia
Cloning Challenge.

Hey my name's Kyle (Kylar on IRC), and welcome to the Cloning Challenge.

The idea of this challenge in short is to write an alias that can:
  • Copy itself as a new and unique alias name
  • Keep track of how many times it has replicated itself

Deadline: 10 days from now. Tuesday 21st July, 11am GMT

Winning
  • PM your entry to me, your last valid entry will be in the results.
  • The winner is the person with the shortest valid entry.
  • Every character will be included towards bytesize except Carriage Return + Line Feed combinations.

/clone
  • Creates a clone of itself

$clone
  • Returns the number of clones that the clone has made itself.
  • Does not create a clone

More details
  • Your alias must be called "clone".
  • Original alias and all clones will reside in remotes in clone.mrc in $mircdir.
  • $mircdir may contain spaces.
  • clone.mrc is the only file you are allowed to write to.
  • Clone names must be unique, new clones don't require "clone" in their name.
  • You don't have to worry about non-clone aliases intefering with your clone names.
  • If you have code that's not within the alias, it must be copied for every clone.
  • If I type /clone and delete all the code you originally gave me, the new clone should still work.
  • This means new clones should be valid entries by themselves, apart from having different alias names.
  • You do not have to reload the script file yourself after a clone is made.
  • Due to the nature of this challenge there will be no test alias.

Testing
  • I will create clone.mrc myself and load your original clone in for testing.
  • I will not restart mIRC or my computer during testing.

Other rules
  • Regex is allowed
  • Sockets and COM are not allowed.
  • Your code does not have to be clean.
    (of course if this interferes with the functioning of your clones it will invalidate your entry.)


Example

I load the alias you send me.

File looks like:
Code:
alias clone {
   ...
}

I type: /clone

A new clone is created, the file now looks like
Code:
alias clone {
  ...
}
alias clone2 {
  ...
}

I type: //echo -a $clone
displays 1

I type: //echo -a $clone2
displays 0

I type: /clone2
clone2 will clone itself

I type: //echo -a $clone2
displays 1

I type: /clone2
clone2 will clone itself

I type: //echo -a $clone2
displays 2

File looks like:
Code:
alias clone {
  ...
}
alias clone2 {
  ...
}
alias clone3 {
  ...
}
alias clone4 {
  ...
}

Now I delete aliases clone, clone3 and clone4. clone2 should still work.

I type: /clone2
I type: /clone2
I type: /clone2

File now looks like:
Code:
alias clone2 {
  ...
}
alias clone5 {
  ...
}
alias clone6 {
  ...
}
alias clone7 {
  ...
}

I type: //echo -a $clone2
displays 5

(first 2 clones that were deleted, plus the new 3)

I type: //echo -a $clone5
displays 0

I type: //echo -a $clone6
displays 0

I type: //echo -a $clone7
displays 0

This shows how each alias only counts it's own clones and don't rely on other clones at all.
I used cloneN for all the clone names here, but you can use any valid name that isn't already being used by another clone.

Entries:
I will update this list as soon as I read and validate/invalidate your entry.

Valid
  • JoshR
  • ImK0tter
  • Zerg
  • Wims
  • Chid
  • Kol
  • Jaytea

Invalid
  • Yochai

Enjoy. =)


Last edited by Mr_K_13 on Mon Jul 20, 2009 3:11 pm, edited 20 times in total.

Offline
 Profile  
 
 Post subject: Re: [Intermediate] /clone and $clone
PostPosted: Sat Jul 11, 2009 9:30 pm 
User
User

Joined: Sun Jul 27, 2008 7:26 pm
Posts: 105
Location: New York
Technically you should be typing //echo -a $clone since /echo will not evaluate anything ;)
I think I'll give this a shot!

_________________
#xmrfunny1x


Offline
 Profile  
 
 Post subject: Re: [Intermediate] /clone and $clone
PostPosted: Sat Jul 11, 2009 10:04 pm 
User
User

Joined: Tue Jan 01, 2008 7:32 pm
Posts: 686
Location: #mSL
well, that was fun for the 10minutes it took to figure out the most obvious way to do it. which i don't feel like shortening. :D

_________________
Image


Offline
 Profile E-mail  
 
 Post subject: Re: [Intermediate] /clone and $clone
PostPosted: Sun Jul 12, 2009 12:56 am 
User
User

Joined: Mon Aug 13, 2007 7:33 am
Posts: 47
Location: Sydney, Australia
Good to see people liking this challenge, just have to clarify one detail though:
$mircdir may contain spaces.

Get your entries in everyone! =)


Offline
 Profile  
 
 Post subject: Re: [Intermediate] /clone and $clone
PostPosted: Mon Jul 13, 2009 8:25 pm 
User avatar
User
User

Joined: Wed Dec 27, 2006 9:51 am
Posts: 4518
Location: #msl
won't do it until i see a test alias :mrgreen:

_________________
Image
Steve's work

- Proscript -


Offline
 Profile E-mail  
 
 Post subject: Re: [Intermediate] /clone and $clone
PostPosted: Tue Jul 14, 2009 6:17 am 
User
User

Joined: Mon Aug 13, 2007 7:33 am
Posts: 47
Location: Sydney, Australia
kerst wrote:
won't do it until i see a test alias :mrgreen:

Haha well considering I'm not making a test alias and .. *brings out pendulum to hypnotise Kerst* You will doooo my challengeeee...

Actually, originally I was going to make $clone create a clone and return the the new clone's alias name, while $clone().count would return the number of clones that the clone had made, so I'd be able to write a test alias. But you can blame Kol for me changing it. =P

ps. Thanks Kol for reading over the details 3 times before I posted. =)


Offline
 Profile  
 
 Post subject: Re: [Intermediate] /clone and $clone
PostPosted: Thu Jul 16, 2009 11:14 am 
Newbie
Newbie

Joined: Sat Apr 26, 2008 2:25 am
Posts: 8
I think I've got it, how many bytes to beat Jaytea?

30? (and, no I'm not even close to that)


Offline
 Profile  
 
 Post subject: Re: [Intermediate] /clone and $clone
PostPosted: Fri Jul 17, 2009 9:26 pm 
User
User

Joined: Thu Mar 08, 2007 4:45 am
Posts: 224
Can't wait to see the results :P

_________________
Image


Offline
 Profile  
 
 Post subject: Re: [Intermediate] /clone and $clone
PostPosted: Mon Jul 20, 2009 7:21 am 
User
User

Joined: Mon Aug 13, 2007 7:33 am
Posts: 47
Location: Sydney, Australia
These aren't new rules.. I just want to be clear (even though there's only 1 day left).

When I test your clones they'll be in a blank file, and I won't be changing the order they appear within the file.

This means no blank lines between clones, or between the top of file and first clone (unless you uh, put them there yourself).

But, even though you know a clone will always be on the first line, you MUST read the lines of the code being executed.


Offline
 Profile  
 
 Post subject: Re: [Intermediate] /clone and $clone
PostPosted: Mon Jul 20, 2009 10:52 pm 
User
User

Joined: Sun Jul 27, 2008 7:26 pm
Posts: 105
Location: New York
:O! I just got back from canada yesterday.. expect a forum PM from me within the hour! :S

_________________
#xmrfunny1x


Offline
 Profile  
 
 Post subject: Re: [Intermediate] /clone and $clone
PostPosted: Tue Jul 21, 2009 12:31 am 
Newbie
Newbie

Joined: Sat Apr 26, 2008 2:25 am
Posts: 8
Quote:
But, even though you know a clone will always be on the first line, you MUST read the lines of the code being executed.


how exactly did someone achieve this without "reading" the code..

/me is scared of <100 bytes!


Offline
 Profile  
 
 Post subject: Re: [Intermediate] /clone and $clone
PostPosted: Tue Jul 21, 2009 11:00 am 
User
User

Joined: Mon Aug 13, 2007 7:33 am
Posts: 47
Location: Sydney, Australia
First thing is for Kerst, you suck! =P

Okay, now in last place to first place.. we have the

Results

  • JoshR - 418
  • Zerg - 152
  • Wims - 137
  • Chid - 136 bytes
  • ImK0tter - 135 bytes
  • Jaytea - 116 bytes












  • Kol - 108 bytes!

Grats Kol!



Now for the code, shortest to longest.


Kol - 108 bytes
Code:
alias clone $iif($isid,rEturn $calc(%e),inc %e) | writE clonE.mrc $rEplacEcs($rEad($script,rn,e),e,e- $+ %e)


Jaytea - 116 bytes
Code:
alias clone $iif($isid,return 0 $+ %o,inc %o) | write $qt($script) $replace($read($script,n,$scriptline),o,o. $+ %o)


ImK0tter - 135 bytes
Code:
alias clone / | if ($isid) return 0 $+ % | inc %z | inc % | write clone.mrc alias %z / $replace($isalias($strip( clone)).alias,,%z)


Chid - 136 bytes
Code:
alias clone {if ($isid) return $calc(%cl) | dec %c | inc %cl | write $nopath($script) alias $replace($isalias(clone).alias,cl,cl $+ %c)}


Wims - 137
Code:
alias clone tokenize 32 $read( clone.mrc ,n,$scriptline) | $iif($isid,return $(,$14),write $6 $1-2. $+ $calc($(,$18)) $3-) | inc $+(%,$2)


Zerg - 152
Code:
alias clone tokenize 32 $read($script,n,$scriptline) | if ($isid) return $iif($(,% $+ $2),$v1,0) | inc %u | write clone.mrc $1 c $+ %u $3- | inc % $+ $2


JoshR - 418
Code:
alias clone {
  var %a ; $+ $token($read($script,$calc($scriptline -1)),2,32),%b $scriptline - 1,%c $calc($read($script,s,;t) +1),%d $calc(%b +13),%e %b
  if ($isid) return $iif($read($script,s,%a),$v1,0)
  else {
    write $+(-s,%a) $qt($script) %a $calc($read($script,s,%a) +1)
    write -s;t $qt($script) ;t %c
    while %b < %d {
      if %b = %e write $qt($script) alias clone $+ %c $chr(123)
      else write $qt($script) $read($script,n,%b)
      inc %b
    }
  }
}



So the main trick to save bytes is to use command separators (|) so that you can read your whole alias in 1 go with $alias().alias or $read() which almost everyone used (lol, except JoshR =P). Then use $replace to get the new and unique alias and variable names.

Thanks to everyone who entered, and once again, well done Kol. I really liked his $replacecs adding 2 bytes for "cs" but then being able to use "clone.mrc" instead of "$qt($script)" ending up 1 byte shorter.


Offline
 Profile  
 
 Post subject: Re: [Intermediate] /clone and $clone
PostPosted: Tue Jul 21, 2009 11:20 am 
User avatar
User
User

Joined: Mon Jun 18, 2007 4:39 am
Posts: 1605
omg I beat jaytea :O

I'm still feeling sad about missing out the 0 $+ %e trick but I'll settle with an 8 byte lead D:

Great job everyone, a nice turnout for a rather unique challenge in terms of function. Props to Kylar for hosting a very smooth challenge and hopefully we'll see some more from him :]

_________________
Image

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


Offline
 Profile  
 
 Post subject: Re: [Intermediate] /clone and $clone
PostPosted: Tue Jul 21, 2009 11:34 am 
User avatar
User
User

Joined: Thu Jun 29, 2006 5:08 pm
Posts: 1504
Location: England!
Excellent work, Kol! Loved the $replacecs trick :D

I wish I'd had the chance to enter this challenge, it looked like fun :(. Thanks for hosting, Kyle - you made a unique and interesting challenge! Btw, you didn't post Yochai's code!

_________________
Ask a question and be dumb for 2 minutes...

... Never ask a question and be dumb for life

Image
Image


Offline
 Profile  
 
 Post subject: Re: [Intermediate] /clone and $clone
PostPosted: Tue Jul 21, 2009 1:13 pm 
User
User

Joined: Mon Aug 13, 2007 7:33 am
Posts: 47
Location: Sydney, Australia
Thanks Chess 'n Kol. =)

Here's Yochai's last entry - invalid because the first clone made by /clone tries to use % as a var which doesn't evaluate unless you use $var, and he reads a random line rather than the line his script is on.

188 bytes
Code:
alias clone { if ($isid) return $calc( %b *1) | %f = $qt($mircdirclone.mrc) | write %f $puttok($puttok($puttok($read(%f,n),$+(c,%a),2,32),$+(%,%a),8,32),$+(%,%a),20,32) | inc %b | inc %a }


Offline
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next


 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
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group