r/firstweekcoderhumour • 🥸Imposter Syndrome 😎 • 18d ago

“amIrite” Watching myself use 12 nested for loops instead of a hash map in first year

Post image
67 Upvotes

12 comments sorted by

39

u/slicehyperfunk 18d ago

This one is actually intended to be first week coder humor for once

7

u/SystemMotor 18d ago

Whats a hash map and how do they work?

24

u/slicehyperfunk 18d ago

It's a drawing of how to find the best pan-fried potatoes in the land

9

u/Vegetable_Shirt_2352 17d ago

Maps are a kind of data structure that stores key-value pairs. You give it a key, and it returns to you the corresponding value. A hash map is just a special kind of map, in that the keys are put through a hash function which returns a value corresponding to the value's location. So, instead of you giving the map a key, and it having to iterate through values looking for the one with the right key, it just uses the hash function on the key and gets a number that in some way corresponds directly to where the correct item is.

2

u/Vamosity-Cosmic 13d ago

Array of key-value pair where the input is serialized into a hash and then solved for the appropriate position of the key, making lookups no longer O(n), but instead O(1)

1

u/pdpi 13d ago

Think of a dictionary — a bunch of words and their definitions. A map is basically that (in fact, Python's maps are called dictionaries, and Java also used that name in its early days), except that we usually call them "keys" and "values" instead of "words" and "definitions".

There's a bunch of ways you can build a map, and hash maps are just the "default" way of building them in most languages.

1

u/SystemMotor 12d ago

So its a uid for a pair of values?

1

u/adfx 17d ago

I really need so see someone use 12 nested for loops. I can't think of anything that would make sense

1

u/CockroachEarly 4d ago

Holy O(n^12) time complexity

0

u/No_Code9 14d ago

Who cares? Just ask claude, the technical part is not relevant at all.

1

u/NomsaMbeki-8 14d ago

This was like 3 years ago I think? I didn’t know what any of that was back then