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

  • Thread starter Thread starter mr_coffee
  • Start date Start date
  • Tags Tags
    Code Lines
Click For Summary

Homework Help Overview

The problem involves determining whether a programmer, who wrote 500 lines of code over 17 days, must have written at least 30 lines on at least one day. The context is rooted in the Pigeonhole Principle.

Discussion Character

  • Exploratory, Conceptual clarification, Assumption checking

Approaches and Questions Raised

  • Participants explore the implications of dividing the total lines of code by the number of days to assess daily output. Questions arise regarding the interpretation of the Pigeonhole Principle and its application to the problem.

Discussion Status

Participants are actively discussing various interpretations of the problem, with some suggesting that if the programmer wrote fewer than 30 lines each day, it would not total 500 lines. Others are considering the implications of the extended Pigeonhole Principle and whether it provides sufficient evidence for the claim.

Contextual Notes

There is a mention of the textbook's assumption that partial lines of code cannot be written, which influences the reasoning about daily output. Some participants express uncertainty about when to apply formal theorems versus intuitive reasoning.

mr_coffee
Messages
1,613
Reaction score
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:
Physics news on Phys.org
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?
 
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.
 
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.
 
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.
 
Ahh thank you! that's a lot of questions I've asked hah, cheers!
:)
 
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.
 
Thanks matt, that makes a lot 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.
 
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.
 
  • #10
Thanks I do see what your saying! I was making it a lot harder than it was, thanks for the help.
 

Similar threads

  • · Replies 4 ·
Replies
4
Views
2K
Replies
15
Views
11K
  • · Replies 9 ·
Replies
9
Views
2K
  • · Replies 54 ·
2
Replies
54
Views
5K
Replies
10
Views
5K
  • · Replies 108 ·
4
Replies
108
Views
20K
Replies
44
Views
14K
  • · Replies 29 ·
Replies
29
Views
3K
  • · Replies 9 ·
Replies
9
Views
7K