diff --git a/challenges/easy/find-missing-number/solutions/valentinadagata/main.erl b/challenges/easy/find-missing-number/solutions/valentinadagata/main.erl new file mode 100644 index 0000000..9c08fab --- /dev/null +++ b/challenges/easy/find-missing-number/solutions/valentinadagata/main.erl @@ -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)]). diff --git a/challenges/easy/find-missing-number/solutions/valentinadagata/main.py b/challenges/easy/find-missing-number/solutions/valentinadagata/main.py new file mode 100644 index 0000000..8db1d76 --- /dev/null +++ b/challenges/easy/find-missing-number/solutions/valentinadagata/main.py @@ -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)) \ No newline at end of file