# \[Adventurer\] Triage

**URL:** <https://discourse.codecombat.com/t/adventurer-triage/9639>\
**Category:** Adventurer\
**Created:** [November 14, 2016, 2:44pm UTC](https://discourse.codecombat.com/t/adventurer-triage/9639 "2016-11-14T14:44:55Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Catsync](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/catsync/32/6431_2.png) [@Catsync](https://discourse.codecombat.com/u/Catsync)\
**Post date:** [November 14, 2016, 2:44pm UTC](https://discourse.codecombat.com/t/adventurer-triage/9639/1 "2016-11-14T14:44:55Z")

</div>

The level [Triage](https://codecombat.com/play/level/triage) is now ready for testing.

The intent of this level is to practice appending items to arrays, it’s in the Mountain campaign, after [Uneasy Truce](https://codecombat.com/play/level/uneasy-truce).

---

<div class="post-metadata">

**Author:** ![ant](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/ant/32/3362_2.png) [@ant](https://discourse.codecombat.com/u/ant)\
**Post date:** [November 14, 2016, 3:31pm UTC](https://discourse.codecombat.com/t/adventurer-triage/9639/2 "2016-11-14T15:31:15Z")

</div>

Looks good and simple, no issues found.

---

<div class="post-metadata">

**Author:** ![dwhittaker](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/dwhittaker/32/2114_2.png) [@dwhittaker](https://discourse.codecombat.com/u/dwhittaker)\
**Post date:** [November 15, 2016, 8:40am UTC](https://discourse.codecombat.com/t/adventurer-triage/9639/3 "2016-11-15T08:40:45Z")

</div>

one-liner!

```python
(hero.findByType("paladin")[0]["patients"],hero.findByType("pixie")[0]["patients"],hero.findByType("peasant")[0]["patients"]) = ([f for f in hero.findByType('soldier') if f.health < f.maxHealth/2],[f for f in hero.findByType('soldier') if f.maxSpeed < 6],[f for f in hero.findByType('soldier') if f.health >= f.maxHealth/2 and f.maxSpeed >= 6])

```

---

<div class="post-metadata">

**Author:** ![harper4](https://avatars.discourse-cdn.com/v4/letter/h/b9e5f3/32.png) [@harper4](https://discourse.codecombat.com/u/harper4)\
**Post date:** [November 16, 2016, 9:58pm UTC](https://discourse.codecombat.com/t/adventurer-triage/9639/4 "2016-11-16T21:58:31Z")

</div>

when I run this, for some reason the first soldier with maxspeed \< 6 walks almost to his post then hangs a turn and go’s to the wrong place. Its not even part of the code I have touched. The rest do as they should. What am I missing?

```python
# Triage the wounded soldiers.

doctor = hero.findByType("paladin")[0]
mage = hero.findByType("pixie")[0]
helper = hero.findByType("peasant")[0]
soldiers = hero.findByType("soldier")

# Initialize patient arrays.
doctorPatients = []
magePatients = []
helperPatients = []

# Iterate all the soldiers:
for soldier in soldiers:
    # If soldier is slowed:
    if soldier.maxSpeed < 6:
        # Add them to the mage's array of patients.
        magePatients.append(soldier)
    # Else if soldier.health is less than half of maxHealth:
    if soldier.health < soldier.maxHealth / 2:
        # Add them to the doctor's array of patients.
        doctorPatients.append(soldier)
    # Else:
    else:
        # Add soldier to the helper's array of patients.
        helperPatients.append(soldier)

# Now assign the patient listss to the appropriate person.
mage["patients"] = magePatients
doctor["patients"] = doctorPatients
helper["patients"] = helperPatients

```

---

<div class="post-metadata">

**Author:** ![Catsync](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/catsync/32/6431_2.png) [@Catsync](https://discourse.codecombat.com/u/Catsync)\
**Post date:** [November 17, 2016, 1:56pm UTC](https://discourse.codecombat.com/t/adventurer-triage/9639/5 "2016-11-17T13:56:34Z")

</div>

> [@harper4](#):
>
> ```python
> # Else if soldier.health is less than half of maxHealth:
> if soldier.health < soldier.maxHealth / 2:
> 
> ```

Check this 🙂 Sounds like the soldier is turning because they’re being added to both `magePatients` and `helperPatients` ?

---

<div class="post-metadata">

**Author:** ![harper4](https://avatars.discourse-cdn.com/v4/letter/h/b9e5f3/32.png) [@harper4](https://discourse.codecombat.com/u/harper4)\
**Post date:** [November 17, 2016, 4:42pm UTC](https://discourse.codecombat.com/t/adventurer-triage/9639/6 "2016-11-17T16:42:10Z")

</div>

Thanks, if it was a rattle snake it would have bit me.

---

<div class="post-metadata">

**Author:** ![Harry\_the\_Wanderer](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/harry_the_wanderer/32/5369_2.png) [@Harry\_the\_Wanderer](https://discourse.codecombat.com/u/Harry_the_Wanderer)\
**Post date:** [November 20, 2016, 8:57am UTC](https://discourse.codecombat.com/t/adventurer-triage/9639/7 "2016-11-20T08:57:34Z")

</div>

was able to complete the level without issue

* * *

Should

> ```
> // Iterate all the soldiers:
> 
> ```

be

> ```
> // Iterate through all the soldiers:
> 
> ```

?

---

<div class="post-metadata">

**Author:** ![htrnblr](https://avatars.discourse-cdn.com/v4/letter/h/f9ae1b/32.png) [@htrnblr](https://discourse.codecombat.com/u/htrnblr)\
**Post date:** [December 22, 2016, 12:59pm UTC](https://discourse.codecombat.com/t/adventurer-triage/9639/8 "2016-12-22T12:59:53Z")

</div>

Nice level  
But what about  
by time scoreboard  
You provide it  
but seems like you provide zero option for improve time  
i have lost a lot of time trying to do it

Why not do it without scoreboard in this case

---

<div class="post-metadata">

**Author:** ![Anish\_Leekkala](https://avatars.discourse-cdn.com/v4/letter/a/9e8a1a/32.png) [@Anish\_Leekkala](https://discourse.codecombat.com/u/Anish_Leekkala)\
**Post date:** [February 16, 2018, 4:43pm UTC](https://discourse.codecombat.com/t/adventurer-triage/9639/9 "2018-02-16T16:43:26Z")

</div>

I don’t get why my code is not working. The level is saying that I ran out of time but it looks like I triaged all my patients.  
Here is the code:

# Triage the wounded soldiers.

doctor = hero.findByType(“paladin”)[0]  
mage = hero.findByType(“pixie”)[0]  
helper = hero.findByType(“peasant”)[0]  
soldiers = hero.findByType(“soldier”)

# Initialize patient arrays.

doctorPatients = []  
magePatients = []  
helperPatients = []

# Iterate all the soldiers:

for soldier in soldiers:  
for soldier in soldiers:  
# If soldier is slowed:  
if soldier.maxSpeed \< 6:  
# Add them to the mage’s array of patients.  
magePatients.append(soldier)  
elif soldier.health \< soldier.maxHealth/2:  
doctorPatients.append(soldier)  
elif soldier.maxSpeed ==6 and soldier.health \> soldier.maxHealth/2:  
helperPatients.append(soldier)

# Now assign the patient lists to the appropriate person.

mage[“patients”] = magePatients  
doctor[“patients”] = doctorPatients  
helper[“patients”] = helperPatients

---

<div class="post-metadata">

**Author:** ![Anish\_Leekkala](https://avatars.discourse-cdn.com/v4/letter/a/9e8a1a/32.png) [@Anish\_Leekkala](https://discourse.codecombat.com/u/Anish_Leekkala)\
**Post date:** [February 16, 2018, 4:45pm UTC](https://discourse.codecombat.com/t/adventurer-triage/9639/10 "2018-02-16T16:45:23Z")

</div>

Sorry, I figured it out
