Skip to content

Count between 2 and 33 instead of 34#2

Open
josher19 wants to merge 5 commits intolinus:masterfrom
josher19:patch-1
Open

Count between 2 and 33 instead of 34#2
josher19 wants to merge 5 commits intolinus:masterfrom
josher19:patch-1

Conversation

@josher19
Copy link
Copy Markdown

@josher19 josher19 commented Jan 5, 2013

It is currently possible to generate random sentences which are not the same but have the same id when parsed. Example:

exports = require('greg');

var phrase1 = '34 cute rabbits sang jovially',
    phrase2 = '2 dapper rabbits sang jovially';

exports.parse(phrase1) === exports.parse(phrase2); // true, both 34.

Updating the count to have a range from 2 to 33 instead of 2 to 34 fixes this.

Look up a Greg sentence from an Id.
greg.confirm('6 sad squid snuggle softly'); // false
greg.confirm('2 cute rabbits sang jovially', 2); // true
@linus
Copy link
Copy Markdown
Owner

linus commented Jan 7, 2013

Thanks @josher19, I'm not sure of the benefit of the fromId and confirm functions -- would you care to elaborate? I actually got a longer list of words from "the" Greg, along with (part of) his implementation. I haven't added the words out of laziness, but I probably should.

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

Successfully merging this pull request may close these issues.

2 participants