# \[Adventurer\] Northwest

**URL:** <https://discourse.codecombat.com/t/adventurer-northwest/9458>\
**Category:** Adventurer\
**Created:** [October 26, 2016, 6:13pm UTC](https://discourse.codecombat.com/t/adventurer-northwest/9458 "2016-10-26T18:13:05Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bryukh](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/bryukh/32/19597_2.png) [@Bryukh](https://discourse.codecombat.com/u/Bryukh)\
**Post date:** [October 26, 2016, 6:13pm UTC](https://discourse.codecombat.com/t/adventurer-northwest/9458/1 "2016-10-26T18:13:05Z")

</div>

Mountain level [Northwest](https://codecombat.com/play/level/northwest) is ready for testing.

Listen to local guides and guide your pet through mountain tracks which are full by traps. Use string search to recognize guides’ orders.

---

<div class="post-metadata">

**Author:** ![juraj\_pechac](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/juraj_pechac/32/4987_2.png) [@juraj\_pechac](https://discourse.codecombat.com/u/juraj_pechac)\
**Post date:** [October 26, 2016, 8:05pm UTC](https://discourse.codecombat.com/t/adventurer-northwest/9458/2 "2016-10-26T20:05:17Z")

</div>

This comment is misleading

```python
# If j is the length of the word:
           

```

Better is:

```python
# If j is the last letter of the word:

```

---

<div class="post-metadata">

**Author:** ![kavacha](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/kavacha/32/5029_2.png) [@kavacha](https://discourse.codecombat.com/u/kavacha)\
**Post date:** [October 26, 2016, 11:47pm UTC](https://discourse.codecombat.com/t/adventurer-northwest/9458/3 "2016-10-26T23:47:00Z")

</div>

Thanks for the tips! I almost couldn’t complete this level 😛 I still feel like I should watch a video / visualization of string search algorithm to understand it fully though.

---

<div class="post-metadata">

**Author:** ![Bryukh](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/bryukh/32/19597_2.png) [@Bryukh](https://discourse.codecombat.com/u/Bryukh)\
**Post date:** [October 27, 2016, 5:12am UTC](https://discourse.codecombat.com/t/adventurer-northwest/9458/4 "2016-10-27T05:12:49Z")

</div>

> [@juraj\_pechac](#):
>
> If j is the last letter of the word:

good point. Thx.

> [@kavacha](#):
>
> I almost couldn’t complete this level 😛 I still feel like I should watch a video / visualization of string search algorithm to understand it fully though.

That level should be placed after “Ice Hunter” where you can see the demo for this Naive algorithm.

---

<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:** [October 27, 2016, 7:47am UTC](https://discourse.codecombat.com/t/adventurer-northwest/9458/5 "2016-10-27T07:47:23Z")

</div>

I can’t get this one to work either. It doesn’t want to do any of the text searching code. But, Ice Hunter worked just fine!

---

<div class="post-metadata">

**Author:** ![Bryukh](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/bryukh/32/19597_2.png) [@Bryukh](https://discourse.codecombat.com/u/Bryukh)\
**Post date:** [October 27, 2016, 7:48am UTC](https://discourse.codecombat.com/t/adventurer-northwest/9458/6 "2016-10-27T07:48:36Z")

</div>

> [@dwhittaker](#):
>
> I can’t get this one to work either. It doesn’t want to do any of the text searching code. But, Ice Hunter worked just fine!

sessionID? code example? Please, give me something to understand your problem 🙂

---

<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:** [October 30, 2016, 1:54pm UTC](https://discourse.codecombat.com/t/adventurer-northwest/9458/7 "2016-10-30T13:54:52Z")

</div>

@juraj_pechac How about:

> `If j is equal to the position of the last letter in word `

As `j` is not a character letter itself but the index.

---

<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:** [October 30, 2016, 4:03pm UTC](https://discourse.codecombat.com/t/adventurer-northwest/9458/8 "2016-10-30T16:03:13Z")

</div>

@Bryukh finished the level without issue with my default gear for that point in the game.

When the level completed and I looked at the leaderboards it kicked me back to the world campaign selection:

 ![](https://us1.discourse-cdn.com/flex016/uploads/codecombat/original/2X/7/7dfb1362136181ae996ed4bbf89709c51f54178d.png)

I submitted a grammar patch  
I submitted a LUA patch

_note: LUA is having scoping issues so I had to create the additional function as a method on `pet` so that the other declared function could call `the pet.wordInText` function_

* * *

LUA patch information for players, go here if the patch is still in development for help with default code:

> [@LUA patches for levels in Cloudrip Mountain Campaign](https://discourse.codecombat.com/t/lua-patches-for-levels-in-cloudrip-mountain-campaign/9484):
>
> Northwest -- Your pet should find and then bring the potion to the hero. -- This new method checks if the word is in the text. pet.wordInText = function(self, text, word) -- Iterate through each character in the text. for i=1, string.len(text) - string.len(word) + 1, 1 do -- For each character in text loop through each character in word. for j=1, #word + 1, 1 do -- Store the shifted index i + j. local shiftedIndex = i + j -- If a …

---

<div class="post-metadata">

**Author:** ![juraj\_pechac](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/juraj_pechac/32/4987_2.png) [@juraj\_pechac](https://discourse.codecombat.com/u/juraj_pechac)\
**Post date:** [October 30, 2016, 5:26pm UTC](https://discourse.codecombat.com/t/adventurer-northwest/9458/9 "2016-10-30T17:26:32Z")

</div>

You are right, this is most precise.

---

<div class="post-metadata">

**Author:** ![Bryukh](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/bryukh/32/19597_2.png) [@Bryukh](https://discourse.codecombat.com/u/Bryukh)\
**Post date:** [October 31, 2016, 4:54am UTC](https://discourse.codecombat.com/t/adventurer-northwest/9458/10 "2016-10-31T04:54:08Z")

</div>

Don’t forget about lengths of comments line. The result length (with whitespaces) should not be more than 59 characters.

---

<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 5, 2016, 3:00pm UTC](https://discourse.codecombat.com/t/adventurer-northwest/9458/11 "2016-11-05T15:00:01Z")

</div>

@Bryukh Thank you for reminding me. Would we then just break out the comment into 2 lines vs 1?

---

<div class="post-metadata">

**Author:** ![Bryukh](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/bryukh/32/19597_2.png) [@Bryukh](https://discourse.codecombat.com/u/Bryukh)\
**Post date:** [November 5, 2016, 6:21pm UTC](https://discourse.codecombat.com/t/adventurer-northwest/9458/12 "2016-11-05T18:21:56Z")

</div>

If it’s possible to write it in one line, then it’s better. Otherwise, two lines are acceptable, but it’s better to make them similar in size.

---

<div class="post-metadata">

**Author:** ![Maksym\_Radchenko](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/maksym_radchenko/32/5750_2.png) [@Maksym\_Radchenko](https://discourse.codecombat.com/u/Maksym_Radchenko)\
**Post date:** [February 20, 2017, 6:22pm UTC](https://discourse.codecombat.com/t/adventurer-northwest/9458/13 "2017-02-20T18:22:55Z")

</div>

default function was too complicated. so

* * *

 ![](https://us1.discourse-cdn.com/flex016/uploads/codecombat/original/2X/d/dffd4b84031f2f690802bf1a697d028534add641.png)

---

<div class="post-metadata">

**Author:** ![Bryukh](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/bryukh/32/19597_2.png) [@Bryukh](https://discourse.codecombat.com/u/Bryukh)\
**Post date:** [February 20, 2017, 6:37pm UTC](https://discourse.codecombat.com/t/adventurer-northwest/9458/14 "2017-02-20T18:37:41Z")

</div>

Do you think I don’t know how to solve most of the levels with one-liners? 😉

---

<div class="post-metadata">

**Author:** ![Maksym\_Radchenko](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/maksym_radchenko/32/5750_2.png) [@Maksym\_Radchenko](https://discourse.codecombat.com/u/Maksym_Radchenko)\
**Post date:** [February 20, 2017, 6:39pm UTC](https://discourse.codecombat.com/t/adventurer-northwest/9458/15 "2017-02-20T18:39:32Z")

</div>

actually I was reading description of the default function and don’t get how it’s work

---

<div class="post-metadata">

**Author:** ![CantMelee](https://avatars.discourse-cdn.com/v4/letter/c/958977/32.png) [@CantMelee](https://discourse.codecombat.com/u/CantMelee)\
**Post date:** [February 22, 2017, 4:24am UTC](https://discourse.codecombat.com/t/adventurer-northwest/9458/16 "2017-02-22T04:24:14Z")

</div>

This one part is ruining the entire level for me.

> **[Gyazo](https://gyazo.com/38d9fe8f25196501da1394b0ed77603d)**
>
> ​

  
I can’t understand for the life of me how to do this.  
(Includes one of my many failed attempts)

---

<div class="post-metadata">

**Author:** ![Bryukh](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/bryukh/32/19597_2.png) [@Bryukh](https://discourse.codecombat.com/u/Bryukh)\
**Post date:** [February 22, 2017, 4:57am UTC](https://discourse.codecombat.com/t/adventurer-northwest/9458/17 "2017-02-22T04:57:55Z")

</div>

Have you played desert levels (and some mountains) about array indexes?

`word.length - 1`

---

<div class="post-metadata">

**Author:** ![CantMelee](https://avatars.discourse-cdn.com/v4/letter/c/958977/32.png) [@CantMelee](https://discourse.codecombat.com/u/CantMelee)\
**Post date:** [February 22, 2017, 6:34pm UTC](https://discourse.codecombat.com/t/adventurer-northwest/9458/18 "2017-02-22T18:34:10Z")

</div>

Yes I have, they tend to confuse me a lot though.

Also, I changed my solution to your line and nothing changed 😕

---

<div class="post-metadata">

**Author:** ![Bryukh](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/bryukh/32/19597_2.png) [@Bryukh](https://discourse.codecombat.com/u/Bryukh)\
**Post date:** [February 23, 2017, 5:46am UTC](https://discourse.codecombat.com/t/adventurer-northwest/9458/19 "2017-02-23T05:46:36Z")

</div>

It wasn’t a line. Just an expression. So you passed all arrays levels before but don’t know how to get the last index of the array(string).

I can’t say why you code doesn’t work without the code.
