.

  • VC:MP Beta Tester
  • .
  • Posts: 1,808
Re: Scripting challenges!
« Reply #60, on April 12th, 2017, 06:32 PM »
Quote from EK.IceFlake on April 12th, 2017, 06:12 PM
Not too fast.
Your script depends on you adjusting for length.
In which case:
function PrintRowz(num)
{
    switch (num)
    {
        case 0: break;
        case 1: print("*"); break;
        case 2: print("*.\n**"); break;
        case 3: print("*..\n**.\n***"); break;
    }
}
And so on
Read my update: (I had to move it to paste-bin because the forum script is too retarded and collapses series of dots down to 3)
Re: Scripting challenges!
« Reply #61, on April 12th, 2017, 07:19 PM »
I just realized that this challenge had no winning factors. No performance, statement count, line count etc. Basically as long as you did what was asked everyone is a winner. So how are we going to decide who won here? I'm curious.

And what's the next challenge? Because these are fun.
.

vito

  • Sr. Member
  • Posts: 405

.

  • VC:MP Beta Tester
  • .
  • Posts: 1,808
Re: Scripting challenges!
« Reply #63, on April 12th, 2017, 07:45 PM »
Quote from vito on April 12th, 2017, 07:43 PM
Quote from happymint on April 12th, 2017, 07:19 PM
And what's the next challenge? Because these are fun.
fast json bridge server <-> client side, at least it will be useful
Huh? Can you be more specific? And you must post one too. We're not here to do your work. What you're looking for is probably serialization.
.

vito

  • Sr. Member
  • Posts: 405
Re: Scripting challenges!
« Reply #64, on April 12th, 2017, 07:55 PM »
serialization + splitting to packages its it above stream limit

.

  • VC:MP Beta Tester
  • .
  • Posts: 1,808
Re: Scripting challenges!
« Reply #65, on April 12th, 2017, 08:03 PM »
Quote from vito on April 12th, 2017, 07:43 PM
... at least it will be useful
Also, that isn't the goal of the topic. But to be fun and probably learn some new/different techniques for doing something.
.

DizzasTeR

  • VC:MP Beta Tester
  • Infinite loops defy infinity by overflowing memory
  • Posts: 1,190
Re: Scripting challenges!
« Reply #66, on April 12th, 2017, 08:07 PM »Last edited on April 12th, 2017, 08:20 PM
@happymint, A small favor to test this one and the results
Code: [Select]
const STARTMASK = "****************************************************************";
const DOTMASK = "................................................................";

function dgen( num ) {
    local counter = num;
    do {
        local sz = DOTMASK.slice( 0, counter ) + STARTMASK.slice( 0, num - counter );
        kprint( sz );
        counter--;
    } while( counter > 0 )
}

.

  • VC:MP Beta Tester
  • .
  • Posts: 1,808
Re: Scripting challenges!
« Reply #67, on April 12th, 2017, 08:20 PM »Last edited on April 12th, 2017, 08:24 PM
My plugin x32:
Code: [Select]
[USR] Flake: 2.77
[USR] Doom: 3.11
[USR] SLC1: 3.122
[USR] SLC2: 0.348
[USR] Doom2: 0.370

My plugin x64:
Code: [Select]
[USR] Flake: 2.287
[USR] Doom: 2.77
[USR] SLC1: 2.664
[USR] SLC2: 0.284
[USR] Doom2: 0.290


After you updated your code while I was doing my first test.

My plugin x32
Code: [Select]
[USR] Flake: 2.728
[USR] Doom: 3.083
[USR] SLC1: 3.127
[USR] SLC2: 0.333
[USR] Doom2: 0.342

My plugin x64:
Code: [Select]
[USR] Flake: 2.271
[USR] Doom: 2.759
[USR] SLC1: 2.651
[USR] SLC2: 0.282
[USR] Doom2: 0.292
Re: Scripting challenges!
« Reply #68, on April 12th, 2017, 08:40 PM »Last edited on April 12th, 2017, 08:55 PM
Here is my third version with pre-computed tables of strings to reduce the heap memory allocations: https://pastebin.com/sSZJMnG6

My plugin x32:
Code: [Select]
[USR] SLC3: 0.146

My plugin x64:
Code: [Select]
[USR] SLC3: 0.123

I'm trying something else now to see if I can take it even further. Seems this is as far as you can take it on the official plugin.
.

DizzasTeR

  • VC:MP Beta Tester
  • Infinite loops defy infinity by overflowing memory
  • Posts: 1,190

Anik

  • Sr. Member
  • Posts: 356
Re: Scripting challenges!
« Reply #70, on April 13th, 2017, 08:28 AM »
@S.L.C can you test the benchmark of it.

(click to show/hide)
Code: [Select]
function anik( num )
{
local dotstr = "", starstr = "";
for( local i = 0; i < num; ++i ) dotstr += ".";
for( local i = 0; i <= num; ++i ) print( dotstr.slice( 0, num - i ) + ( starstr += "*" ) );
}

Shadow

  • Beta Tester Emeritus
  • Posts: 176
Re: Scripting challenges!
« Reply #71, on April 13th, 2017, 11:53 AM »


There's really no other way of getting a better time than using constant tables and loops as @S.L.C mentioned above. Recursion is not a solution either (even though it has logarithmic complexion, you still need other instructions to ensure the function return which might not be as easy to optimize as for-loops)
Quote
PS:is trash is ur home language??

EK.IceFlake

  • Hero Member
  • "We are the champions my fellahs" - Sufyan/VK.SuFy
  • Posts: 1,761
Re: Scripting challenges!
« Reply #72, on April 13th, 2017, 01:58 PM »
Quote from Shadow on April 13th, 2017, 11:53 AM
There's really no other way of getting a better time than using constant tables and loops as @S.L.C mentioned above.
Are you sure?
https://www.solidfiles.com/v/q6YqYPvxMWzxB
[USR] Total iterations: 1000
[USR] Average for Flake: 15 us
[USR] Average for Doom: 81 us
[USR] Average for SLC: 32 us

(where:
Flake's method is given a special download link as it is 342 MB
Doom's method is:
Code: [Select]
function dum( maxStars ) {
 if( maxStars ) {
 for( local mainRun = 0; mainRun <= maxStars-1; mainRun++ ) {
 local string = "";
 for( local j = 1; j <= maxStars; j++ ) {
 if( maxStars - j > mainRun ) {
 string += ".";
 }
 else {
 string += "*";
 }
 }
 kprint( string );
 }
 }
}
and SLC's method is:
Code: [Select]
const G_PERIOD_CONST = "...";
const G_ASTERIX_CONST = "********************************************************************************************************************************";
function Generate(l) for (local p = 1; p <= l; ++p) kprint(G_PERIOD_CONST.slice(0, l-p) + G_ASTERIX_CONST.slice(0, p));
)

DizzasTeR

  • VC:MP Beta Tester
  • Infinite loops defy infinity by overflowing memory
  • Posts: 1,190
Re: Scripting challenges!
« Reply #73, on April 13th, 2017, 02:09 PM »
You used the old method of mine @EK.IceFlake but nevermind :D The main thing is that the task got accomplished though in more than expected ways haha, way to go.

Shadow

  • Beta Tester Emeritus
  • Posts: 176
Re: Scripting challenges!
« Reply #74, on April 13th, 2017, 04:41 PM »
Quote from EK.IceFlake on April 13th, 2017, 01:58 PM
...
On the same note, I could also make a C++ plugin which would destroy squirrel at the execution time. The simple fact that your solution consists of 150 cases inside a switch renders it useless.
Quote
PS:is trash is ur home language??