8 Card Programming Challenges

Challenges list below…

  1. Question: Do you have a Nine?
    Goal: Run the program. Check the “Left Hand Value”. If it is 9 then the answer is yes. If “Left Hand Value” is not a 9 then the answer is no.
  2. Question: Do you have a 2 or a 10?
    Goal: Run the program. Check the “Left Hand Value”. If it is 2 or 10 then the answer is yes. If “Left Hand Value” is not a 2 or 1 0 then the answer is no.
  3. Question: Do you have a 2 and a 10?
    Goal: Run the program. Check the “Left Hand Value” and see if it is a 2. Check the “Right hand Value” and see if it is a 10. If the hands are not on a 2 & 10 as described above then the answer to the question is no.
  4. Question: How many 2s do you have?
    Goal: Run the program. Check the “Left Hand Position”. The “Left Hand Position” will be the number of 2s that you have.
  5. Question: What is the smallest card?
    Goal: Run the program. Check the “Left Hand Value”. The “Left Hand Value” will be the smallest card.
  6. Action: Move the smallest card to Position 0. (Read about the swap command at the bottom of this page)
  7. Action: Move the smallest card to Position 0 and the largest card to position 7.
  8. Action: Shift all card one position to the right (the card in position seven should
    move to position zero).
  9. Action: Sort the cards from smallest to largest.
  • For  challenges 6+ you will need to move cards. To move cards you will need the SWAP command (S). The swap command moves cards not hands. It will move the left hand card to the right hand position and move the right hand card to the left hand position. To enable this command you will need to edit your IDE URL as shown below…
    https://mxepstein.com/HML/?swap=true&cards=48530296&code=X

Robot Maze Challenge

Available commands are…

  • MOVE_FORWARD();
  • ROTATE_RIGHT();
  • MOVE_FORWARD();
  • CAN_MOVE(“direction”);

Choices for “direction” are…

  • “forward”
  • “backward”
  • “right”
  • “left”

Example Code…

if(CAN_MOVE(“right”)){
    ROTATE_RIGHT();
    MOVE_FORWARD();
}

Write one code that can guide the robot from the top left square to the bottom right square no matter which of the 6 situations the robot finds itself in.

You can test your code here. *

Programming Challenges 2024-2025

When completing your code challenges keep in mind the four characteristics of quality code…

  1. Functional – Accomplishes it’s task every time.
  2. Readable – Easy for a human to read and edit
  3. Efficient – Executes quickly without unnecessary steps.
  4. Short – Uses the fewest lines of code.

Or put another way…

  1. Does it work? Your code should meet all of the requirements and work in every situation.
  2.  Is it understandable? Your code should be easy for a human to read and understand.
  3. Is it fast? You code should execute and finish as quickly as possible.
  4. Is it short? Your code should be as few line of code as possible.

Submit Your Programming Challenges here. Please make sure your challenge meets all of the requirements before submitting. Also please make sure your app is titled “Programming Challenge #__” to make it extra clear which challenge you have completed.

  1. Four Function Calculator App – Create a basic four function calculator. Remix this template to start. Watch a video example to see how it should work here.
  2. Four Function Calculator App (Final Draft) – Fine tune your calculator to handle these weird errors and other small things…
    • What if the user puts a non-number into one of the boxes?
      • Print “Error: Please only enter numbers”
    • Do not allow users to edit the big output text area
    • What if they divide by zero?
      • Print “Error: Cannot divide by zero”
    • What if the output is scientific notation
      • If the output is scientific notation, then print “Error: Answer is too long”
  3. Robot Maze Challenge
  4. getSquarePerimeter(area) – Given the area of a square return the perimeter of the square.
  5. Write a function getSmallestNumber(n1,n2,n3,n4) that returns a numeric value that represents the smallest number given four numbers. Please do not use the built in Math.min function
  6. Fix the code to make a “Match Object to Color” app. Remix template here.
  7. 4 Function Calculator (Model View Controller)
  8. Safe to Eat (See template)
  9. Tri-Tac-Toe
  10. Create a 2-Button AppSee details here.
  11. Create List App #1Watch the video. Start by remixing the template.
  12. Create List App #2Watch the video. Start by remixing the template.
  13. Create List App #3Watch the video. Start by remixing the template .
  14. Create List App #4Watch the video. Start by remixing the template.

Turtle Challenge 2024-2025

When completing your code challenges keep in mind the four characteristics of quality code…

  1. Functional – Accomplishes it’s task every time.
  2. Readable – Easy for a human to read and edit.
  3. Efficient – Executes quickly without unnecessary steps.
  4. Short – Uses the fewest lines of code.

Or put another way…

  1. Does it work? Your code should meet all of the requirements and work in every situation.
  2.  Is it understandable? Your code should be easy for a human to read and understand.
  3. Is it fast? You code should execute and finish as quickly as possible.
  4. Is it short? Your code should be as few line of code as possible.

Submit Your Turtle Challenges here. Please make sure your challenge meets all of the requirements before submitting. Also please make sure your app is titled “Turtle #__” to make it extra clear which challenge you have completed.

  1. Draw Square – Draw a single square in front of and to the right of the turtle (image).
    • Only use moveForward(),  turnLeft()
    • No loops, No functions, No parameters.
  2. Draw Square – Draw a single square in front of and to the right of the turtle (image)
  3. Draw Square – Draw a single square in front of and to the right of the turtle (image)
  4. Draw Square – Draw a single square in front of and to the right of the turtle (image)
  5. 2×2 Grid – Draw a two by two grid in front of and to the right of the turtle (image).
    • Only use moveForward(),  turnLeft()
    • No loops, No functions, No parameters.
  6. 2×2 Grid – Draw a two by two grid in front of and to the right of the turtle (image).
    • Only use move(), penUp(), penDown()
    • No loops, No functions.
    • You can use “parameters
    • Must be less than 15 lines of code.
  7. 2×2 Grid – Draw a two by two grid in front of and to the right of the turtle (image).
    • Only use moveForward(),  turnLeft()
    • No loops, No parameters.
    • You can use “functions
    • Must be less than 30 lines of code
  8. 2×2 Grid – Draw a two by two grid in front of and to the right of the turtle (image).
    • Only use moveForward(), turnLeft()
    • No functions, No parameters.
    • You can use “For Loops” (You can put loops inside of other loops, just make sure each loop uses different letters: i, j, k, etc)
    • Must be less than than 20 lines of code.
  9. 3×3 Grid – Draw a three by three grid in front of and to the right of the turtle.
    • Only use moveForward(), turnLeft()
    • No functions, No loops, No parameters.
    • Use less than 55 lines of code (Extra credit if less than 45 lines)
  10. 3×3 Grid – Draw a three by three grid in front of and to the right of the turtle.
    • Only use move(), penUp(), penDown()
    • No loops, No functions.
    • You can use “parameters” (example: move(50,25) )
    • Use less than 25 lines of code (Extra credit if less than 15 lines)
  11. 3×3 Grid – Draw a three by three grid in front of and to the right of the turtle (image).
    • Only use moveForward(), turnLeft()
    • No loops, No parameters
    • You can use “Functions
    • Use less than 35 lines of code (Extra extra credit if less than 20 lines of code).
  12. 3×3 Grid – Draw a three by three grid in front of and to the right of the turtle.
    • Only use moveForward(), turnLeft()
    • No functions, No parameters.
    • You can use “For Loops
    • Use less than 35 lines of code (Extra credit if less than 20 lines)
  13. Draw A Polygon – Write a function drawRegularPolygon(numberOfSides, sideLength) that draws a regular polygon with a given number of sides and a given side length.
  14. Draw Square Grid – Write a function drawSquareGrid(unitSize,rows,columns) that draws a grid of squares in front of and to the right of the turtle where each little square has a side length of “unitSize” and the grid is “rows” units tall and “columns” units wide. The turtle should end at the position and orientation where it started. View Example Code.
  15. Draw a triangle inside a rectangle – Write a function drawTriangleInRectangle(width, height) that draws a rectangle with a base length of “width” and a height of “height”. This should all be draw in front of, and to the right of, the turtle. The turtle should end where is began. You may use whatever commands or functions that you would like. View Example (click view code).
    • Extra Credit: Do this by only moving the turtle using the move command
  16. Extra Credit: Draw a square inside of a circle. drawSquareInsideCircle(radius). Then make a new function that draws a regular polygon inside a circle  drawPolygonInsideCircle(radius, numberOfSides)
  17. Draw a square pyramid – Write a function drawSquarePyramid(baseLength, numberOfLayers). Each square should have half the side length of the square below. View Example/Template here (click view code).
  18. Extra Credit: Draw a dot surrounded by circles (minimum of 3). drawDotWithCircles(dotRadius, numberOfCircles) (see example)
  19. Draw a Pyramid of Circles – Write a function drawPyramidOfCircles(radius, numberOfBaseCircles) that draws a pyramid made of circles (see example)
  20. Draw a Wave – Write a function drawWave(numberOfBumps, totalLength). See an example here. Your turtle should end in the same position and orientation as where is started.
  21. Draw Shaded Rectangle – Write a function drawShadedRectangle(width, height) that draws a rectangle that is shaded in with a random color. See example here. Your turtle should end in the same position and orientation as where is started. You should do this with the regular Turtle commands (nothing from the canvas library).
  22. Draw Bullseye – Write a function drawBullseye(innerRadius, numberOfCircles, whiteWidth) that draws a circle with an innerRadius and draws other larger circles that have a whiteWidth blank area in between them. See an example here.
  23. Optional: Screensaver – Use the turtle to make a screensaver screen that you like. It can look like however you’d like. It is a chance to be creative (Example A, Example B)

Donate

Would you like to donate to Mx. Epstein’s classroom? Please consider using one of the following methods…

You donation will go toward things like…

  • Buying doughnuts to encourage participation in our upcaoming COVID-19 vaccine drive.
  • Buying math and logic games to give students a positive attitude toward mathematics.
  • Buying prizes for the prize box which encourages students to go above and beyond.

Thank you for you donation!