I used a completely different strategy than what you did so it might be hard not to give away the answer

Okay, here’s where the step comes in. Think about what the message looks like:

Something like:

“a4562s8237P2347g1111p4567”

Can you see that every 5 characters there’s the letter that indicates what type you should use?

You can use that in the for loop. Just use:

for i in range(0, len(message), step):

You want to replace step with a number (5 in this case) and it will only do every 5 characters. So it will start on the first: a, then go to the 5th: s, then the 10th: P.

You can find out the x and y coordinates later, by adding 1, 2, 3, or 4 to the i variable which will find the x and y coordinates.

```
# Read the message on the sign to determine which units to summon and where to place them.
# Check the guide for instructions on interpreting the orders.
sign = hero.findByType("sign")[0]
message = sign.message
# Tip: parse the sign, then summon the units, then send each unit to the right position.
def code(summonType, cordX, cordY):
for i in range(0, len(message), 5):
character = message[i]
if character == "a":
hero.summon("archer")
if character == "s":
hero.summon("soldier")
if character == "p":
hero.summon("peasant")
if character == "g":
hero.summon("griffin-rider")
if character == "p":
pass
if character == "A":
pass
while True:
code()
```

My hero just summons all the types until it runs out of money

Lydia

Hi Lydia,

Well done on working out how to summon the right allies using ‘i’ in each loop. Now you need to use all the other information in the message. Each time you run the loop, ‘i +1’ and ‘i+2’ give the x co-ordinates. Then ‘i+3’ and ‘i+4’ give the y co-ordinates. You need to interpret these numbers, and then get the hero to command the friend to move to that position.

Jenny

So I do

`for i+1 in range(0, len(message), 5 )`

And do the almost same thing for the other for-loops?

And where do I put it?

Lydia

Not quite, you want to keep this the same:

But **inside** each if statement you will find the troop you have just built (hero.built[-1] returns the last troop that you built), and *then* you store the x and y values inside variables. You get the x and y values by (as Jenny said) getting the value of [i+1] (first X value), [i+2] (second X value), [i+3] (first Y value), [i+4] (second Y value).

And because all this information is stored inside the message array, you can put those [i+somethings] at the end of the message array to find the x and y values.

```
# Read the message on the sign to determine which units to summon and where to place them.
# Check the guide for instructions on interpreting the orders.
sign = hero.findByType("sign")[0]
message = sign.message
# Tip: parse the sign, then summon the units, then send each unit to the right position.
def code(summonType, cordX, cordY):
for i in range(0, len(message), 5):
character = message[i]
if character == "a":
hero.summon("archer")
lastBuilt = hero.built[-1]
for character+1 in range(0, len(message), 5):
xcharacterone = character + 1
if character == "s":
hero.summon("soldier")
if character == "p":
hero.summon("peasant")
if character == "g":
hero.summon("griffin-rider")
if character == "p":
pass
if character == "A":
pass
```

So I did something like this, but it says on this line:

`for character+1 in range(0, len(message), 5):`

Lydia

Umm . . . hello?

Lydia

That’s not quite right. You don’t need a for loop inside the if character == “a”. What you need to do is something like:

```
x = message[i+1]
```

That would be the first x value. Then you need to find the second x value, and the first y value and the second y value. Remember how the order is:

```
T x x y y
i i+1 i+2 i+3 i+4
```

T is the type, e.g “a”.

So you just put those i+ somethings in the square brackets of message, no for loop required.

```
sign = hero.findByType("sign")[0]
message = sign.message
# Tip: parse the sign, then summon the units, then send each unit to the right position.
def code(summonType, cordX, cordY):
for i in range(0, len(message), 5):
character = message[i]
if character == "a":
hero.summon("archer")
lastBuilt = hero.built[-1]
xone = message[i+1]
xtwo = message[1+2]
yone = message[1+3]
ytwo = message[1+4]
archer = hero.findNearest(hero.findByType("archer"))
if archer:
hero.command(archer, "move", {'x':xone xtwo, 'y':yone, ytwo})
if character == "s":
hero.summon("soldier")
if character == "p":
hero.summon("peasant")
if character == "g":
hero.summon("griffin-rider")
if character == "p":
pass
if character == "A":
pass
while True:
code()
```

This is what it said.

Lydia

Instead of pass try doing continue.

It just does the same thing

Lydia

You forgot a comma there

Nope, still nothing

Same error

Lydia

Hmm try doing this `archer = hero.findNearest(hero.findByType("archer"), hero.findFriends())`

for this

That doesn’t do anything different

Lydia

This is really good. Just remember they all use i+ something. You’ve got i+1, but the rest are 1 + something. They should all use i+ the number.

Next, you have to think about combining the individual characters like “5” and “4” into the X coordinate. Remember they should be 1 single number like 23, or 56. So you need to combine the numbers to make one 2 digit number like 14. However, it’s not a simple as adding them. Look at this:

Two x numbers are:

1 and 4

That means the X coordinate you will command your soldier to move to will be 14. But how do you do that in code?

1+4 is 5. That’s no good…

Hints:

Think about how the first x number is in the tens column. Each number represents 10 times what is says. So if you have a 1 in the tens column it’s equal to 10, right? The 1 in 14 is equal to 10. And if it was 24, the 2 in the tens column would be equal to 2x10 = 20.

So for the first x number and the first y number, which are in the tens column, you need to times them by 10 to get the correct number. Then you can add the first and second numbers making something like x: 14 and y: 44 that you can command your troops to move to.

One last thing, because you’re doing calculations on the number inside:

message[i+1], which is currently a string, like: “1”,

you want it to be a number, because you can’t times a string by 10, even if it represents a number.

To turn a string into an integer (a number) you do `int(message[i+1])`

. That’s will turn it into a number.

Danny

```
# Read the message on the sign to determine which units to summon and where to place them.
# Check the guide for instructions on interpreting the orders.
sign = hero.findByType("sign")[0]
message = sign.message
# Tip: parse the sign, then summon the units, then send each unit to the right position.
def code(summonType, cordX, cordY):
for i in range(0, len(message), 5):
character = message[i]
if character == "a":
hero.summon("archer")
lastBuilt = hero.built[-1]
int(message[i+1])
int(message[i+2])
int(message[i+3])
int(message[i+4])
xone = message[i+1]
xtwo = message[i+2]
yone = message[i+3]
ytwo = message[i+4]
archer = hero.findNearest(hero.findByType("archer"))
xone = xone * 10
x = xone + xtwo
yone = yone*10
y = yone + ytwo
if archer:
hero.command(archer, "move", {'x':x, 'y':y})
if character == "s":
hero.summon("soldier")
if character == "p":
hero.summon("peasant")
if character == "g":
hero.summon("griffin-rider")
if character == "p":
pass
if character == "A":
pass
while True:
code()
```

It said: Line 28:ArgumentError: `move`

's argument `pos.x`

should have type `number`

, but got `string`

:`"201`

. Target an {x: number, y: number} position

Lydia

try doing `pos.x, pos.y`

The coordinates are translated into strings, you need them to be integers.