Today was technically the last class of the year. We still meet on Monday and Wednesday, and Wednesday is technically the last class of the year, but we will be having presentation on those days. So after today, I won't be doing any more full on coding during class.
I came in today, and was about to get to work when Mr. Daly called Tommy, Preston and me over. He asked how we were going to format our presentation on Monday, since we are all presenting about CodingBat. We went outside and tried ot figure it out, but we ended up arguing over who would argue what problem. Tommy would present level 1 problems, but then both Preston and I wanted to present level 2 problems. But we couldn't agree on who would present Arrays and who would present Strings, since we both wanted to present both.
So we went back inside to see Mr. Daly, and we told him about our problem. He then gave us an idea which Tommy disliked, but I thought it was interesting : we choose one problem, as a whole, the three of us. Then, Tommy and Preston pair up, and I work alone. Separately, without even looking at the problem, we record our screen and we solve the problem while thinking out loud. It was a super good idea, in my opinion. It is something new to the audience who is most likely bored of my CodingBat presentations for the past 2 quarter, and it saves a lot of time since all three of us don't have to present separately anymore.
After more argument about which problem to solve now, we ended up choosing the problem no14 from Array 2. We went upstair to the library, and I sat on a bean bag while Tommy and Preston sat in Ms. Beasley's office. I set up my screen recording with QuickTime and my audio recording through my earphones' mic, and went on to solve the problem. I solved it first try. It was pretty easy.
I won't be showing a problem today. I didn't work on anything, and I don't want to show the no14 problem, since it will already be seen in class.
Looking forward to presenting !
Thursday, May 28, 2015
Tuesday, May 26, 2015
Tuesday, May 26th
Today was not my turn at the genius bar, but we still worked in the library, because there was MAP testing in our regular classroom. It was nice though. It was an efficient class. I didn't do anything special, but got a lot done. I managed to finish the problem in the AP booklet, which actually turned out to be a lot easier than expected. I will be showing it in the blog.
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.
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 !
Friday, May 22, 2015
Friday, May 22nd
Regular class today.
I came in and ended up going to Mr. Daly during the first five minutes of class, since I still couldn't figure out the problem that I had last time. We managed to fix that problem, and I will be showing it at the end of the blog.
However, I have decided that for the remainder of the year, I will not be working on Level 3. I've decided that I want to solidify my knowledge at the second level completely before moving on to Level 3. Most likely during the course of the year in AP Computer Science, I'll do some level 3 problems to practice, if the new teacher doesn't already ask us to do them for the class. Although I'm pretty comfortable with what CodingBat asks of me at level 2, I still want to practice a bit more before moving on.
After completing the problem, I went outside to help Matan, Natalie, and May with their rap. I rapped two lines for them, and then went back inside.
I came back in, and Tommy was stuck on a problem. It asked him to add all of the numbers of the array, but to leave out numbers that were in the range of after a 6, and before a 7. He did not know what to do, so he asked for my help. I taught him the concept of flagging, with booleans. I felt good after teaching him because I knew that he understood.
Following this, Mr. Daly gave me and AP Computer Science packet, and told me that there was a problem or two that I would be able to complete. I completed one of them quickly, as it was relatively easy ( it was exactly like Tommy's problem), and began to work on the second one but didn't have time to finish it since class was ending. I will be looking at it at home to see what I can do.
This is the problem that Mr. Daly and I completed :
----------------------------------------------------------------------------------------------------------------------------------
Given two arrays of ints sorted in increasing order, outer and inner, return true if all of the numbers in inner appear in outer. The best solution makes only a single "linear" pass of both arrays, taking advantage of the fact that both arrays are already in sorted order. linearIn({1, 2, 4, 6}, {2, 4}) → true linearIn({1, 2, 4, 6}, {2, 3, 4}) → false linearIn({1, 2, 4, 4, 6}, {2, 4}) → true |
Looking forward to continuing. Next class (I think) I am presenting. See you then ! |
Wednesday, May 20, 2015
Wednesday, May 20th
Today was a good class.
I came in, not knowing exactly what to do. Mr. Daly proposed doing something ( I forgot what it was called) where I stood behind Tommy, and he was in front of a problem, and I told him from behind what to code. He was reluctant to do it, however, because he claims he is not comfortable enough with loops to do it.
After that, Mr. Daly gave me two problems. One problem from Array 2, and another one from String 2. It was to test my knowledge of Level 2 CodingBat. I managed to do both. It was interesting though, because after looking at my code from before, I realised that the code that I used to solve the string problem this time was much shorter, and used different methods. This makes me happy, because it shows that I have learned over time. The Array 2 Problem was also relatively easy. I think that if I were to redo each one from level 2, it would be way easier to complete than the first time around, just how I felt when I completed Level 1.
Following the tests, I went on to try a level 3 array problem. Without having any idea what I was writing, I did manage to get a few right. But, we couldn't use that code, so Mr. Daly and I wrote a different one to try and solve the problem. Unfortunately, I encountered a compile problem while working on it at home, and I don't know how to get past it. I use two loops, and in one of them I use i. In the second one, I use int r, because I don't want to have two int i with different value. So, I don't know how to get passed that.
Unfortunately, I don't have a problem to show for today. You have already seen them all ! Nothing new for this time. But, hopefully, I will have at least one level 3 problem for you by the end of next class. Looking forward to after tomorrow !
I came in, not knowing exactly what to do. Mr. Daly proposed doing something ( I forgot what it was called) where I stood behind Tommy, and he was in front of a problem, and I told him from behind what to code. He was reluctant to do it, however, because he claims he is not comfortable enough with loops to do it.
After that, Mr. Daly gave me two problems. One problem from Array 2, and another one from String 2. It was to test my knowledge of Level 2 CodingBat. I managed to do both. It was interesting though, because after looking at my code from before, I realised that the code that I used to solve the string problem this time was much shorter, and used different methods. This makes me happy, because it shows that I have learned over time. The Array 2 Problem was also relatively easy. I think that if I were to redo each one from level 2, it would be way easier to complete than the first time around, just how I felt when I completed Level 1.
Following the tests, I went on to try a level 3 array problem. Without having any idea what I was writing, I did manage to get a few right. But, we couldn't use that code, so Mr. Daly and I wrote a different one to try and solve the problem. Unfortunately, I encountered a compile problem while working on it at home, and I don't know how to get past it. I use two loops, and in one of them I use i. In the second one, I use int r, because I don't want to have two int i with different value. So, I don't know how to get passed that.
Unfortunately, I don't have a problem to show for today. You have already seen them all ! Nothing new for this time. But, hopefully, I will have at least one level 3 problem for you by the end of next class. Looking forward to after tomorrow !
Monday, May 18, 2015
Monday, May 18th
IT'S DONE ! Level 2 of CodingBat is officially completed!
After a dreadful month of suffering with endless problems, I have completed String 2. I left class on the verge of crying because I had half a problem to fix until I was done, but I had to wait to come home before completing it. It took a while, the last problem, but was definitely worth it once I saw the green check with the star.
Here is my last problem:
----------------------------------------------------------------------------------------------------------------------------------
Given a string and a non-empty word string, return a version of the original String where all chars have been replaced by pluses ("+"), except for appearances of the word string which are preserved unchanged.
public String plusOut(String str, String word) {
String abc = new String("");
// create a new string.
int i= 0;
while (i<str.length())
// as long as we don't exceed the string length,
{
if (str.substring(i).startsWith(word))
{
abc+=word;
i+=word.length();
// when we see the word, we want to add the word to our new string abc. then, make i skip to
// the next letter after the end of the word.
}
else
{
abc+="+";
i++;
// if we're not looking at the word, then simply replace every letter with a +, and increment i by
// one so that it looks at the next letter.
}
}
return abc;
// return our modified string.
}
----------------------------------------------------------------------------------------------------------------------------------
After a dreadful month of suffering with endless problems, I have completed String 2. I left class on the verge of crying because I had half a problem to fix until I was done, but I had to wait to come home before completing it. It took a while, the last problem, but was definitely worth it once I saw the green check with the star.
Here is my last problem:
----------------------------------------------------------------------------------------------------------------------------------
Given a string and a non-empty word string, return a version of the original String where all chars have been replaced by pluses ("+"), except for appearances of the word string which are preserved unchanged.
public String plusOut(String str, String word) {
String abc = new String("");
// create a new string.
int i= 0;
while (i<str.length())
// as long as we don't exceed the string length,
{
if (str.substring(i).startsWith(word))
{
abc+=word;
i+=word.length();
// when we see the word, we want to add the word to our new string abc. then, make i skip to
// the next letter after the end of the word.
}
else
{
abc+="+";
i++;
// if we're not looking at the word, then simply replace every letter with a +, and increment i by
// one so that it looks at the next letter.
}
}
return abc;
// return our modified string.
}
----------------------------------------------------------------------------------------------------------------------------------
It was very enjoyable to work on Level 2. Although at times the problems frustrated me, it made me learn a lot. I constantly learned new methods (as you saw above), and new ways of thinking. New logic. I am starting to develop the sense of thinking in code.
From here, I do not know where I will go. I will either work on some level 2 things, like warmup 2, or Logic 2, or even maybe AP CS 1 if Mr. Daly thinks that I have a high enough level to work on those. I don't think I will start Level 3, because it is more complicated and I won't have access to Mr. Daly's help over the summer. It all depends on what I decide with Mr. Daly next class.
Either way, I am presenting in 2 weeks time.
I'm very excited !
Thursday, May 14, 2015
Thursday, May 14th
Today was a good class. I got closer than ever to finishing String 2. I got into class, and began to work on a problem that I had partially solved with Mr. Daly last class. I couldn't figure out what the problem was; it was an out of bounds. I proceeded to go to Mr. Daly for help, but it turned out that immediately as I sat down, I figured out what the problem was, and without Mr. Daly even saying a word, I changed one number which solved the whole problem. It's funny how sometimes you can look at a problem for a long time, and not have the right solution to it, and then look at it again another time and know exactly what to do right when you see the problem.
That was the one out of two problems that I worked on during class. I completed another one. I now only have two problems left in String 2.
Here it is:
----------------------------------------------------------------------------------------------------------------------------------
public String starOut(String str) {
if ((str.length()<3) && (str.contains("*")))
{
return "";
}
// if the string length is less than two and there's a star, return an empty string because everything will
// be gone.
if (!str.contains("*"))
{
return str;
}
// if there is no star in the string, then we don't want to take anything out. return the string unmodified.
if (str.substring(0,1).equals("*"))
{
str=str.substring(2);
// if the star is at the very beginning of the string, then return only the string from two chars after the star
// onwards.
}
if (str.substring(str.length()-1).equals("*"))
{
str=str.substring(0,str.length()-2);
// if the star is at the very end of the string, return the string from the beginning until the char before one
// to the left of the star.
}
while (str.indexOf("*")!=-1)
// as long as there is still a star in the string,
{
int cutpoint = str.indexOf("*");
int cutpointend = cutpoint;
while (str.substring(cutpointend,cutpointend+1).equals("*"))
{
cutpointend ++;
// if the next char after the star is another star, then the cutpointend is incremented by one. this helps to
// find series of stars that come in two or three.
}
str=str.substring(0,cutpoint-1) + str.substring(cutpointend+1);
// return the string from the beginning until two before the first star, and from two after the last star until
// the end.
}
return str;
// return the modified string.
}
----------------------------------------------------------------------------------------------------------------------------------
We are approaching the end. It's almost the end of the year, and I am at arm's length of finishing String 2. Can't wait !!!
That was the one out of two problems that I worked on during class. I completed another one. I now only have two problems left in String 2.
Here it is:
----------------------------------------------------------------------------------------------------------------------------------
Return a version of the given string, where for every star (*) in the string the star and the chars immediately to its left and right are gone. So "ab*cd" yields "ad" and "ab**cd" also yields "ad". starOut("ab*cd") → "ad" starOut("ab**cd") → "ad" starOut("sm*eilly") → "silly" ----------------------------------------------------------------------------------------------------------- |
public String starOut(String str) {
if ((str.length()<3) && (str.contains("*")))
{
return "";
}
// if the string length is less than two and there's a star, return an empty string because everything will
// be gone.
if (!str.contains("*"))
{
return str;
}
// if there is no star in the string, then we don't want to take anything out. return the string unmodified.
if (str.substring(0,1).equals("*"))
{
str=str.substring(2);
// if the star is at the very beginning of the string, then return only the string from two chars after the star
// onwards.
}
if (str.substring(str.length()-1).equals("*"))
{
str=str.substring(0,str.length()-2);
// if the star is at the very end of the string, return the string from the beginning until the char before one
// to the left of the star.
}
while (str.indexOf("*")!=-1)
// as long as there is still a star in the string,
{
int cutpoint = str.indexOf("*");
int cutpointend = cutpoint;
while (str.substring(cutpointend,cutpointend+1).equals("*"))
{
cutpointend ++;
// if the next char after the star is another star, then the cutpointend is incremented by one. this helps to
// find series of stars that come in two or three.
}
str=str.substring(0,cutpoint-1) + str.substring(cutpointend+1);
// return the string from the beginning until two before the first star, and from two after the last star until
// the end.
}
return str;
// return the modified string.
}
----------------------------------------------------------------------------------------------------------------------------------
We are approaching the end. It's almost the end of the year, and I am at arm's length of finishing String 2. Can't wait !!!
Tuesday, May 12, 2015
Mid-Quarter Report, May 2015
Mid Quarter Report for Computer Applications
May 2015
Mid Quarter November 2015
|
Please answer the questions fully in the spaces below.
|
Module
|
CodingBat
|
Summarize what you have achieved in the first half of this quarter.
|
I have worked on CodingBat. I have completed Array 2, and now am very close to finishing String 2 with only four problems left.
|
Please indicate any days that you know you will be missing between now and the end of the course.
|
I am not missing any school days that I know of in advance.
|
Describe what you expect to achieve by the end of the module?
How much material will you have covered?
What projects will you have completed?
What will you be presenting?
|
By the end of this module, I hope to have finished level 2 of CodingBat. i should definitely finish it, with only four problems left. I will have learned for loops, while loops, and many many different methods for arrays and strings.
I will be presenting how CodingBat works and demonstrating a few problems.
|
Your teacher will be entering a grade-in-progress in PowerSchool for mid-quarter. He will be considering your performance in terms of theassessment guidelines. At this stage he will be asking about the extent to which the statements below apply to your performance in the course.
|
Comment below if you feel there has been a change since mid-semester.
I do not feel this way.
|
His/her written communication (blogs and reports) are done according to deadlines and contain enough information for the teacher to understand what he/she is doing, what kinds of problems he/she is facing and how he/she feels about his/her learning experiences.
Are you consistently doing your blogs? How does your BLog keeping compare to the first half of the quarter? Are you providing more details of your learning? Do you take care to express yourself clearly and use conventional grammar and spelling? Are you using images, videos, links to illustrate the work that you are doing? Are you satisfied that your blog reflects in a complete way what you are doing?
|
inadequate adequate good outstanding
I always do my blogs. They are always very thorough, and gives lots of insight to the reader of what I'm working on and how well or not well it is going. However, I will admit that there have been a few times where I have forgotten to post the blog the day of the class. I use correct spellings, and in my blogs always put a piece of code to explain how I solved a problem. My blog completely represents what I am doing.
|
Typically this student makes effective use of class time by increasing his/her competence and confidence using software that he/she has chosen.
Are you using your time effectively? Are you learning each time you come to class? Are you becoming more competent and confident?
|
inadequate adequate good outstanding
I use my time wisely. I always come into class ready to work, and work throughout the class on my CodingBat problems. As I go through them, they get harder, but I have more experience in solving them.
|
He/she attends all class sessions, coming and leaving on time, making sure to make up missing time by working during free periods or at home.
Have you missed class this quarter? How many times? What have you done to make up lost time?
|
inadequate adequate good outstanding
I always come in on time, and leave on time. I have not missed a single class this first half of the quarter.
|
His/her oral communication during class is focused on the learning tasks that he/she is engaged in.
Are your conversations in class focused on your learning tasks?
|
inadequate adequate good outstanding
The only two people I talk to in class are Tommy and Mr. Daly. I talk to Tommy when he needs my help, since he's also working on CodingBat. I talk to Mr. Daly when we are trying to solve a problem together. Occasionally also, Matan shows me the music that he's working on.
|
During class he/she remains focused on the task at hand and generally respects the integrity of the learning environment for all students.
Do you stay on task throughout the block? Do you effectively resist temptations to use the computer for unrelated activities (other homework, e-mail, facebook, youtube, sports results, music etc.)? Do you resist temptations to take unnecessary breaks, arrive late, leave early? Are all your interactions with other students focused on the task at hand?
|
inadequate adequate good outstanding
When I get to work, I don't stop working until I complete a problem. After completing a problem, I might take a 2-3 minute break, and then straight back to work. I've learned throughout a year of computer applications to resist my temptations to go on facebook and other things, and now in class solely focus on my work. I have one goal: to complete as many problems as I can per class. I only interact with other students when it's about work that we are doing.
|
He/she has positive attitudes towards acquiring technology skills, and makes a conscious effort to acquire new skills and apply them in meaningful ways.
Are you acquiring new skills each class? Are you effectively documenting these in your blog? Have you found ways to apply your skills beyond classroom exercises?
|
inadequate adequate good outstanding
I love learning Java. There is no better feeling than completing a problem. I am always striving to improve my skills, and if I have the chance to learn a new method, I won't think twice before browsing through the Java class documentation to find one. I have learned many new methods throughout this quarter, like str.contains(). I always mention these newly learned skills in my blog. If I do create my own application in the future, or even simply for the APCS, all of these methods will come in handy.
|
He/she is an independent learner, who tries to solve problems by himself/herself, but finds effective ways to overcome problems using a variety of other resources.
Have you become more independent as a learner? What resources are you using to learn effectively?
|
inadequate adequate good outstanding
Before going to Mr. Daly, I always try to find a solution to the problem. I will spend 10 minutes on it, and if I really can't find another method to solve the problem, then I will go to ask for Mr. Daly's help. I will sometimes look for new methods myself through the Java class documentation.
|
He/she is respectful of all members of this learning community and his/her behavior is in compliance with all school policies, in particular the AUP (Appropriate Use Policy) and Academic Honesty Policy.
Are you respectful, appropriate, honest? Do you make sure that your behavior does not interfere with the learning of others by distracting them from their work?
|
inadequate adequate good outstanding
I always respect my classmates and their learning environment. I do follow the Appropriate Use and Academic Honesty policies of the school. I do not do anything that could possibly interfere with the work of others, and respect their working space.
|
Your grade will take into account your performance in the above areas and also..
The amount of documented learning time that you have spent in and out of class.
The amount and/or depth of material that you have covered
| |
What is your grade-in-progress (see PowerSchool)?
Typically if the grade is in the 80s your overall performance has been good. If your grade is in the 70s your performance has been adequate.
How would you describe your overall performance at this point? Is your assessment in-line with the assessment of your instructor?
|
My current grade-in-progress is 92.
This is the grade that I would have imagined for myself. It truly does remark the hard work that I have done throughout the beginning of this quarter. I absolutely agree with this grade, and my assessment of myself is definitely in-line with that of Mr. Daly's.
|
Is there any other information that you would like to provide your teacher to help decide on your grade-in-progress?
|
I have worked hard throughout the quarter, taking on more and more challenging problems of Level 2 CodingBat. They have been challenging, but I have been working hard to increase my knowledge of Java and to be prepared for the AP Computer Science next year.
|
Tuesday, May 12th
Today was a good class. I got to class and I realised that I hadn't done the mid quarter report. Mr. Daly wanted me to do it during class, but I preferred to work on CodingBat and have Mr. Daly around to help me if I needed it. So right after this blog post, I will be posting the mid quarter report.
It was a good class today. It was a particularly good class since I got a problem done completely by myself, without needing help from Mr. Daly at all. To me, this is one of the best possible feelings in this class. I have 25 stars on CodingBat, and now only 4 problems to complete. I have more than enough time to finish level 2.
In honour of my life accomplishment, I'll be showing the problem that I completed alone today.
Here it is:
----------------------------------------------------------------------------------------------------------------------------------
Given two strings, return true if either of the strings appears at the very end of the other string, ignoring upper/lower case differences (in other words, the computation should not be "case sensitive"). Note: str.toLowerCase() returns the lowercase version of a string.
endOther("Hiabc", "abc") → true
endOther("AbC", "HiaBc") → true
endOther("abc", "abXabc") → true
public boolean endOther(String a, String b) {
String aone = new String (a.toLowerCase());
String bone = new String (b.toLowerCase());
// convert both strings to only lowercase letters, so that we don't have an issue with whether
// or not the letters are capitalised or not.
if (aone.equals(bone))
{
return true;
// if the two strings are identical, then it does appear at the end, so return true.
}
if ((a.length()>b.length()) && aone.substring(aone.length()-bone.length()).equals(bone))
{
return true;
// if a is longer than b, and b appears in the last few characters of a, then return true.
}
if ((b.length()>a.length()) && bone.substring(bone.length()-aone.length()).equals(aone))
{
return true;
// if b is longer than a, and a appears in the last few characters of b, then return true.
}
return false;
// if the above conditions are not true and neither string appears at the end of the other, then
// return true;
}
------------------------------------------------------------------------------------------------------------
This is what I have for today. Obviously, I worked on some other problems. I was close to finishing a problem with Mr. Daly towards the end of class, but I had a meeting during break so we couldn't finish it. Soon, I will be done with everything. Looking forward to Thursday afternoon !
It was a good class today. It was a particularly good class since I got a problem done completely by myself, without needing help from Mr. Daly at all. To me, this is one of the best possible feelings in this class. I have 25 stars on CodingBat, and now only 4 problems to complete. I have more than enough time to finish level 2.
In honour of my life accomplishment, I'll be showing the problem that I completed alone today.
Here it is:
----------------------------------------------------------------------------------------------------------------------------------
Given two strings, return true if either of the strings appears at the very end of the other string, ignoring upper/lower case differences (in other words, the computation should not be "case sensitive"). Note: str.toLowerCase() returns the lowercase version of a string.
endOther("Hiabc", "abc") → true
endOther("AbC", "HiaBc") → true
endOther("abc", "abXabc") → true
public boolean endOther(String a, String b) {
String aone = new String (a.toLowerCase());
String bone = new String (b.toLowerCase());
// convert both strings to only lowercase letters, so that we don't have an issue with whether
// or not the letters are capitalised or not.
if (aone.equals(bone))
{
return true;
// if the two strings are identical, then it does appear at the end, so return true.
}
if ((a.length()>b.length()) && aone.substring(aone.length()-bone.length()).equals(bone))
{
return true;
// if a is longer than b, and b appears in the last few characters of a, then return true.
}
if ((b.length()>a.length()) && bone.substring(bone.length()-aone.length()).equals(aone))
{
return true;
// if b is longer than a, and a appears in the last few characters of b, then return true.
}
return false;
// if the above conditions are not true and neither string appears at the end of the other, then
// return true;
}
------------------------------------------------------------------------------------------------------------
This is what I have for today. Obviously, I worked on some other problems. I was close to finishing a problem with Mr. Daly towards the end of class, but I had a meeting during break so we couldn't finish it. Soon, I will be done with everything. Looking forward to Thursday afternoon !
Friday, May 8, 2015
Friday, May 8th
Today was an interesting class. I went up to the Genius Bar with Tommy, but went straight back downstairs after realising that I wouldn't be able to solve the problems without Mr. Daly.
I came down at 14:20 from the library, and we worked on one problem. One single problem, for 40 minutes. I think this was the longest and most draining problem I have encountered in CodingBat. Mr. Daly and I tried every single possible Java method and different ways to try and solve the problem - still unsolvable.
After enduring 40 minutes of mental torture on a Friday afternoon, we finally managed (I don't know how) to solve the problem.
Here it is :
----------------------------------------------------------------------------------------------------------------------------------
I came down at 14:20 from the library, and we worked on one problem. One single problem, for 40 minutes. I think this was the longest and most draining problem I have encountered in CodingBat. Mr. Daly and I tried every single possible Java method and different ways to try and solve the problem - still unsolvable.
After enduring 40 minutes of mental torture on a Friday afternoon, we finally managed (I don't know how) to solve the problem.
Here it is :
----------------------------------------------------------------------------------------------------------------------------------
Given a string and a non-empty word string, return a string made of each char just before and just after every appearance of the word in the string. Ignore cases where there is no char before or after the word, and a char may be included twice if it is between two words. wordEnds("abcXY123XYijk", "XY") → "c13i" wordEnds("XY123XY", "XY") → "13" wordEnds("XY1XY", "XY") → "11" |
I think it was also the longest piece of code I have written all year. It was long, but worth it in the end when we finally had the joy of seeing the "All Correct".
I only have 5 problems left in String 2. Let's do it ! Until next class.
Wednesday, May 6, 2015
Wednesday, May 6th
Regular class today.
I worked on String 2, and managed to get a few problems done. Only 6 problems left after this class !
I worked on a few interesting problems. One problem asked me to return true or false according to what a part of the string was, when there was a star. What they asked of me, I could do. The problem for me came when there were multiple stars, and I had already returned true, when the next star appearance turned out to be false. I could only return true if their conditions applied to all of the stars in the string, so how could I write the code so that it would take into consideration all of the other stars in the string?
This is the problem:
----------------------------------------------------------------------------------------------------------------------------------
Returns true if for every '*' (star) in the string, if there are chars both immediately before and after the star, they are the same.
sameStarChar("xy*yzz") → true
sameStarChar("xy*zzz") → false
sameStarChar("*xa*az") → true
public boolean sameStarChar(String str) {
if (!str.contains("*")){
return true;
}
// if the string doesn't even contain a star, then return true since we won't even have that //problem.
for (int i=1;i<str.length()-1;i++)
{
if (str.substring(i,i+1).equals("*"))
// we want to make sure we're dealing with a star.
{
if (!str.substring(i-1,i).equals(str.substring(i+1,i+2)))
{
return false;
// if the star's characters before and after are not the same, then return false;
}
}
}
return true;
// otherwise, return true. The fact that we put the return true at the end, allowed the computer
// to go through the entire string, and if it finds one irregularity with the stars, it will return
// false. It will only return true if all of the instances of stars have the chars before and after
// the same.
}
------------------------------------------------------------------------------------------------------------
It is thanks to Mr. Daly that I understood this problem. He explained the logic to me when I came to see him.
I am currently working on another problem with stars, but I haven't completed it. I will most likely show that one for next class's blog.
Looking forward to finishing Level 2 !
I worked on String 2, and managed to get a few problems done. Only 6 problems left after this class !
I worked on a few interesting problems. One problem asked me to return true or false according to what a part of the string was, when there was a star. What they asked of me, I could do. The problem for me came when there were multiple stars, and I had already returned true, when the next star appearance turned out to be false. I could only return true if their conditions applied to all of the stars in the string, so how could I write the code so that it would take into consideration all of the other stars in the string?
This is the problem:
----------------------------------------------------------------------------------------------------------------------------------
Returns true if for every '*' (star) in the string, if there are chars both immediately before and after the star, they are the same.
sameStarChar("xy*yzz") → true
sameStarChar("xy*zzz") → false
sameStarChar("*xa*az") → true
public boolean sameStarChar(String str) {
if (!str.contains("*")){
return true;
}
// if the string doesn't even contain a star, then return true since we won't even have that //problem.
for (int i=1;i<str.length()-1;i++)
{
if (str.substring(i,i+1).equals("*"))
// we want to make sure we're dealing with a star.
{
if (!str.substring(i-1,i).equals(str.substring(i+1,i+2)))
{
return false;
// if the star's characters before and after are not the same, then return false;
}
}
}
return true;
// otherwise, return true. The fact that we put the return true at the end, allowed the computer
// to go through the entire string, and if it finds one irregularity with the stars, it will return
// false. It will only return true if all of the instances of stars have the chars before and after
// the same.
}
------------------------------------------------------------------------------------------------------------
It is thanks to Mr. Daly that I understood this problem. He explained the logic to me when I came to see him.
I am currently working on another problem with stars, but I haven't completed it. I will most likely show that one for next class's blog.
Looking forward to finishing Level 2 !
Monday, May 4, 2015
Monday, May 4th
Regular afternoon class today. I came to class a bit late since I was working with Ms. Prey during lunch, but as soon as I got to class, I got straight to work. It was a good class, I managed to get two or three problems complete.
I have four starts out of 7 on String 2. Tough, but almost done!
I don't have anything special to say for today, to be honest. I didn't learn or use any new methods, and there wasn't a particularly special problem that was very interesting. It was a regular class, where I used all of my known methods, and nothing else besides that.
Here is one of my problems from today :
----------------------------------------------------------------------------------------------------------------------------------
I have four starts out of 7 on String 2. Tough, but almost done!
I don't have anything special to say for today, to be honest. I didn't learn or use any new methods, and there wasn't a particularly special problem that was very interesting. It was a regular class, where I used all of my known methods, and nothing else besides that.
Here is one of my problems from today :
----------------------------------------------------------------------------------------------------------------------------------
Given a string and an int N, return a string made of N repetitions of the last N characters of the string. You may assume that N is between 0 and the length of the string, inclusive. repeatEnd("Hello", 3) → "llollollo" repeatEnd("Hello", 2) → "lolo" repeatEnd("Hello", 1) → "o" |
I know this is a short blog, but it's all I have to say for today. See you next class ! |
Subscribe to:
Posts (Atom)