14

1

## Introduction:

At home we have a clock that strikes the stated amount at each hour, but also strikes once at every half-hour. So from 0:01 to and including 12:00 it strikes in this order:

```
1, 1, 1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10, 1, 11, 1, 12
```

## Challenge:

Given an integer `n`

, output a list of time-frames in which the total strikes are equal to `n`

. In addition, always start at least 1 minute before this time-frame and end at least 1 minute after this time-frame (and at most 29 minutes).

For example, if the input is `n=8`

, the output could be:

```
[00:59-03:01, 01:29-03:31, 02:59-04:01, 05:29-06:31, 06:29-07:01, 06:59-07:31, 07:59-08:01]
```

For which these time-frames have the following sums, all equaling `8`

:

```
[1+1+2+1+3, 1+2+1+3+1, 3+1+4, 1+6+1, 1+7, 7+1, 8]
```

## Challenge rules:

- Output is flexible. You can output as Time (or Date/DateTime) objects, timestamps, strings (with or without leading zeroes), decimals with
`.29`

/`.31`

/`.59`

/`.01`

(i.e.`0.29-3.01`

instead of`00:29-03:01`

), etc. As long as it's clear it's before and after the time-frame.

In addition, you can choose the amount yourself. In all my examples I use 1 minute, but you can also choose 5 minutes, 15 minutes, etc. This also means you can use`.4`

/`.6`

/`.9`

/`.1`

(i.e.`0.4-3.1`

instead of`00:24-03:06`

) for example. The list is also flexible. Can be a list/collection, array, delimiter-separated string, printing per line to STDOUT, etc.

**Please state which output choice you've made.**Note: You are not allowed to output the sums of the time-frames like above, this is only mentioned as clarification. You must output the time-frames, including slightly before and after it. - The strikes do wrap around from
`12:00`

to`00:30`

. So if`n=14`

, two of the time-frames are`11:29-00:31`

and`11:59-01:01`

. - Input will be in the range
`1 <= n <= 90`

, where 90 is the total sum of all possible strikes. - The time-frames you return can be in any order.

## General rules:

- This is code-golf, so shortest answer in bytes wins.

Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language. - Standard rules apply for your answer, so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters and return-type, full programs. Your call.
- Default Loopholes are forbidden.
- If possible, please add a link with a test for your code.
- Also, please add an explanation if necessary.

## Test cases:

(all using 1 minute before / after the time-frames and leading zeroes)

```
Input: 8
Ouput:
[00:59-03:01, 01:29-03:31, 02:59-04:01, 05:29-06:31, 06:29-07:01, 06:59-07:31, 07:59-08:01]
Input: 14
Output:
[00:29-04:01, 00:59-04:31, 02:59-05:01, 04:29-06:31, 05:59-07:01, 11:29-00:31, 11:59-01:01]
Input: 90
Output:
[00:29-00:01, 00:59-00:31, 01:29-01:01, 01:59-01:31, 02:29-02:01, 02:59-02:31, 03:29-03:01, 03:59-03:31, 04:29-04:01, 04:59-04:31, 05:29-05:01, 05:59-05:31, 06:29-06:01, 06:59-06:31, 07:29-07:01, 07:59-07:31, 08:29-08:01, 08:59-08:31, 09:29-09:01, 09:59-09:31, 10:29-10:01, 10:59-10:31, 11:29-11:01, 11:59-11:31]
Input: 1
Output:
[00:29-00:31, 00:59-01:01, 01:29-01:31, 02:29-02:31, 03:29-03:31, 04:29-04:31, 05:29-05:31, 06:29-06:31, 07:29-07:31, 08:29-08:31, 09:29-09:31, 10:29-10:31, 11:29-11:31]
Input: 2
Output:
[00:29-01:01, 00:59-01:31, 01:59-02:01]
```

1I'd go for whatever is most flexible. This includes decimal hour numbers, as long as the result numbers fall between two ringing times. – Adám – 2018-01-05T10:09:44.660

@Adám Guess you're right. I've edited my answer accordingly. You should have at least 1 minute and at most 29 minutes, so

`.4`

/`.6`

/`.9`

/`.1`

is allowed (being 6 minutes like you've stated:`:24`

/`:36`

/`:54`

/`:06`

). – Kevin Cruijssen – 2018-01-05T10:18:09.0531Maybe mention that the time pairs may be returned in any order? – Adám – 2018-01-05T11:13:08.950

Ok n is in 0..90, I not find clear what is the time period for calculate the n strikes: It is 12 hours? They are 24 hours? Are 48 hours? Than are allowed return time in the format 0..24:0..60 ? – RosLuP – 2018-01-07T14:59:09.983

@RosLuP The time frame is a regular analog clock, so from 00:01 to 12:00. So instead of 0..24:0..60, it should be 0..12:0..60. How that clears any confusion. – Kevin Cruijssen – 2018-01-07T18:03:34.807