by cs0 · 8y ago · 0 comments
I felt of low value for not being able to provide immediate help for most of the problems that she's being taught to work on.
Some of the examples (since some of you were asking for them): https://github.com/cs50/docs/blob/master/_pages/2018/x/psets...
https://github.com/cs50/docs/blob/master/_pages/2018/x/psets...
I realise that I may have written my original post a little hastily as I was feeling quite strong about having inadequate knowledge to solve these problems.
You've all been super nice to me, and I can understand where you are all coming from.
Again, thank you.
As an aside, the problem that I was stuck on earlier, I managed to solve through a bunch of trial and error, so I'm chalking that one up as a win for tonight.
This requires a completely different skillset. You rarely have to come up with novel algorithms when building a CRUD app, hence why you've never gotten the chance to practice those skills. That said, it's definitely worth learning - if nothing else because it will help you in job interviews.
There's no shortcut to this. Go on leetcode or hackerrank or similar sites - or do all the homework assignments and projects along with your fiance. You're working out a brand new muscle, so it will definitely seem frustrating at first, but you'll get much better with practice.
Thank you for your reply. I do intend to work further on my skills in order to get better!
For example, you could take python or java (or C#, pretty much any general OOP language), and make a simple crud application. Then add a "reporting" page where you can see different results on for example uses of trees, sorting algorithms or storage data structures (like linked lists, hash maps etc). The crud part can be your familiar part where you have a good feel of what's what, and the report/test/whatever page can be your sandbox to see how your experiments deal with your data.
One of the books I found helpful was Data Structures and Problem Solving Using Java by Mark A. Weiss.
A softer start can be found with http://interactivepython.org/runestone/static/pythonds/index...
If you want something using languages you already know, that's fine too. Say for example you wanted to simply know how to build a tree, or more generally a graph. Those concepts may sound big or complex, but they are only as big or as complex as you want them to be allowing you to build a simple version (i.e. a class that is a node in a linked list, and it holds just a number as a value and the next node for your list as a pointer or value or whatever you like). It's something you could do in 10 lines of code just to get yourself started. Building on top of that is a whole lot easier than jumping straight into AVL trees and A* path finding algorithms.
Starting light, say, making a few things yourself in a language of your choice will get you a good feel as to what you want to explore and how easy it is to grasp the concepts, for example:
- linked lists and doubly linked lists
- binary trees (binary doesn't mean binary data, don't worry)
- sorting (check quicksort, shellsort, bubblesort on wikipedia for starters to get an animation for an idea what it is)
- heap
- stack
- (priority-) queue
If you don't know his name, you should - he's written some of the best books on these algorithms and his MOOC is similarly rich in visualizations and concrete examples that help you develop the intuition for the algorithms. Also incidentally his doctoral advisor was Donald Knuth, who he evidently learned a lot from.
You have probably problems with text comprehension because I don't know how you can't solve it.
It's not coding that's needed - you should be able to do it on "paper".
What are you really struggling with?
1) understanding problem setup (reading)
2) coming with solution to problem (search)
3) implementing solution in programming language (coding)
To be honest, I'm surprised a seasoned developer of 5+ years can't do these, or at least have a decent stab at them.
There is a chance I wouldn’t know what ASCII encoding was if my exposure to programming didn’t start in the 8 bit era. C is foreign to a lot of self taught programmers.
You should be able to use a search engine to figure out what ASCII is, though. That's fair game to expect. The text document mentions ASCII, so it's not like a developer would be left without a clue.
Also, all the ASCII you need to know to solve the problem is explained at length in the problem description.
...But if you give me a second...
Now that I've typed "ascii character codes" into google, I can tell you how to convert between an int and a character.
You don't have to memorize everything. Well over half of our job is knowing how to find information quickly.
Even completely ignoring ASCII, it is trivial to create a dictionary mapping integers to characters.
JSR $FDED
The fast way was to copy the bytes directly to the $400-$7FF address space and figure out the non contiguous memory map -> screen yourself.
I base my Opinion on it being a bad idea to rely on manual translation, and untill then I'll have learned to write code that does the translation for me.
If I get something wrong, my boss lets me know, I learn from my mistakes and ship out good quality software.
I do tend to make things harder for myself, as my boss and fianceè have told me before.
I usually end up with a very convoluted solution which I end up coming back to and refactoring the next day.
The thing is that performance issues tend to creep up on you so slowly that you don't realise it until you have a very important client with tons of data screaming at you to fix it now. To fix it then you have a huge architecture issue because the whole system is so inefficient. So rather than rewrite the entire code base to actually be efficient you are forced to hack in some kind of caching solution. Then your problems multiply.
Make it fast from the start. Premature optimisation being the root of all evil is a lie!
- This is a different game than your day to day. Those two being easy stuff means nothing if you never played the game.
- Now you moved a "unknown unknown" to the category of "known unknowns". You know you have no competence in this category, and if you wish to improve in it you can do so. Or not, it's your choice. Before, you didn't have the choice. So that's good!
- It's not about the language. You can solve these in Java, C, Assembly, Haskell. Most training website for interview questions (like these) allow you to implement in any of the major languages. If you want to play the game and get better, I recommend Hackerrank (for structure) and TopcoderArena (for variety, since they give you a bit more fuzzy spec and you also need to identify the algo for the issue at hand). The latter is slow as balls though, and offers no solution (except the best submitted, which may be cryptic).
- This stuff takes time, and if you want to learn about things you'll have to book up. Cormen's "Intro to algorithms" or Skiena's Manual are the goto texts. They are thick. Take your time. Persevere.
Based on your original description I was expecting something more heavy on straight CS theory. “how do you sort an unordered binary tree in place“ kind of thing.
I was having a related conversation earlier, and feel like I'm reprising the same argument for a new audience, but... I don't see what is either Computer Science or theoretical about that. It seems like an eminently practical task: Handling things in a tree structure, sorting items, and doing work in-place to conserve resources are all very concrete, real-world aspects of writing software. You might not need them in _every_ case, but they aren't really "theory" in any real sense.
I turned down a job offer where the interviewer was more concerned about whether I could write a merge sort on the board (I did), than whether I could design a system. It told me a lot about the kind of people they hire.
I spent my first 12 years as a developer doing a lot of bit twiddling in C writing cross platform code with nothing but the standard library, but these days if someone asked me how to sort I would call a library function. Heck even C has a built in sort function.
You can argue that someone doesn't need something, that it's the wrong level of abstraction, or that it's not an appropriate interview question. I even agree to some degree. But that still doesn't make those "CS theory" subjects.
And some of the questions being posed (which are all expected to be solved in C) are a little tricky for me to figure out on my own without some of the niceties which I have been exposed to in higher level languages.
Perhaps the hardest of these was the Credit Card Validation example.
I was stuck for such a long time on trying to figure out how to utilise an array with for loops to multiply every second number of the card backwards.
This is Introduction to Computer Science and all of this is from week 1, so I was pretty much falling at the first hurdle.
The logic was there, but I still couldn't understand most of what was going on, unfortunately.
Through trial and error, I eventually managed to get something working.
>How can you write business logic at work without loops? It's not that I don't use them, it's that I have a hard time figuring out how to use them in the context of solving the problem.
Maybe you're making it too complicated. The reason for loops is simply that you need to repeat an operation. Call it repetition if that helps.
- for x;y;z - repeat a specific number of times, or need an index #
- for x in y - iterate over container
- while x - repeat while a condition is true
- do while x - like while, but run at least once.
So, imagine we have a string and need to add 1 to each character. The second bullet above looks best, first if the language is lower level.
You probably lack in "coding"(maping solution to code) department - it's totally normal in language you don't work in day to day. You are probably less skilled in implementing simple, lower level abstractions - understandable given your background.
I have more exp than you - recently I was helping friend with python ML code - it took me 40 mins to code 20 lines. I don't feel bad at all, because even though I knew solution, to write it in python I had to google for each line and read docs to know range handling, dsl of libs, array comprehension syntax, lambdas etc.
Good news is that it's easy to get proficient fast by doing such exercises. I can recommend codewars.com
If you have been working as software engineer for five years, but can't solve that task, that indeed makes me doubt how were you hired in the first place. I'm sorry if that sounds harsh; I appreciate your honesty and I would want to support you in your self-doubt, but I consider honesty to be more valuable in such a situation than being nice.
Caesar's algorithm in particular looks like a high school assignment, to be honest.
To be honest, I'm only just able to write a program in C, which is the required language for these CS50 tasks.
I've never been asked to do this kind of work before, so I had no idea where to really start.
The walkthroughs provided in the course gave me a high level overview to the solution required, but being able to translate that pseudo-code, if you will, was the part which I was completely stuck on for a while.
I felt like I should have known at least how to start off solving this problem using prior knowledge I had gained through commercial experience, but I was wrong, and none of my experience thus far was able to guide me in the direction which ended up with an answer to the problem.
A thing that may help: Approach this CS50 material as if you have no knowledge of programming. Set aside your preconceptions about both your ability and the nature of programming itself (to the extent that this is possible). Review the materials and read/watch all of it, even the things that you know. You may know them, but exercise the discipline to persist through them and practice the material.
I've since learned to also follow along using the walkthroughs provided, since they provide answers to the most basic of questions that I would have asked.
Most of the problems you've listed become easy the more familiar you are with data structures. This is a more common problem for anyone outside the SV/SF bubble and I wouldn't worry. Just start doing homework and you'll be fine.
Once you're done with data structures, I would start checking out design patterns: http://shop.oreilly.com/product/9780596007126.do
Hope it helps
In either case you constantly consult the language reference and standard libraries until you find something that works. The C reference at https://reference.cs50.net/ looks perfectly good.
To be honest I don't know how I would load a CC# into an array to compute Luhn's algorithm on it in C. In Python I know there are easy ways of doing that, because strings are automatically arrays in the first place (same as that Caesar cypher problem, Python makes it much easier to work with strings). I don't even know if that's the "right" way to do it, but that's what I would do in Python: Convert the number to a string, operate on it as an array, converting each character to an int as it goes, running the algorithm as given in the problem, back-converting to string and then back again to int as needed (like if I need to add the digits of a number together). Fine I suppose I could avoid doing that by taking modulos and if I didn't know what a modulo was I would divide by 10 for instance and then take a floor to get the first digit of a 2-digit number.
I have no idea if any of these methods are "correct", I would just hammer away at the code until the acceptance tests passed. It would take over an hour for each of these solutions, after getting into the zone, so let's say 2 hours. There you go, 4 hours of work to get through these two problems in C, let's add on a lunch break and we have a full work day. That will be $325 thank you. Oh I don't get paid to study computer science in my free time? Oh ok. I guess I will just bookmark CS50 and come back to it... some day.
Your wife is lucky she gets to study this stuff. Don't be so hard on yourself.
You said that you have used PHP, Javascript and VB.Net. C is much harder to use than any of these, and exposes you to many concepts that these languages have abstracted away.
What? How is that even remotely fair to ask as a challenge alongside something like the caesar cipher? One of these is a children's task while the other is a professional cryptographer's task. Am I missing something here? I'm sure it must not be terribly hard to do, but it's still so disproportionate to the previous task that I'm shocked.
Secondly, it's DES. DES hasn't been viable for almost two decades now.
So, I'd like to offer a couple of things that may be of immediately actionable, relevant assistance: SICP and NAND2Tetris.
--
SICP - the Structure and Interpretation of Computer Programs - was designed as an entry-level theory-first approach to programming. If you want to drown your brain in abstraction and get oriented quick, this will help you do that. It's very dense; expect to read it slowly, and also don't force yourself to block on one specific spot until you've understood it. If you can reach some sense of logic and order that lets you get through CS questions without breaking a sweat, who cares if you had to read the textbooks backwards or out of order.
I explicitly recommend SICP because you can find PDFs and EPUBs of it online (it's quite an old/classic book). I see a lot of book recommendations on here that I can't follow up on due to insufficient throwaway budget.
Plus, studying SICP with your fianceè will put her in a significantly better position to ace her CS courses.
I found this HTML rendering: http://sarabander.github.io/sicp/ (google will very readily find PDF and EPUB copies, but this version seems nice)
--
NAND2Tetris explains every step of a CPU from the electrons up (as opposed to the top-down orientation taken by eg JS, VB, etc), and has you build a toy CPU.
Unfortunately I've just discovered that this course, which used to be a little more open, seems to have closed down somewhat. Either that or I misunderstood and it was never an open course.
This being said, searching for "The Elements of Computing Systems" - the reference textbook for this series - is finding a PDF pretty quickly. The book itself is apparently listed on Amazon, so perhaps the PDF version could provide an idea of whether it would provide any value.
This course is taught in many CS classes IIUC, so studying this with your fianceè will also leave you both in a better position.
--
Also - I've been wanting to see how well I can explain pointers and so forth for a while now. Ping me if you like.
(I seem to be atrocious at email/IM-style communication, FWIW, so this may go horribly wrong)
In javascript I would solve it like so: "HELLO".replace(/./g, character => String.fromCharCode(character.charCodeAt() + 1))
This would result in "IFMMP".
Basically it's just a matter of shifting charcodes.
I had a lot of fun playing with a few of these problems: https://adventofcode.com/
I'm not sure if they are classic CS though.
Obviously I knew next to nothing about cryptography, and I did feel very smart about making a safer cypher.