Help on queue manager

Help.
this is my code

# Manage the queue without mistakes.

# Useful string constants.
PHRASE_IN = " in"
PHRASE_OUT = " out"
IDLE = "idle"
# The list of workers.
workers = hero.findByType("peasant", hero.findFriends())
# Use this array to control the worker queue.
queue = []

while True:
    # Iterate through all the workers:
    for work in workers:
        if work.status == IDLE:
            hero.say(work + PHRASE_IN)
        # If the worker's "status" property is "idle":
            queue.append(work)
            # Say the worker's name and the string " in":
            # Add the worker to the end of the queue:
    item = hero.findNearestItem()
    # If the item exists and the queue isn't empty:
    if item and queue != []:
        hero.say(work + PHRASE_OUT)
        # Say the name of the first worker in the queue
        # with the string " out":
        queue.pop()
        #  Remove (shift) the first worker from the queue:

Here try to put: if work.status is idle:

I will let @xython to tell you more, but I think that you copied your code from github.

Andrei

2 Likes

OK; @AnSeDra I am by your side now, although what about here:

for work in workers:
        if work.status == IDLE

Please @crafter do tell us if this is a copied code. We will not be mad if you tell us.

2 Likes

He just put instead of the “is” the “==” and instead of “array.remove()” this “array.pop()”. The rest is exactly the same. And if read the hints he would see that pop() does not work really welll in Python.

Andrei

ok well I asked him to tell us whether this is copied or not.
For @crafter:

  • Yes, I copied. I am sorry
  • No I did not Copy.

0 voters

Please no one else answer

2 Likes

@crafter I am positive you copied the code since it looks identical. What is the point of using CodeCombat if you’re not even writing the code yourself, so please don’t copy others code.

1 Like

@weary can u show me and others code and then there code so we can see closer?

What do you mean?

can u post the code form github then their code next to it so we can see if they did or not.

@AnSeDra posted it, but maybe now he deleted it.

and thats why im asking if he can.

You can seach on github on your own, why do you want for I to post that code here?

Andrei

so others like deadpool can see

@AnSeDra You might want to edit the post again because if people click on the changes on the top of the post they can still access the link.

2 Likes

Done. Thanks for reminding me!

Andrei

2 Likes

tecnically there is no way to do that ill PM u weary and AnseDra why

I did actually see it, and having decided it was copied, I asked if the link could be removed. Because people can’t seem to stop using it and claiming it’s their own, I think it would be better the fewer people knew about it. Just my opinion… I think it’s the best way to deal with it, a few years ago when most people didn’t know about it I didn’t see stolen code that often.
Danny

2 Likes

And I agreed to @Deadpool198. The fewer people that know how to find those solutions, the better.

Andrei