Death First Search - Episode 1 - Puzzle discussion

What is your build_graph method?
I solved this puzzle with pure math (ie no graph).

/u/player_one showed me a great trick to force the debug print statements to go:

sys.stderr.flush()

Once the code started outputting my debug messages it became clear that my graph + breadth first search are simply too slow for the triple star test case. As Nicolas said, I will have to convert the graph into a simpler method that runs in the time allotted. It was fun to write the full optimal search, but I need to trim it to just getting a good enough answer in time.

Thanks all for your help!

1 Like

C++. Having a few problems with this one. I keep getting segmentation error. Iā€™ve tested my initialization of the array in another IDE and itā€™s working correctly.

int **arr;
for (int i = 0; i < N; i++) {
arr[i] = new int[N];
}
for (int i = 0; i < N; i++) {
for (int j = 0; j < N; j++) {
arr[i][j] = 0;
}
}

But when I attempt later to print out the matrix in the game loop (to confirm itā€™s being generated correctly) I get segmentation error with:
for (int i = 0; i < N; i++) {
for (int j = 0; j < N; j++) {
cerr << arr[i][j] << flush;
}
cerr << endl;
}

Any thoughts on where iā€™m going wrong?

The variable arr is never initialized.

1 Like

Cheers, ended up missing:

arr = new int*[N]; prior to the first for loop

and iā€™d positioned the construction of matrix before the Cin call for N. So it previously didnā€™t have a size/value.

I had the same problem, and I was using a FOR to cycle from 0 to count(NODES)-1. and the bot(SI) was on the very last NODE wich I was not cheking.

` for (int i = 0; i < L; i++) {
int N1; // N1 and N2 defines a link between these nodes
int N2;
scanf("%d%d", &N1, &N2);
}

How does N1 and N2 store all the conections? I dont understand! I expected an array!
Im thinking that only stores the last input!
Can someone help me! :)`

As you said it does juste save the last input, but nobody forbids you to create an array to save it.

Just to be sure it is working for you, try outputting the nodes you think would be best to cut, eg;

cerr << "1 3" << endl;
cerr << "2 3" << endl;

Just tacking those on the end of the main while loop should work as it seems to ignore already cut paths.

I wonder if youā€™re overstepping the array boundaries, try i<N-1;

Very fun, I have obtained 100% with submission.

I have a suggestion but I donā€™t know if this is the right way to submit a feedback: ā€œI think the validation is a bit naiveā€.

In detail:
The problem definition permits cases where simple approaches do not suffice, for example, the case of a node with two or more edges to gates (yes a node adjacent to a lot of gates).
When skynet agent moves on this node you have lost, and a right algorithm should take this into account by stopping skynet to move into this node.

I think that adding these cases to the validations may better discern partial(wrong) solutions from right solutions.

Imho
Regards

@fabtar try Skynet Revolution- Episode 2

1 Like

My solution. I have 61 links left in the IDE, and 52 links left in the assessment.

1 Like

like mine

[code removed]

I just finished testing all the PHP solutions to Skynet Revolution - Episode 1, and upvoted all the ones who made it in 24 moves or less :slight_smile:

I just finished the first episode and managed to complete the 4th test case with 52 links remaining, but I still havenā€™t gotten the ambush achievement. I have submitted it several times. I programmed it in java.

EDIT: nevermind, I just found the results of the actual tests and they were below 50.

Time ago I have posted about the validation tests being a bit ā€œeasyā€ and that are not covering the problem definition well.

I was wrong.

This is my fault, validation are just fine, I have wrongly read the problem statement and misunderstood. They were just ok, with my code I have covered more difficult cases than required.
My fault

Hi, Iā€™m having a bit of a problem with Episode 1. My code works for all the tests, except the last one. In my infinite loop, I assign SI as follows:
SI = input()
but at this point, the program just freezes waiting for input. However, if I put
print(input(), file=sys.stderr)
it prints 37, which is the first position of the agent. Has anyone else had this problem? I know we arenā€™t meant to put too much code up here, so I donā€™t want to break that rule, but also worry it may be too little information

Can someone tell me why this is a failure in the test? The agent hasnā€™t reached the gateway but the test is considered fail.

Post a link to the replay (click the share icon beside the gear in the lower-right corner). My guess is that your code most likely either crashed or timed out.

  • danBhentschel
1 Like