This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Saas1 question 6 questions: | |
Part A: currency converter -- searched you will see for help - autograder had issues with the solution | |
Part B: have not yet resubmitted -- but seems to work just fine | |
Part C: tried to modify my Enumerable but has an issue! | |
# -*- coding: utf-8 -*- | |
=begin | |
Karen West - April 7th, 2013 - homework#1 question#6 | |
HW 1-6: Advanced OOP, Metaprogramming, Open Classes and Duck Typing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Question is at bottom! | |
=begin | |
Karen West April 7th, 2013 - Homework #1 - Saas1 take2 - Question #5 | |
HW 1-5: Advanced OOP, Metaprogramming, Open Classes and Duck Typing | |
In lecture, we saw how attr_accessor uses metaprogramming to create getters and setters for object attributes on the fly. | |
Define a method attr_accessor_with_history that provides the same functionality as attr_accessor but also tracks every value the attribute has ever taken. The following example shows the basic behavior of the new accessor: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=begin | |
Karen West - April 7th, 2013 | |
HW 1-2: Rock-Paper-Scissors | |
In a game of rock-paper-scissors (RPS), each player chooses to play Rock (R), Paper (P), or Scissors (S). The rules are: R beats S; S beats P; and P beats R. We will encode a rock-paper-scissors game as a list, where the elements are themselves 2-element lists that encode a player's name and a player's selected move, as shown below: | |
[ ["Armando", "P"], ["Dave", "S"] ] # Dave would win since S > P | |
Part A: Write a method rps_game_winner that takes a two-element list and behaves as follows: | |
-- If the number of players is not equal to 2, raise WrongNumberOfPlayersError. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Below were my attempts at questions1 and 2 from project2, and given the trouble I had with these, I ran out | |
of time and never got to questions 3-5. However, in my defense, I did understand these algorithms from a | |
conceptual level when we did homework3 for AI, and on paper, mostly got these algorithms correct. However, | |
when I tried to implement them in the pacman game--totally lost as you will see below. Any suggestions or | |
help would be great! If I cannot work out my issues with project2, well, I'm guessing it makes no sense next | |
week to attempt project3. No worries if you are unable to help here! ;-) | |
Specifically in class ReflexAgent(), my evaluationFunction() did not pass. I tried referencing the notes, | |
the homework3 and previous projects, and still could not get this correct. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Below someone named pyTony (who was also in my Python class last semester from MIT) posted the following solutions | |
to his project1, which I used to try to get mine working after the due date, since he had posted them, and then | |
they took down the solutions, perhaps since they want to reuse these questions another time, not sure. | |
Those are from search.py and all work (dfs, bfs, ucs, astar searching). I don't know if you were in the MIT class | |
in Python last semester, but they were much more lenient (and may have changed since then) about not only posting | |
an official solution after the due date, but they also allowed ALL students who may have had different approaches | |
to the problem to post their solutions for comparison and learning purposes on the class Wiki, and in the cases where | |
I got the answer wrong, I was able to correct it and move onto the next project the next week, or in the cases where | |
I got it correct but someone had implemented a better and more efficient solution, I could also learn from that. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For 169.1 saas homework #1 question #4, I have not yet read in the book about this which is what I plan to do later today. | |
So that may help me here. For this question, it passes 4 of the 6 autograder tests. | |
=begin | |
Karen West, Homework #1, part 4, SaaS1, April 8th, 2013 | |
HW 1-4: Basic Object Oriented Programming | |
Part A: Create a class Dessert with getters and setters for name and calories. Define instance methods healthy?, which returns true if a dessert has less than 200 calories, and delicious? which returns true for all desserts. | |
Here is the framework: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In this 169.1 homework #1 question #3, I can see that I find the anagrams correctly and put them in a list, | |
but it is not in the correct form for the expected output. I am guessing here that my ignorance with Ruby | |
is causing me trouble here again? | |
=begin | |
Karen West, April 8th, 2013 | |
HW 1-3: Anagrams | |
An anagram is a word obtained by rearranging the letters of another word. For example, "rats", "tars", and "star" are anagrams of one another, as are "dictionary" and "indicatory". We will call any array of single-word anagrams an anagram group. For instance, ["rats", "tars", "star"] is an anagram group, as is ["dictionary"]. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
My code for 169.1 (take 2) homework #1 question #2 (RPS game) is below along with the testing output. | |
I realize that you should take any nested level of an RPS game, but I started out simply here, not yet | |
knowing how to do any nesting level, so that would be my first question. | |
But given my code below and the test cases I gave it, the specific 8 player given in the description, | |
along with the 16 player, this works fine for me. Yet it fails the autograder, so this simplified version | |
that does not allow any nesting level is my first question. | |
I'm new to Ruby and have mostly been writing in Python and before that C, so new to this syntax, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Here is my first question on Homework #2 Problem #1 and I did the worst on question #1 (where I got the most parts incorrect). | |
Part 1: Unary Constraints: | |
My incorrect answer was: (i), (iii), (iv), (v), (vi) | |
Domains after unary constraints: | |
A: (1,1), (1,3), (2,2), (2,3) | |
B: (1,3), (2,3) | |
C: (1,1), (1,2), (1,3), (2,1), (2,2) | |
D: (1,2), (2,1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Let me know if you can see this - also - how do I see that you responded | |
or commented on these - you said you commented earlier on the not-logged-in | |
post of a gist whose URL worked for me. |