The Easiest way to check if one array is a subset of another

Discussion in 'Ruby' started by Thriving K., Aug 4, 2009.

  1. Thriving K.

    Thriving K. Guest

    I want to find the easiest way if one array is a subset of another

    for example

    A b
    [1,2,4,5,6,7,9] [1,3,9] =>true

    A b
    [1,2,4,5,6,7,9] [1,3,8] =>false
    --
    Posted via http://www.ruby-forum.com/.
     
    Thriving K., Aug 4, 2009
    #1
    1. Advertising

  2. Thriving K.

    Thriving K. Guest

    Thriving K., Aug 4, 2009
    #2
    1. Advertising

  3. PiAtLS0tLU9yaWdpbmFsIE1lc3NhZ2UtLS0tLQ0KPiBGcm9tOiBzdXBlcmRpc2Nvbm5lY3RAaG90
    bWFpbC5jb20gW21haWx0bzpzdXBlcmRpc2Nvbm5lY3RAaG90bWFpbC5jb21dDQo+IFNlbnQ6IE1v
    bmRheSwgQXVndXN0IDAzLCAyMDA5IDEwOjEzIFBNDQo+IFRvOiBydWJ5LXRhbGsgTUwNCj4gU3Vi
    amVjdDogVGhlIEVhc2llc3Qgd2F5IHRvIGNoZWNrIGlmIG9uZSBhcnJheSBpcyBhIHN1YnNldCBv
    ZiBhbm90aGVyDQo+IA0KPiBJIHdhbnQgdG8gZmluZCB0aGUgZWFzaWVzdCB3YXkgaWYgb25lIGFy
    cmF5IGlzIGEgc3Vic2V0IG9mIGFub3RoZXINCj4gDQo+IGZvciBleGFtcGxlDQo+IA0KPiAgQSAg
    ICAgICAgICAgICAgICAgICAgYg0KPiBbMSwyLDQsNSw2LDcsOV0gICAgICBbMSwzLDldID0+dHJ1
    ZQ0KPiANCj4gIEEgICAgICAgICAgICAgICAgICAgIGINCj4gWzEsMiw0LDUsNiw3LDldICAgICAg
    WzEsMyw4XSA9PmZhbHNlDQo+IC0tDQo+IFBvc3RlZCB2aWEgaHR0cDovL3d3dy5ydWJ5LWZvcnVt
    LmNvbS8uDQoNCg0KSWYgSSB1bmRlcnN0YW5kIGNvcnJlY3RseSB3aGF0IHlvdSByZWFsbHkgd2Fu
    dCwgdGhlIGZpcnN0IGV4YW1wbGUgc2hvdWxkIHByb2R1Y2UgZmFsc2UsIGFzIGFycmF5ICJhIiBk
    b2VzIG5vdCBoYXZlIDMuIEFzc3VtaW5nIHRoYXQgeW91IG1lYW50IFsxLDIsMyw0LDUsNiw3LDld
    IEkgdGhpbmsgdGhlIGZvbGxvd2luZyB3aWxsIHdvcmsgZm9yIHlvdToNCg0KKGEgJiBiKSA9PSBi
    DQoNCkdlbm5hZHkuDQoNCg==
     
    Gennady Bystritsky, Aug 4, 2009
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jay Tee
    Replies:
    15
    Views:
    671
    Jay Tee
    Feb 20, 2007
  2. dmitrey
    Replies:
    3
    Views:
    401
    Steve Ferg
    Jun 22, 2009
  3. Phlip
    Replies:
    6
    Views:
    1,451
    Peter Flynn
    Apr 23, 2010
  4. dblock
    Replies:
    2
    Views:
    680
    Simon Krahnke
    Oct 9, 2011
  5. Christopher

    one enum is a subset of another

    Christopher, Jan 31, 2012, in forum: C++
    Replies:
    10
    Views:
    1,171
    Thomas Boell
    Feb 2, 2012
Loading...

Share This Page