Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
-module(main).
-import(lists,[sum/1]).
-export([start/0]).

findMissingNumber(MyList) ->
Total = sum(lists:seq(lists:min(MyList), lists:max(MyList))),
MissingNum = Total - sum(MyList),
MissingNum.

start() ->
MyList=[230, 222, 220, 224, 229, 221, 225, 223, 228, 226],
io:fwrite("~w~n", [findMissingNumber(MyList)]).
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
def find_missing_number(l):
# sort the list to get the min and the max taking the first and the last item
l.sort()
# total list = sum all the numbers between the min and the max of the list
# difference between the total list and the list will be the missing number
n = sum(range(l[0], l[len(l)-1] + 1)) - sum(l)
return n


if __name__ == '__main__':
mylist = [230, 222, 220, 224, 229, 221, 225, 223, 228, 226]
print(find_missing_number(mylist))