CMU 15-112: Fundamentals of Programming and Computer Science
Collab 7 (Due Monday 19-Oct at 8pm ET (Pittsburgh-time))
...but submit at the end of your collab section!




  1. Word Search with Wildcards and Wraparound
    Today we're asking you to add two features into our Word Search case study! Your TA will briefly explain these two features, and then you and your partner(s) will attempt to add them in. Note, you should add these one at a time, in order! Don't try to have one person add each feature and then try to smash your code together. You won't get collaboration points, and it'll be harder! However, after you have added one feature, swap off so that another partner is doing most of the typing.

    1. Feature 1: Word Search with Wraparound
      If one of you has done most of the typing so far, switch off so that someone else types this feature!
      Add wraparound behavior so that a word can be found even if it goes off the edge of the board, as long as the rest of the word continues on the opposite edge. Can you enable wraparound by changing just one wordsearch function?

    2. Feature 2: Word Search with Wildcards
      Take note that this was FR3 on the F19 midterm so we could ask you to do something like this on a future exam!
      Both the board and the word can contain '?', which is a so-called wildcard that matches any letter, so 'a?c' matches each of 'abc', 'acc', 'adc', and so on. However, a match can only use up to one wildcard, so 'a??' does not match 'abc', and 'a?c' does not match 'ab?', since each would use two wildcards. As in the notes, your function should return whatever word was searched for along with the starting location and direction. (This means your returned word might still have a '?' in it.)
      Hint: You might also only need to modify one of the three wordsearch functions for this feature.
      Oh! And remember to write a few of your own tests!
      def testWordSearchWithWildcardsAndWraparound(): print('Testing wordSearchWithWildcardsAndWraparound()...', end='') board = [ [ 'd', 'o', 'g' ], [ 't', 'a', 'c' ], [ '?', 'r', 't' ], [ 'u', 'r', 'k' ], ] assert(wordSearch(board, "dog") == ('dog', (0, 0), 'right')) assert(wordSearch(board, "roar") == ('roar', (3, 1), 'down')) assert(wordSearch(board, "rug") == ('rug', (2, 1), 'down-left')) #Wildcards should still work! assert(wordSearch(board, "tort") == ('tort', (2, 2), 'right')) assert(wordSearch(board, "rat") == ('rat', (2, 1), 'left')) #Note: Your function *may* return one of two different (but still correct) answers! # One is not obvious, and counts the second letter as 'o' in (0, 1). # Adding (-1,-1) for 'up-left' then puts us at (-1, 0) which should # wrap around to the 'u' at (3, 0). Which does your code return? assert((wordSearch(board, "c?u") == ('c?u', (1, 2), 'up-left')) or (wordSearch(board, "c?u") == ('c?u', (1, 2), 'down-left'))) assert(wordSearch(board, "tur?") == None) #Can't use two wildcards though! assert(wordSearch(board, "cow") == None)

    3. Optional/Advanced Feature 3: Text Interface
      If you added the two features above and still have time, can you make a text interface for Word Search? The details are up to you, but we imagine it won't play like a normal word search. Instead, your code asks the user for a word with input(), and if that word is present in the board, its starting location and direction are printed, and all the relevant letters in the board become uppercase. Note that this means your word search should be case-insensitive!


  2. Discuss solutions to Word Search
    TAs will lead a discussion where all teams discuss what features they implemented, and very briefly how they were implemented. As before, your TA will be individually grading you based on demonstrated effort and good collaboration, so participate! (As always, this means you and your partner(s) should all speak and contribute.)



  3. CT Review Game
    Lots of you have asked for some guided CT practice, so let's have some fun while we do it. The basic rules are this:
    1. You each start with 1000 "points" (In quotes because they don't affect your grade. Once more for those in the back: Your score does not affect your grade! They're just for fun. Participation and effort determine your grade.)
    2. In fact... your group should immediately rename these to something other than "points," like kudos or stonks.
    3. Your TA will show you a CT. You have about 15 seconds to decide how many of your "points" you want to wager.
    4. Now, you'll have a few minutes to solve the CT on your own. Do it on paper! No computers! Your TA will tell you how long you have.
    5. Your TA will call on a group member to say what they think the answer is.
    6. Others can give a thumbs-up if they agree, or raise their hand to be called on in if they have a different answer that they believe is correct.
    7. Once the TA reveals the answer, you lose your wagered points if you got it wrong, you win twice your wager if you got it right, and you win three times your wager if you were the first one to give the right answer. (but you have to be called on; don't blurt it out!)
    8. Keep track of your answers and your own score. Honor system! If you want to share your score at the end, you may (but you don't have to).
    9. Have fun!



  4. Video Discussion: Asimov's Three Laws
    Watch this video on Asimov's Three Laws of Robotics and discuss! This is open-ended, though here are some starter questions if you need them:
    1. If we could implement the Three Laws, are these sufficient to prevent "bad robots?"
    2. If not, what other laws could we add to close the loopholes?
    3. Or... are the three laws just a distraction that won't help us build safe robots at all?

    Note: You are graded on attentiveness, participation, and courtesy. (Please pay attention and be respectful.)





  5. SUBMIT TO AUTOLAB!
    Note the submission deadline at the top of the page. You must submit to autolab by that time. The time is in ET (Pittsburgh time) and is an absolutely final deadline. You should submit immediately after your group is finished! No work will be accepted after the deadline (unless of course your collab meeting is after the deadline).

    Submit collab7.py to Autolab (Note: this is a python file, not a zip file!).
    All you need to submit in collab7.py is your modified word search code with an attempt (hopefully successful) to add wildcards and wraparound. Remember to leave a comment at the top of your file explaining what features you added.

    (While we hope your file runs, you won't receive a zero on the collab if it doesn't, as long as we can see your genuine effort in the code.) You are graded on demonstrated effort during the collab session, and your submission should provide extra evidence of that effort. You do not need to finish your work after the collab. There is no autograder.

    If you realize you messed up your submission (i.e. submitted a blank file, zip file, etc) you can submit up to 5 times, but you really ought not need to.

    Remember, no late work is accepted! Uploading to autolab takes a few minutes at most. Do not wait until the deadline and risk getting a zero.