A document from MCS 275 Spring 2022, instructor David Dumas. You can also get the notebook file.

MCS 275 Spring 2022 Homework 1

  • Course Instructor: David Dumas

Instructions:

  • Complete the problems below, which ask you to write Python scripts.
  • Upload your python code directly to gradescope, i.e. upload the .py files containing your work. (If you upload a screenshot or other file format, you won't get credit.)

Deadline

This homework assignment must be submitted in Gradescope by Noon central time on Wednesday 19 January 2022.

(Note:That's a deviation from the usual schedule where homework is due on Tuesdays.)

Collaboration

Collaboration is prohibited, and you may only access resources (books, online, etc.) listed below.

Resources you may consult

The course materials you may refer to for this homework are:

Point distribution

This homework assignment has 2 problems, numbered 2 and 3. The grading breakdown is:

Points Item
2 Autograder
4 Problem 2
4 Problem 3
10 Total

The part marked "autograder" reflects points assigned to your submission based on some simple automated checks for Python syntax, etc. The result of these checks is shown immediately after you submit.

What to do if you're stuck

Ask your instructor or TA a question by email, in office hours, or on discord.

Problem 1 doesn't exist

In Gradescope, the score assigned to your homework submission by the autograder (checking for syntax and docstrings) will be recorded as "Problem 1". Therefore, the numbering of the actual problems begins with 2.

Problem 2: Filled fancy box

In worksheet 1, you made a program to draw a box using unicode box-drawing characters. An 9x6 box of that type looks like this:

╔═══════╗ 
║       ║
║       ║
║       ║
║       ║
╚═══════╝

Modify that program (calling the new one hwk1prob2.py) so that it generates a "fancy box" with decorative inset corners and plus signs, like this:

+╔═════╗+
╔╝     ╚╗
║       ║
║       ║
╚╗     ╔╝ 
+╚═════╝+

and so that each empty space inside the box gets filled with a copy of a specified character, e.g.

+╔══════════════╗+
╔╝FFFFFFFFFFFFFF╚╗
║FFFFFFFFFFFFFFFF║
╚╗FFFFFFFFFFFFFF╔╝ 
+╚══════════════╝+

Specifically:

  • The output filename will be given as the first command line argument
  • The total width of the box, in characters, is the second command line argument (will be at least 5)
  • The total height of the box, in lines, is the third command line argument (will be at least 5)
  • The fill character ("F" in the example above) is the fourth command line argument

Examples:

  • If called as

    python3 hwk1prob2.py out1.txt 9 6 j

    the output file out1.txt is created and the following is written to it:

    +╔═════╗+
    ╔╝jjjjj╚╗
    ║jjjjjjj║
    ║jjjjjjj║
    ╚╗jjjjj╔╝ 
    +╚═════╝+
  • If called as

    python3 hwk1prob2.py out2.txt 15 5 X

    the output file out2.txt is created and the following is written to it:

    +╔═══════════╗+
    ╔╝XXXXXXXXXXX╚╗
    ║XXXXXXXXXXXXX║
    ╚╗XXXXXXXXXXX╔╝ 
    +╚═══════════╝+

Problem 3: Finding 260 in powers of 275

The large integer shown below is $275^{50}$ (or in Python syntax, 275**50):

92605054467343067837474447744797179339681065959901609623272419896243561247711783591951562044641832471825182437896728515625

If you look near the beginning, you'll see that the three digits 260 appear inside this number (contiguously). Those digits are shown in bold.

There are other powers of 275 that contain 260 within the decimal digits, and the one above isn't even the smallest power that works.

Write a program to find the four smallest powers of 275 that contain 260 in their decimal digits. Have it print just the exponents (e.g. 50 in the example above), rather than the actual huge integer.

Save your program as hwk1prob3.py and submit it.

Note: We're not looking for 2, 6, and 0 to appear in arbitrary places. They must be next to one another and in the order 260. So, for example, $275^3 = 20796875$ wouldn't count.

Special request

Add a comment at the bottom of the program you wrote in the last problem indicating how long it took you to complete this entire assignment, e.g.

# Completing homework 1 took me about 1 hour and 25 minutes to complete, including the time it took to read the instructions and questions.

Revision history

  • 2022-01-13 Initial publication
  • 2022-01-14 Changed @ to X in second example for problem 2, because the @ character causes problems for some OS/terminal combinations.