[Adventurer] Tiresome GCD


#1

d

What the difference between various algorithms. Let’s check it in the new level about GCD: Tiresome GCD

It’s a really simple level the main point of that is to show the difference between various algorithms.


#2

This level was easy, because all you had to do was change one small part of a line.


#3

Yes. I’ve written about it.


#4

but what do i need to change?


#5

Read comments in the default code.


#6

but how? i don’t know what to do


#7

Do you know what are comments in the code? Have you completed the Forest campaign? If you had removed the sample code you can click “Restart” and get the default code. Try to read instructions carefully.


#8

okay. thanks for your instruction


#9

I should say it is funny that you show bruteforceGCD algorithm work on the numbers that code combat can’t handle

Sems like cc realization of while( true ) have integrated 100ms delay for each cycle.
And if you try something like while ( 5 > 4 ) you end up with infinity loop.
And even if you do something like that

    while ( 5 > 4 ) {
        cycles++;
        if ( cycles % 10000 === 0 )
        {
            hero.wait( 0.1 );
            console.log( cycles + "counter" + counter );
        }
        // If both number have "counter" divisor.
        if (a % counter === 0 && b % counter === 0) {
            break;
        }
        counter--;
    }

You are limited by ~750000 statement execution limit.


#10

This level was REALLY easy


#11

Surprise! Surprise! :wink:


#12

was I supposed to change bruteforceGCD(number1, number2) to euclideanGCD(number1, number2) in Lua?


#13

Does it work? Then yes. :slight_smile:


#14

But I wonder if that was part of what the player needed to do, other than add an extra line where the arrow is.