about summary refs log tree commit diff
path: root/daily/303easy/README.md
blob: b970342057dbf14ac68834b9b2f61c02f46c5039 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# [[2017-02-21] Challenge #303 [Easy] Ricochet](https://www.reddit.com/r/dailyprogrammer/comments/5vb1wf/20170221_challenge_303_easy_ricochet/)

## Description

Start with a grid _h_ units high by _w_ units wide. Set a point particle in
motion from the upper-left corner of the grid, 45 degrees from the horizontal,
so that it crosses from one corner of each unit square to the other. When the
particle reaches the bounds of the grid, it ricochets and continues until it
reaches another corner. 

Given the size of the grid (_h_ and _w_), and the velocity (_v_) of the
particle in unit squares per second, determine _C_: the corner where the
particle will stop, _b_: how many times the particle ricocheted off the bounds
of the grid, and _t_: the time it took for the particle to reach _C_.

## Constraints

The particle always starts from the upper-left corner of the grid (and will
therefore always end up in one of the other corners).

Since we'll be working with unit squares, _h_ and _w_ are always integers.

## Formal Inputs & Outputs

### Input description

The input will be an arbitrary number of lines containing _h_, _w_, and _v_,
each separated by spaces:

     8 3 1
     15 4 2

### Output description

For each line of input, your program should output a line containing _C_, _b_,
and _t_, where _C_ can be UR, LR, or LL depending on where the particle ends
up:

     LL 9 24
     UR 17 30

## Bonus

Instead of a particle, determine the behavior of a rectangle _m_ units high by
_n_ units wide. Input should be as follows: _h_ _w_ _m_ _n_ _v_. So for a 10 by
7 grid with a 3 by 2 rectangle, the input would be:

     10 7 3 2 1

The output format is the same:

     LR 10 35

# Finally

Have a good challenge idea like /u/sceleris927 did?

Consider submitting it to /r/dailyprogrammer_ideas