Open Side Menu Go to the Top

01-11-2014 , 07:21 PM
@derada4,
For software architecture guidance I highly recommend some of Netflix's presentations on Youtube. Not only do they have a ton of talks but a ton of their stuff is open source.

A few years ago they had 1 monolothic Java app but they have transformed into a bunch of services using various technologies and databases. They mainly use Java/Python and Cassandra/Memcached to run most of their infrastructure.

In my "learn chef!" binge that I had a few weeks ago I came across a bunch of AWS videos which eventually lead into seeing not totally relevant but very enjoyable talks given by Netflix on how they architect and deploy their systems.

You should consider watching some of Riot's presentations too. They deploy a game among many other services and they use some components of Netflix's stack. They've openly said they lean quite heavily on Netflix's tech. They deploy to tens of thousands of AWS instances.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **
$25m Guaranteed WPM on CoinPoker
Join the action now
Daily Rewards • Splash Pots • CoinRaces
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **
01-11-2014 , 10:02 PM
Thanks for all the responses/resources guys.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-12-2014 , 03:42 PM
So I just waitlisted the pre-calculas course at my local community college (first position). However, last time I took pre-calc was in high school (pre-calc honors). I will probably be hitting khan academy really hard to prep for this.

So my schedule starting late January will be 8-5pm work Monday - Friday; Then straight to school for Monday-Thursday. Taking Java 1 and pre-calc. Hopefully I'm not taking too much of a load. But it's community college, how hard could it be? Amirite?? :P

Honestly though, I am more worried about the math class than the Java. With Java, I have already started learning using Udacity, so I should be prepared. Math on the other hand, I haven't touched in a long time.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-12-2014 , 05:06 PM
Assuming you don't have many other distractions (like a needy gf) you should be ok. I had a schedule similar to yours my last 3 semesters of school.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-12-2014 , 05:11 PM
if you were in "honors pre-calc" in high school, community college math is going to be babytown frolicks

Last edited by tyler_cracker; 01-12-2014 at 05:12 PM. Reason: which is not to say that you can't use online tools to improve your understanding
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-12-2014 , 06:42 PM
I wouldn't worry about it I jumped right into Calc 2 after taking Calc 1 8 years before and got an A
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-12-2014 , 06:58 PM
Programming in C for the CS50 course.

I'm taking a userinput value as a float, say, .25 as a currency.

I need to convert it to an int. Is it acceptable to type:

float x;
x = round(.25 * 100);

I noticed before that while leaving it as a float, I was getting wrong answers when it was thinking that 0.00 was actually greater than 0 because within the float it was 0.00000000000002341000000. So when my loop should stop at 0.00, it was making one more loop when it shouldn't have.

When I check the solution through the terminal I'm now getting all green responses, which means I'm good, but I'd like to make sure there isn't a more standard way of conversion.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-12-2014 , 07:05 PM
you haven't converted it to an int; it's still a float.

you're probably supposed to be learning about casting here.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-12-2014 , 07:36 PM
Quote:
Originally Posted by tyler_cracker
you haven't converted it to an int; it's still a float.

you're probably supposed to be learning about casting here.
Yeah you're right. I was thinking int because my other variables are ints.

I was trying to do some casting, but I don't know where to put it. I've been searching through Google, but none of it was relevant.

I guess it would be easier to talk about the program rather than trying to give examples.

I have to create a program that takes a userinput on how much money I owe them, for example, I owe you .18 (18 cents). The program then wants you to return the smallest amount of coins. So instead of giving you back 18 pennies, I'd give you 1 dime, 1 nickel, and 3 pennies.

The result they want is the total of those coins, which would be 5.

Functionally, my code works, or so it seems, but I don't know how to use casting in the proper way. They definitely don't want you to just truncate it from a float to an int because then you lose cents.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-12-2014 , 07:47 PM
Do you have to accept values over a dollar?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-12-2014 , 07:58 PM
Quote:
Originally Posted by kerowo
Do you have to accept values over a dollar?
Yes, because the automated check checks for values over a dollar. My code works as it is, afaik. If the user inputs 1.25, it still returns 5, since it converts 1.25 to 125.

The check checks for 4.2, which correctly returns 18, whereas before I added the "round" it was returning 23.

As far as currency goes, I don't know if what I did is actually the right way to handle floats.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-12-2014 , 08:00 PM
Quote:
Originally Posted by ItalianFX
As far as currency goes, I don't know if what I did is actually the right way to handle floats in regards to currencies.
I don't either, and I'm convinced no one does. We have some code at work dealing with currency conversions, and everyone grumbles about it being terrible but no one can explain why they have that opinion.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-12-2014 , 08:01 PM
Quote:
Originally Posted by ItalianFX
I noticed before that while leaving it as a float, I was getting wrong answers when it was thinking that 0.00 was actually greater than 0 because within the float it was 0.00000000000002341000000. So when my loop should stop at 0.00, it was making one more loop when it shouldn't have.
Floating point precision can be a pain. One solution is to compare to a really small number rather than zero. Since you are dealing with currency, you could do something like "if x < 0.001" and get the intended result.

You'll find some good reference by Googling "compare floating point number to zero".
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-12-2014 , 08:01 PM
The point was probably to have to convert the input into pennies as a float then cast those pennies to an int.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-12-2014 , 08:02 PM
ItalianFX,

I didn't take CS50 this year but have you been watching the "sections" videos? They are generally an hour each (2 per week) and go into detail code wise on the topic of what was discussed in the lecture video.

They are a must watch IMO.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-12-2014 , 08:19 PM
Quote:
Originally Posted by kerowo
The point was probably to have to convert the input into pennies as a float then cast those pennies to an int.
The instructions kind of give you a hint that "Before doing any math, then, you’ll probably want to convert the user’s input entirely to cents (i.e., from a float to an int) to avoid tiny errors that might otherwise add up! Of course, don’t just cast the user’s input from a float to an int! After all, how many cents does one dollar equal? And be careful to round and not truncate your pennies!"

Reading that quote a couple times I think my brain is saying they don't want you to cast? My thinking is that if I need to convert $.10 to pennies, then I'd have to multiply by 100. 10 cents is still $.10. Then my program enters the while loop and goes to the "dime" and subtracts 10. Then at 0, it exits, and prints 1.

But in any other financial scenario, is doing that actually wrong?

Quote:
Originally Posted by Shoe Lace
ItalianFX,

I didn't take CS50 this year but have you been watching the "sections" videos? They are generally an hour each (2 per week) and go into detail code wise on the topic of what was discussed in the lecture video.

They are a must watch IMO.
Yes, I watch all the videos, sometimes more than once if I need to. This year there is only 1 section per week, and it is ~1.25hr. Week 1 was extremely disorganized and awkward so it was hard to watch. I didn't find anything on casting. I got more use out of watching the problem set walkthroughs and the shorts, but week 2 could be better. I still plan on watching everything. I'm trying to soak up as much as I can since I have all year to finish this, and I actually want to learn rather than just do whatever is necessary and move on.

I mean, I'm pretty proud of myself to say that I worked on this problem for quite awhile and figured out the entire code on my own - minus watching the walkthroughs and getting an idea how it should be structured. I didn't look at anyone else's code and after hours of being stuck, I just kept trying and retrying and deleting and recoding until it started to work little by little.

If the check50 works I have to imagine that my code is correct.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-12-2014 , 08:25 PM
italian,

you need two operations to solve this problem: converting a number of dollars to a number of cents; converting a floating point representation of some number to an integer representation of that number.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-12-2014 , 08:31 PM
Quote:
Originally Posted by ItalianFX
The instructions kind of give you a hint that "Before doing any math, then, you’ll probably want to convert the user’s input entirely to cents (i.e., from a float to an int) to avoid tiny errors that might otherwise add up! Of course, don’t just cast the user’s input from a float to an int! After all, how many cents does one dollar equal? And be careful to round and not truncate your pennies!"

Reading that quote a couple times I think my brain is saying they don't want you to cast?
They want you to cast to int, just not without doing some work first to make sure you don't lose the cents. I think you are doing exactly what they are talking about except without casting to int in the end.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-12-2014 , 08:48 PM
Quote:
Originally Posted by tyler_cracker
italian,

you need two operations to solve this problem: converting a number of dollars to a number of cents; converting a floating point representation of some number to an integer representation of that number.
Quote:
Originally Posted by Benholio
They want you to cast to int, just not without doing some work first to make sure you don't lose the cents. I think you are doing exactly what they are talking about except without casting to int in the end.
If I'm understanding this, what I did was convert the userinput of $.30 into pennies by multiplying by 100, rounding it, and then they want you to take a float of 30.000 cents, and turn it into an int of just 30 cents?

It seems to make sense that it works because if I used .15 before the rounding, it would give me 3 instead of 2 (1 dime and 1 nickel). It would minus a dime, and then minus a nickel and would think there was still a tiny amount somewhere in the float so it would subtract a penny. And then since it turned it into a negative number, it would drop out of the loop and stop, giving me a result of 3 coins. Now with the rounding, I don't have that problem, but I'm not sure what changed.

Is it just taking .15, turning it into 15.000000000000001414124, rounding it to 15.0000000000000000000000000 and producing the correct result? How do I take 15.00000000000001423123 and turn it into a strict int of 15? -- or does that truncate it? I think I'm thinking into it too much because in a banking scenario you don't want to lose cents.

Same for 4.2. It would give me 23 when it should be 18 so that was a big error. Now with rounding it correctly gives me 18.

But I guess it would be beneficial to learn how to cast correctly. I saw an example through Google about printf("%d\n", (int)y); but I don't know where that would be used correctly. With this problem set I'm worrying that I fit the code to work the problem rather than a correct and universal solution to using currencies.

And, like I said, the check within the terminal gives me all green, which means at least how they are checking I'm good to go, whereas before, I had some red frowny faces, which alerted me to my non-rounding problem.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-12-2014 , 08:53 PM
Definitely find a tutorial on casting in c, I think you will find it is much simpler than you thought.

edit: Hope I didn't come off as smug, I just wasn't sure if you wanted someone to tell you how to do it or preferred to figure it out on your own.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-12-2014 , 09:01 PM
Quote:
Originally Posted by ItalianFX
If I'm understanding this, what I did was convert the userinput of $.30 into pennies by multiplying by 100, rounding it, and then they want you to take a float of 30.000 cents, and turn it into an int of just 30 cents?
yes

Quote:
But I guess it would be beneficial to learn how to cast correctly.
yes. that is surely one of the pedagogic points of this exercise.

Quote:
And, like I said, the check within the terminal gives me all green, which means at least how they are checking I'm good to go, whereas before, I had some red frowny faces, which alerted me to my non-rounding problem.
remember this feeling -- it's how it feels to do TDD. don't even look up TDD now; just know when it comes up that it's something you want.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-12-2014 , 09:04 PM
ItalianFX, there is a time to argue and there is a time to not argue. This is one of those times you may want to go back and rethink your solution considering the advice you have been given.

And for all your C needs: http://www.scribd.com/doc/39933932/C...ition-K-N-King
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-12-2014 , 09:10 PM
Quote:
Originally Posted by Benholio
Definitely find a tutorial on casting in c, I think you will find it is much simpler than you thought.

edit: Hope I didn't come off as smug, I just wasn't sure if you wanted someone to tell you how to do it or preferred to figure it out on your own.
I just looked it up, which made it easier to understand compared to the video in the course.

Quote:
Originally Posted by tyler_cracker
remember this feeling -- it's how it feels to do TDD. don't even look up TDD now; just know when it comes up that it's something you want.
Not sure what TDD is.

Quote:
Originally Posted by daveT
ItalianFX, there is a time to argue and there is a time to not argue. This is one of those times you may want to go back and rethink your solution considering the advice you have been given.
Hmm..not sure where you got the arguing at? I don't think I have argued at all. I'm simply asking questions and making sure I understand what I'm being told.

If you're referring to me asking about rounding compared to talking about casting, I'm only trying to figure out if what I did was wrong compared to what would happen if I casted -- since I don't know how to do the casting in my program. So yeah, I'm not sure how you're getting arguing out of that. I'm trying to talk through the finer details of what is going on behind the scenes.

Thanks for the link, though. Definitely going to bookmark that.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-12-2014 , 09:29 PM
Quote:
Originally Posted by ItalianFX
Thanks for the link, though. Definitely going to bookmark that.
That book is worth reading and doing all of the exercises in it. Not only is is excellent for learning C, it is excellent for learning about programming and many silly areas of the world around us. Definitely in my top 10.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-13-2014 , 11:02 AM
I'm very curious about the answer for this question:

I "forget" stuff about languages pretty quickly if I don't use them for some time (syntax details, standard library etc.). I can always read code in a language just fine but I'm wondering what I put on my CV. I usually have something like "productive within a week" for say Java.
How long would you guess it takes to learn up to "can solve silly job interview stuff". I just tested myself and could write a FizzBuzz with no syntax errors right away. I'd guess it would take about a day to relearn some idioms and typical library stuff (for example I had to think a bit before remembering Integer.toString()...stuff like that) and well for actually writing decent quality code my guess is a week (including looking up the unit/functional etc. testing of the language and those things)

Also is there maybe a set of standard programming tests (i.e. FizzBuzz and maybe 3-5 others) where you can review how well you remember a language? Would like to run through that for all languages I used at one point (C/C++ for example)
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **
$25m Guaranteed WPM on CoinPoker
Join the action now
Daily Rewards • Splash Pots • CoinRaces
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **

      
m