list of all possible values

Discussion in 'Python' started by David Gibb, Jul 13, 2009.

  1. David Gibb

    David Gibb Guest

    Hi guys.

    I was thinking about a problem I had: suppose I have a list of
    possible values. I want to to have a list of all possible lists of
    length n whose values are in that original list.

    For example: if my values are ['a', 'b', 'c'], then all possible lists
    of length 2 would be: aa, ab, ac, ba, bb, bc, ca, cb, cc.

    I created a recursive program to do it, but I was wondering if there
    was a better way of doing it (possibly with list comprehensions).

    Here's my recursive version:

    vals = ['a', 'b', 'c']

    def foo(length):
    if length <=0:
    return []
    if length == 1:
    return [[x] for x in vals]
    else:
    return [x + [y] for x in foo(length - 1) for y in vals]

    print foo(3)

    Thanks,
    David
     
    David Gibb, Jul 13, 2009
    #1
    1. Advertising

  2. David Gibb

    Bearophile Guest

    David Gibb:
    > For example: if my values are ['a', 'b', 'c'], then all possible lists
    > of length 2 would be: aa, ab, ac, ba, bb, bc, ca, cb, cc.


    >>> from itertools import product
    >>> list(product("abc", repeat=2))

    [('a', 'a'), ('a', 'b'), ('a', 'c'), ('b', 'a'), ('b', 'b'), ('b',
    'c'), ('c', 'a'), ('c', 'b'), ('c', 'c')]

    Bye,
    bearophile
     
    Bearophile, Jul 13, 2009
    #2
    1. Advertising

  3. David Gibb

    Andreas Tawn Guest

    > David Gibb:
    > > For example: if my values are ['a', 'b', 'c'], then all possible

    lists
    > > of length 2 would be: aa, ab, ac, ba, bb, bc, ca, cb, cc.

    >
    > >>> from itertools import product
    > >>> list(product("abc", repeat=2))

    > [('a', 'a'), ('a', 'b'), ('a', 'c'), ('b', 'a'), ('b', 'b'), ('b',
    > 'c'), ('c', 'a'), ('c', 'b'), ('c', 'c')]
    >
    > Bye,
    > bearophile


    Certainly possible with list comprehensions.

    >>> a = "abc"
    >>> [(x, y) for x in a for y in a]

    [('a', 'a'), ('a', 'b'), ('a', 'c'), ('b', 'a'), ('b', 'b'), ('b', 'c'),
    ('c', 'a'), ('c', 'b'), ('c', 'c')]

    But I like bearophile's version better.

    Cheers,

    Drea
     
    Andreas Tawn, Jul 13, 2009
    #3
  4. David Gibb

    David Gibb Guest

    > Certainly possible with list comprehensions.
    >
    >>>> a = "abc"
    >>>> [(x, y) for x in a for y in a]

    > [('a', 'a'), ('a', 'b'), ('a', 'c'), ('b', 'a'), ('b', 'b'), ('b', 'c'),
    > ('c', 'a'), ('c', 'b'), ('c', 'c')]
    >
    > But I like bearophile's version better.
    >


    Andreas,

    Thanks, but I think you were missing my point. I should have explained better.

    The advantage that bearophile's version is generic with respect to the
    number of elements in each combination. To go from 2 element pairs
    (e.g. ('a', 'c')) to 5 element pairs (e.g. ('a', 'c', 'b', 'b', 'e'))
    requires only a change in a parameter passed to itertools.

    I don't see how you would do that with list comprehensions. You're
    example works nicely with 2 element pairs, but it seems to me like
    you'd need to recode it if you wanted to change it to 5 element pairs.

    Am I wrong about that? Can you think of a way to write a function
    that, using list comprehensions, takes a list of values and the size
    of each combination, and returns the len(list)**(combination size)
    possible combinations using those values?

    Thanks again,
    David
     
    David Gibb, Jul 16, 2009
    #4
  5. David Gibb

    Andreas Tawn Guest

    > > Certainly possible with list comprehensions.
    > >
    > >>>> a = "abc"
    > >>>> [(x, y) for x in a for y in a]

    > > [('a', 'a'), ('a', 'b'), ('a', 'c'), ('b', 'a'), ('b', 'b'), ('b',

    'c'),
    > > ('c', 'a'), ('c', 'b'), ('c', 'c')]
    > >
    > > But I like bearophile's version better.
    > >

    >
    > Andreas,
    >
    > Thanks, but I think you were missing my point. I should have explained

    better.
    >
    > The advantage that bearophile's version is generic with respect to the
    > number of elements in each combination. To go from 2 element pairs
    > (e.g. ('a', 'c')) to 5 element pairs (e.g. ('a', 'c', 'b', 'b', 'e'))
    > requires only a change in a parameter passed to itertools.
    >
    > I don't see how you would do that with list comprehensions. You're
    > example works nicely with 2 element pairs, but it seems to me like
    > you'd need to recode it if you wanted to change it to 5 element pairs.
    >
    > Am I wrong about that? Can you think of a way to write a function
    > that, using list comprehensions, takes a list of values and the size
    > of each combination, and returns the len(list)**(combination size)
    > possible combinations using those values?
    >
    > Thanks again,
    > David


    David,

    I think my post got caught in the nebulous email eddys and seems to have
    taken 16 hours to arrive on the list. It was meant to be a reply to your
    first post, not your second.

    Having said that, I think I missed the point of that post too ;o)

    Maybe someone smarter than me can come up with a way to dynamically nest
    the fors in a list comprehension, but I certainly can't do it.

    Sorry for the confusion.

    Cheers,

    Drea
     
    Andreas Tawn, Jul 16, 2009
    #5
  6. David Gibb

    Mensanator Guest

    On Jul 16, 11:49 am, "Andreas Tawn" <> wrote:
    > > > Certainly possible with list comprehensions.

    >
    > > >>>> a = "abc"
    > > >>>> [(x, y) for x in a for y in a]
    > > > [('a', 'a'), ('a', 'b'), ('a', 'c'), ('b', 'a'), ('b', 'b'), ('b',

    > 'c'),
    > > > ('c', 'a'), ('c', 'b'), ('c', 'c')]

    >
    > > > But I like bearophile's version better.

    >
    > > Andreas,

    >
    > > Thanks, but I think you were missing my point. I should have explained

    > better.
    >
    > > The advantage that bearophile's version is generic with respect to the
    > > number of elements in each combination. To go from 2 element pairs
    > > (e.g. ('a', 'c')) to 5 element pairs (e.g. ('a', 'c', 'b', 'b', 'e'))
    > > requires only a change in a parameter passed to itertools.

    >
    > > I don't see how you would do that with list comprehensions. You're
    > > example works nicely with 2 element pairs, but it seems to me like
    > > you'd need to recode it if you wanted to change it to 5 element pairs.

    >
    > > Am I wrong about that? Can you think of a way to write a function
    > > that, using list comprehensions, takes a list of values and the size
    > > of each combination, and returns the len(list)**(combination size)
    > > possible combinations using those values?

    >
    > > Thanks again,
    > > David

    >
    > David,
    >
    > I think my post got caught in the nebulous email eddys and seems to have
    > taken 16 hours to arrive on the list. It was meant to be a reply to your
    > first post, not your second.
    >
    > Having said that, I think I missed the point of that post too ;o)
    >
    > Maybe someone smarter than me can come up with a way to dynamically nest
    > the fors in a list comprehension, but I certainly can't do it.


    Well, I don't use list comprehension, but you can certainly
    make dynamic for loops. Not that this is a replacement for
    itertools (I wrote it before itertools had the ability to do
    all this).

    def ooloop6(a, n, perm=True, repl=True):
    if (not repl) and (n>len(a)): return
    r0 = range(n)
    r1 = r0[1:]
    if perm and repl: # ok
    v = ','.join(['c%s' % i for i in r0])
    f = ' '.join(['for c%s in a' % i for i in r0])
    e = ''.join(["p = [''.join((",v,")) ",f,"]"])
    exec e
    return p
    if (not perm) and repl: # ok
    v = ','.join(['c%s' % i for i in r0])
    f = ' '.join(['for c%s in a' % i for i in r0])
    i = ' and '.join(['(c%s>=c%s)' % (j,j-1) for j in r1])
    e = ''.join(["p = [''.join((",v,")) ",f," if ",i,"]"])
    exec e
    return p
    if perm and (not repl): # ok
    v = ','.join(['c%s' % i for i in r0])
    f = ' '.join(['for c%s in a' % i for i in r0])
    i = ' and '.join([' and '.join(['(c%s!=c%s)' % (j,k) for k in
    range(j)]) for j in r1])
    e = ''.join(["p = [''.join((",v,")) ",f," if ",i,"]"])
    exec e
    return p
    if (not perm) and (not repl): # ok
    v = ','.join(['c%s' % i for i in r0])
    f = ' '.join(['for c%s in a' % i for i in r0])
    i = ' and '.join(['(c%s>c%s)' % (j,j-1) for j in r1])
    e = ''.join(["p = [''.join((",v,")) ",f," if ",i,"]"])
    exec e
    return p

    print '0123456789 taken 2 at a time'

    p = ooloop6('0123456789',2,True,True)
    print
    print 'Permutations with Replacement: %6d' % (len(p))
    print p

    p = ooloop6('0123456789',2,True,False)
    print
    print 'Permutations without Replacement: %6d' % (len(p))
    print p

    p = ooloop6('0123456789',2,False,True)
    print
    print 'Combinations with Replacement: %6d' % (len(p))
    print p

    p = ooloop6('0123456789',2,False,False)
    print
    print 'Combinations without Replacement: %6d' % (len(p))
    print p

    print

    print '0123456789 taken 3 at a time'

    p = ooloop6('0123456789',3,True,True)
    print
    print 'Permutations with Replacement: %6d' % (len(p))
    print p

    p = ooloop6('0123456789',3,True,False)
    print
    print 'Permutations without Replacement: %6d' % (len(p))
    print p

    p = ooloop6('0123456789',3,False,True)
    print
    print 'Combinations with Replacement: %6d' % (len(p))
    print p

    p = ooloop6('0123456789',3,False,False)
    print
    print 'Combinations without Replacement: %6d' % (len(p))
    print p

    0123456789 taken 2 at a time

    Permutations with Replacement: 100
    ['00', '01', '02', '03', '04', '05', '06', '07', '08', '09', '10',
    '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21',
    '22', '23', '24', '25', '26', '27', '28', '29', '30', '31', '32',
    '33', '34', '35', '36', '37', '38', '39', '40', '41', '42', '43',
    '44', '45', '46', '47', '48', '49', '50', '51', '52', '53', '54',
    '55', '56', '57', '58', '59', '60', '61', '62', '63', '64', '65',
    '66', '67', '68', '69', '70', '71', '72', '73', '74', '75', '76',
    '77', '78', '79', '80', '81', '82', '83', '84', '85', '86', '87',
    '88', '89', '90', '91', '92', '93', '94', '95', '96', '97', '98',
    '99']

    Permutations without Replacement: 90
    ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '12',
    '13', '14', '15', '16', '17', '18', '19', '20', '21', '23', '24',
    '25', '26', '27', '28', '29', '30', '31', '32', '34', '35', '36',
    '37', '38', '39', '40', '41', '42', '43', '45', '46', '47', '48',
    '49', '50', '51', '52', '53', '54', '56', '57', '58', '59', '60',
    '61', '62', '63', '64', '65', '67', '68', '69', '70', '71', '72',
    '73', '74', '75', '76', '78', '79', '80', '81', '82', '83', '84',
    '85', '86', '87', '89', '90', '91', '92', '93', '94', '95', '96',
    '97', '98']

    Combinations with Replacement: 55
    ['00', '01', '02', '03', '04', '05', '06', '07', '08', '09', '11',
    '12', '13', '14', '15', '16', '17', '18', '19', '22', '23', '24',
    '25', '26', '27', '28', '29', '33', '34', '35', '36', '37', '38',
    '39', '44', '45', '46', '47', '48', '49', '55', '56', '57', '58',
    '59', '66', '67', '68', '69', '77', '78', '79', '88', '89', '99']

    Combinations without Replacement: 45
    ['01', '02', '03', '04', '05', '06', '07', '08', '09', '12', '13',
    '14', '15', '16', '17', '18', '19', '23', '24', '25', '26', '27',
    '28', '29', '34', '35', '36', '37', '38', '39', '45', '46', '47',
    '48', '49', '56', '57', '58', '59', '67', '68', '69', '78', '79',
    '89']

    0123456789 taken 3 at a time

    Permutations with Replacement: 1000
    ['000', '001', '002', '003', '004', '005', '006', '007', '008', '009',
    '010', '011', '012', '013', '014', '015', '016', '017', '018', '019',
    '020', '021', '022', '023', '024', '025', '026', '027', '028', '029',
    '030', '031', '032', '033', '034', '035', '036', '037', '038', '039',
    '040', '041', '042', '043', '044', '045', '046', '047', '048', '049',
    '050', '051', '052', '053', '054', '055', '056', '057', '058', '059',
    '060', '061', '062', '063', '064', '065', '066', '067', '068', '069',
    '070', '071', '072', '073', '074', '075', '076', '077', '078', '079',
    '080', '081', '082', '083', '084', '085', '086', '087', '088', '089',
    '090', '091', '092', '093', '094', '095', '096', '097', '098', '099',
    '100', '101', '102', '103', '104', '105', '106', '107', '108', '109',
    '110', '111', '112', '113', '114', '115', '116', '117', '118', '119',
    '120', '121', '122', '123', '124', '125', '126', '127', '128', '129',
    '130', '131', '132', '133', '134', '135', '136', '137', '138', '139',
    '140', '141', '142', '143', '144', '145', '146', '147', '148', '149',
    '150', '151', '152', '153', '154', '155', '156', '157', '158', '159',
    '160', '161', '162', '163', '164', '165', '166', '167', '168', '169',
    '170', '171', '172', '173', '174', '175', '176', '177', '178', '179',
    '180', '181', '182', '183', '184', '185', '186', '187', '188', '189',
    '190', '191', '192', '193', '194', '195', '196', '197', '198', '199',
    '200', '201', '202', '203', '204', '205', '206', '207', '208', '209',
    '210', '211', '212', '213', '214', '215', '216', '217', '218', '219',
    '220', '221', '222', '223', '224', '225', '226', '227', '228', '229',
    '230', '231', '232', '233', '234', '235', '236', '237', '238', '239',
    '240', '241', '242', '243', '244', '245', '246', '247', '248', '249',
    '250', '251', '252', '253', '254', '255', '256', '257', '258', '259',
    '260', '261', '262', '263', '264', '265', '266', '267', '268', '269',
    '270', '271', '272', '273', '274', '275', '276', '277', '278', '279',
    '280', '281', '282', '283', '284', '285', '286', '287', '288', '289',
    '290', '291', '292', '293', '294', '295', '296', '297', '298', '299',
    '300', '301', '302', '303', '304', '305', '306', '307', '308', '309',
    '310', '311', '312', '313', '314', '315', '316', '317', '318', '319',
    '320', '321', '322', '323', '324', '325', '326', '327', '328', '329',
    '330', '331', '332', '333', '334', '335', '336', '337', '338', '339',
    '340', '341', '342', '343', '344', '345', '346', '347', '348', '349',
    '350', '351', '352', '353', '354', '355', '356', '357', '358', '359',
    '360', '361', '362', '363', '364', '365', '366', '367', '368', '369',
    '370', '371', '372', '373', '374', '375', '376', '377', '378', '379',
    '380', '381', '382', '383', '384', '385', '386', '387', '388', '389',
    '390', '391', '392', '393', '394', '395', '396', '397', '398', '399',
    '400', '401', '402', '403', '404', '405', '406', '407', '408', '409',
    '410', '411', '412', '413', '414', '415', '416', '417', '418', '419',
    '420', '421', '422', '423', '424', '425', '426', '427', '428', '429',
    '430', '431', '432', '433', '434', '435', '436', '437', '438', '439',
    '440', '441', '442', '443', '444', '445', '446', '447', '448', '449',
    '450', '451', '452', '453', '454', '455', '456', '457', '458', '459',
    '460', '461', '462', '463', '464', '465', '466', '467', '468', '469',
    '470', '471', '472', '473', '474', '475', '476', '477', '478', '479',
    '480', '481', '482', '483', '484', '485', '486', '487', '488', '489',
    '490', '491', '492', '493', '494', '495', '496', '497', '498', '499',
    '500', '501', '502', '503', '504', '505', '506', '507', '508', '509',
    '510', '511', '512', '513', '514', '515', '516', '517', '518', '519',
    '520', '521', '522', '523', '524', '525', '526', '527', '528', '529',
    '530', '531', '532', '533', '534', '535', '536', '537', '538', '539',
    '540', '541', '542', '543', '544', '545', '546', '547', '548', '549',
    '550', '551', '552', '553', '554', '555', '556', '557', '558', '559',
    '560', '561', '562', '563', '564', '565', '566', '567', '568', '569',
    '570', '571', '572', '573', '574', '575', '576', '577', '578', '579',
    '580', '581', '582', '583', '584', '585', '586', '587', '588', '589',
    '590', '591', '592', '593', '594', '595', '596', '597', '598', '599',
    '600', '601', '602', '603', '604', '605', '606', '607', '608', '609',
    '610', '611', '612', '613', '614', '615', '616', '617', '618', '619',
    '620', '621', '622', '623', '624', '625', '626', '627', '628', '629',
    '630', '631', '632', '633', '634', '635', '636', '637', '638', '639',
    '640', '641', '642', '643', '644', '645', '646', '647', '648', '649',
    '650', '651', '652', '653', '654', '655', '656', '657', '658', '659',
    '660', '661', '662', '663', '664', '665', '666', '667', '668', '669',
    '670', '671', '672', '673', '674', '675', '676', '677', '678', '679',
    '680', '681', '682', '683', '684', '685', '686', '687', '688', '689',
    '690', '691', '692', '693', '694', '695', '696', '697', '698', '699',
    '700', '701', '702', '703', '704', '705', '706', '707', '708', '709',
    '710', '711', '712', '713', '714', '715', '716', '717', '718', '719',
    '720', '721', '722', '723', '724', '725', '726', '727', '728', '729',
    '730', '731', '732', '733', '734', '735', '736', '737', '738', '739',
    '740', '741', '742', '743', '744', '745', '746', '747', '748', '749',
    '750', '751', '752', '753', '754', '755', '756', '757', '758', '759',
    '760', '761', '762', '763', '764', '765', '766', '767', '768', '769',
    '770', '771', '772', '773', '774', '775', '776', '777', '778', '779',
    '780', '781', '782', '783', '784', '785', '786', '787', '788', '789',
    '790', '791', '792', '793', '794', '795', '796', '797', '798', '799',
    '800', '801', '802', '803', '804', '805', '806', '807', '808', '809',
    '810', '811', '812', '813', '814', '815', '816', '817', '818', '819',
    '820', '821', '822', '823', '824', '825', '826', '827', '828', '829',
    '830', '831', '832', '833', '834', '835', '836', '837', '838', '839',
    '840', '841', '842', '843', '844', '845', '846', '847', '848', '849',
    '850', '851', '852', '853', '854', '855', '856', '857', '858', '859',
    '860', '861', '862', '863', '864', '865', '866', '867', '868', '869',
    '870', '871', '872', '873', '874', '875', '876', '877', '878', '879',
    '880', '881', '882', '883', '884', '885', '886', '887', '888', '889',
    '890', '891', '892', '893', '894', '895', '896', '897', '898', '899',
    '900', '901', '902', '903', '904', '905', '906', '907', '908', '909',
    '910', '911', '912', '913', '914', '915', '916', '917', '918', '919',
    '920', '921', '922', '923', '924', '925', '926', '927', '928', '929',
    '930', '931', '932', '933', '934', '935', '936', '937', '938', '939',
    '940', '941', '942', '943', '944', '945', '946', '947', '948', '949',
    '950', '951', '952', '953', '954', '955', '956', '957', '958', '959',
    '960', '961', '962', '963', '964', '965', '966', '967', '968', '969',
    '970', '971', '972', '973', '974', '975', '976', '977', '978', '979',
    '980', '981', '982', '983', '984', '985', '986', '987', '988', '989',
    '990', '991', '992', '993', '994', '995', '996', '997', '998', '999']

    Permutations without Replacement: 720
    ['012', '013', '014', '015', '016', '017', '018', '019', '021', '023',
    '024', '025', '026', '027', '028', '029', '031', '032', '034', '035',
    '036', '037', '038', '039', '041', '042', '043', '045', '046', '047',
    '048', '049', '051', '052', '053', '054', '056', '057', '058', '059',
    '061', '062', '063', '064', '065', '067', '068', '069', '071', '072',
    '073', '074', '075', '076', '078', '079', '081', '082', '083', '084',
    '085', '086', '087', '089', '091', '092', '093', '094', '095', '096',
    '097', '098', '102', '103', '104', '105', '106', '107', '108', '109',
    '120', '123', '124', '125', '126', '127', '128', '129', '130', '132',
    '134', '135', '136', '137', '138', '139', '140', '142', '143', '145',
    '146', '147', '148', '149', '150', '152', '153', '154', '156', '157',
    '158', '159', '160', '162', '163', '164', '165', '167', '168', '169',
    '170', '172', '173', '174', '175', '176', '178', '179', '180', '182',
    '183', '184', '185', '186', '187', '189', '190', '192', '193', '194',
    '195', '196', '197', '198', '201', '203', '204', '205', '206', '207',
    '208', '209', '210', '213', '214', '215', '216', '217', '218', '219',
    '230', '231', '234', '235', '236', '237', '238', '239', '240', '241',
    '243', '245', '246', '247', '248', '249', '250', '251', '253', '254',
    '256', '257', '258', '259', '260', '261', '263', '264', '265', '267',
    '268', '269', '270', '271', '273', '274', '275', '276', '278', '279',
    '280', '281', '283', '284', '285', '286', '287', '289', '290', '291',
    '293', '294', '295', '296', '297', '298', '301', '302', '304', '305',
    '306', '307', '308', '309', '310', '312', '314', '315', '316', '317',
    '318', '319', '320', '321', '324', '325', '326', '327', '328', '329',
    '340', '341', '342', '345', '346', '347', '348', '349', '350', '351',
    '352', '354', '356', '357', '358', '359', '360', '361', '362', '364',
    '365', '367', '368', '369', '370', '371', '372', '374', '375', '376',
    '378', '379', '380', '381', '382', '384', '385', '386', '387', '389',
    '390', '391', '392', '394', '395', '396', '397', '398', '401', '402',
    '403', '405', '406', '407', '408', '409', '410', '412', '413', '415',
    '416', '417', '418', '419', '420', '421', '423', '425', '426', '427',
    '428', '429', '430', '431', '432', '435', '436', '437', '438', '439',
    '450', '451', '452', '453', '456', '457', '458', '459', '460', '461',
    '462', '463', '465', '467', '468', '469', '470', '471', '472', '473',
    '475', '476', '478', '479', '480', '481', '482', '483', '485', '486',
    '487', '489', '490', '491', '492', '493', '495', '496', '497', '498',
    '501', '502', '503', '504', '506', '507', '508', '509', '510', '512',
    '513', '514', '516', '517', '518', '519', '520', '521', '523', '524',
    '526', '527', '528', '529', '530', '531', '532', '534', '536', '537',
    '538', '539', '540', '541', '542', '543', '546', '547', '548', '549',
    '560', '561', '562', '563', '564', '567', '568', '569', '570', '571',
    '572', '573', '574', '576', '578', '579', '580', '581', '582', '583',
    '584', '586', '587', '589', '590', '591', '592', '593', '594', '596',
    '597', '598', '601', '602', '603', '604', '605', '607', '608', '609',
    '610', '612', '613', '614', '615', '617', '618', '619', '620', '621',
    '623', '624', '625', '627', '628', '629', '630', '631', '632', '634',
    '635', '637', '638', '639', '640', '641', '642', '643', '645', '647',
    '648', '649', '650', '651', '652', '653', '654', '657', '658', '659',
    '670', '671', '672', '673', '674', '675', '678', '679', '680', '681',
    '682', '683', '684', '685', '687', '689', '690', '691', '692', '693',
    '694', '695', '697', '698', '701', '702', '703', '704', '705', '706',
    '708', '709', '710', '712', '713', '714', '715', '716', '718', '719',
    '720', '721', '723', '724', '725', '726', '728', '729', '730', '731',
    '732', '734', '735', '736', '738', '739', '740', '741', '742', '743',
    '745', '746', '748', '749', '750', '751', '752', '753', '754', '756',
    '758', '759', '760', '761', '762', '763', '764', '765', '768', '769',
    '780', '781', '782', '783', '784', '785', '786', '789', '790', '791',
    '792', '793', '794', '795', '796', '798', '801', '802', '803', '804',
    '805', '806', '807', '809', '810', '812', '813', '814', '815', '816',
    '817', '819', '820', '821', '823', '824', '825', '826', '827', '829',
    '830', '831', '832', '834', '835', '836', '837', '839', '840', '841',
    '842', '843', '845', '846', '847', '849', '850', '851', '852', '853',
    '854', '856', '857', '859', '860', '861', '862', '863', '864', '865',
    '867', '869', '870', '871', '872', '873', '874', '875', '876', '879',
    '890', '891', '892', '893', '894', '895', '896', '897', '901', '902',
    '903', '904', '905', '906', '907', '908', '910', '912', '913', '914',
    '915', '916', '917', '918', '920', '921', '923', '924', '925', '926',
    '927', '928', '930', '931', '932', '934', '935', '936', '937', '938',
    '940', '941', '942', '943', '945', '946', '947', '948', '950', '951',
    '952', '953', '954', '956', '957', '958', '960', '961', '962', '963',
    '964', '965', '967', '968', '970', '971', '972', '973', '974', '975',
    '976', '978', '980', '981', '982', '983', '984', '985', '986', '987']

    Combinations with Replacement: 220
    ['000', '001', '002', '003', '004', '005', '006', '007', '008', '009',
    '011', '012', '013', '014', '015', '016', '017', '018', '019', '022',
    '023', '024', '025', '026', '027', '028', '029', '033', '034', '035',
    '036', '037', '038', '039', '044', '045', '046', '047', '048', '049',
    '055', '056', '057', '058', '059', '066', '067', '068', '069', '077',
    '078', '079', '088', '089', '099', '111', '112', '113', '114', '115',
    '116', '117', '118', '119', '122', '123', '124', '125', '126', '127',
    '128', '129', '133', '134', '135', '136', '137', '138', '139', '144',
    '145', '146', '147', '148', '149', '155', '156', '157', '158', '159',
    '166', '167', '168', '169', '177', '178', '179', '188', '189', '199',
    '222', '223', '224', '225', '226', '227', '228', '229', '233', '234',
    '235', '236', '237', '238', '239', '244', '245', '246', '247', '248',
    '249', '255', '256', '257', '258', '259', '266', '267', '268', '269',
    '277', '278', '279', '288', '289', '299', '333', '334', '335', '336',
    '337', '338', '339', '344', '345', '346', '347', '348', '349', '355',
    '356', '357', '358', '359', '366', '367', '368', '369', '377', '378',
    '379', '388', '389', '399', '444', '445', '446', '447', '448', '449',
    '455', '456', '457', '458', '459', '466', '467', '468', '469', '477',
    '478', '479', '488', '489', '499', '555', '556', '557', '558', '559',
    '566', '567', '568', '569', '577', '578', '579', '588', '589', '599',
    '666', '667', '668', '669', '677', '678', '679', '688', '689', '699',
    '777', '778', '779', '788', '789', '799', '888', '889', '899', '999']

    Combinations without Replacement: 120
    ['012', '013', '014', '015', '016', '017', '018', '019', '023', '024',
    '025', '026', '027', '028', '029', '034', '035', '036', '037', '038',
    '039', '045', '046', '047', '048', '049', '056', '057', '058', '059',
    '067', '068', '069', '078', '079', '089', '123', '124', '125', '126',
    '127', '128', '129', '134', '135', '136', '137', '138', '139', '145',
    '146', '147', '148', '149', '156', '157', '158', '159', '167', '168',
    '169', '178', '179', '189', '234', '235', '236', '237', '238', '239',
    '245', '246', '247', '248', '249', '256', '257', '258', '259', '267',
    '268', '269', '278', '279', '289', '345', '346', '347', '348', '349',
    '356', '357', '358', '359', '367', '368', '369', '378', '379', '389',
    '456', '457', '458', '459', '467', '468', '469', '478', '479', '489',
    '567', '568', '569', '578', '579', '589', '678', '679', '689', '789']
    >>>


    >
    > Sorry for the confusion.
    >
    > Cheers,
    >
    > Drea
     
    Mensanator, Jul 16, 2009
    #6
    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. Jim in Arizona
    Replies:
    4
    Views:
    8,067
    Jim in Arizona
    Aug 24, 2005
  2. Markus
    Replies:
    1
    Views:
    513
    Markus
    Nov 22, 2005
  3. Al Hatch
    Replies:
    3
    Views:
    1,019
    Johannes Koch
    Jun 5, 2006
  4. Replies:
    17
    Views:
    503
    Frederick Gotham
    Aug 25, 2006
  5. ToshiBoy
    Replies:
    6
    Views:
    886
    ToshiBoy
    Aug 12, 2008
Loading...

Share This Page