Play Home Contribute GitHub Join Us Discourse Staff Members GitHub Contribution Guides Team

[Adventurer] Tiresome GCD



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.


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


Yes. I’ve written about it.


but what do i need to change?


Read comments in the default code.


but how? i don’t know what to do


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.


okay. thanks for your instruction


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 ) {
        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) {

You are limited by ~750000 statement execution limit.


This level was REALLY easy


Surprise! Surprise! :wink:


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


Does it work? Then yes. :slight_smile:


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