From 6d48e9fdfcc535f2c61ef4352e1e404af3409362 Mon Sep 17 00:00:00 2001 From: kin Date: Sun, 13 Nov 2022 12:18:59 +0100 Subject: [PATCH] coderbyte challenge week 7 --- week8/akinola/consecutive.md | 2 ++ week8/akinola/consecutive.py | 8 ++++++++ 2 files changed, 10 insertions(+) create mode 100644 week8/akinola/consecutive.md create mode 100644 week8/akinola/consecutive.py diff --git a/week8/akinola/consecutive.md b/week8/akinola/consecutive.md new file mode 100644 index 0000000..af84706 --- /dev/null +++ b/week8/akinola/consecutive.md @@ -0,0 +1,2 @@ +Consecutive +Have the function Consecutive(arr) take the array of integers stored in arr and return the minimum number of integers needed to make the contents of arr consecutive from the lowest number to the highest number. For example: If arr contains [4, 8, 6] then the output should be 2 because two numbers need to be added to the array (5 and 7) to make it a consecutive array of numbers from 4 to 8. Negative numbers may be entered as parameters and no array will have less than 2 elements. \ No newline at end of file diff --git a/week8/akinola/consecutive.py b/week8/akinola/consecutive.py new file mode 100644 index 0000000..1e1acd4 --- /dev/null +++ b/week8/akinola/consecutive.py @@ -0,0 +1,8 @@ +def Consecutive(arr): + l = range(min(arr),max(arr)+1) + + # code goes here + return len(l)-len(arr) + +# keep this function call here +print Consecutive(raw_input()) \ No newline at end of file