It's UWAweek 47

help3001

This forum is provided to promote discussion amongst students enrolled in CITS3001 Advanced Algorithms.

Please consider offering answers and suggestions to help other students! And if you fix a problem by following a suggestion here, it would be great if other interested students could see a short "Great, fixed it!"  followup message.

How do I ask a good question?
Displaying selected article
Showing 1 of 202 articles.
Currently 8 other people reading this forum.


 UWA week 40 (2nd semester, week 10) ↓
SVG not supported

Login to reply

👍?
helpful
5:19pm Tue 1st Oct, ANONYMOUS

Hi, for the 'flip' problem, my code works for all my test cases, but I get a run-error when submitting.

I have also fuzzed it with a large number of random test cases for all row lengths, and column lengths, and the program still succeeds with no exception.

Is there any chance we can have access to additional test cases to debug our algorithms? Because I' not sure what to do after fuzzing the possible inputs so thoroughly.

Here is the fuzzing script I'm using to test for runtime errors:

import subprocess
import os
import random
import time

filename = "flip.py"

fuzz_runs = 1000

path = os.getcwd()
file_path = os.path.join(path, filename)

while fuzz_runs > 0:
    rows = 1 + int(999 * random.random())
    cols = 1 + int(999 * random.random())

    values = [["." if random.random() < 0.5 else "x" for c in range(cols)] for r in range(rows)]
    grid_lines = "\n".join("".join(values[r]) for r in range(rows))
    question = f"{rows} {cols}\n{grid_lines}"
    with open("test/22.in", 'w') as f:
        f.write(question)

    result = subprocess.run(['python3', file_path], input=question, capture_output=True, text=True, check=False)

    if result.stderr:
        print(result.stderr)
    else:
        print(result.stdout)

    fuzz_runs -= 1

The University of Western Australia

Computer Science and Software Engineering

CRICOS Code: 00126G
Written by [email protected]
Powered by history
Feedback always welcome - it makes our software better!
Last modified  8:08AM Aug 25 2024
Privacy policy