> Community
This page aims to collect exercises that will later be added to the LeekScript tutorial.
Thanks in advance to everyone who will contribute!
You can suggest exercises that are related to Leek Wars as well as ones that aren't.
Keep in mind that exercises should be simple, aimed at understanding one concept. But you can also suggest exercises that require more thought, for those who want a bit of a challenge ;)
Write a piece of code that uses the say and getName functions to say "Hi LEEK, nice to fight you today.", where LEEK is the name of an enemy leek.
You can "add" strings of characters (called strings) together, like this:
var MyString = "A string" + ", then another string"; debug (MyString); // Displays: A string, then another string var MyNumber = 5; MyString = MyNumber + ", this number has been converted into a string!"; debug (MyString); // Displays: 5, this number has been converted into a string!
I recommend checking the doc or the wiki for more information about the functions.
Not that complicated, right? Here is one possible solution:
say("Hi " + getName(getNearestEnemy()) + ", nice to fight you today."); // Careful: the "say" function costs 1 TP, so it's not a priority ;)
Using setWeapon and getTurn, write a conditional statement that equips your weapon on turn 1 only.
Two giant monsters, Fridgezilla and Godzillasagna, are trying to terrorize the little village of Tiercelieux by wreaking havoc there. Each of them arrives in the village and leaves it at a specific time of day. Tiercelieux's only hope of survival is that if both monsters are in town at the same time, each sees the other as a rival and they tear each other apart, giving the village a bit of respite. Knowing the arrival and departure times of each monster, you must find out whether there is a time when both giants are in the village, in which case the village is saved! For example, if Fridgezilla arrives in the village at 2 a.m. and leaves at 3 p.m., and Godzillasagna arrives at 10 a.m. and leaves at 6 p.m., then from 10 a.m. to 3 p.m. both monsters are in the village at the same time. Careful! Even if the two monsters only just cross paths, they still fight! That is, if one monster arrives at the exact moment the other one leaves, they kill each other and spare Tiercelieux.
var tmp = array[start]; array[start] = array[end]; array[end] = tmp; } if(end-start+1 > 2){ var i = round((end-start+1)/3); auxStoogeSort(array, start, end-i); auxStoogeSort(array, start+i, end); auxStoogeSort(array, start, end-i); } }; auxStoogeSort(T, 0, count(T)-1); }
2) No. Not at all.
Impossible de charger les données du jeu.
Vérifiez votre connexion et réessayez.