some help to find the bug

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
14 messages Options
Reply | Threaded
Open this post in threaded view
|

some help to find the bug

Roelof
Hello,

I have this code : https://gist.github.com/RoelofWobben/7c08680797d1d9f84436653a0e4edd3b
as  my solution to a AoC challenge.


But the last test `testIsNice`  is still  outputting the wrong output.
The right output is :   `ugknbfddgicrmopn ` and `aaa`

Someone who can think with me where I make a thinking error so that the right output is seen.

Regards,

Roelof

Reply | Threaded
Open this post in threaded view
|

Re: some help to find the bug

Nicole de Graaf
Hi Roelof,

I started to read you code , can you please give me the implementation of: ByteString>>#includesSubstring:

Regards,
Nic

On 15 Dec 2018, at 19:36, Roelof Wobben <[hidden email]> wrote:

Hello,

I have this code : https://gist.github.com/RoelofWobben/7c08680797d1d9f84436653a0e4edd3b
as  my solution to a AoC challenge.


But the last test `testIsNice`  is still  outputting the wrong output.
The right output is :   `ugknbfddgicrmopn ` and `aaa`

Someone who can think with me where I make a thinking error so that the right output is seen.

Regards,

Roelof


Reply | Threaded
Open this post in threaded view
|

Re: some help to find the bug

Nicole de Graaf
p.s. and also Array>>#overlappingPairsCollect:  

Regards,
Nic

On 15 Dec 2018, at 20:52, Nicole de Graaf <[hidden email]> wrote:

Hi Roelof,

I started to read you code , can you please give me the implementation of: ByteString>>#includesSubstring:

Regards,
Nic

On 15 Dec 2018, at 19:36, Roelof Wobben <[hidden email]> wrote:

Hello,

I have this code : https://gist.github.com/RoelofWobben/7c08680797d1d9f84436653a0e4edd3b
as  my solution to a AoC challenge.


But the last test `testIsNice`  is still  outputting the wrong output.
The right output is :   `ugknbfddgicrmopn ` and `aaa`

Someone who can think with me where I make a thinking error so that the right output is seen.

Regards,

Roelof


Reply | Threaded
Open this post in threaded view
|

Re: some help to find the bug

Roelof
In reply to this post by Nicole de Graaf

of course

includesSubstring: substring
    "Returns whether the receiver contains the argument."
    "('abcdefgh' includesSubstring: 'de') >>> true"
   
    ^ substring isEmpty or: [ (self findString: substring startingAt: 1) > 0 ]

It can be found in the class String with finder

Roelof


Op 15-12-2018 om 20:52 schreef Nicole de Graaf:
Hi Roelof,

I started to read you code , can you please give me the implementation of: ByteString>>#includesSubstring:

Regards,
Nic

On 15 Dec 2018, at 19:36, Roelof Wobben <[hidden email]> wrote:

Hello,

I have this code : https://gist.github.com/RoelofWobben/7c08680797d1d9f84436653a0e4edd3b
as  my solution to a AoC challenge.


But the last test `testIsNice`  is still  outputting the wrong output.
The right output is :   `ugknbfddgicrmopn ` and `aaa`

Someone who can think with me where I make a thinking error so that the right output is seen.

Regards,

Roelof



Reply | Threaded
Open this post in threaded view
|

Re: some help to find the bug

Nicole de Graaf
Hi Roelof,

Question:
With your “fileout” can I run all test. (Green) 
or only the last one #testisNice.

I started  with: #test1CheckForForbiddenParts  that is failing .. the substring is not in the input!


Regards,
Nic



 



Op 15-12-2018 om 20:52 schreef Nicole de Graaf:
Hi Roelof,

I started to read you code , can you please give me the implementation of: ByteString>>#includesSubstring:

Regards,
Nic

On 15 Dec 2018, at 19:36, Roelof Wobben <[hidden email]> wrote:

Hello,

I have this code : https://gist.github.com/RoelofWobben/7c08680797d1d9f84436653a0e4edd3b
as  my solution to a AoC challenge.


But the last test `testIsNice`  is still  outputting the wrong output.
The right output is :   `ugknbfddgicrmopn ` and `aaa`

Someone who can think with me where I make a thinking error so that the right output is seen.

Regards,

Roelof




Reply | Threaded
Open this post in threaded view
|

Re: some help to find the bug

Roelof
In reply to this post by Nicole de Graaf
You can find that one also with the finder.


overlappingPairsCollect: aBlock
    "Answer the result of evaluating aBlock with all of the overlapping pairs of my elements."
    | retval |
    retval := self species ofSize: self size - 1.
    1 to: self size - 1
        do: [:i | retval at: i put: (aBlock value: (self at: i) value: (self at: i + 1)) ].
    ^retval

can be found at sequenceCollection.

Roelof


Op 15-12-2018 om 21:03 schreef Nicole de Graaf:
p.s. and also Array>>#overlappingPairsCollect:  

Regards,
Nic

On 15 Dec 2018, at 20:52, Nicole de Graaf <[hidden email]> wrote:

Hi Roelof,

I started to read you code , can you please give me the implementation of: ByteString>>#includesSubstring:

Regards,
Nic

On 15 Dec 2018, at 19:36, Roelof Wobben <[hidden email]> wrote:

Hello,

I have this code : https://gist.github.com/RoelofWobben/7c08680797d1d9f84436653a0e4edd3b
as  my solution to a AoC challenge.


But the last test `testIsNice`  is still  outputting the wrong output.
The right output is :   `ugknbfddgicrmopn ` and `aaa`

Someone who can think with me where I make a thinking error so that the right output is seen.

Regards,

Roelof



Reply | Threaded
Open this post in threaded view
|

Re: some help to find the bug

Nicole de Graaf
Hi Roelof,

the result of:
FindNiceStrings new isNice: testData   >>  #('haegwjzuvuyypxyu’).

First idee is your algo is fine, but you test assert correct implemented (I can be wrong side I use not Pharo 7 or 6) 

My implementation:

testisNice
"comment stating purpose of message"

| testData |
testData := #('ugknbfddgicrmopn' 'aaa' 'jchzalrnumimnmhp' 'haegwjzuvuyypxyu').
self assert: (FindNiceStrings new isNice: testData) equals: #('haegwjzuvuyypxyu’)

is working fine.

Please can you check it on your side!

Regards,
Nic

On 15 Dec 2018, at 21:20, Roelof Wobben <[hidden email]> wrote:

You can find that one also with the finder.


overlappingPairsCollect: aBlock
    "Answer the result of evaluating aBlock with all of the overlapping pairs of my elements."
    | retval |
    retval := self species ofSize: self size - 1.
    1 to: self size - 1
        do: [:i | retval at: i put: (aBlock value: (self at: i) value: (self at: i + 1)) ].
    ^retval

can be found at sequenceCollection.

Roelof


Op 15-12-2018 om 21:03 schreef Nicole de Graaf:
p.s. and also Array>>#overlappingPairsCollect:  

Regards,
Nic

On 15 Dec 2018, at 20:52, Nicole de Graaf <[hidden email]> wrote:

Hi Roelof,

I started to read you code , can you please give me the implementation of: ByteString>>#includesSubstring:

Regards,
Nic

On 15 Dec 2018, at 19:36, Roelof Wobben <[hidden email]> wrote:

Hello,

I have this code : https://gist.github.com/RoelofWobben/7c08680797d1d9f84436653a0e4edd3b
as  my solution to a AoC challenge.


But the last test `testIsNice`  is still  outputting the wrong output.
The right output is :   `ugknbfddgicrmopn ` and `aaa`

Someone who can think with me where I make a thinking error so that the right output is seen.

Regards,

Roelof




Reply | Threaded
Open this post in threaded view
|

Re: some help to find the bug

Roelof
moment

Does the isNice  not ends on  result nice.

What do you then use as smalltalk version.

Roelof


Op 15-12-2018 om 21:36 schreef Nicole de Graaf:
Hi Roelof,

the result of:
FindNiceStrings new isNice: testData   >>  #('haegwjzuvuyypxyu’).

First idee is your algo is fine, but you test assert correct implemented (I can be wrong side I use not Pharo 7 or 6) 

My implementation:

testisNice
"comment stating purpose of message"

| testData |
testData := #('ugknbfddgicrmopn' 'aaa' 'jchzalrnumimnmhp' 'haegwjzuvuyypxyu').
self assert: (FindNiceStrings new isNice: testData) equals: #('haegwjzuvuyypxyu’)

is working fine.

Please can you check it on your side!

Regards,
Nic

On 15 Dec 2018, at 21:20, Roelof Wobben <[hidden email]> wrote:

You can find that one also with the finder.


overlappingPairsCollect: aBlock
    "Answer the result of evaluating aBlock with all of the overlapping pairs of my elements."
    | retval |
    retval := self species ofSize: self size - 1.
    1 to: self size - 1
        do: [:i | retval at: i put: (aBlock value: (self at: i) value: (self at: i + 1)) ].
    ^retval

can be found at sequenceCollection.

Roelof


Op 15-12-2018 om 21:03 schreef Nicole de Graaf:
p.s. and also Array>>#overlappingPairsCollect:  

Regards,
Nic

On 15 Dec 2018, at 20:52, Nicole de Graaf <[hidden email]> wrote:

Hi Roelof,

I started to read you code , can you please give me the implementation of: ByteString>>#includesSubstring:

Regards,
Nic

On 15 Dec 2018, at 19:36, Roelof Wobben <[hidden email]> wrote:

Hello,

I have this code : https://gist.github.com/RoelofWobben/7c08680797d1d9f84436653a0e4edd3b
as  my solution to a AoC challenge.


But the last test `testIsNice`  is still  outputting the wrong output.
The right output is :   `ugknbfddgicrmopn ` and `aaa`

Someone who can think with me where I make a thinking error so that the right output is seen.

Regards,

Roelof





Reply | Threaded
Open this post in threaded view
|

Re: some help to find the bug

Roelof
isNice must look like this :

isNice: aCollection
    "comment stating purpose of message"

    | niceStringsObject answer |
    niceStringsObject := self class new.
    answer := aCollection
        select: [ :word |
            (niceStringsObject checkForbiddenParts: word) not
                and: [ (niceStringsObject checkLessThen3Vowels: word)
                        and: [ niceStringsObject checkOverLapping: word ] ] ].
    ^ answer size

Roelof



Op 15-12-2018 om 21:46 schreef Roelof Wobben:
moment

Does the isNice  not ends on  result nice.

What do you then use as smalltalk version.

Roelof


Op 15-12-2018 om 21:36 schreef Nicole de Graaf:
Hi Roelof,

the result of:
FindNiceStrings new isNice: testData   >>  #('haegwjzuvuyypxyu’).

First idee is your algo is fine, but you test assert correct implemented (I can be wrong side I use not Pharo 7 or 6) 

My implementation:

testisNice
"comment stating purpose of message"

| testData |
testData := #('ugknbfddgicrmopn' 'aaa' 'jchzalrnumimnmhp' 'haegwjzuvuyypxyu').
self assert: (FindNiceStrings new isNice: testData) equals: #('haegwjzuvuyypxyu’)

is working fine.

Please can you check it on your side!

Regards,
Nic

On 15 Dec 2018, at 21:20, Roelof Wobben <[hidden email]> wrote:

You can find that one also with the finder.


overlappingPairsCollect: aBlock
    "Answer the result of evaluating aBlock with all of the overlapping pairs of my elements."
    | retval |
    retval := self species ofSize: self size - 1.
    1 to: self size - 1
        do: [:i | retval at: i put: (aBlock value: (self at: i) value: (self at: i + 1)) ].
    ^retval

can be found at sequenceCollection.

Roelof


Op 15-12-2018 om 21:03 schreef Nicole de Graaf:
p.s. and also Array>>#overlappingPairsCollect:  

Regards,
Nic

On 15 Dec 2018, at 20:52, Nicole de Graaf <[hidden email]> wrote:

Hi Roelof,

I started to read you code , can you please give me the implementation of: ByteString>>#includesSubstring:

Regards,
Nic

On 15 Dec 2018, at 19:36, Roelof Wobben <[hidden email]> wrote:

Hello,

I have this code : https://gist.github.com/RoelofWobben/7c08680797d1d9f84436653a0e4edd3b
as  my solution to a AoC challenge.


But the last test `testIsNice`  is still  outputting the wrong output.
The right output is :   `ugknbfddgicrmopn ` and `aaa`

Someone who can think with me where I make a thinking error so that the right output is seen.

Regards,

Roelof






Reply | Threaded
Open this post in threaded view
|

Re: some help to find the bug

Nicole de Graaf
In reply to this post by Roelof
Hi Roelof,

on my side all the test methods went green:

changes I need to apply:

1.  

checkForbiddenParts: word
"deletes all the words that contain forbidden parts"

^( forbiddenWords anySatisfy: [ :forbidden | word includesSubstring: forbidden ]) not



2.

testisNice
"comment stating purpose of message"

| testData |
testData := #('ugknbfddgicrmopn' 'aaa' 'jchzalrnumimnmhp' 'haegwjzuvuyypxyu').
self assert: (FindNiceStrings new isNice: testData) equals:  #('ugknbfddgicrmopn' 'aaa’)


Regards,
Nic



On 15 Dec 2018, at 19:36, Roelof Wobben <[hidden email]> wrote:

Hello,

I have this code : https://gist.github.com/RoelofWobben/7c08680797d1d9f84436653a0e4edd3b
as  my solution to a AoC challenge.


But the last test `testIsNice`  is still  outputting the wrong output.
The right output is :   `ugknbfddgicrmopn ` and `aaa`

Someone who can think with me where I make a thinking error so that the right output is seen.

Regards,

Roelof


Reply | Threaded
Open this post in threaded view
|

Re: some help to find the bug

Roelof
Thanks

Roelof


Op 15-12-2018 om 21:52 schreef Nicole de Graaf:
Hi Roelof,

on my side all the test methods went green:

changes I need to apply:

1.  

checkForbiddenParts: word
"deletes all the words that contain forbidden parts"

^( forbiddenWords anySatisfy: [ :forbidden | word includesSubstring: forbidden ]) not



2.

testisNice
"comment stating purpose of message"

| testData |
testData := #('ugknbfddgicrmopn' 'aaa' 'jchzalrnumimnmhp' 'haegwjzuvuyypxyu').
self assert: (FindNiceStrings new isNice: testData) equals:  #('ugknbfddgicrmopn' 'aaa’)


Regards,
Nic



On 15 Dec 2018, at 19:36, Roelof Wobben <[hidden email]> wrote:

Hello,

I have this code : https://gist.github.com/RoelofWobben/7c08680797d1d9f84436653a0e4edd3b
as  my solution to a AoC challenge.


But the last test `testIsNice`  is still  outputting the wrong output.
The right output is :   `ugknbfddgicrmopn ` and `aaa`

Someone who can think with me where I make a thinking error so that the right output is seen.

Regards,

Roelof



Reply | Threaded
Open this post in threaded view
|

Re: some help to find the bug

Ben Coman
In reply to this post by Roelof


On Sun, 16 Dec 2018 at 02:37, Roelof Wobben <[hidden email]> wrote:
Hello,

I have this code : https://gist.github.com/RoelofWobben/7c08680797d1d9f84436653a0e4edd3b
as  my solution to a AoC challenge.


But the last test `testIsNice`  is still  outputting the wrong output.
The right output is :   `ugknbfddgicrmopn ` and `aaa`

Someone who can think with me where I make a thinking error so that the right output is seen.

You seem to already have fixed that problem, so just some general feedback...

Your #isNice is an instance method, so you are already inside a FindNiceStrings object.
So you don't need... 
```niceStringsObject := FindNiceStrings new.```
Just use self.

By convention, all #isXXXXX methods should return a Boolean
Your ```isNice: aCollection``` method returns a collection. That would be better renamed #selectNice:

The two #and: messages inside the #select: makes that a bit verbose.
I'd refactor that condition out to its own method, i.e. ```isNice: aWord``` since that was freed up
So you would have:
```    
FindNiceStrings  selectNice: aCollection
^ aCollection select: [ :word | self isNice: word ]
```


> self assert: (FindNiceStrings new checkForbiddenParts: string) equals: true

The "equals: true" part is redundant.

cheers -ben
Reply | Threaded
Open this post in threaded view
|

Re: some help to find the bug

Roelof
Op 16-12-2018 om 12:34 schreef Ben Coman:


On Sun, 16 Dec 2018 at 02:37, Roelof Wobben <[hidden email]> wrote:
Hello,

I have this code : https://gist.github.com/RoelofWobben/7c08680797d1d9f84436653a0e4edd3b
as  my solution to a AoC challenge.


But the last test `testIsNice`  is still  outputting the wrong output.
The right output is :   `ugknbfddgicrmopn ` and `aaa`

Someone who can think with me where I make a thinking error so that the right output is seen.

You seem to already have fixed that problem, so just some general feedback...

Your #isNice is an instance method, so you are already inside a FindNiceStrings object.
So you don't need... 
```niceStringsObject := FindNiceStrings new.```
Just use self.

By convention, all #isXXXXX methods should return a Boolean
Your ```isNice: aCollection``` method returns a collection. That would be better renamed #selectNice:

The two #and: messages inside the #select: makes that a bit verbose.
I'd refactor that condition out to its own method, i.e. ```isNice: aWord``` since that was freed up
So you would have:
```    
FindNiceStrings  selectNice: aCollection
^ aCollection select: [ :word | self isNice: word ]
```


> self assert: (FindNiceStrings new checkForbiddenParts: string) equals: true

The "equals: true" part is redundant.

cheers -ben


Thanks,

So the isNice function has all the code with the 2 times and.

and what must i use when a test is false so instead of equals:  false

Roelof

Reply | Threaded
Open this post in threaded view
|

Re: some help to find the bug

Ben Coman


On Sun, 16 Dec 2018 at 19:57, Roelof Wobben <[hidden email]> wrote:
Op 16-12-2018 om 12:34 schreef Ben Coman:


On Sun, 16 Dec 2018 at 02:37, Roelof Wobben <[hidden email]> wrote:
Hello,

I have this code : https://gist.github.com/RoelofWobben/7c08680797d1d9f84436653a0e4edd3b
as  my solution to a AoC challenge.


But the last test `testIsNice`  is still  outputting the wrong output.
The right output is :   `ugknbfddgicrmopn ` and `aaa`

Someone who can think with me where I make a thinking error so that the right output is seen.

You seem to already have fixed that problem, so just some general feedback...

Your #isNice is an instance method, so you are already inside a FindNiceStrings object.
So you don't need... 
```niceStringsObject := FindNiceStrings new.```
Just use self.

By convention, all #isXXXXX methods should return a Boolean
Your ```isNice: aCollection``` method returns a collection. That would be better renamed #selectNice:

The two #and: messages inside the #select: makes that a bit verbose.
I'd refactor that condition out to its own method, i.e. ```isNice: aWord``` since that was freed up
So you would have:
```    
FindNiceStrings  selectNice: aCollection
^ aCollection select: [ :word | self isNice: word ]
```


> self assert: (FindNiceStrings new checkForbiddenParts: string) equals: true

The "equals: true" part is redundant.

cheers -ben


Thanks,

So the isNice function has all the code with the 2 times and.

and what must i use when a test is false so instead of equals:  false


Evaluate this... ```#deny: senders inspect```