Quote:
Originally Posted by splashpot
I just did vigenere but holy **** is my code ugly. Embarrasingly ugly. I haven't found a good C reference or at least I suck at searching the C docs. I couldn't figure out the equivalent of the following python code
Code:
if letter in string:
so I wrote for loops to compare each and every character every time I wanted to do that. Shoe Lace, I'm def interested to see how you did it.
I think our definition of good is different. I'm not too concerned with syntax or super conciseness. I care about how easy would it be to modify, extend and use.
They mentioned we should look at the string lib in one of the videos.
I didn't use any string functions though except for strlen(). My solution isn't special, it's just IMO very modular. I wrote it from the perspective of "if I wanted to use a library that did caesar or vig encryption would I use mine?".
That means I had to abstract away how the algorithm worked and it had to be designed in a way that both algorithms shared some parts. There's very little logic in my main() function. It just mostly calls out to other functions with names that describe what's going on.
The 6.00x never got into this at all. My 6.00x version is shorter but it looks like someone vomited a bunch of Python in the main loop with no thought process on how hard/easy it would be to use as an end user. It's only shorter too because it's using functions that abstract away for loops. I chose not to use them in the C version for now.