Ruby N-Queens implementation