EK.IceFlake

  • Hero Member
  • "We are the champions my fellahs" - Sufyan/VK.SuFy
  • Posts: 1,757
Re: Scripting challenges!
« Reply #90, on May 24th, 2017, 03:56 PM »Last edited on May 25th, 2017, 01:32 PM
Your challenge is to make a function that accepts an array and returns a sorted array. You have to assume that every element in the array is an integer. You can't use the default array.sort method.
It will be given an antiscore using this formula: time * bytes where time is measured in milliseconds. It will be tested with this array: [960, 659, 528, 42, 562, 252, 453, 874, 682, 263, 172, 919, 388, 784, 205, 736] which I got off random.org, however, you are in no way to be optimizing your code for this particular list or sequence. It will be tested with 10000 iterations.
The one with the lowest antiscore wins.
Re: Scripting challenges!
« Reply #91, on May 24th, 2017, 04:13 PM »Last edited on May 30th, 2017, 12:22 PM
Here's mine, 125 bytes.
Performance testing at the end.

(click to show/hide)
Code: [Select]
function a(b){c<-[(1<<63)-1];b.map(function(d){foreach(e,f in c)if(f>=d){c.insert(e,d);break}});c.remove(c.len()-1);return c}

Note that this only works on a 64-bit build of Squirrel. To deal with 32-bit builds, change 1<<63 to 1<<31.
Re: Scripting challenges!
« Reply #92, on May 30th, 2017, 12:14 PM »
This post has been buried.
I have successfully unburied it.

(this, if you didn't realize, is just a bump)

Sebastian

  • VC:MP Beta Tester
  • Something like this: hga hga hga
  • Posts: 1,193
Re: Scripting challenges!
« Reply #93, on May 30th, 2017, 04:08 PM »
Chill out, I'm not here for the challenges :D
I just made @EK.IceFlake 's post more visible, if anyone's ready to try.

Code: [Select]
function a( b )
{
          c <- [ ( 1 << 63 ) - 1 ];
          b.map( function( d )
          {
                    foreach( e, f in c )
                             if( f >= d )
                             {
                                        c.insert( e, d );
                              break
                              }
          } );
c.remove( c.len() - 1 );
return c
}