-
-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Elm Track - Robot Simulator - All tests passed but not able to complete the exercise #33
Comments
Hi and welcome to Exercism! 👋 Thanks for opening an issue 🙂
|
@exercism/haskell can you take a look? |
I guess it has to do with my solution, cause I tried now with the example solution and it worked normally. It seems like my code broke the page: I'm posting it therfore here down. It's dirty beginner spaghetti code. Sorry for that. module RobotSimulator exposing
( Bearing(..)
, Robot
, advance
, defaultRobot
, simulate
, turnLeft
, turnRight
)
type Bearing
= North
| East
| South
| West
type alias Robot =
{ bearing : Bearing
, coordinates : { x : Int, y : Int }
}
defaultRobot : Robot
defaultRobot =
{ bearing = North
, coordinates = { x = 0, y = 0 }
}
turnRight : Robot -> Robot
turnRight robot =
let
turnRightBearing =
case robot.bearing of
North -> East
East -> South
South -> West
West -> North
in
{ robot | bearing = turnRightBearing }
turnLeft : Robot -> Robot
turnLeft robot =
let
turnLeftBearing =
case robot.bearing of
North -> West
East -> North
South -> East
West -> South
in
{ robot | bearing = turnLeftBearing }
advance : Robot -> Robot
advance robot =
case robot.bearing of
North ->
let
previousCoordinates = robot.coordinates
myY = robot.coordinates.y
in
{ robot | coordinates = { previousCoordinates | y = myY + 1}}
East ->
let previousCoordinates = robot.coordinates
myX = robot.coordinates.x
in
{ robot | coordinates = { previousCoordinates | x = myX + 1}}
South ->
let previousCoordinates = robot.coordinates
myY = robot.coordinates.y
in
{ robot | coordinates = { previousCoordinates | y = myY - 1}}
West ->
let previousCoordinates = robot.coordinates
myX = robot.coordinates.x
in
{ robot | coordinates = { previousCoordinates | x = myX + 1}}
execute : Char -> Robot -> Robot
execute directionChar thisRobot =
case directionChar of
'A' -> advance thisRobot
'L' -> turnLeft thisRobot
'R' -> turnRight thisRobot
_ -> thisRobot
simulate : String -> Robot -> Robot
simulate directions robot =
let
charList = String.toList directions
in
case charList of
[] -> robot
first :: rest ->
execute first (simulate (List.foldl (++) "" (List.map (\x -> String.fromChar x) rest )) robot) |
@ErikSchierboom Could you take a look at this one pls? |
I've tested this locally, and the problem seems to be in the produced {
"version": 3,
"status": "fail",
"tests": [
{
"name": "coordinates",
"task_id": null,
"status": "pass",
"message": null,
"output": null,
"test_code": "Expect.equal {x = 0, y = 0} defaultRobot.coordinates"
},
{
"name": "bearing",
"task_id": null,
"status": "pass",
"message": null,
"output": null,
"test_code": "Expect.equal North defaultRobot.bearing"
},
{
"name": "coordinates",
"task_id": null,
"status": "pass",
"message": null,
"output": null,
"test_code": "Robot anyBearing {x = -1, y = 1} |> ..coordinates\n |> Expect.equal {x = -1, y = 1}"
},
{
"name": "bearing",
"task_id": null,
"status": "pass",
"message": null,
"output": null,
"test_code": "Robot South anyCoordinates |> ..bearing\n |> Expect.equal South"
},
{
"name": "step 0",
"task_id": null,
"status": "pass",
"message": null,
"output": null,
"test_code": "Robot North {x = 0, y = 0} |> advance |> ..coordinates\n |> Expect.equal {x = 0, y = 1}"
},
{
"name": "step 1",
"task_id": null,
"status": "pass",
"message": null,
"output": null,
"test_code": "Robot North {x = 0, y = 0} |> advance |> ..bearing\n |> Expect.equal North"
},
{
"name": "step 2",
"task_id": null,
"status": "pass",
"message": null,
"output": null,
"test_code": "Robot East {x = 0, y = 0} |> advance |> ..coordinates\n |> Expect.equal {x = 1, y = 0}"
},
{
"name": "step 3",
"task_id": null,
"status": "pass",
"message": null,
"output": null,
"test_code": "Robot East {x = 0, y = 0} |> advance |> ..bearing\n |> Expect.equal East"
},
{
"name": "step 0",
"task_id": null,
"status": "pass",
"message": null,
"output": null,
"test_code": "Robot South {x = 0, y = 0} |> advance |> ..coordinates\n |> Expect.equal {x = 0, y = -1}"
},
{
"name": "step 1",
"task_id": null,
"status": "pass",
"message": null,
"output": null,
"test_code": "Robot South {x = 0, y = 0} |> advance |> ..bearing\n |> Expect.equal South"
},
{
"name": "step 2",
"task_id": null,
"status": "pass",
"message": null,
"output": null,
"test_code": "Robot West {x = 0, y = 0} |> advance |> ..coordinates\n |> Expect.equal {x = -1, y = 0}"
},
{
"name": "step 3",
"task_id": null,
"status": "pass",
"message": null,
"output": null,
"test_code": "Robot West {x = 0, y = 0} |> advance |> ..bearing\n |> Expect.equal West"
},
{
"name": "coordinates",
"task_id": null,
"status": "pass",
"message": null,
"output": null,
"test_code": "Robot North {x = 0, y = 0} |> simulate \"LAAARALA\" |> ..coordinates\n |> Expect.equal {x = -4, y = 1}"
},
{
"name": "bearing",
"task_id": null,
"status": "pass",
"message": null,
"output": null,
"test_code": "Robot North {x = 0, y = 0} |> simulate \"LAAARALA\" |> ..bearing\n |> Expect.equal West"
},
{
"name": "coordinates",
"task_id": null,
"status": "pass",
"message": null,
"output": null,
"test_code": "Robot East {x = 2, y = -7} |> simulate \"RRAAAAALA\" |> ..coordinates\n |> Expect.equal {x = -3, y = -8}"
},
{
"name": "bearing",
"task_id": null,
"status": "pass",
"message": null,
"output": null,
"test_code": "Robot East {x = 2, y = -7} |> simulate \"RRAAAAALA\" |> ..bearing\n |> Expect.equal South"
},
{
"name": "coordinates",
"task_id": null,
"status": "pass",
"message": null,
"output": null,
"test_code": "Robot South {x = 8, y = 4} |> simulate \"LAAARRRALLLL\" |> ..coordinates\n |> Expect.equal {x = 11, y = 5}"
},
{
"name": "bearing",
"task_id": null,
"status": "pass",
"message": null,
"output": null,
"test_code": "Robot South {x = 8, y = 4} |> simulate \"LAAARRRALLLL\" |> ..bearing\n |> Expect.equal North"
}
]
} The |
@552020 @ErikSchierboom thanks for the report. We are indeed aware of this bug. This is related to our test parser that extracts the test code for the test runner report. It has been fixed as seen in #29. This will be rolled out as soon as I take some time updating the test runner, which I suspect is next week. |
Excellent! |
Hum, my bad, the fix was done by removing the I'm reopening this issue then because It should be solved since the exercise was updated (exercism/elm#463). Is it possible @552020 that you are still running the tests of the old version (previous to our fix), how could we check that @ErikSchierboom ? |
@mpizenberg I don't think it is fixed. I've upgraded the exercise to the latest version (which you can do on the website) and tested it in the online editor, and found the same issue. |
I took a look, there is definitely a problem, and it's not exactly the same as before. Basically, the test code extractor fails on the 8 tests in |> List.indexedMap (\i e -> test ("step " ++ String.fromInt i) (\() -> e)) The code extractor cannot work with |
@552020 the tests have been updated, please try again. You should get some failing tests this time, because your |
Thanks for reporting / fixing this everyone, I've been away on holiday . |
Thank you everyone for fixing this. @jiegillet I run the updated exercise with my old spaghetti code and it works as it is. I will open nonetheless a mentoring request, cause I struggled a lot with this one. Probably this is not the right place for this question and I should open another issue for it: sometimes, as a learner, you would need mentoring before you pass all the tests. Probably this is not possible cause you want to avoid too many mentoring requests but in certain cases, it would help to be mentored before you pass all the tests. I'm stuck for example on the Pythagorean Triplets challenge. I solved it conceptually with a brute force approach based on recursion which is too expensive memory-wise and I get a stackoverflow on the test with the big numbers. I tried to refactor it but my alternative solutions give similar problems and now I'm trying to understand the maths behind the triplet and deliver a mathematical solution. I think that for cases like these, where the learner came up with a valid working solution with some flaws it would be meaningful to allow him to open a mentoring request. If you think that is issue/proposal is worth to be discussed I can open a separate issue. |
Thanks for fixing @jiegillet ! |
And by the way, what I wrote is not true. My spaghetti code solution throws 4 errors, so everything is fine. I forgot that I've copied the example solution in the editor. |
@552020 I'm glad that your code fails now (lol). I will close the issue then. Concerning receiving mentorship, there is trick: if you submit via the CLI you should be able to ask for it even if the tests fail, but your request is a common one, please check exercism/exercism to see if there is an issue open already. Concerning pythagorean triples, my favorite way to solve the exercise very efficiently is via this mathematical trick, (there are also a bunch ways on that link). |
@jiegillet Thank you for the trick suggestion. I found a forgotten open issue/suggestion about it: exercism/exercism#6187 |
I tried many times also to submit the solution through the CLI: all tests have been passed but it says 'failed' nonetheless.
The text was updated successfully, but these errors were encountered: