-3
$\begingroup$

Winston the Hobo really loves smoking. Every $7$ cigarette butts he finds on the ground, he rolls the tobacco in a cigarette and smokes it.

Winston is very poor, so he actually rolls cigarettes with his own butts. For instance, if he finds $49$ butts, he'll smoke $7+1$ cigarettes: $7$ from the butts he found, and $1$ rolled from the butts of the cigarettes he smoked.

How many cigarettes does Winston smoke after he finds $n$ butts?

Addendum: the function $f(n)$ must not make use of the floor function.

$\endgroup$
1
  • $\begingroup$ Why don't you post your answer that does not involve the floor function? (I'm guessing that instead of $\lfloor \frac{n-1}{6} \rfloor$ you have something in mind like: "if $6m \le n - 1 < 6m + 6$, then the answer is $m$". Or "the answer is $((n-1) - ((n-1) \bmod 6)) / 6$". All of which are equivalent.) $\endgroup$ Nov 28 '16 at 18:52
7
$\begingroup$

(Very similar questions have been asked and answered here before: A Fairly Simple Riddle and The Chain Smokers. This is different in that it asks for an answer for arbitrary $n$.)

Let's generalize a bit more and say that Winston can make a cigarette from $k$ butts.

Every time Winston makes a cigarette and smokes it, he reduces the number of butts by $k-1$. He can do this as long as there are at least $k$ butts; that is, as long as he ends up with at least one butt. So we can hide one of the butts and say that he just repeatedly turns $k-1$ butts to no butts (making a cigarette each time) until none remain. Therefore the number of cigarettes he makes is $\left\lfloor\frac{n-1}{k-1}\right\rfloor$.

$\endgroup$
7
  • $\begingroup$ I will add the requirement that the formula must not use the floor function. Does that make it more interesting? $\endgroup$
    – Lonidard
    Nov 24 '16 at 13:19
  • 7
    $\begingroup$ If the answer equals a simple formula with a floor in it (which it does) then requiring that the formula not have an explicit floor in it just amounts to saying "find a way to write the floor function without using the floor symbol"... $\endgroup$
    – Gareth McCaughan
    Nov 24 '16 at 13:29
  • 2
    $\begingroup$ @Lonidard: Will this lead to a more elegant solution or just to some song and dance to work around the floor function? If the latter, no, that's not more interesting. $\endgroup$
    – M Oehm
    Nov 24 '16 at 13:29
  • $\begingroup$ This is not my point. I am saying that the case for this particolar $k$ does not require the use of floor function or equivalent forms. $\endgroup$
    – Lonidard
    Nov 24 '16 at 13:30
  • 1
    $\begingroup$ It seems unlikely that anyone is going to be unhappy with the floor function but happy with the fractional-part function. (Of course that's your point.) I am curious what sort of thing Lonidard has in mind. $\endgroup$
    – Gareth McCaughan
    Nov 24 '16 at 20:26

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.