HW4: Advanced Colorwork and Transfers
Assigned: 3/24/2026
Code Due: 4/2/2026 at 11:59 PM (Submit on Gradescope)
Feedback Returned By: 4/5/2026
Fabrication: 4/2/2026 during lecture or sign up for open hours (check Ed posts from TAs) Fabrication Artifact Due: 4/26/2026
Overview
In this assignment, you will implement a pattern generator that can take in an image input and generate a birdseye jacquard knitting pattern, and then implement several helper functions for the schoolbus transfer planning algorithm. If you would like to practice more on Python programming, you can look for the Exercise sections at the end of corresponding chapters of the textbook Think Python 3e.
Competencies and Evidence Points
HW4 maps to 1 Evidence Point under the Programming Fundamentals competency, 1 Evidence Point under the Data Structures & Algorithms competency, 1 Evidence Point under the Software Engineering Practices competency, and 2 Evidence Point under the Fabrication & Physical Computing competency.
Programming Fundamentals (1 Evidence Points)
EP1 — Conditionals, Loops, Modulo
Satisfactory work shows you can:
- Combine these basic operations to accomplish more complex tasks in Python code
Data Structures & Algorithms (1 Evidence Points)
EP2 — Dictionaries and Sets
Satisfactory work shows you can:
- Use loops to iterate over dictionaries
- Build dictionaries and sets
- Access values from a dictionary using the keys
Software Engineering Practices (1 Evidence Point)
EP3 — Code Quality and Testing (overall quality)
Satisfactory work shows you can:
- Find multiple, meaningfully different test cases, including edge cases, to probe the effect on the output
- Maintain readable code: consistent style (snake_case), clear names, appropriate amount of comments and docstrings (explain not obvious parts and not too extensive)
- Required citations of at least two sources
Fabrication & Physical Computing (2 Evidence Points)
EP4 - Colorwork and Transfer Planning
Satisfactory work shows you can:
- Reason about the back-bed patterns for doubleknit jacquard colorwork
- Understand the concept of racking and needle offsets
- Understand the concept of passes and count the passes for schoolbus algorithm
- Implement the correct logic for the helper functions for schoolbus
EP5 - Knitting the Artifact
Satisfactory work shows you can:
- Connect abstract code to physical knitted output
- Generate valid machine code from your pattern generator
- Operate the knitting machine independently to fabricate a custom pattern
- Troubleshoot fabrication errors and iterate if needed
- Document your physical artifact with photo and observations
Preparation Before You Start
Download comp116-hw4.zip from Ed Discussion > Resources.
This assignment will be completed in two files: (1) programming exercises by editing a Jupyter Notebook file comp116-hw4.ipynb; (2) the pattern generator by editing a Python file pattern_generator.py.
A reminder to create a separate folder for hw4 to keep under the course homeworks/assignments folder. You can unzip the comp116-hw4.zip into the hw4 subfolder.
You can now use VSCode to open the folder that contains the files of this assignment.
For working on the Jupyter notebook: navigate to open the Jupyter notebook file for this assignment. Don’t forget to select the comp116 kernel in the top right corner of the window before running the code cells in the notebook!
For working on the Python file: navigate to open the Python file and edit that file. To run the file, please follow the steps from the Ed post on How to Run a Python File.
How to Submit
Code Submission
Go to Moodle and find the Gradescope link for “HW4: Advanced Colorwork and Transfers” and upload your completed comp116-hw4.ipynb (keeping all the cell outputs instead of clearing them) and pattern_generator.py to Gradescope. You can also upload the generated knitout files (*.k) you tried for testing.
Fabrication Artifact Submission
Go to Moodle and find the Gradescope link for “HW4: Advanced Colorwork and Transfers - Fabrication Artifact” and upload the following:
- Photo of your knitted artifact
- Clear, well-lit photo showing the full pattern
- Include a ruler or size reference if specified
- Brief description (2-3 sentences)
- Describe the image and the threshold value(s) you used
- Any observations about the physical result vs. your expectations
- Any challenges encountered during fabrication
Example Artifacts
What you can expect from this assignment is as follows:
| Input | Front | Back |
|---|---|---|
| Random Noise, t200, c2,3 | ![]() |
![]() |
| Cardinal, t100, c2,4 | ![]() |
![]() |
| Example, t85,170, c3,4,5 | ![]() |
![]() |
Note that we do not expect the artifact to be free of errors; the machine is not tuned to perfection so errors like edge stitches dropping or sticking together, some stitches dropping in the middle, or the waste yarn region having failed stitches are all reasonable, just like what you might see in the example photos here.
Especially for the last row where three yarns are used, as discussed in the notebook, due to the thickness of the yarns we have, using more than two yarns is actually failure prone because the colorwork here is double layer. Using four is likely to cause breakage so it is advisable to stay within 3 yarns.
Questions? Post on Ed Discussion or come to office hours!





