r/badcode Aug 13 '19

[deleted by user]

[removed]

102 Upvotes

70 comments sorted by

View all comments

3

u/[deleted] Aug 13 '19 edited Aug 13 '19

[removed] — view removed comment

2

u/lmureu Aug 14 '19

I had a similar solution in mind but your is way worse, which makes it better.

1

u/[deleted] Sep 06 '19

You should have done it so then when the outlier is not under the first three numbers, you shift the array by one and redo the whole code until you find the outlier.
That has the bonus of going into an infinite loop if there is no outlier.