3
$\begingroup$

Your cell phone carrier sends you a text message when you have reached your data limit (which you know) for the month, after which you are charged for extra data usage.

Question 1: You want to determine on what day of the month the cycle changes without ever exceeding the data limit. How much time will that take at most if you use the most efficient strategy? To simplify things, assume that all months contain 30 days.

Question 2: Suppose you also don't know the length of a cycle, but know that it is a whole number of days and at most 60 days. How long will it take you to determine both the duration and the change date of the cycle?

$\endgroup$
  • 2
    $\begingroup$ What's a data limit? (Greetings from the Nordics :-) $\endgroup$ – Bass Nov 21 '17 at 20:22
  • $\begingroup$ @Bass: The amount of mobile data (in GB) you can use per month before being charged extra for each GB. $\endgroup$ – Runemoro Nov 21 '17 at 20:24
  • 2
    $\begingroup$ I guess I would have a close look at my contract. Mine is quite specific on these details. $\endgroup$ – Dr t Nov 21 '17 at 20:31
  • $\begingroup$ As you can probably tell, we don't really do data limits in my country. Will the carrier send the text (more or less) immediately when the limit is reached, or are those messages sent only at the end of each day? This information will have a huge-ish effect on the solutions. $\endgroup$ – Bass Nov 21 '17 at 22:12
  • $\begingroup$ @Bass: Immediately $\endgroup$ – Runemoro Nov 21 '17 at 22:37
1
$\begingroup$

Partial answer:

I believe the best strategy is to use 1/30th of the plan every day. The plan will be reset at some point in the cycle, then you will be able to go on exactly 30 days and get an SMS on the day of the reset. In the worst case, this strategy will take 59 days to determine on which day the cycle ends.

For example:

you have 30Gb of data. If you use 1Gb of data per day and the plan resets after 5 days, you will receive the SMS on the 35th day of applying this strategy

Exception:

the only situation in which you will not need a first reset is if you get lucky and start on day 1 of the plan. Then on day 30 you will get the SMS and you will know that was the reset date

EDIT

Following Bass' answer, 58 days is sufficient to determine when the cycle ends as no SMS on day 58 means the reset is on 59 (i.e. 29th day of the month)

$\endgroup$
  • $\begingroup$ Looks like we both got caught in the same gotcha. (see the comments on the question itself) $\endgroup$ – Bass Nov 21 '17 at 22:56
  • $\begingroup$ well done my friend $\endgroup$ – sousben Nov 22 '17 at 9:18
7
$\begingroup$

Question 1: you'll need no more than

30 days (rounded up to full days)

using this strategy:

Use 1/30 of the limit each day. On day 30, first use the missing 30th, and wait a bit. If you get no text, use another 30th, and wait again. Repeat until you get the text. The total number of 30ths that you needed to use on day 30 is equal to the number of the first day of the cycle.

Trying this same method on day 29 (or earlier) will have a failure mode; the second 30th of data will cause a text if the first day of the cycle is either day 30 or day 1, and if you use any additional data on day 30 to figure out which it is, you risk running over the limit, so you cannot do that. So in this case, 30 days (again, rounded up to full days) seems to be the absolute minimum.

For question 2, the best I could do is (THIS IS ALL MESSED UP. YOU'LL RUN OVER THE DATA LIMIT ON DAY 60 ALMOST CERTAINLY. I removed my misguided answer for question 2, and will take a new look in the morning, looks like I'm too tired to wrap my head around the question right now.)


Below is the answer I posted before asking for clarification on the response speed of the text message from the carrier. I assumed that the messages would only come at the end of each day.


Assuming the reset always happens at a known time (say, midnight), you'll need no more than

58 days (rounding up to full days. With careful timing, 57 days + 1 minute would do.)

I have no idea if this is optimal, but couldn't figure out a better way. The method is this:

Start by using a bit of data each day. On day 30, subtract the accumulated data from your data cap, and use that much. If you get the text, the cycle resets the next day.

If you didn't get the text, on every following day, use the exact same amount of data as you did last month on that day. If you get text, the cycle will reset the next day.

On day 58, if you didn't get the text, you already know that you'd get the text on day 59, so you don't have to wait that long.

Commenting on question 2: How on earth did I get coerced into getting a plan that not only has a data limit, but the limit period (and thus, the average allowed daily usage) is unknown and can vary by a factor of 60? :-)

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.