mirror of
https://github.com/theoludwig/programming-challenges.git
synced 2025-05-18 12:02:53 +02:00
feat: rewrite programming-challenges CLI (#3)
This commit is contained in:
13
challenges/fibonacci/README.md
Normal file
13
challenges/fibonacci/README.md
Normal file
@ -0,0 +1,13 @@
|
||||
# fibonacci
|
||||
|
||||
Created by [@Divlo](https://github.com/Divlo) on 5 July 2020.
|
||||
|
||||
## Instructions
|
||||
|
||||
The function should return an array of fibonacci numbers. The function takes a `number` as an argument to decide how many number of elements to produce.
|
||||
|
||||
**Note :** The Fibonacci Sequence is the series of numbers: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, ... Each subsequent number is the sum of the previous two.
|
||||
|
||||
## Examples
|
||||
|
||||
See the `test` folder for examples of input/output.
|
0
challenges/fibonacci/solutions/.gitkeep
Normal file
0
challenges/fibonacci/solutions/.gitkeep
Normal file
3
challenges/fibonacci/solutions/python/function/README.md
Normal file
3
challenges/fibonacci/solutions/python/function/README.md
Normal file
@ -0,0 +1,3 @@
|
||||
# fibonacci/python/function
|
||||
|
||||
Created by [@Divlo](https://github.com/Divlo) on 6 June 2021.
|
13
challenges/fibonacci/solutions/python/function/solution.py
Normal file
13
challenges/fibonacci/solutions/python/function/solution.py
Normal file
@ -0,0 +1,13 @@
|
||||
from typing import List
|
||||
import sys
|
||||
|
||||
input_values: List[str] = []
|
||||
for value in sys.stdin:
|
||||
input_values.append(value.rstrip('\n'))
|
||||
|
||||
|
||||
def fibonacci(number: int) -> int:
|
||||
return number if number < 2 else fibonacci(number-1) + fibonacci(number-2)
|
||||
|
||||
|
||||
print(fibonacci(int(input_values[0])))
|
1
challenges/fibonacci/test/1/input.txt
Normal file
1
challenges/fibonacci/test/1/input.txt
Normal file
@ -0,0 +1 @@
|
||||
14
|
1
challenges/fibonacci/test/1/output.txt
Normal file
1
challenges/fibonacci/test/1/output.txt
Normal file
@ -0,0 +1 @@
|
||||
377
|
Reference in New Issue
Block a user