Skip to content

Oct 30: PA1 Hints, PA2, Quiz4

Learning Objectives

After today's class, you should be able to:

  • Summarize the algorithms of the last three functions of PA 1.
  • Describe the requirements and programming topics of PA 2.

Announcements

  • Read Ch 10 before Monday (due Tuesday)
  • Due Friday: PA 1 Part 2 and PA1 Reflection
  • No office hours tomorrow or Friday (sorry)

PA1 Hints & Tips

  • get_block_vals()
  • check_valid_move()
    • Use the functions to test each case
    • Don't duplicate code in the functions
  • check_completion_status
    • Check each row – easy
    • Check each column – easy
    • Check each block – hard

PA2 Introduction

  • Main Idea

    • Read vote count data from files
    • Determine who won the election
    Submission Points Due Notes
    Part A. Canvas Quiz 10 points Sunday 11/3 predict the return value
    Part B. Code + Tests 30 points Tuesday 11/5 first two voting systems
    Part C. Code + Tests 60 points Tuesday 11/12 last two voting systems
  • Voting Systems

    • Popular Vote – The candidate with the highest number of votes wins. A tie results in an invalid election (return -2 in that case). For all other invalid elections return -1.
    • Absolute Majority – The candidate with the highest number of votes wins, but only if the number of votes is more than 50% of all votes cast in the election. If the highest number of votes is not a majority, the election should return -3 in that case, or -2 if a tie, or -1 if invalid in any other case.
    • Electoral Vote – You will read in the electoral distribution from a JSON file. This will have 538 votes for an election in the United States, and a candidate needs a majority (270 electoral votes) to win a presidential election. Most states use a "winner takes all" system for electoral votes, but some don't.
    • Instant Runoff Voting – IRV elections have 2 rounds. Round one determines the top two highest vote count candidates. Round 2 then redistributes votes so that only highest ranked vote for one of the top 2 candidates is counted. If round 2 determines a majority winner, that index is returned. Otherwise, if there is a tie between the round 2 candidates, then the candidate that has the most first-place votes wins.

Quiz 4

  • 1st sheet: "written potion"
  • 2nd sheet: "coding potion" (write code on paper)
  • Turn off monitor during quiz