.py
files containing your work. (If you upload a screenshot or other file format, you won't get credit.)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 is prohibited, and you may only access resources (books, online, etc.) listed below.
The course materials you may refer to for this homework are:
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.
Ask your instructor or TA a question by email, in office hours, or on discord.
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.
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:
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╔╝
+╚═══════════╝+
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.
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.