1. Not finding help here? Sign up for a free 30min tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Hm again i don't think im solving this right, 500 lines of code, in 17 days

  1. Nov 5, 2006 #1
    Hello everyone.

    Again I think i'm not doing this right. The questions asks:
    A programmer writes 500 lines of computer code in 17 days. Must there have at least one day when the programmer wrote 30 or more lines of code? why?

    Well the first thing that came to mind was to see if he wrote 500 lines of code a day, how much code per day would he write, so I divided it by 17,a nd got 29.4. So if this is the case, then he wouldn't have to write 30 or more lines of code a certain day, because 29.4 < 30.

    Again this is in the Pigeon Hole Principal chapter, and if i try to break it down into birds and holes i get i think:

    500 lines of code would be the pigeons, and 17 would be the holes or categories I think, but what would 30 be?

    I just did this it looks like somthing!
    if you take 17x30 = 510 which is greater than the (500 lines of code) is this what tells me that no, he wouldn't have to write 30 or more lines of code a certain day?
     
    Last edited: Nov 5, 2006
  2. jcsd
  3. Nov 5, 2006 #2
    The textbook is assuming that you can't write a partial line of code. So you have to write either 29 or 30 lines of code in a day. That is the idea behind the pigeonhole principle. It needs to go in one hole or the other.

    That said, if you need to wirte 29.4 lines per day, can you get away with writing 29 lines or less per day, every day?
     
  4. Nov 5, 2006 #3

    0rthodontist

    User Avatar
    Science Advisor

    There is an extended pigeonhole principle which is at work here. It says that if you have n pigeons and m pigeonholes, then one pigeonhole must have at least ceiling(n/m) pigeons. You are right, the pigeons in this case are the lines of code and the pigeonholes are the days.
     
  5. Nov 6, 2006 #4
    Thanks for the info guys. Ortho when u said at least one pigeonhole must have at least ceiliing(n/m) = (500/17) = 30...so If i have 17 pigeon holes, each with 30 lines of code in it, that means I have a total of 510 lines of code in the 17 pigeon holes, but there are only 500 lines of code. But the fact that I got 30, is that enough info to say, yes There was at least 1 day when the programmer wrote 30 or more lines of code.
     
  6. Nov 6, 2006 #5

    0rthodontist

    User Avatar
    Science Advisor

    I don't know if I understand your question. Are you asking whether having 17 days in which you wrote exactly 30 lines of code implies you have at least one day where you wrote at least 30 lines of code? Yes, it does. By the way you just made your 1000th post.
     
  7. Nov 6, 2006 #6
    Ahh thank you! thats alot of questions i've asked hah, cheers!
    :)
     
  8. Nov 6, 2006 #7

    matt grime

    User Avatar
    Science Advisor
    Homework Helper

    How about instead of trying to appeal to some theorem you think about the question.

    What would happen if he wrote 29 lines of code or fewer each day? He'd have at most 29*17<500 lines. So he must have had one day (or more) where he wrote at least 30.

    No need to invoke any fancy theorems or try to force it to be in a specific format.
     
  9. Nov 6, 2006 #8
    Thanks matt, that makes alot of sense, more so than trying to fit it into a formula. I was just trying to get a feel for when I should apply the formula and when I shouldn't. The professor wants us to do the problems like the section teaches us rather than finding our own way for the time being but on exams its all game.
     
  10. Nov 6, 2006 #9

    matt grime

    User Avatar
    Science Advisor
    Homework Helper

    But all I did was invoke the pigeon hole principle, albeit in disguise. There's nothing wrong in using *the proof* of the named theorem to prove something else without using the name. You have 500 lines and 17 holes. So one must contain at least ceiling(500/17)=30 by the p-hole principle, because if none did then there would be at most 17*29<500.
     
  11. Nov 6, 2006 #10
    Thanks I do see what your saying! I was making it alot harder than it was, thanks for the help.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?