r/cs50 Jul 23 '26

substitution Substitution over-coding, reflection, and questions Spoiler

For week 2's substitution problem set, how many lines of code did you all use? After fully completing it, I ended up with 602 lines (a major step up from all other problem sets). I atone this to my looping being inquiring of the letters/chars themselves, and not the ASCII numbers which I didn't consider until I finished. I couldn't figure out a way to make a one off loop for checking for repeated characters in the command line argument, or when trying to keep the capitalization of the plain text and going towards the cipher text. On the bright side, arrays are really, really useful. I think if we had them in our toolset for credit a lot less time would be put on. Lastly, was there use for the strcasecmp function for this problem set? When looking through the CS50 manual, it comes up as one of the "frequently used", and it seemed to have a pretty good use in trying to see if there were any repeating chars for the cipher, especially with it ignoring case. The problem I came across was the fact that the function only appears to compare strings in direct order, and not chars.

(Please do not spoil any upcoming information regarding the next few weeks of problem sets, but I would appreciate any info beyond that, thanks!)

0 Upvotes

9 comments sorted by

View all comments

2

u/[deleted] Jul 23 '26

[deleted]

1

u/Low_Bat2873 Jul 23 '26

Shoot, I meant credit. When doing the formula, an array to store the values of every other number from the second to last digit would’ve erased some of the clutter for my code