Computer science students code Solitaire card game for in-class lab
Aarav Borthakur (10) and Tanay Sharma (12) review the Solitaire lab from the AP Computer Science with Data Structures classes. The students completed the lab to better understand the implementation of the stack data structure.
November 25, 2022
Advanced Placement Computer Science with Data Structures classes taught by upper school computer science teacher Anu Datar programmed the card game Solitaire to practice using the stack data structure from Oct. 21 to Nov. 18.
Students started off the lab by familiarizing themselves with Solitaire by playing the game with real cards. After understanding the rules better, the students coded the lab with pre-existing files and an instruction sheet with a step-by-step procedure. First, students set up the tableau and stock piles for the cards and created the deck. Then, they coded functions to select the cards and move them between piles. Students completed the basic structure of the game by implementing the foundation piles.
Usually, when players make moves in Solitaire, only the topmost card in a pile is considered, so students practiced using a stack. The stack, a last-in first-out data structure, efficiently maintains its topmost element. Like a stack of plates, the cards can only be added, removed and accessed from the top.
“We were [studying] stacks and queues, and it [allowed] us [to] practice with those pretty well,” AP Computer Science student Akul Goyal (10) said.

In addition to the basic structure, students implemented extra features, such as moving a card from the foundation to a pile. They could also choose to code more features into their game such as a timer or a scoring system. When students finished their projects, they ran a tester program provided by Datar to check the accuracy of their methods. In addition, students had to play through their game to fully test the functionality of their code. After finishing the writing and testing, students completed the lab by showing their code to Datar or a teaching assistant for review.
“It was a pretty fun lab because of the whole interface where you’re creating a game,” Akul said. “That makes it a lot more fun than previous labs.”





![“I wasn't discouraged by some of the obstacles we faced. I learned a lot from the leadership. I found that different people need different ways of receiving feedback — you can't [just] tell them to do something and expect the best. [Some] people needed more incentive. A large part of my role was to figure out what worked for everyone and to figure out how to lead all these separate individuals as a team,” Suhana Bhandare (’26) said.](https://harkeraquila.com/wp-content/uploads/2026/06/SuhanaBhandare_JasmineHansra-1-1200x798.jpg)


![“This is actually from Randy Pausch Randy P. Brick: ‘Walls are there for a reason. You have to show how much you want to overcome them.’ You have to show how much you want something. That's what I've always been able to do with tennis, Link Crew and getting that internship [with Kushy Baby]. It’s important pushing through that — getting around that brick wall, climbing over it or clawing through it,” Yash Sachdeva (’26) said.](https://harkeraquila.com/wp-content/uploads/2026/05/YashSachdeva_RamBatchu-copy-1200x1002.jpg)


















![“[Building nerf blasters] became this outlet of creativity for me that hasn't been matched by anything else. The process [of] making a build complete to your desire is such a painstakingly difficult process, but I've had to learn from [the skills needed from] soldering to proper painting. There's so many different options for everything, if you think about it, it exists. The best part is [that] if it doesn't exist, you can build it yourself," Ishaan Parate said.](https://harkeraquila.com/wp-content/uploads/2022/08/DSC_8149-900x604.jpg)




![“When I came into high school, I was ready to be a follower. But DECA was a game changer for me. It helped me overcome my fear of public speaking, and it's played such a major role in who I've become today. To be able to successfully lead a chapter of 150 students, an officer team and be one of the upperclassmen I once really admired is something I'm [really] proud of,” Anvitha Tummala ('21) said.](https://harkeraquila.com/wp-content/uploads/2021/07/Screen-Shot-2021-07-25-at-9.50.05-AM-900x594.png)







![“I think getting up in the morning and having a sense of purpose [is exciting]. I think without a certain amount of drive, life is kind of obsolete and mundane, and I think having that every single day is what makes each day unique and kind of makes life exciting,” Neymika Jain (12) said.](https://harkeraquila.com/wp-content/uploads/2017/06/Screen-Shot-2017-06-03-at-4.54.16-PM.png)








![“My slogan is ‘slow feet, don’t eat, and I’m hungry.’ You need to run fast to get where you are–you aren't going to get those championships if you aren't fast,” Angel Cervantes (12) said. “I want to do well in school on my tests and in track and win championships for my team. I live by that, [and] I can do that anywhere: in the classroom or on the field.”](https://harkeraquila.com/wp-content/uploads/2018/06/DSC5146-900x601.jpg)
![“[Volleyball has] taught me how to fall correctly, and another thing it taught is that you don’t have to be the best at something to be good at it. If you just hit the ball in a smart way, then it still scores points and you’re good at it. You could be a background player and still make a much bigger impact on the team than you would think,” Anya Gert (’20) said.](https://harkeraquila.com/wp-content/uploads/2020/06/AnnaGert_JinTuan_HoHPhotoEdited-600x900.jpeg)

![“I'm not nearly there yet, but [my confidence has] definitely been getting better since I was pretty shy and timid coming into Harker my freshman year. I know that there's a lot of people that are really confident in what they do, and I really admire them. Everyone's so driven and that has really pushed me to kind of try to find my own place in high school and be more confident,” Alyssa Huang (’20) said.](https://harkeraquila.com/wp-content/uploads/2020/06/AlyssaHuang_EmilyChen_HoHPhoto-900x749.jpeg)











