There is an elective class in the middle school (I'm not sure what it's called) that works with computer programs, very similar to us in fact. It was only coding, however. Only 4 people were in that class (or at least only 4 people came to the library). Mei and I started off by giving them a description of what the course computer applications is. We explained to them that this class was like no other- we came in, and there is no "paying attention to the teacher for 80 minutes". We come in, sit down, and work on whatever we are working.
We then proceeded to go around the table at which everybody was sitting, and one by one, each person explained what they were working on, and how it was going. Natalie, for example, said that she was using Greenfoot and that she was working on a few games. One of the kids even tried her game.
It was interesting for them, but it was also interesting for me because I didn't actually know what some people in the class were working on but I found out. I found out that Martynas was working on HTML, and that Tomas was working on modifying games.
After giving the tour of the class, we switched roles and gathered around the kids, who then showed us what they were working on. They worked on a program called Scratch, which very much resembled the Hour of Code that we worked with earlier this year. They worked on game, and the code was created exactly like it was with the Hour of Code: with blocks.
After that little tour of the class, I got back to work. I got lucky and had a lot of easy problems until the end of the class, they weren't hard at all. Here is one of them:
----------------------------------------------------------------------------------------------------------------------------------
Given an array of ints, return true if the number of 1's is greater than the number of 4's
more14({1, 4, 1}) → true
more14({1, 4, 1, 4}) → false
more14({1, 1}) → true
public boolean more14(int[] nums) {
int sum1 = 0;
int sum2 = 0;
// create two different sums, one for each time there is a 1, and one for each time there is a 4.
for (int i=0; i<nums.length; i++)
{
if (nums[i]==1)
{
sum1=sum1 +1;
// if there is a 1 in the array, add 1 to the sum for the ones.
}
if (nums[i]==4)
{
sum2=sum2 +1;
// if there is a 4 in the array, add 1 to the sum for the fours.
}
if (sum1 > sum2)
{
return true;
// if the amount of 1's is greater than the amount of 4's in the array, then return true.
}
return false;
// if there are more 4's than ones, then return false.
}
Looking forward to continuing with loops!
No comments:
Post a Comment