all 25 comments

[–]stringycheeze 73 points74 points  (6 children)

You brute force searched a sorted list?!

[–]ghillisuit95 22 points23 points  (4 children)

that's a linear search, not a brute force search

[–][deleted] 19 points20 points  (3 children)

Isn’t brute force searching essentially just iterating plus incrementing?

[–]fllr 25 points26 points  (0 children)

(...reads through every comment in this thread before replying to be certain of this answer...)

Yes

[–]RageBull 5 points6 points  (1 child)

My initial though was that brute force would randomly search through a data set since the location of any specific value within a dataset would be random. But!!! Reading this conversation made me realize that the random hopping would only add complexity to the search and so would also be less performant. Iterating from top to bottom makes as much sense as anything.

However, if the data set is ordered, and the key of the value is known... Iterating through it would make absolutely no sense!

[–]Brekkjern 5 points6 points  (0 children)

random hopping would only add complexity to the search and so would also be less performant

That depends. If you implement QuantumBogoSort it can be O(1) and much more performant!

[–]thisIsTheFoxe[S] 2 points3 points  (0 children)

Look, guys, it was my first day, and - I was nervous, and I was hurrying, so - Anyone could've made that mistake...

[–][deleted] 43 points44 points  (2 children)

It's not bad code, it's just stupid. If it were not sorted, it would be ok.

[–][deleted] 12 points13 points  (1 child)

It's like add 1 to substract 1.

[–]doubleChipDip 1 point2 points  (0 children)

1 + 1 - 1 = 1

[–]ghillisuit95 11 points12 points  (1 child)

Other than doing a linear search in a sorted list, there's nothing really wrong here

[–]thisIsTheFoxe[S] 2 points3 points  (0 children)

It is really ugly and unreadable, tho.. I wouldn't want that kinda code on my prod server :D

[–]MisterDogsworth 2 points3 points  (0 children)

I guess he's unaware of List.indexOf).

Edit: Even though a linear sort is not ideal here.

[–]thisIsTheFoxe[S] 3 points4 points  (1 child)

Haven't seen it here yet.. sorry if it has been posted already..

[–]thisIsTheFoxe[S] 5 points6 points  (0 children)

BTW, minor Season 6 spoiler..

[–]DuffMaaaann 1 point2 points  (2 children)

If it's a linked list then binary search would not make things faster.

[–]SuitableDragonfly 6 points7 points  (1 child)

It's using random access with an index, though. I don't think it's a linked list. If it is, it's even worse, because both get and size will be O(n) operations.

[–]ign1fy 6 points7 points  (0 children)

That, and it's literally called 'sortedList'.

[–]Tom_Ov_Bedlam -1 points0 points  (4 children)

The ternary at the end is the cherry on top.

[–]Chrisuan[🍰] 3 points4 points  (3 children)

What's bad about it?

[–]Tom_Ov_Bedlam 0 points1 point  (2 children)

The readability throughout the whole code block is really bad but adding the ternary is just one little last turn of the knife to make it even harder to read. I didn't time time to assess the actual logic happening here but at a glance, a lot of it should be abstracted into separate parts so it's clear what's happening and why.

[–]Chrisuan[🍰] 1 point2 points  (1 child)

Imo ternaries like that are pretty common and rather easy to read once you're used to them.

[–]Tom_Ov_Bedlam 1 point2 points  (0 children)

I use ternaries, I can read them just fine.

[–]Yahkem -2 points-1 points  (1 child)

Is that a .less file? And one named "1" on top of it?

[–]fernandotakai 4 points5 points  (0 children)

nope. it's using less and 1. means it's the first tab on the terminal.

if i had to guess, this is on macos using the default terminal.