Skip to content
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

diamond exercise fails to build, while it build fine locally and all tests pass #1022

Closed
Grenkin1988 opened this issue Nov 2, 2021 · 6 comments

Comments

@Grenkin1988
Copy link
Contributor

Given:

module Diamond
let make (target: char) =
    let witeLine letterCount (line: int, letter: char) =
        let beforeAndAfter = "".PadRight(letterCount - line - 1)
        let middleLenght = if line = 0 then 0 else (line * 2 - 1)
        let middle = "".PadRight(middleLenght)
        if letter = 'A' then
            sprintf "%s%c%s" beforeAndAfter letter beforeAndAfter
        else
            sprintf "%s%c%s%c%s" beforeAndAfter letter middle letter beforeAndAfter
    
    let usedLetters = ['A'..target] |> List.mapi (fun x y -> (x,y))
    usedLetters
    |> List.rev |> List.tail
    |> List.append usedLetters
    |> List.map (fun (line, letter) -> witeLine usedLetters.Length (line, letter))
    |> List.reduce (fun x y -> sprintf "%s\n%s" x y)

When I submit code
Then it fails with not informative error:
image

@ErikSchierboom
Copy link
Member

This is a really weird issue as I can't reproduce it locally (using the test runner).

@Grenkin1988
Copy link
Contributor Author

module SimpleLinkedList

type LinkedList<'a> =
    | Empty
    | List of current : 'a * next : LinkedList<'a>

let nil = Empty

let create x n = List(x, n)

let isNil x = x = nil

let next x = match x with List(_,n) -> n | Empty -> x

let datum x = match x with List(x,_) -> x | Empty -> failwith "The list is empty"

let toList x =
    let rec build x list =
        match x with
        | Empty -> list
        | List(cur, next) ->
            List.append list [cur] |> build next
    build x []

let fromList xs =
    let rec build list acc =
        match list with
        | [] -> acc
        | head :: tail -> create head acc |> build tail
    build (List.rev xs) nil

let reverse x =
    let rec build x rev =
        match x with
        | Empty -> rev
        | List(cur, next) ->
            create cur rev
            |> build next
    build x nil

@ErikSchierboom
Here is another one, again I submit code and it give error without any information

Am I cursed?

@ErikSchierboom
Copy link
Member

That seems unlikely. I'll look into it

@ErikSchierboom
Copy link
Member

Both problems are due to the test files using xUnit attributes that are not [<Fact>]. This is a known issue and something that @martinfreedman is looking into.

@ErikSchierboom
Copy link
Member

See #1029 (comment) for the discussion.

@Grenkin1988
Copy link
Contributor Author

Looks like it is fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants