שאלות ותשובות - Wet1 Frequently Asked Questions - Wet1 Вопросы и Ответы - Wet1 أسئلة وأجوبة - Wet1
Last Update: 6.12.2010
- 6.12: Added Clarifications 6.
- 5.12: Added Clarifications Update (Must Read).
- 28.11: Modified Clarifications 5.
- 28.11: Added Clarifications 4, Clarifications 5.
- 21.11: Added Clarifications 3.
- 18.11: Added Clarifications 2.
- 17.11: Added Implementational Questions 2.
- 16.11: Added Clarifications 1, Implementational Questions 1.
|
|
Clarifications |
|
|
1. Regarding the "Wet test" contest: Are the tests we write the ones you will use to grade our assignments?!?!?!?!111oneone |
No.
The purpose of this part of the assignment is that you will write your own tests. To motivate you into writing good tests, that go over as many scenarios as possible, we have decided to give a bonus for the best tests files written by you. The best way for us to compare between tests is by running your code with them as input.
Your grades will be given according to tests we write. We are not vicious, nor stupid ("Init, Quit, Yay everyone got 100!!!"), but we do write vicious test files and enjoy stupid jokes, so beware (of both).
|
2. In Yaniv every hand has at most 5 cards. Is it true in this assignment too? |
No.
In this assignment you are implementing a "Generalized Yaniv" game, in which the deck size may be larger than 52 cards and the number of cards in the hand can be as large as the deck size. At the initialization stage, the hand is empty. Cards are added to the hand using the TakeCard function. This may not be the way Yaniv is usually played, but it is easier to explain and much easier to implement when the hand is initially empty.
|
3. Is it possible to implement LongestStraightWithJoker in O(1)? |
Yes (even more than one way), however these solutions are much more difficult to implement, let alone debug. To make this assignment easier, we required a time complexity of O(n) for this function. We recommend that you stick to solutions with simple implementations.
Kudos for those of you who found a solution where this function runs in O(1).
|
4. What is the length of the shortest series or straight? |
A series can contain between one card and 4 cards. A straight can contain one card and can be as long as N, the highest number in the deck.
|
5. What should LongestStraightWithJoker() return if no straight can be constructed with a joker? |
The function LongestStraightWithJoker() returns the longest straight that may use a joker (not at the beginning or end of a straight). In case no such straight exists, the longest straight without a joker will be returned.
For instance, if the hand contains: 7h, 8h, 10h, 8c, 9c, 10c The function LongestStraightWithJoker() will return: 7h-10h. If we drop the card 8h, the function LongestStraightWithJoker() will return 8c-10c.
Another example: if the hand contains: 1h, 2h, 3h, 4h, 10c, 12c The function LongestStraightWithJoker() will return 1h-4h. Even though we can construct a straight with length 3 using a joker, it is still shorter than the straight 1h-4h of length 4.
|
Update regarding LongestStraightWithJoker() |
It is possible that two straights will have the same length, sum and suite. For instance, if the hand holds: 9h, 10h, 11h, 14h, 16h
There are two possible longest straights: 9h, 10h, 11h And: 14h, J, 16h
Both with length 3, sum 30 and all hearts. In this case, return the straight with the higher end point. In the example, you should return 14h-16h.
How to correct your code: When comparing straights by length, sum and suite, instead of returning "equal" when all 3 parameters are equal, compare the straights one last time according to their highest cards.
We have added a zip file called DataStructures_Winter2010_11_UpdateTest.zip, containing a test checking this issue with its required output.
|
6. I have a great test file for the "Wet test competition", but I call multiple times to Init and Quit. Is it OK? |
Yes and no.
There is no use in calling Init and Quit many times. Finding bugs in the implementation does not mean finding bugs in our main.cpp file (good luck with that :P). You are supposed to look for test cases which aren't easy to find or generate, using some random test generator. The whole idea is that by writing these tests, you might accidentally find bugs in your implementation.
Stick to test files that call Init only once, at the beginning, and call Quit once at the end.
|
|
|
|
Implementational Questions |
|
|
1. How do I pass the test file name as an input parameter to debug more easily? |
In Eclipse: Follow: Run -> Run Configurations -> Arguments. Write the relative path (relative to your project) or absolute path of the input file. Don't forget to click "Apply" to make these changes relevant to the next run of your program.
In Visual Studio 2008: Right click your project name (or choose "Project" from the upper bar) and choose "Properties". Click on "Debugging" and enter the name of the test file under "Command Arguments". Note that if you only write the filename (e.g. test1.txt), you should put the test1.txt in your working directory (by default, the directory in which your project is located).
|
2. What should the function TakeCard(i,suite) return when the card taken is the joker (i=0)? |
INVALID_INPUT.
Assume that the joker is not part of the data structure. The only function that addresses the joker card is LongestStraightWithJoker. In this function, you can assume that you have the joker in your hand.
|
3. How to I easily run the course tests? |
You can run the random tests yourself by doing the following: 1. Put your executable file (a.out) and the DataStructures_Winter2010_11_Course_Tests.zip file (appears under "Assignments" on the website) in the same folder.
2. Call: unzip DataStructures_Winter2010_11_Course_Tests.zip
3. Use the following command in order to run test #0 (in the same way you can run the other random tests): set i = 0 zcat Tests/randtest${i}.zip | ./a.out > tmp unzip Results/randtest${i}.zip diff tmp randtest${i}.out rm randtest${i}.out rm tmp
You can paste this code into the SSH terminal using shift+insert.
|
|