# When the result will reach the people? [closed]

Assume the result of an exam has been published.

After 5 minutes, First person knows the result.

In next 5 minutes, new 8 persons know the result, and in total 9 know it.

Again after 5 minutes, new 27 people know, and total 36 know.

In similar fashion, total 100, 225..... people keep knowing it on 5 minute interval.

Challenge

Given a total number of people knowing (n), and a starting time in hour and minutes, output when total n people will know the result.

Example: If start is 1:02, and n is 225 the output time will be 1:27.

In output colons of time aren't needed, you may input or output as list or seperate variables.

n will be always in the sequence of totals, i.e. (1,9,36,100,225....)

• Relevant OEIS entry Nov 13, 2021 at 9:21
• Do times wrap around? Can the hour be zero? Test cases would be good.
– xnor
Nov 13, 2021 at 9:30
• @xnor jour can be zero and time will wrap Nov 13, 2021 at 9:35

# Python 3.8 (pre-release), 85 bytes

lambda h,m,x:[(h+(y:=(((((x**.5)*8)+1)**.5)-1)*2.5)//60)%24+(m+y%60)//60,(m+y%60)%60]


Try it online!

The sequence of totals is just sum of first $$\n\$$ cubes.

It is a known formula that sum of first $$\n\$$ cubes is the square of $$\n\$$th triangular number (Proof), i.e.

$$\ \{\frac{n(n+1)}{2}\}^2 \$$

If we assume given input is $$\x\$$, then

$$\ \{\frac{n(n+1)}{2}\}^2=x \\ \frac{n(n+1)}{2}=\sqrt{x} \\ n(n+1)=2\sqrt{x} \\ n^2+n=2\sqrt{x} \\ n^2+n-2\sqrt{x}=0 \$$

We get a quadratic equation with $$\a=1, b=1, c=-2\sqrt{x}\$$

The formula for the quadratic equation is

$$\ \frac{-b\pm\sqrt{b^2-4ac}}{2a} \$$

We will only take the positive root and plug in

$$\ \frac{-b+\sqrt{b^2-4ac}}{2a} \\ =\frac{-1+\sqrt{(-1)^2-4\times(-2\sqrt{x})\times1}}{2\times1} \\ =\frac{-1+\sqrt{1+8\sqrt{x}}}{2} \\ =\frac{(\sqrt{1+8\sqrt{x}})-1}{2} \$$

Which is the formula for the $$\n\$$, then we just multiply it by 5, divmod by $$\60\$$ and add with start time.

• Fails for input 1, 40, 225 among others. Nov 13, 2021 at 9:36
• @Dingus works now Nov 13, 2021 at 9:40
• The question is unclear on whether a 12 or 24 hour clock is in use, though comments suggest 24. In that case, this still fails when the time wraps back around, e.g. 23, 40, 225. Nov 13, 2021 at 9:49
• You absolutely do not need that many sets of brackets Nov 13, 2021 at 14:25

# Retina 0.8.2, 103 bytes

\d+
$* (^1|11\1)+$#1$* (^1|1\1)+¶(.+)$2$1$1$1$1$1 +:1{60} 1: +1{24}: : (1*):(1*)$.1:$.2 :(.)$
:0$1  Try it online! Takes n on the first line and the time (including colon) on the second.Explanation: \d+$*


Convert to unary.

(^1|11\1)+
$#1$*


Take the square root.

(^1|1\1)+¶(.+)
$2$1$1$1$1$1


Add 5 times the triangular index to the minutes.

+:1{60}
1:


Convert 60 minutes to an hour.

+1{24}:
:


Ignore days.

(1*):(1*)
$.1:$.2
:(.)$:0$1


Convert to decimal.