After showing it to Mr. Daly, he suggested that I try some more AP problems from Georgia Tech. We looked at some together (they were multiple choice problems), but we figured that they involved things that I didn't understand and hadn't learned yet, so I decided that I would work on the AP-1 section in CodingBat.
I went back to sit with Tommy and Preston. I helped Tommy out with a problem. I forget which one exactly, but it was an Array 2 problem. While I wasn't helping the two, I was working on my AP-1 problems, which were also relatively at my level. I was working on them, and I noticed that I didn't really need help. I didn't always get the problems the first try, but I knew what to fix most of the time and what logic to use. I felt for once like I was the teacher at the table with Preston and Tommy. It was a good feeling. When Tommy showed me his problem, I knew how to solve it in a split second. It's nice to know that I've improved from 2 months ago where I was also struggling to complete an Array 2 problem.
Before I show the problem, I also realised that for last class's blog, I wrote that I was presenting today. I was wrong about that. Turns out I will be presenting on Monday.
Here is today's problem.
----------------------------------------------------------------------------------------------------------------------------------
Here is the code rewritten, so that it is clearer:
public String getHint (String guess, String hidden){
String str = new String("");
for (int i=0;i<guess.length();i++)
{
if (!hidden.contains(guess.substring(i,i+1))
{
str+="*";
}
if (hidden.contains(guess.substring(i,i+1) && !(hidden.substring(i,i+1).equals(guess.substring(i,i+1)))
{
str+="+";
}
if (hidden.substring(i,i+1).equals(guess.substring(i,i+1))
{
str+= hidden.substring(i,i+1);
}
return str;
}
}
Looking forward to next class !
No comments:
Post a Comment