Learning to program is hard. The first semester of Computer Science introduces students to a world where syntax errors and logic bugs feel insurmountable. At UCAB, the Algorithms and Programming I course uses Pascal as its teaching language. Students struggle to connect theory with practice.
I served as a tutoring advisor for this course. My goal was simple: create exercises that bridge the gap between lectures and exams. Each week brought new challenges. Students needed hands-on examples that made abstract concepts concrete.
This repository collects eight weeks of programming exercises. Each exercise targets specific skills the students would need for workshops, tests, and projects.
What it does
The tutoring materials cover the complete first-semester curriculum. Topics progress from basic syntax to complex data structures.
Week 2 introduces the development environment. Students learn to configure SublimeText for Pascal compilation and execution.
Week 3 tackles the Sudoku problem. I provided two solutions: one functional approach using procedures and functions, another monolithic approach with everything in the main block. Students could compare both styles and understand why modular code is easier to maintain.
Week 4 offers reusable utility patterns. Variable swapping, string manipulation, odd/even detection. These small building blocks appear repeatedly in larger projects.
Week 6 combines number systems with date calculations. A Roman numeral converter translates MCLXVI to 1166. A calendar generator computes the day of the week for any date using Zeller-like formulas.
Week 7 introduces structured data. Sets, enumerated types, and matrices open new possibilities for organizing information.
Week 8 presents the 2048 game. A complete implementation showing grid manipulation, input handling, and game state management.
Week 9 focuses on matrix operations. Deleting rows and columns from two-dimensional arrays requires careful index management.
Technical approach
Teaching through contrast
The Sudoku exercise demonstrates the teaching philosophy. Students receive two versions of the same solution. The monolithic version spans hundreds of lines in a single block. The functional version breaks the problem into small procedures.
The monolithic code works, but it is nearly impossible to debug. Students see how repeated patterns emerge. They notice copy-pasted logic that could become a single function. The comparison makes the value of modularity obvious.
Algorithm visualization
The 2048 implementation breaks down a seemingly complex game into simple operations. Each move (up, down, left, right) follows the same pattern:
- Extract a row or column
- Shift all non-zero values toward one end
- Merge adjacent equal values
- Shift again to close gaps
- Put the modified row or column back
By expressing vertical moves as rotated horizontal moves, the code reuses the same shifting logic in four directions. Students learn that many problems simplify when you find the right abstraction.
Real-world math problems
The calendar exercise connects programming to mathematics. Computing what day of the week January 1st, 2020 falls on requires:
- Century adjustments for the Gregorian calendar
- Year calculations accounting for leap years
- Month factors based on day distribution
- Modular arithmetic to cycle through weekdays
Students see how formulas translate directly into code. The leap year check combines multiple conditions: divisible by 4, not divisible by 100 unless also divisible by 400.
String-based Sudoku
The Sudoku solver stores rows as strings rather than arrays. This unconventional choice shows students that data representation affects algorithm design. Checking for duplicates becomes a string search operation. Zone validation requires careful index arithmetic to identify which 3x3 block contains each cell.
Challenges
Curriculum constraints
Students could not use certain language features until later weeks. The Sudoku comment explicitly notes that the solution uses techniques beyond current student capabilities. This prevented students from submitting the example code as their own work while still showing them the target they would eventually reach.
Balancing complexity
Each exercise needed enough depth to be educational without overwhelming beginners. The 2048 game sits at the upper limit of first-semester complexity. It requires matrices, user input, random number generation, and careful state management. Simpler exercises like Roman numeral conversion focus on single concepts.
Pascal limitations
Pascal is not a modern language. It lacks conveniences found in Python or JavaScript. But this constraint forces students to understand memory, types, and control flow at a fundamental level. Working within Pascal’s limitations builds appreciation for language features they will encounter later.
Learnings
Teaching reinforced my own understanding. Explaining why code works requires deeper knowledge than simply writing working code. Every exercise went through multiple revisions as I anticipated student questions.
The modular approach proved itself repeatedly. Breaking problems into small, testable pieces made debugging easier for students and for me. The 2048 game started as a tangled mess before refactoring revealed the underlying pattern.
Documentation matters even for teaching materials. Clear comments and structured progression help students navigate unfamiliar code. The exercise comments explain not just what the code does but why it takes that approach.


