CodeHS Karel Answers

We thoroughly check each answer to a question to provide you with the most correct answers. Found a mistake? Tell us about it through the REPORT button at the bottom of the page. Ctrl+F (Cmd+F) will help you a lot when searching through such a large set of questions.

While the solutions provided might not be the quickest route to the end goal, their effectiveness is guaranteed. It’s important to remember that these solutions are tailored for the Video Game Design course focusing on JavaScript, particularly Unit 1: Video Game Design.

You Might Be Interested in CodeHS AP CSA (Nitro) Answers and CodeHS Python Answers

Programming With Karel Answers

ExerciseSolution
1.1.4 Your First Karel Programmove();
move();
move();
move();
takeBall();
1.1.5 Short Stackmove();
putBall();
putBall();
move();
1.2.4 Make a Towermove();
putBall();
turnLeft();
move();
putBall();
move();
putBall();
move();
turnLeft();
turnLeft();
turnLeft();
1.2.5 Pyramid of KarelputBall();
move();
putBall();
turnLeft();
move();
putBall();
turnLeft();
turnLeft();
turnLeft();
move();
putBall();
turnLeft();
turnLeft();
turnLeft();
move();
putBall();
turnLeft();
turnLeft();
move();
move();
putBall();
turnLeft();
turnLeft();
turnLeft();
1.3.4 Slide Karelfunction turnRight()
{
turnLeft();
turnLeft();
turnLeft();
}
putBall();
move();
turnRight();
move();
putBall();
turnLeft();
move();
turnRight();
move();
putBall();
turnLeft();
1.3.5 Fireman Karelfunction turnRight()
{
turnLeft();
turnLeft();
turnLeft();
}
turnRight();
move();
move();
move();
turnLeft();
1.4.4 Pancakesfunction makePancakes()
{
putBall();
putBall();
putBall();
}
move();
makePancakes();
move();
move();
makePancakes();
move();
move();
makePancakes();
move();
1.4.5 Mario Karelfunction turnRight()
{
turnLeft();
turnLeft();
turnLeft();
}
function collectCoins()
{
turnLeft();
move();
move();
move();
takeBall();
takeBall();
turnLeft();
turnLeft();
move();
move();
move();
turnLeft();
}
move();
collectCoins();
move();
move();
collectCoins();
move();
move();
collectCoins();
move();
move();
collectCoins();
1.5.4 Pancakes with Startfunction makePancakes()
{
putBall();
putBall();
putBall();
}
function start()
{
move();
makePancakes();
move();
move(); makePancakes(); move(); move(); makePancakes(); move();
}
1.6.4 The Two Towersfunction start()
{
buildTower();
buildTower2();
// Write your code here
}
function buildTower()
{
move();
turnLeft();
putBall();
move();
putBall();
move();
putBall();
turnLeft();
turnLeft();
move();
move();
turnLeft();
}
function buildTower2()
{
move();
move();
turnLeft();
putBall();
move();
putBall();
move();
putBall();
move();
turnRight();
}
function turnRight()
{
turnLeft();
turnLeft();
turnLeft();
}
1.7.4 The Two Towers + Commentsfunction start()
{
buildTower();///hhahhah captian obvious
buildTower2();///why am i doing this, can’t this just submit already?
// So like literally this just calls in the buildTower functions lol
}
function buildTower() // This one literally builds the towers and goes down
{
move(); //move
turnLeft(); //turn
putBall(); //puttingBall
move(); //move
putBall(); //putting ball
move(); //move
putBall(); //putting ball
turnLeft(); //turn
turnLeft(); //turn
move(); //moving
move(); //moing again
turnLeft(); //turning again
}
function buildTower2() // This one is how to build the second tower becaues for some reason this one is a bit different from the first
{
move();//aaa
move();//aaa
turnLeft();//aa
putBall();//a
move();//a
putBall();//a
move();//a
putBall();//a
move();//aaaaa
turnRight();//aaaaaa
}
function turnRight() // This is so self explanatory i don’t even see whsy I need to explain this lool
{
turnLeft();//yeet
turnLeft();//xd
turnLeft();//exdeeh
}
1.8.4 The Two Towers + SuperKarelfunction start()
{
buildTower();
buildTower2();
// Write your code here
}
function buildTower()
{
move();
turnLeft();
putBall();
move();
putBall();
move();
putBall();
turnLeft();
turnLeft();
move();
move();
turnLeft();
}
function buildTower2()
{
move();
move();
turnLeft();
putBall();
move();
putBall();
move();
putBall();
move();
turnRight();
}
1.9.5 Take ’em Allfunction start()
{
move();
for(var i = 0; i < 100; i++) { takeBall(); } move();
}
1.9.6 Dizzy Karelfunction start()
{
for(var i = 0; i < 32; i++)
{
turnLeft();
}
}
1.9.7 For Loop Squarefunction start()
{
for(var i = 0; i < 4; i++)
{
move();
putBall();
turnLeft();
}
}
1.9.8 Lots of Hurdlesfunction start()
{
for(var i = 0; i < 5; i++)
{
jumpHurdle();
}
}
function jumpHurdle()
{
move();
move();
turnLeft();
move();
turnRight();
move();
turnLeft();
turnLeft();
turnLeft();
move();
turnLeft();
}
1.10.5 Is There a Ball?function start()
{
if(ballsPresent())
{
takeBall();
}
if(noBallsPresent()) { putBall(); } move();
}
1.11.5 Right Side Upfunction start()
{
south();
west();
}
function south()
{
if(facingSouth())
{
turnRight();
}
}
function west()
{
if(facingWest())
{
turnLeft();
turnLeft();
}
}
1.12.4 Follow The Yellow Ball Road// Follow the yellow ball road!
// Karel moves until it’s not on a tennis ball.
function start()
{
while(ballsPresent())
{
move();
}
}
1.12.5 Lay Row of Tennis Ballsfunction start()
{
while(noBallsPresent())
{
putBall();
if(frontIsClear())
{
move();
}
}
}
1.12.6 Big Tower/* This program draws a big tower from Karel’s starting spot */
function start()
{
faceNorth();
placeBalls();
}
function placeBalls()
{
while(noBallsPresent())
{
putBall();
if(frontIsClear())
{
move();
}
}
}
function faceNorth()
{
while(notFacingNorth())
{
turnLeft();
}
}
1.13.4 Random Hurdlesfunction start()
{
for(var i = 0; i < 13; i++)
{
if(frontIsClear())
{
move();
}
else
{
jumpHurdle();
}
}
}
function jumpHurdle()
{
turnLeft();
move();
turnRight();
move();
turnRight();
move();
turnLeft();
}
1.15.4 Diagonal/* This program has karel lay a diagonal row of tennis balls.
However, the indenting is all wrong. Can you properly
indent this program? */
function start(){
while(frontIsClear()){
putBall();
move();
turnLeft();
move();
for(var i = 0; i < 3; i++){
turnLeft();
}
}
putBall();
}
1.15.5 Staircase/* This program creates a staircase from the first spot all the
way across the world for any sized world.
*
This program works, but its indentation is completely wrong.
Run the program first, so you know what it does and don’t break it.
*/
function start(){
putBall();
while(frontIsClear()){
turnLeft();
while (ballsPresent()) {
move();
}
turnRight();
move();
createStep();
}
}
function createStep() {
turnRight();
putBall();
while (frontIsClear()) {
move();
putBall();
}
turnLeft();
}
1.16.1 Fetchfunction start()
{
goUp();
goDown();
}
function goUp() //Going up
{
move();
turnLeft();
move();
move();
move();
move();
turnRight();
move();
takeBall();
}
function goDown() //Going down
{
turnLeft();
turnLeft();
move();
move();
turnLeft();
move();
move();
move();
move();
turnLeft();
putBall();
}
1.16.2 Racing Karelfunction start() //Thanks, Captain Obvious
{
for(var i = 0; i < 8; i++)
{
runLap();
}
}
function run() //Running in a single line
{
while(frontIsClear())
{
move();
}
putBall();
turnLeft();
}
function runLap() //Running a lap
{
run();
run();
run();
run();
}
1.16.3 Tower Builderfunction start()
{
buildTower();
buildTower2();
// Write your code here
}
function buildTower()
{
move();
turnLeft();
putBall();
move();
putBall();
move();
putBall();
turnLeft();
turnLeft();
move();
move();
turnLeft();
}
function buildTower2()
{
move();
move();
turnLeft();
putBall();
move();
putBall();
move();
putBall();
move();
turnRight();
}
function turnRight()
{
turnLeft();
turnLeft();
turnLeft();
}
1.16.4 Super Cleanup Karelfunction start()
{
cleanRows();
}
function cleanRows()
{
while(frontIsClear())
{
if(ballsPresent())
{
takeBall();
}
move(); //Proceed
}
if(facingEast()) { turn1(); } if(facingWest()) { turn2(); }
}
function turn1()
{
turnLeft();
if(ballsPresent())
{
takeBall();
}
if(frontIsClear())
{
move();
if(ballsPresent())
{
takeBall();
}
turnLeft();
}
cleanRows();
}
function turn2()
{
turnRight();
if(ballsPresent())
{
takeBall();
}
if(frontIsClear())
{
move();
if(ballsPresent())
{
takeBall();
}
turnLeft();
turnLeft();
turnLeft();
}
cleanRows();
}
1.16.5 Double Tennis Balls//Have 5 functions 1 start
function start(){
move();
putTwoBalls();
moveBack();
}
function putTwoBalls(){
while(ballsPresent()){
takeBall();
putTwoMoreBallsNextAve();
}
moveBallsNextDoorBack();
}
function putTwoMoreBallsNextAve(){
move();
putBall();
putBall();
moveBack();
}
function moveBallsNextDoorBack(){
move();
while(ballsPresent()){
moveOneBallBack();
}
moveBack();
}
function moveOneBallBack(){
takeBall();
moveBack();
putBall();
move();
}
function moveBack(){
turnAround();
move();
turnAround();
}

For those seeking solutions to the “JavaScript and Graphics” section, specifically Unit 2: Video Game Design from CodeHS, you are advised to visit the

Was this helpful?

quizzma
Quizzma Team
+ posts

The Quizzma Team is a collective of experienced educators, subject matter experts, and content developers dedicated to providing accurate and high-quality educational resources. With a diverse range of expertise across various subjects, the team collaboratively reviews, creates, and publishes content to aid in learning and self-assessment.
Each piece of content undergoes a rigorous review process to ensure accuracy, relevance, and clarity. The Quizzma Team is committed to fostering a conducive learning environment for individuals and continually strives to provide reliable and valuable educational resources on a wide array of topics. Through collaborative effort and a shared passion for education, the Quizzma Team aims to contribute positively to the broader learning community.