---
id: 6a2037a68a0bc2aef0006006
title: "Challenge 344: Golden Ratio"
challengeType: 29
dashedName: challenge-344
---

# --description--

Given two numbers, determine if their ratio approximates the golden ratio.

- Use a golden ratio of `1.618`
- Allow a tolerance of `0.01`

# --hints--

`is_golden_ratio(21, 34)` should return `True`.

```js
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertIs(is_golden_ratio(21, 34), True)`)
}})
```

`is_golden_ratio(15, 20)` should return `False`.

```js
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertIs(is_golden_ratio(15, 20), False)`)
}})
```

`is_golden_ratio(8, 13)` should return `True`.

```js
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertIs(is_golden_ratio(8, 13), True)`)
}})
```

`is_golden_ratio(10, 16)` should return `False`.

```js
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertIs(is_golden_ratio(10, 16), False)`)
}})
```

`is_golden_ratio(1618, 1000)` should return `True`.

```js
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertIs(is_golden_ratio(1618, 1000), True)`)
}})
```

`is_golden_ratio(88, 55)` should return `False`.

```js
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertIs(is_golden_ratio(88, 55), False)`)
}})
```

# --seed--

## --seed-contents--

```py
def is_golden_ratio(a, b):

    return a
```

# --solutions--

```py
def is_golden_ratio(a, b):
    golden_ratio = 1.618
    ratio = max(a, b) / min(a, b)
    return abs(ratio - golden_ratio) <= 0.01
```
