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

• mr_coffee
In summary, the programmer wrote 500 lines of code in 17 days. Must there have been at least one day when he wrote 30 or more lines of code? The textbook assumes that you cannot write a partial line of code. Therefore, if you need to write 29.4 lines per day, you can get away with writing 29 lines or less per day, every day.
mr_coffee
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:
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!
:)

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.

Thanks I do see what your saying! I was making it a lot harder than it was, thanks for the help.

## 1. How do you approach a project with 500 lines of code in a short time frame of 17 days?

As a scientist, I first analyze the scope and complexity of the project. Then, I break down the code into smaller, manageable tasks and create a timeline for each task. I prioritize the tasks based on their importance and allocate my time accordingly. I also make sure to regularly review and optimize my code to save time and improve efficiency.

## 2. What challenges do you face when working on a project with 500 lines of code?

The main challenge is managing time effectively. With a large amount of code, it is important to stay organized and focused to ensure that all aspects of the project are completed within the given time frame. Debugging and troubleshooting can also be time-consuming, so it is crucial to have a thorough understanding of the code and anticipate potential issues.

## 3. How do you ensure the accuracy and functionality of your code?

I use various techniques such as code reviews, unit testing, and debugging to ensure that my code is accurate and functional. I also make sure to thoroughly test my code with different inputs and scenarios to catch any potential errors. Collaborating with other scientists and seeking feedback from peers also helps to improve the accuracy and functionality of my code.

## 4. How do you manage unexpected obstacles or roadblocks while working on a project?

When faced with unexpected obstacles or roadblocks, I first assess the situation and find the root cause of the issue. Then, I brainstorm potential solutions and consult with my team or colleagues for their insights. I also make sure to constantly communicate and update any changes or delays to the project timeline to ensure that everyone is on the same page.

## 5. What advice do you have for others trying to complete a project with a tight deadline?

My advice would be to stay organized, prioritize tasks, and communicate effectively with your team. Break down the project into smaller, achievable goals and create a timeline for each task. It is also important to take breaks and manage your time effectively to avoid burnout. Lastly, don't be afraid to ask for help or seek guidance from others when needed.

Replies
4
Views
240
• Computing and Technology
Replies
15
Views
5K
• Programming and Computer Science
Replies
8
Views
2K
• Computing and Technology
Replies
10
Views
2K
• Special and General Relativity
Replies
29
Views
1K
• Science Fiction and Fantasy Media
Replies
44
Views
5K
• Programming and Computer Science
Replies
54
Views
4K
• STEM Career Guidance
Replies
108
Views
15K