# Could someone explain me what to do(Match Cord, Computer Science 6)?

I’ve been stuck in the level number 12 of Computer Science 6, Match Cord (Javascript).
I don’t know how to complete it and I’d like to be explained what to do. I don’t want the code, just an explaination of what should I do.

``````// Ogres mined the field to protect their Chieftain.
// But we can use the "domino" effect get our target.
// The scout has prepared the map of the minefield.
// All mines are placed the same distance apart.
// The map is an array of strings, where "x" is a mine and "." is nothing.
// The first row in the array is the row nearest to the hero.

// The map and helpful constants are listed below.
var fieldMap = hero.findFriends()[0].getMap();

var mine = "x";
var empty = ".";
var mineDistance = 5;
var firstXPos = 15;
var firstYPos = 40;

// Find which starting mine connects to the ogre Chieftain.

var resultColumn = 21; // ∆ Change this to your actual result!

hero.say("I think it's column number: " + resultColumn);
var resultX = resultColumn * mineDistance + firstXPos;
hero.moveXY(resultX, hero.pos.y);
hero.moveXY(resultX, firstYPos);

``````
1 Like

Hi @PAL_7, welcome to the CodeCombat Discourse.
If you need help with a level, please post your code and follow the instructions in the FAQ on how to format it so we can read it.
Thanks,

1 Like

Bumped by @Chaboi_3000

I’m curious too, what exactly is the approach we should be taking for this code? I figured out how to send my hero to the right starting point and complete the level, but I don’t think that is what was intended. My answer wasn’t found from a variable after a line of code, I just told him what column that tracks back from the Chieftain by visually following it.

I think the idea is to trace the mines back to the Chieftain by code using the array and distance checks. Although the comments are minimal and don’t provide much direction on how to accomplish that code. I saw another post on this from a while back and they brought up some interesting ideas.

Feedback: Match Cord from 2016

Update: After a lot of time pondering what tactics to use, I was able to complete the level by writing the full code to trace the mines to the chieftain. I started at the chieftain and worked my way back one mine at a time. I have submitted it with two different seed mine arrangements and the code put the hero where he needed to be so far.

2 Likes

I did what @brooksy125 did as well, I just got lucky with submitting it.
To do it properly (i say properly, it doesn’t really matter as long as it works) you need to iterate through the array and do stuff. … that’s why I did the level like I did, I don’t really get that kind of 2D array thing.

1 Like

I don’t wanna give too much, but my best hint for this level is that you want to visualize a map. And the griffin friend already drew out a map for you, meaning that it is something like:

``````.............C..........|
.............x..........|
x.....x......x.....xxx..|
x.....x......xxx...x....|
xx....x........x...x....|
.x....x........x...x....|
.x....x........x...x....|
........................|
............H...........|
________________________

Note:
H=Hero
C=Chieftain
.=Empty space
x=Mine

``````

The field map array looks something like this above. When H is the hero and C is the Chieftain. You need to determine if the nth mine/empty in the array is a mine or not, and the location in the array and build from there.

2 Likes