Arrays [i + 1]?

Hi guys, i don't understand why this happen. Exist another way to use
math expression in arrays?

expected: [[" ", "X", "X", "X", " ", "X", "X", "X"], ["X", "X", "X",
"X", " ", " ", "X", "X"], ["X", "X", "X", "X", "A", " ", " ", "A"],
["X", "X", "X", " ", " ", " ", " ", " "], ["X", "X", "X", " ", " ", " ",
"A", " "], [" ", "X", " ", "A", " ", " ", " ", " "], [" ", " ", " ", "
", " ", " ", " ", " "]]
     got: [[" ", "X", "X", "X", " ", "X", "X", "X", "X"], ["X", "X",
"X", "X", " ", " ", "X", "X"], ["X", "X", "X", "X", "A", " ", " ", "A"],
["X", "X", "X", " ", " ", " ", " ", " "], ["X", "X", "X", " ", " ", " ",
"A", " "], [" ", "X", " ", "A", " ", " ", " ", " "], [" ", " ", "X", "
", " ", " ", "X", "X"]] (using ==)
./testes_spec.rb:104:in `block (2 levels) in <top (required)>'

The code is here:

(def Expande)

https://bitbucket.org/ronnyamarante/nuvem-de-cinzas/src/dea63a21e63b544899c9279e7abea45cadaaacdb/desafio.rb?at=master

Thanks!

···

--
Posted via http://www.ruby-forum.com/.

looking at the code, you are adding 'X" to the adjacent cells when an 'X'
is found in a given cell,
but what is the expected behaviour when a 'X' is found on an edge?

···

On Thu, Nov 21, 2013 at 2:30 PM, Ronny Amarante <lists@ruby-forum.com>wrote:

Hi guys, i don't understand why this happen. Exist another way to use
math expression in arrays?

expected: [[" ", "X", "X", "X", " ", "X", "X", "X"], ["X", "X", "X",
"X", " ", " ", "X", "X"], ["X", "X", "X", "X", "A", " ", " ", "A"],
["X", "X", "X", " ", " ", " ", " ", " "], ["X", "X", "X", " ", " ", " ",
"A", " "], [" ", "X", " ", "A", " ", " ", " ", " "], [" ", " ", " ", "
", " ", " ", " ", " "]]
     got: [[" ", "X", "X", "X", " ", "X", "X", "X", "X"], ["X", "X",
"X", "X", " ", " ", "X", "X"], ["X", "X", "X", "X", "A", " ", " ", "A"],
["X", "X", "X", " ", " ", " ", " ", " "], ["X", "X", "X", " ", " ", " ",
"A", " "], [" ", "X", " ", "A", " ", " ", " ", " "], [" ", " ", "X", "
", " ", " ", "X", "X"]] (using ==)
./testes_spec.rb:104:in `block (2 levels) in <top (required)>'

The code is here:

(def Expande)

https://bitbucket.org/ronnyamarante/nuvem-de-cinzas/src/dea63a21e63b544899c9279e7abea45cadaaacdb/desafio.rb?at=master

Thanks!

--
Posted via http://www.ruby-forum.com/\.

Chris Hulan wrote in post #1128203:

looking at the code, you are adding 'X" to the adjacent cells when an
'X'
is found in a given cell,
but what is the expected behaviour when a 'X' is found on an edge?

I fix it, but the result is the same..

···

--
Posted via http://www.ruby-forum.com/\.

I know nothing about tests, I am not able to help you in this matter

but I can tell you the following:

if !esperado[i-1][j].nil? esperado[i - 1][j] = "X"
     end if !esperado[i+1][j].nil?
esperado[i+1][j] = "X" end if
!esperado[i][j-1].nil? esperado[i][j-1] = "X"
end if !esperado[i][j+1].nil? esperado[i][j+1]
= "X" end

None of these if will evaluate to false, lets say you are at position
[0, 0] and apply the [i - 1][j]

it will become [-1, 0]

and index -1 is the last index of an array

example:

irb(main):001:0> array = ['first', 'second', 'third']
=> ["first", "second", "third"]
irb(main):002:0> array[0]
=> "first"
irb(main):003:0> array[-1]
=> "third"

···

On 21 November 2013 17:52, Chris Hulan <chris.hulan@gmail.com> wrote:

looking at the code, you are adding 'X" to the adjacent cells when an 'X'
is found in a given cell,
but what is the expected behaviour when a 'X' is found on an edge?

On Thu, Nov 21, 2013 at 2:30 PM, Ronny Amarante <lists@ruby-forum.com>wrote:

Hi guys, i don't understand why this happen. Exist another way to use
math expression in arrays?

expected: [[" ", "X", "X", "X", " ", "X", "X", "X"], ["X", "X", "X",
"X", " ", " ", "X", "X"], ["X", "X", "X", "X", "A", " ", " ", "A"],
["X", "X", "X", " ", " ", " ", " ", " "], ["X", "X", "X", " ", " ", " ",
"A", " "], [" ", "X", " ", "A", " ", " ", " ", " "], [" ", " ", " ", "
", " ", " ", " ", " "]]
     got: [[" ", "X", "X", "X", " ", "X", "X", "X", "X"], ["X", "X",
"X", "X", " ", " ", "X", "X"], ["X", "X", "X", "X", "A", " ", " ", "A"],
["X", "X", "X", " ", " ", " ", " ", " "], ["X", "X", "X", " ", " ", " ",
"A", " "], [" ", "X", " ", "A", " ", " ", " ", " "], [" ", " ", "X", "
", " ", " ", "X", "X"]] (using ==)
./testes_spec.rb:104:in `block (2 levels) in <top (required)>'

The code is here:

(def Expande)

https://bitbucket.org/ronnyamarante/nuvem-de-cinzas/src/dea63a21e63b544899c9279e7abea45cadaaacdb/desafio.rb?at=master

Thanks!

--
Posted via http://www.ruby-forum.com/\.

Only correcting myself
none of the ifs with minus operations

···

On 23 November 2013 00:23, Rafael Moraes <rafaelmoraesdefreitas@gmail.com>wrote:

I know nothing about tests, I am not able to help you in this matter

but I can tell you the following:

if !esperado[i-1][j].nil? esperado[i - 1][j] = "X" end if !esperado[i+1][j].nil? esperado[i+1][j] = "X" end if !esperado[i][j-1].nil? esperado[i][j-1] = "X" end if !esperado[i][j+1].nil? esperado[i][j+1] = "X" end

None of these if will evaluate to false, lets say you are at position [0, 0] and apply the [i - 1][j]

it will become [-1, 0]

and index -1 is the last index of an array

example:

irb(main):001:0> array = ['first', 'second', 'third']
=> ["first", "second", "third"]
irb(main):002:0> array[0]
=> "first"
irb(main):003:0> array[-1]
=> "third"

On 21 November 2013 17:52, Chris Hulan <chris.hulan@gmail.com> wrote:

looking at the code, you are adding 'X" to the adjacent cells when an 'X'
is found in a given cell,
but what is the expected behaviour when a 'X' is found on an edge?

On Thu, Nov 21, 2013 at 2:30 PM, Ronny Amarante <lists@ruby-forum.com>wrote:

Hi guys, i don't understand why this happen. Exist another way to use
math expression in arrays?

expected: [[" ", "X", "X", "X", " ", "X", "X", "X"], ["X", "X", "X",
"X", " ", " ", "X", "X"], ["X", "X", "X", "X", "A", " ", " ", "A"],
["X", "X", "X", " ", " ", " ", " ", " "], ["X", "X", "X", " ", " ", " ",
"A", " "], [" ", "X", " ", "A", " ", " ", " ", " "], [" ", " ", " ", "
", " ", " ", " ", " "]]
     got: [[" ", "X", "X", "X", " ", "X", "X", "X", "X"], ["X", "X",
"X", "X", " ", " ", "X", "X"], ["X", "X", "X", "X", "A", " ", " ", "A"],
["X", "X", "X", " ", " ", " ", " ", " "], ["X", "X", "X", " ", " ", " ",
"A", " "], [" ", "X", " ", "A", " ", " ", " ", " "], [" ", " ", "X", "
", " ", " ", "X", "X"]] (using ==)
./testes_spec.rb:104:in `block (2 levels) in <top (required)>'

The code is here:

(def Expande)

https://bitbucket.org/ronnyamarante/nuvem-de-cinzas/src/dea63a21e63b544899c9279e7abea45cadaaacdb/desafio.rb?at=master

Thanks!

--
Posted via http://www.ruby-forum.com/\.

Note that Ruby arrays re-size as needed

so when j = 7 (the last index of a 8 element array)
and you assign a value to j+1, then the array is expanded to 9 elements and
the value stored

···

On Fri, Nov 22, 2013 at 9:26 PM, Rafael Moraes < rafaelmoraesdefreitas@gmail.com> wrote:

Only correcting myself
none of the ifs with minus operations

On 23 November 2013 00:23, Rafael Moraes <rafaelmoraesdefreitas@gmail.com>wrote:

I know nothing about tests, I am not able to help you in this matter

but I can tell you the following:

if !esperado[i-1][j].nil? esperado[i - 1][j] = "X" end if !esperado[i+1][j].nil? esperado[i+1][j] = "X" end if !esperado[i][j-1].nil? esperado[i][j-1] = "X" end if !esperado[i][j+1].nil? esperado[i][j+1] = "X" end

None of these if will evaluate to false, lets say you are at position [0, 0] and apply the [i - 1][j]

it will become [-1, 0]

and index -1 is the last index of an array

example:

irb(main):001:0> array = ['first', 'second', 'third']
=> ["first", "second", "third"]
irb(main):002:0> array[0]
=> "first"
irb(main):003:0> array[-1]
=> "third"

On 21 November 2013 17:52, Chris Hulan <chris.hulan@gmail.com> wrote:

looking at the code, you are adding 'X" to the adjacent cells when an
'X' is found in a given cell,
but what is the expected behaviour when a 'X' is found on an edge?

On Thu, Nov 21, 2013 at 2:30 PM, Ronny Amarante <lists@ruby-forum.com>wrote:

Hi guys, i don't understand why this happen. Exist another way to use
math expression in arrays?

expected: [[" ", "X", "X", "X", " ", "X", "X", "X"], ["X", "X", "X",
"X", " ", " ", "X", "X"], ["X", "X", "X", "X", "A", " ", " ", "A"],
["X", "X", "X", " ", " ", " ", " ", " "], ["X", "X", "X", " ", " ", " ",
"A", " "], [" ", "X", " ", "A", " ", " ", " ", " "], [" ", " ", " ", "
", " ", " ", " ", " "]]
     got: [[" ", "X", "X", "X", " ", "X", "X", "X", "X"], ["X", "X",
"X", "X", " ", " ", "X", "X"], ["X", "X", "X", "X", "A", " ", " ", "A"],
["X", "X", "X", " ", " ", " ", " ", " "], ["X", "X", "X", " ", " ", " ",
"A", " "], [" ", "X", " ", "A", " ", " ", " ", " "], [" ", " ", "X", "
", " ", " ", "X", "X"]] (using ==)
./testes_spec.rb:104:in `block (2 levels) in <top (required)>'

The code is here:

(def Expande)

https://bitbucket.org/ronnyamarante/nuvem-de-cinzas/src/dea63a21e63b544899c9279e7abea45cadaaacdb/desafio.rb?at=master

Thanks!

--
Posted via http://www.ruby-forum.com/\.

@Chris Hulan,
I thought I could improve that code, so I made this
https://bitbucket.org/rafaelmoraesdefreitas/nuvem-de-cinzas/src/303ae3987a83a0772ad886b7c2bbbc4e4283d751/desafio.rb?at=master

Could you look at it and come with some critics and/or advices?

···

On 23 November 2013 14:55, Chris Hulan <chris.hulan@gmail.com> wrote:

Note that Ruby arrays re-size as needed

so when j = 7 (the last index of a 8 element array)
and you assign a value to j+1, then the array is expanded to 9 elements
and the value stored

On Fri, Nov 22, 2013 at 9:26 PM, Rafael Moraes < > rafaelmoraesdefreitas@gmail.com> wrote:

Only correcting myself
none of the ifs with minus operations

On 23 November 2013 00:23, Rafael Moraes <rafaelmoraesdefreitas@gmail.com >> > wrote:

I know nothing about tests, I am not able to help you in this matter

but I can tell you the following:

if !esperado[i-1][j].nil? esperado[i - 1][j] = "X" end if !esperado[i+1][j].nil? esperado[i+1][j] = "X" end if !esperado[i][j-1].nil? esperado[i][j-1] = "X" end if !esperado[i][j+1].nil? esperado[i][j+1] = "X" end

None of these if will evaluate to false, lets say you are at position [0, 0] and apply the [i - 1][j]

it will become [-1, 0]

and index -1 is the last index of an array

example:

irb(main):001:0> array = ['first', 'second', 'third']
=> ["first", "second", "third"]
irb(main):002:0> array[0]
=> "first"
irb(main):003:0> array[-1]
=> "third"

On 21 November 2013 17:52, Chris Hulan <chris.hulan@gmail.com> wrote:

looking at the code, you are adding 'X" to the adjacent cells when an
'X' is found in a given cell,
but what is the expected behaviour when a 'X' is found on an edge?

On Thu, Nov 21, 2013 at 2:30 PM, Ronny Amarante <lists@ruby-forum.com>wrote:

Hi guys, i don't understand why this happen. Exist another way to use
math expression in arrays?

expected: [[" ", "X", "X", "X", " ", "X", "X", "X"], ["X", "X", "X",
"X", " ", " ", "X", "X"], ["X", "X", "X", "X", "A", " ", " ", "A"],
["X", "X", "X", " ", " ", " ", " ", " "], ["X", "X", "X", " ", " ", "
",
"A", " "], [" ", "X", " ", "A", " ", " ", " ", " "], [" ", " ", " ", "
", " ", " ", " ", " "]]
     got: [[" ", "X", "X", "X", " ", "X", "X", "X", "X"], ["X", "X",
"X", "X", " ", " ", "X", "X"], ["X", "X", "X", "X", "A", " ", " ",
"A"],
["X", "X", "X", " ", " ", " ", " ", " "], ["X", "X", "X", " ", " ", "
",
"A", " "], [" ", "X", " ", "A", " ", " ", " ", " "], [" ", " ", "X", "
", " ", " ", "X", "X"]] (using ==)
./testes_spec.rb:104:in `block (2 levels) in <top (required)>'

The code is here:

(def Expande)

https://bitbucket.org/ronnyamarante/nuvem-de-cinzas/src/dea63a21e63b544899c9279e7abea45cadaaacdb/desafio.rb?at=master

Thanks!

--
Posted via http://www.ruby-forum.com/\.

the changes look like they ensure you don't add elements, which i'm
guessing is the desired behaviour

the loop at line 42-44 looks like its setting all elements of mapa
to @fumaca, but i would guess you rather intend to copy the contents of
expansao?
In which case line 2 should be:
mapa[y] = expansao[y]

however that can be shortened to:
mapa = expansao

Since your are returning the array, do you really need to copy it to mapa??

···

On Sun, Nov 24, 2013 at 6:34 AM, Rafael Moraes < rafaelmoraesdefreitas@gmail.com> wrote:

@Chris Hulan,
I thought I could improve that code, so I made this

Bitbucket

Could you look at it and come with some critics and/or advices?

On 23 November 2013 14:55, Chris Hulan <chris.hulan@gmail.com> wrote:

Note that Ruby arrays re-size as needed

so when j = 7 (the last index of a 8 element array)
and you assign a value to j+1, then the array is expanded to 9 elements
and the value stored

On Fri, Nov 22, 2013 at 9:26 PM, Rafael Moraes < >> rafaelmoraesdefreitas@gmail.com> wrote:

Only correcting myself
none of the ifs with minus operations

On 23 November 2013 00:23, Rafael Moraes < >>> rafaelmoraesdefreitas@gmail.com> wrote:

I know nothing about tests, I am not able to help you in this matter

but I can tell you the following:

if !esperado[i-1][j].nil? esperado[i - 1][j] = "X" end if !esperado[i+1][j].nil? esperado[i+1][j] = "X" end if !esperado[i][j-1].nil? esperado[i][j-1] = "X" end if !esperado[i][j+1].nil? esperado[i][j+1] = "X" end

None of these if will evaluate to false, lets say you are at position [0, 0] and apply the [i - 1][j]

it will become [-1, 0]

and index -1 is the last index of an array

example:

irb(main):001:0> array = ['first', 'second', 'third']
=> ["first", "second", "third"]
irb(main):002:0> array[0]
=> "first"
irb(main):003:0> array[-1]
=> "third"

On 21 November 2013 17:52, Chris Hulan <chris.hulan@gmail.com> wrote:

looking at the code, you are adding 'X" to the adjacent cells when an
'X' is found in a given cell,
but what is the expected behaviour when a 'X' is found on an edge?

On Thu, Nov 21, 2013 at 2:30 PM, Ronny Amarante <lists@ruby-forum.com>wrote:

Hi guys, i don't understand why this happen. Exist another way to use
math expression in arrays?

expected: [[" ", "X", "X", "X", " ", "X", "X", "X"], ["X", "X", "X",
"X", " ", " ", "X", "X"], ["X", "X", "X", "X", "A", " ", " ", "A"],
["X", "X", "X", " ", " ", " ", " ", " "], ["X", "X", "X", " ", " ", "
",
"A", " "], [" ", "X", " ", "A", " ", " ", " ", " "], [" ", " ", " ", "
", " ", " ", " ", " "]]
     got: [[" ", "X", "X", "X", " ", "X", "X", "X", "X"], ["X", "X",
"X", "X", " ", " ", "X", "X"], ["X", "X", "X", "X", "A", " ", " ",
"A"],
["X", "X", "X", " ", " ", " ", " ", " "], ["X", "X", "X", " ", " ", "
",
"A", " "], [" ", "X", " ", "A", " ", " ", " ", " "], [" ", " ", "X", "
", " ", " ", "X", "X"]] (using ==)
./testes_spec.rb:104:in `block (2 levels) in <top (required)>'

The code is here:

(def Expande)

https://bitbucket.org/ronnyamarante/nuvem-de-cinzas/src/dea63a21e63b544899c9279e7abea45cadaaacdb/desafio.rb?at=master

Thanks!

--
Posted via http://www.ruby-forum.com/\.

oh, thanks for the reply
"fumaca" means smoke(in portuguese) I set @fumaca = 'X'
I thought it would be a good idea because I have to test it in line 29 if
the area is "covered with smoke"
I only get the areas where the smoke should expand(expansao)
@expansao has the IDs of the areas
and those areas in the map(mapa) will be marked with the value of @fumaca

···

On 24 November 2013 17:08, Chris Hulan <chris.hulan@gmail.com> wrote:

the changes look like they ensure you don't add elements, which i'm
guessing is the desired behaviour

the loop at line 42-44 looks like its setting all elements of mapa
to @fumaca, but i would guess you rather intend to copy the contents of
expansao?
In which case line 2 should be:
mapa[y] = expansao[y]

however that can be shortened to:
mapa = expansao

Since your are returning the array, do you really need to copy it to mapa??

On Sun, Nov 24, 2013 at 6:34 AM, Rafael Moraes < > rafaelmoraesdefreitas@gmail.com> wrote:

@Chris Hulan,
I thought I could improve that code, so I made this

Bitbucket

Could you look at it and come with some critics and/or advices?

On 23 November 2013 14:55, Chris Hulan <chris.hulan@gmail.com> wrote:

Note that Ruby arrays re-size as needed

so when j = 7 (the last index of a 8 element array)
and you assign a value to j+1, then the array is expanded to 9 elements
and the value stored

On Fri, Nov 22, 2013 at 9:26 PM, Rafael Moraes < >>> rafaelmoraesdefreitas@gmail.com> wrote:

Only correcting myself
none of the ifs with minus operations

On 23 November 2013 00:23, Rafael Moraes < >>>> rafaelmoraesdefreitas@gmail.com> wrote:

I know nothing about tests, I am not able to help you in this matter

but I can tell you the following:

if !esperado[i-1][j].nil? esperado[i - 1][j] = "X" end if !esperado[i+1][j].nil? esperado[i+1][j] = "X" end if !esperado[i][j-1].nil? esperado[i][j-1] = "X" end if !esperado[i][j+1].nil? esperado[i][j+1] = "X" end

None of these if will evaluate to false, lets say you are at position [0, 0] and apply the [i - 1][j]

it will become [-1, 0]

and index -1 is the last index of an array

example:

irb(main):001:0> array = ['first', 'second', 'third']
=> ["first", "second", "third"]
irb(main):002:0> array[0]
=> "first"
irb(main):003:0> array[-1]
=> "third"

On 21 November 2013 17:52, Chris Hulan <chris.hulan@gmail.com> wrote:

looking at the code, you are adding 'X" to the adjacent cells when an
'X' is found in a given cell,
but what is the expected behaviour when a 'X' is found on an edge?

On Thu, Nov 21, 2013 at 2:30 PM, Ronny Amarante <lists@ruby-forum.com >>>>>> > wrote:

Hi guys, i don't understand why this happen. Exist another way to use
math expression in arrays?

expected: [[" ", "X", "X", "X", " ", "X", "X", "X"], ["X", "X", "X",
"X", " ", " ", "X", "X"], ["X", "X", "X", "X", "A", " ", " ", "A"],
["X", "X", "X", " ", " ", " ", " ", " "], ["X", "X", "X", " ", " ",
" ",
"A", " "], [" ", "X", " ", "A", " ", " ", " ", " "], [" ", " ", " ",
"
", " ", " ", " ", " "]]
     got: [[" ", "X", "X", "X", " ", "X", "X", "X", "X"], ["X", "X",
"X", "X", " ", " ", "X", "X"], ["X", "X", "X", "X", "A", " ", " ",
"A"],
["X", "X", "X", " ", " ", " ", " ", " "], ["X", "X", "X", " ", " ",
" ",
"A", " "], [" ", "X", " ", "A", " ", " ", " ", " "], [" ", " ", "X",
"
", " ", " ", "X", "X"]] (using ==)
./testes_spec.rb:104:in `block (2 levels) in <top (required)>'

The code is here:

(def Expande)

https://bitbucket.org/ronnyamarante/nuvem-de-cinzas/src/dea63a21e63b544899c9279e7abea45cadaaacdb/desafio.rb?at=master

Thanks!

--
Posted via http://www.ruby-forum.com/\.

right, sorry, I missread the code

So does it work? :wink:

···

On Sun, Nov 24, 2013 at 2:42 PM, Rafael Moraes < rafaelmoraesdefreitas@gmail.com> wrote:

oh, thanks for the reply
"fumaca" means smoke(in portuguese) I set @fumaca = 'X'
I thought it would be a good idea because I have to test it in line 29 if
the area is "covered with smoke"
I only get the areas where the smoke should expand(expansao)
@expansao has the IDs of the areas
and those areas in the map(mapa) will be marked with the value of @fumaca

On 24 November 2013 17:08, Chris Hulan <chris.hulan@gmail.com> wrote:

the changes look like they ensure you don't add elements, which i'm
guessing is the desired behaviour

the loop at line 42-44 looks like its setting all elements of mapa
to @fumaca, but i would guess you rather intend to copy the contents of
expansao?
In which case line 2 should be:
mapa[y] = expansao[y]

however that can be shortened to:
mapa = expansao

Since your are returning the array, do you really need to copy it to
mapa??

On Sun, Nov 24, 2013 at 6:34 AM, Rafael Moraes < >> rafaelmoraesdefreitas@gmail.com> wrote:

@Chris Hulan,
I thought I could improve that code, so I made this

Bitbucket

Could you look at it and come with some critics and/or advices?

On 23 November 2013 14:55, Chris Hulan <chris.hulan@gmail.com> wrote:

Note that Ruby arrays re-size as needed

so when j = 7 (the last index of a 8 element array)
and you assign a value to j+1, then the array is expanded to 9 elements
and the value stored

On Fri, Nov 22, 2013 at 9:26 PM, Rafael Moraes < >>>> rafaelmoraesdefreitas@gmail.com> wrote:

Only correcting myself
none of the ifs with minus operations

On 23 November 2013 00:23, Rafael Moraes < >>>>> rafaelmoraesdefreitas@gmail.com> wrote:

I know nothing about tests, I am not able to help you in this matter

but I can tell you the following:

if !esperado[i-1][j].nil? esperado[i - 1][j] = "X" end if !esperado[i+1][j].nil? esperado[i+1][j] = "X" end if !esperado[i][j-1].nil? esperado[i][j-1] = "X" end if !esperado[i][j+1].nil? esperado[i][j+1] = "X" end

None of these if will evaluate to false, lets say you are at position [0, 0] and apply the [i - 1][j]

it will become [-1, 0]

and index -1 is the last index of an array

example:

irb(main):001:0> array = ['first', 'second', 'third']
=> ["first", "second", "third"]
irb(main):002:0> array[0]
=> "first"
irb(main):003:0> array[-1]
=> "third"

On 21 November 2013 17:52, Chris Hulan <chris.hulan@gmail.com> wrote:

looking at the code, you are adding 'X" to the adjacent cells when
an 'X' is found in a given cell,
but what is the expected behaviour when a 'X' is found on an edge?

On Thu, Nov 21, 2013 at 2:30 PM, Ronny Amarante < >>>>>>> lists@ruby-forum.com> wrote:

Hi guys, i don't understand why this happen. Exist another way to
use
math expression in arrays?

expected: [[" ", "X", "X", "X", " ", "X", "X", "X"], ["X", "X", "X",
"X", " ", " ", "X", "X"], ["X", "X", "X", "X", "A", " ", " ", "A"],
["X", "X", "X", " ", " ", " ", " ", " "], ["X", "X", "X", " ", " ",
" ",
"A", " "], [" ", "X", " ", "A", " ", " ", " ", " "], [" ", " ", "
", "
", " ", " ", " ", " "]]
     got: [[" ", "X", "X", "X", " ", "X", "X", "X", "X"], ["X", "X",
"X", "X", " ", " ", "X", "X"], ["X", "X", "X", "X", "A", " ", " ",
"A"],
["X", "X", "X", " ", " ", " ", " ", " "], ["X", "X", "X", " ", " ",
" ",
"A", " "], [" ", "X", " ", "A", " ", " ", " ", " "], [" ", " ",
"X", "
", " ", " ", "X", "X"]] (using ==)
./testes_spec.rb:104:in `block (2 levels) in <top (required)>'

The code is here:

(def Expande)

https://bitbucket.org/ronnyamarante/nuvem-de-cinzas/src/dea63a21e63b544899c9279e7abea45cadaaacdb/desafio.rb?at=master

Thanks!

--
Posted via http://www.ruby-forum.com/\.