kareljrobot-blog
kareljrobot-blog
Karel Learns Java
6 posts
A beginners introduction to programming with Karel the robot in Java, prior to CS106A at Stanford University. The purpose of this site is to share solutions to others and get feedback on code. Credits to Richard E. Pattis for creating this program.
Don't wanna be here? Send us removal request.
kareljrobot-blog · 12 years ago
Note
Hi! So for problem 3, I can see how your solution would work for even and one rows, but how would it work for odd rows? Wouldn't it have to move before putting down a beeper to make a checker pattern?
Hi there. I'm not even sure how the code works anymore because I haven't looked at it for 2 years. I suggest you paste the code in ecplise and debug it to see all the steps. Good luck!
1 note · View note
kareljrobot-blog · 14 years ago
Text
Assignment 1 - Problem 4
Starting Position & Final Position
As an exercise in solving algorithmic problems, program Karel to place a single beeper at the center of 1st Street.
Note that the final configuration of the world should have only a single beeper at the midpoint of 1st Street.  Along the way, Karel is allowed to place additional beepers wherever it wants to, but must pick them all up again before it finishes.
In solving this problem, you may count on the following facts about the world:
Karel starts at 1st Avenue and 1st Street, facing east, with an infinite number of beepers in its bag.
The initial state of the world includes no interior walls or beepers.
The world need not be square, but you may assume that it is at least as tall as it is wide.
Your program, moreover, can assume the following simplifications:
If the width of the world is odd, Karel must put the beeper in the center square. If the width is even, Karel may drop the beeper on either of the two center squares.
It does not matter which direction Karel is facing at the end of the run.
My solution:
197 notes · View notes
kareljrobot-blog · 14 years ago
Text
Assignment 1 - Problem 3
In this exercise, your job is to get Karel to create a checkerboard pattern of beepers inside an empty rectangular world, as illustrated in the following before-and-after diagram.
Must work in all worlds, odd, even and one row.
Karels final location and the final direction it is facing at end of the ron do not matter.
Okay, so I spent the last couple of days trying to crack this nut going back and forth like crazy until I finally got it figured out, and I have to admit it was way more difficult than first expected. I guess programming never was easy :)
Anyways, heres the code. I know it's shitty but it does the job and works on all words last time I checked. If you guys sovled the problem any differently I would really appreciate if you sent me the code so I can take a look at it.
9 notes · View notes
kareljrobot-blog · 14 years ago
Text
Assignment 1 - Problem 2
Final position & Starting position
Karel’s final location and the final direction he is facing at end of the run do not matter.Karel may count on the following facts about the world, listed below:
Karel starts at 1st Avenue and 1st Street, facing east, with an infinite number of beepers in Karel’s beeper bag
The columns are exactly four units apart, on 1st, 5th, 9th Avenue, and so forth.
The end of the columns is marked by a wall immediately after the final column. This 
wall section appears after 13th Avenue in the example, but your program should work or any number of columns.
The top of the column is marked by a wall, but Karel cannot assume that columns are always five units high, or even that all columns are the same height.
Some of the corners in the column may already contain beepers representing stones that are still in place. Your program should not put a second beeper on these corners.
My solution:
0 notes
kareljrobot-blog · 14 years ago
Text
Assignment 1 - Problem 1
Starting Position: Final Position:
1. Move to the newspaper,
2. Pick it up, and
3. Return to its starting point
My solution:
0 notes
kareljrobot-blog · 14 years ago
Link
"Programming Methodology (CS106A) is an Introduction to the engineering of computer applications emphasizing modern software engineering principles: object-oriented design, decomposition, encapsulation, abstraction, and testing. Uses the Java programming language. Emphasis is on good programming style and the built-in facilities of the Java language."
At the Standford CS106A courrse, you'll find all the necessary information and resources for CS106A, like how-to-videos, handouts, assignments and so on. If you haven't seen it already, be sure to check out their youtube lecture videos.
The great thing about this educational course is that you don't have to be a Standford student complete them. Of course, you wont get a grade, but it's really a great learning experience to anyone who is interested in programming and Java. If you are, I encourage you to follow along and post your assignment solutions and ideas here. Good luck :)
12 notes · View notes