Skip to content

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Programming Bingo

A 5x5 card of 25 coding challenges. Solve five in a row, column, or diagonal to get a bingo.

You do not need to know anything in advance. Follow the steps below in order.


Step 1 — Install Python

You need Python 3.8 or newer. Nothing else. No libraries to install.

Do you already have it? Open a terminal and type this, then press Enter:

python3 --version
  • On Windows: open the Start menu, type cmd, press Enter. Use python --version instead of python3 --version.
  • On Mac: press Cmd + Space, type terminal, press Enter.

If you see something like Python 3.11.4, you are done — skip to Step 2.

If not, install it:

  • Windows — go to python.org/downloads, click the big yellow download button, run the installer. Tick the box that says "Add python.exe to PATH" before clicking Install. This matters. Then close and reopen your terminal.
  • Mac — go to python.org/downloads, download, run the installer, click through.

Check it worked by running the version command again.

Throughout this guide we write python3. On Windows, type python instead every time.


Step 2 — Get the code

Download the ZIP from the GitHub page (green Code button → Download ZIP), then unzip it somewhere you can find, like your Desktop.

If you know git, you can instead run:

git clone https://github.com/UoaUOACS/Programming-Bingo.git

Step 3 — Open the folder in an editor

Use VS Code if you have no preference. Install it, open it, then File → Open Folder and pick the Programming-Bingo folder you just unzipped.

You should see these files:

solutions.py      <- you write your answers here
check.py          <- you run this to see how you are doing
debug/            <- three broken programs to fix
bingo/            <- the checker's own code, ignore this

Step 4 — Run the checker

In VS Code, open a terminal with Terminal → New Terminal. Then type:

python3 check.py

You should see your card:

     C1      C2      C3      C4      C5
R1    1 .     2 .     3 .     4 .     5 .
R2    6 .     7 .     8 x     9 .    10 .
R3   11 .    12 .    13 .    14 .    15 .
R4   16 .    17 .    18 .    19 x    20 .
R5   21 .    22 x    23 .    24 .    25 .

* done  x not right yet  . not started  ! could not run

0 of 25 squares complete

Squares 8, 19 and 22 start as x rather than . — those are the debug questions, and they come with code already written for you in the debug/ folder. It just doesn't work yet.

What the symbols mean

Symbol Meaning
. You haven't started this question yet.
x You wrote something, but it doesn't pass every test yet. Scroll down — the checker tells you exactly which tests failed.
* Done. This square counts towards a bingo.
! Your file has a typo in it and Python couldn't read it. The error message will point at the line.

A square only turns * when every one of its 10–15 tests passes. There is no partial credit.

If the command fails with command not found, you are probably in the wrong folder or Python isn't installed — go back to Steps 1 and 3.


Step 5 — Write an answer

Open solutions.py. Every question has a big banner with its number and its position on the card:

# ═════════════════════════════════════════════════════════════════
#  QUESTION 1                                        (row 1, col 1)
#  Count the number of vowels in a string
# ═════════════════════════════════════════════════════════════════
def q01_count_vowels(s: str) -> int:
    """
    ... the full description, the rules, and two examples ...
    """
    raise NotImplementedError

Delete the raise NotImplementedError line and write your code in its place.

def q01_count_vowels(s: str) -> int:
    """..."""
    # your solution goes here
    ...

Rules for editing the file:

  • Do not rename the functions or change what goes inside the brackets. The checker finds them by name.
  • Do not delete the ListNode or TreeNode classes.
  • You can add your own extra helper functions anywhere in the file.
  • Save the file (Ctrl+S, or Cmd+S on Mac) before running the checker.

Then run python3 check.py again.


Step 6 — Check just one question

Checking all 25 every time is slow and noisy. To focus on one:

python3 check.py 1

This prints the full detail for question 1 only — every failing test, with the input, what was expected, and what your code actually returned:

Question 20 (row 4, col 5) — Check if a number is prime
  passed 11 of 15 test cases
  - one is not prime
    with (1)
          expected: False
          you gave:  True

Read that as: "we called your function with 1, it should have returned False, but it returned True."

You can also check several at once: python3 check.py 1 7 13


Step 7 — How to debug

Print things. This is the whole technique. Put print() inside your function to see what is actually happening:

def q01_count_vowels(s: str) -> int:
    count = 0
    for character in s:
        print("looking at:", character, "count so far:", count)   # <-- add this
        ...   # the rest of your solution
    return count

Run python3 check.py 1 and your prints appear in the output. Delete them when you're done.

Try your function by hand. At the very bottom of solutions.py, add:

print(q01_count_vowels("Hello World"))

Then run python3 solutions.py to see just that one result. Delete these lines before your final check.

Common errors and what they mean

Message What it means
IndentationError Your spacing is off. Everything inside a function must be indented by 4 spaces.
SyntaxError: invalid syntax A typo — usually a missing : at the end of an if/for line, or an unclosed bracket.
NameError: name 'x' is not defined You used a variable before creating it, or misspelled it.
IndexError: list index out of range You asked for nums[5] in a list that isn't that long. Very common in loops.
TypeError: 'NoneType' object is not ... Something is None that you expected to be a value — often a missing return.
RecursionError A function calls itself forever. Your stopping condition is wrong.
did not finish within 10 seconds Your loop never ends. Check that the thing your while condition depends on actually changes.

Step 8 — Printing linked lists and trees

Questions 5, 14 and 21 use ListNode and TreeNode objects. Printing one directly is useless:

print(head)     # <__main__.ListNode object at 0x104f2a3d0>   <- not helpful

Paste these helpers at the very bottom of solutions.py while you're working on those questions. They are just for your own debugging — the checker ignores them.

def show_list(head):
    """Print a linked list like: 1 -> 2 -> 3 -> None"""
    parts = []
    node = head
    while node is not None:
        parts.append(str(node.val))
        node = node.next
    if not parts:
        print("empty list")
    else:
        print(" -> ".join(parts) + " -> None")


def show_tree(node, depth=0):
    """Print a tree sideways. Read it with your head tilted left."""
    if node is None:
        return
    show_tree(node.right, depth + 1)
    print("    " * depth + str(node.val))
    show_tree(node.left, depth + 1)

Now you can build an example and watch what your code does to it:

# Build:  1 -> 2 -> 3
head = ListNode(1, ListNode(2, ListNode(3)))
show_list(head)                          #  1 -> 2 -> 3 -> None
show_list(q05_reverse_linked_list(head)) #  3 -> 2 -> 1 -> None

# Build:      1
#            / \
#           2   3
root = TreeNode(1, TreeNode(2), TreeNode(3))
show_tree(root)
print(q14_preorder_traversal(root))      #  [1, 2, 3]

Run it with python3 solutions.py.


Step 9 — The three debug questions

Squares 8, 19 and 22 are different. Instead of writing new code, you fix broken code.

They live in their own files: debug/debug_1.py, debug/debug_2.py, debug/debug_3.py. Open the file, work out what the program is meant to do, find the bug, fix it in place. Keep the function named run and keep its parameters the same.

Check them the same way: python3 check.py 19


The "without X" rules

Some questions ban a shortcut — question 7 says you can't use [::-1], question 23 bans % and /. The checker enforces these automatically. If you use a banned thing, the square fails even when your logic is perfect, and you'll see:

banned for this question — your answer uses a negative-step slice such as [::-1] on line 74

Every ban is written in that question's docstring under BANNED, so read it before you start. The bans also apply to any helper function your answer calls.


Winning

A line is complete when all five of its squares are *. You can win with:

  • any row (5 across)
  • any column (5 down)
  • either diagonal (corner to corner)
  • full house — all 25

The checker tells you the moment you have one:

BINGO! You have completed row 3, column 1.

Good luck.


The card

C1 C2 C3 C4 C5
R1 1. Count vowels 2. Contains duplicate 3. Binary search 4. Leap year 5. Reverse linked list
R2 6. Two Sum 7. Palindrome 8. Debug #2 9. Char frequency 10. Add binary strings
R3 11. Missing number 12. Stack 13. Valid parentheses 14. Preorder traversal 15. Reverse words
R4 16. Reverse a list 17. Int to binary 18. Flatten nested list 19. Debug #1 20. Is prime
R5 21. Same tree 22. Debug #3 23. Is even 24. Add number strings 25. Second largest

About

Repository for Programming Bingo Event

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages