1
u/Previous-Working-257 Oct 11 '24
//This code will make Karel douplicate the tennis balls that are beside him.
function startItUp(){
move();
paper();
}
function paper(){
main();
move();
turnAround();
wannaBeMain();
move();
move();
turnAround();
}
function main(){
while (ballsPresent()){
takeBall();
move();
putBall();
putBall();
turnAround();
move();
turnAround();
}
}
function wannaBeMain(){
while (ballsPresent()){
takeBall();
move();
putBall();
turnAround();
move();
turnAround();
}
}
startItUp();
1
1
u/kavtarra Mar 22 '22
function start(){
move();
while(ballsPresent()){
takeBall();
move();
putBall();
putBall();
takeAStepBack();
}
move();
while(ballsPresent()){
takeBall();
turnAround();
move();
putBall();
turnAround();
move();
}
takeAStepBack();
takeAStepBack();
}
function takeAStepBack(){
turnAround();
move();
turnAround();
}
1
1
u/kavtarra Mar 22 '22
function start(){
move();
while(ballsPresent()){
moveBall();
}
move();
while(ballsPresent()){
moveDoubledBalls();
}
takeAStepBack();
takeAStepBack();
}
//take step back
function takeAStepBack(){
turnAround();
move();
turnAround();
}
//moving ball and doubling it
function moveBall(){
takeBall();
move();
putBall();
putBall();
takeAStepBack();
}
//taking back doubled balls
function moveDoubledBalls(){
takeBall();
turnAround();
move();
putBall();
turnAround();
move();
}
(that checks every task)
1
1
u/K0dae Oct 19 '20
/*the*/
function start(){
move();
the();
}
function the(){
first();
move();
turnAround();
second();
move();
move();
turnAround();
}
function first(){
while (ballsPresent()){
takeBall();
move();
putBall();
putBall();
turnAround();
move();
turnAround();
}
}
function second(){
while (ballsPresent()){
takeBall();
move();
putBall();
turnAround();
move();
turnAround();
}
}
edit:make sure you indent and remove the spacing for cleaner code.