Challenges

Reddit challenges in python language.

Files Code and Result

challenge1_easy

challenge2_easy

challenge3_easy

challenge4_easy

challenge5_easy

challenge6_easy

challenge7_easy

challenge8_easy

challenge9_easy

challenge10_easy

challenge11.easy

challenge12_easy

challenge13_easy

challenge14_easy

challenge15_easy

challenge16_easy

challenge17_easy

challenge18_easy

challenge19_easy

challenge20_easy

challenge21_easy

challenge22_easy

challenge23_easy

challenge25_easy

challenge26_easy

challenge27_easy

challenge28_easy

challenge29_easy

challenge30_easy

challenge31_easy

challenge32_easy

challenge33_easy

challenge34_easy

challenge35_easy

challenge36_easy

challenge37_easy

challenge38_easy

challenge39_easy

challenge40_easy

challenge41_easy

challenge42_easy

challenge44_easy

challenge45_easy

challenge46_easy

challenge47_easy

challenge48_easy

challenge49_easy

challenge50_easy

challenge51_easy

challenge52_easy

challenge53_easy

challenge54_easy

challenge55_easy

challenge56_easy

challenge57_easy

challenge58_easy

challenge59_easy

challenge60_easy

challenge61_easy

challenge62_easy

challenge63_easy

challenge64_easy

challenge65_easy

challenge66_Dev

challenge66_easy

challenge67_easy

challenge68_easy

challenge69_easy

challenge69_easyBonus

challenge70_easy

challenge71_easy.py

challenge72_easy

challenge73_easy

challenge74_easy

challenge76_easy

challenge77_easy

challenge79_easy

challenge80_easyone

challenge82_easy

challenge83_easy

challenge86_easy

challenge94_easy

challenge104_easy

challenge130_easy

challenge143_easy

challenge146_easy

challenge148_easy

challenge149_easy

challenge153_easy

challenge154_easy

challenge158_easy

challenge158_easybonus

challenge159_easy

challenge160_easy

challenge169_easy

challenge169_easybonus

challenge172_easy

challenge174_easy

challenge175_easy

challenge177_easy

challenge180_easy

challenge181_easy

challenge185_easy

challenge192_easy

challenge193_easy

challenge197_easy

challenge198_easy

challenge199_easy

challenge201_easy

challenge202_easy

challenge203_easy

challenge204_easy

challenge204_easyBonus

challenge205_easy

challenge205_easyBonu

challenge206_easy

challenge208_easy

challenge210_easy

challenge211_easy

challenge212_easy

challenge212_easybonus

challenge213_easy

challenge214_easy

challenge215_easy

challenge216_easy

challenge217_easy

challenge218_easy

challenge218_easyBonus1

challenge218_easyBunus2

challenge219_easy

challenge220_easy.py

challenge221_easy

challenge221_easy

challenge222_easy

challenge222_easy.py

challenge223_easy

challenge226_easy

challenge226_easy

challenge228_easy.py

challenge228_easydev

challenge229_easy

challenge229_easybonus.py

challenge232_easy

challenge232_easy

challenge232_easybonus

challenge232_easybonus

challenge234_easy

challenge234_easybonus

challenge235_easy

challenge236_easy

challenge237_easy

challenge238_easy

challenge238_easybonus

challenge239_easy

challenge240_easy

challenge242_easy

challenge242_easy

challenge242_easyBonus

challenge243_easy

challenge245_easy

challenge245_easyBonus

challenge246_easy

challenge247_easy

challenge249_easy

challenge252_easy

challenge254_easy

challenge255_easy

challenge270_easy

challenge284_easy

challenge286_easy

challenge287_easy

challenge288_easy

challenge290_easy

challenge290_easybonus

challenge291_easy

challenge291_easybonus

challenge218_easyBonus1

'''
Bonus: see which input numbers, through 1000, yield identical palindromes.

'''

def ispal(n):
    n = str(n)
    # a copy for output
    m = n
    acc = 1
    while True:
        n = str(n)
        # reverse the string
        reversed_n = str(n[::-1])
        # convert to integer and add
        summed = int(n) + int(reversed_n)
        summed = str(summed)
        # are they a palindrome?'
        if summed == summed[::-1]:
            return (summed, m)
        else:
            n = summed
            acc += 1
            if acc >= 25:
                return None
            continue


if __name__ == '__main__':
    dikt = {}
    output = []
    for x in range(1, 1001):
        # output a tuple of (resulting palindrome, candidate)
        ans = ispal(x)
        # this ans would not converge
        if ans == None:
            continue
        # check if palindrome is in dictionary
        if ans[0] in dikt:
            # if so, add the two keys (candidates) to a list
            output.append((ans[1], dikt.get(ans[0])))
        else:
            # else add to dictionary
            dikt[ans[0]] = ans[1]

    print('output: ', output)

Result

output:  [('10', '5'), ('12', '6'), ('14', '7'), ('16', '8'), ('18', '9'), ('20', '11'), ('21', '6'), ('22', '13'), ('23', '7'), ('24', '15'), ('25', '8'), ('26', '17'), ('27', '9'), ('28', '19'), ('29', '19'), ('30', '6'), ('31', '13'), ('32', '7'), ('33', '15'), ('34', '8'), ('35', '17'), ('36', '9'), ('37', '19'), ('38', '19'), ('40', '13'), ('41', '7'), ('42', '15'), ('43', '8'), ('44', '17'), ('45', '9'), ('46', '19'), ('47', '19'), ('48', '39'), ('50', '7'), ('51', '15'), ('52', '8'), ('53', '17'), ('54', '9'), ('55', '19'), ('56', '19'), ('57', '39'), ('58', '49'), ('60', '15'), ('61', '8'), ('62', '17'), ('63', '9'), ('64', '19'), ('65', '19'), ('66', '39'), ('67', '49'), ('68', '59'), ('70', '8'), ('71', '17'), ('72', '9'), ('73', '19'), ('74', '19'), ('75', '39'), ('76', '49'), ('77', '59'), ('78', '69'), ('80', '17'), ('81', '9'), ('82', '19'), ('83', '19'), ('84', '39'), ('85', '49'), ('86', '59'), ('87', '69'), ('88', '79'), ('90', '9'), ('91', '19'), ('92', '19'), ('93', '39'), ('94', '49'), ('95', '59'), ('96', '69'), ('97', '79'), ('98', '89'), ('109', '59'), ('110', '19'), ('132', '39'), ('143', '49'), ('150', '102'), ('151', '104'), ('152', '106'), ('153', '108'), ('154', '59'), ('160', '122'), ('161', '124'), ('162', '126'), ('163', '128'), ('165', '69'), ('170', '142'), ('171', '144'), ('172', '146'), ('173', '148'), ('176', '79'), ('180', '126'), ('181', '164'), ('182', '166'), ('183', '168'), ('187', '89'), ('190', '166'), ('191', '184'), ('192', '186'), ('193', '188'), ('198', '99'), ('200', '101'), ('201', '102'), ('202', '103'), ('203', '104'), ('204', '105'), ('205', '106'), ('206', '107'), ('207', '108'), ('208', '59'), ('209', '59'), ('210', '111'), ('211', '112'), ('212', '113'), ('213', '114'), ('214', '115'), ('215', '116'), ('216', '117'), ('217', '118'), ('218', '119'), ('220', '121'), ('221', '122'), ('222', '123'), ('223', '124'), ('224', '125'), ('225', '126'), ('226', '127'), ('227', '128'), ('228', '129'), ('229', '164'), ('230', '131'), ('231', '39'), ('232', '133'), ('233', '134'), ('234', '135'), ('235', '136'), ('236', '137'), ('237', '138'), ('238', '139'), ('240', '141'), ('241', '142'), ('242', '49'), ('243', '144'), ('244', '145'), ('245', '146'), ('246', '147'), ('247', '148'), ('248', '149'), ('249', '174'), ('250', '104'), ('251', '106'), ('252', '108'), ('253', '59'), ('254', '155'), ('255', '156'), ('256', '157'), ('257', '158'), ('258', '159'), ('260', '124'), ('261', '126'), ('262', '128'), ('263', '164'), ('264', '69'), ('265', '166'), ('266', '167'), ('267', '168'), ('268', '169'), ('269', '184'), ('270', '144'), ('271', '146'), ('272', '148'), ('273', '174'), ('274', '175'), ('275', '79'), ('276', '177'), ('277', '178'), ('278', '179'), ('280', '164'), ('281', '166'), ('282', '168'), ('283', '184'), ('284', '185'), ('285', '186'), ('286', '89'), ('287', '188'), ('288', '189'), ('289', '194'), ('290', '184'), ('291', '186'), ('292', '188'), ('293', '194'), ('294', '195'), ('296', '197'), ('297', '99'), ('298', '199'), ('300', '102'), ('301', '103'), ('302', '104'), ('303', '105'), ('304', '106'), ('305', '107'), ('306', '108'), ('307', '59'), ('308', '59'), ('310', '112'), ('311', '113'), ('312', '114'), ('313', '115'), ('314', '116'), ('315', '117'), ('316', '118'), ('317', '119'), ('318', '219'), ('320', '122'), ('321', '123'), ('322', '124'), ('323', '125'), ('324', '126'), ('325', '127'), ('326', '128'), ('327', '129'), ('328', '164'), ('330', '39'), ('331', '133'), ('332', '134'), ('333', '135'), ('334', '136'), ('335', '137'), ('336', '138'), ('337', '139'), ('338', '239'), ('340', '142'), ('341', '49'), ('342', '144'), ('343', '145'), ('344', '146'), ('345', '147'), ('346', '148'), ('347', '149'), ('348', '174'), ('350', '106'), ('351', '108'), ('352', '59'), ('353', '155'), ('354', '156'), ('355', '157'), ('356', '158'), ('357', '159'), ('358', '259'), ('360', '126'), ('361', '128'), ('362', '164'), ('363', '69'), ('364', '166'), ('365', '167'), ('366', '168'), ('367', '169'), ('368', '184'), ('370', '146'), ('371', '148'), ('372', '174'), ('373', '175'), ('374', '79'), ('375', '177'), ('376', '178'), ('377', '179'), ('378', '279'), ('380', '166'), ('381', '168'), ('382', '184'), ('383', '185'), ('384', '186'), ('385', '89'), ('386', '188'), ('387', '189'), ('388', '194'), ('390', '186'), ('391', '188'), ('392', '194'), ('393', '195'), ('395', '197'), ('396', '99'), ('397', '199'), ('398', '299'), ('400', '103'), ('401', '104'), ('402', '105'), ('403', '106'), ('404', '107'), ('405', '108'), ('406', '59'), ('407', '59'), ('408', '309'), ('409', '155'), ('410', '113'), ('411', '114'), ('412', '115'), ('413', '116'), ('414', '117'), ('415', '118'), ('416', '119'), ('417', '219'), ('418', '319'), ('420', '123'), ('421', '124'), ('422', '125'), ('423', '126'), ('424', '127'), ('425', '128'), ('426', '129'), ('427', '164'), ('428', '329'), ('429', '69'), ('430', '133'), ('431', '134'), ('432', '135'), ('433', '136'), ('434', '137'), ('435', '138'), ('436', '139'), ('437', '239'), ('438', '339'), ('440', '49'), ('441', '144'), ('442', '145'), ('443', '146'), ('444', '147'), ('445', '148'), ('446', '149'), ('447', '174'), ('448', '349'), ('449', '175'), ('450', '108'), ('451', '59'), ('452', '155'), ('453', '156'), ('454', '157'), ('455', '158'), ('456', '159'), ('457', '259'), ('458', '359'), ('460', '128'), ('461', '164'), ('462', '69'), ('463', '166'), ('464', '167'), ('465', '168'), ('466', '169'), ('467', '184'), ('468', '369'), ('469', '185'), ('470', '148'), ('471', '174'), ('472', '175'), ('473', '79'), ('474', '177'), ('475', '178'), ('476', '179'), ('477', '279'), ('478', '379'), ('480', '168'), ('481', '184'), ('482', '185'), ('483', '186'), ('484', '89'), ('485', '188'), ('486', '189'), ('487', '194'), ('488', '389'), ('489', '195'), ('490', '188'), ('491', '194'), ('492', '195'), ('494', '197'), ('495', '99'), ('496', '199'), ('497', '299'), ('498', '399'), ('500', '104'), ('501', '105'), ('502', '106'), ('503', '107'), ('504', '108'), ('505', '59'), ('506', '59'), ('507', '309'), ('508', '155'), ('510', '114'), ('511', '115'), ('512', '116'), ('513', '117'), ('514', '118'), ('515', '119'), ('516', '219'), ('517', '319'), ('518', '419'), ('520', '124'), ('521', '125'), ('522', '126'), ('523', '127'), ('524', '128'), ('525', '129'), ('526', '164'), ('527', '329'), ('528', '69'), ('530', '134'), ('531', '135'), ('532', '136'), ('533', '137'), ('534', '138'), ('535', '139'), ('536', '239'), ('537', '339'), ('538', '439'), ('540', '144'), ('541', '145'), ('542', '146'), ('543', '147'), ('544', '148'), ('545', '149'), ('546', '174'), ('547', '349'), ('548', '175'), ('550', '59'), ('551', '155'), ('552', '156'), ('553', '157'), ('554', '158'), ('555', '159'), ('556', '259'), ('557', '359'), ('558', '459'), ('560', '164'), ('561', '69'), ('562', '166'), ('563', '167'), ('564', '168'), ('565', '169'), ('566', '184'), ('567', '369'), ('568', '185'), ('570', '174'), ('571', '175'), ('572', '79'), ('573', '177'), ('574', '178'), ('575', '179'), ('576', '279'), ('577', '379'), ('578', '479'), ('580', '184'), ('581', '185'), ('582', '186'), ('583', '89'), ('584', '188'), ('585', '189'), ('586', '194'), ('587', '389'), ('588', '195'), ('590', '194'), ('591', '195'), ('593', '197'), ('594', '99'), ('595', '199'), ('596', '299'), ('597', '399'), ('598', '499'), ('600', '105'), ('601', '106'), ('602', '107'), ('603', '108'), ('604', '59'), ('605', '59'), ('606', '309'), ('607', '155'), ('608', '509'), ('609', '156'), ('610', '115'), ('611', '116'), ('612', '117'), ('613', '118'), ('614', '119'), ('615', '219'), ('616', '319'), ('617', '419'), ('618', '519'), ('620', '125'), ('621', '126'), ('622', '127'), ('623', '128'), ('624', '129'), ('625', '164'), ('626', '329'), ('627', '69'), ('628', '529'), ('629', '166'), ('630', '135'), ('631', '136'), ('632', '137'), ('633', '138'), ('634', '139'), ('635', '239'), ('636', '339'), ('637', '439'), ('638', '539'), ('640', '145'), ('641', '146'), ('642', '147'), ('643', '148'), ('644', '149'), ('645', '174'), ('646', '349'), ('647', '175'), ('648', '549'), ('649', '79'), ('650', '155'), ('651', '156'), ('652', '157'), ('653', '158'), ('654', '159'), ('655', '259'), ('656', '359'), ('657', '459'), ('658', '559'), ('660', '69'), ('661', '166'), ('662', '167'), ('663', '168'), ('664', '169'), ('665', '184'), ('666', '369'), ('667', '185'), ('668', '569'), ('669', '186'), ('670', '175'), ('671', '79'), ('672', '177'), ('673', '178'), ('674', '179'), ('675', '279'), ('676', '379'), ('677', '479'), ('678', '579'), ('680', '185'), ('681', '186'), ('682', '89'), ('683', '188'), ('684', '189'), ('685', '194'), ('686', '389'), ('687', '195'), ('688', '589'), ('690', '195'), ('692', '197'), ('693', '99'), ('694', '199'), ('695', '299'), ('696', '399'), ('697', '499'), ('698', '599'), ('700', '106'), ('701', '107'), ('702', '108'), ('703', '59'), ('704', '59'), ('705', '309'), ('706', '155'), ('707', '509'), ('708', '156'), ('710', '116'), ('711', '117'), ('712', '118'), ('713', '119'), ('714', '219'), ('715', '319'), ('716', '419'), ('717', '519'), ('718', '619'), ('720', '126'), ('721', '127'), ('722', '128'), ('723', '129'), ('724', '164'), ('725', '329'), ('726', '69'), ('727', '529'), ('728', '166'), ('730', '136'), ('731', '137'), ('732', '138'), ('733', '139'), ('734', '239'), ('735', '339'), ('736', '439'), ('737', '539'), ('738', '639'), ('740', '146'), ('741', '147'), ('742', '148'), ('743', '149'), ('744', '174'), ('745', '349'), ('746', '175'), ('747', '549'), ('748', '79'), ('750', '156'), ('751', '157'), ('752', '158'), ('753', '159'), ('754', '259'), ('755', '359'), ('756', '459'), ('757', '559'), ('758', '659'), ('760', '166'), ('761', '167'), ('762', '168'), ('763', '169'), ('764', '184'), ('765', '369'), ('766', '185'), ('767', '569'), ('768', '186'), ('770', '79'), ('771', '177'), ('772', '178'), ('773', '179'), ('774', '279'), ('775', '379'), ('776', '479'), ('777', '579'), ('778', '679'), ('780', '186'), ('781', '89'), ('782', '188'), ('783', '189'), ('784', '194'), ('785', '389'), ('786', '195'), ('787', '589'), ('791', '197'), ('792', '99'), ('793', '199'), ('794', '299'), ('795', '399'), ('796', '499'), ('797', '599'), ('798', '699'), ('800', '107'), ('801', '108'), ('802', '59'), ('803', '59'), ('804', '309'), ('805', '155'), ('806', '509'), ('807', '156'), ('808', '709'), ('809', '157'), ('810', '117'), ('811', '118'), ('812', '119'), ('813', '219'), ('814', '319'), ('815', '419'), ('816', '519'), ('817', '619'), ('818', '719'), ('820', '127'), ('821', '128'), ('822', '129'), ('823', '164'), ('824', '329'), ('825', '69'), ('826', '529'), ('827', '166'), ('828', '729'), ('829', '167'), ('830', '137'), ('831', '138'), ('832', '139'), ('833', '239'), ('834', '339'), ('835', '439'), ('836', '539'), ('837', '639'), ('838', '739'), ('840', '147'), ('841', '148'), ('842', '149'), ('843', '174'), ('844', '349'), ('845', '175'), ('846', '549'), ('847', '79'), ('848', '749'), ('849', '177'), ('850', '157'), ('851', '158'), ('852', '159'), ('853', '259'), ('854', '359'), ('855', '459'), ('856', '559'), ('857', '659'), ('858', '759'), ('860', '167'), ('861', '168'), ('862', '169'), ('863', '184'), ('864', '369'), ('865', '185'), ('866', '569'), ('867', '186'), ('868', '769'), ('869', '89'), ('870', '177'), ('871', '178'), ('872', '179'), ('873', '279'), ('874', '379'), ('875', '479'), ('876', '579'), ('877', '679'), ('878', '779'), ('880', '89'), ('881', '188'), ('882', '189'), ('883', '194'), ('884', '389'), ('885', '195'), ('886', '589'), ('888', '789'), ('889', '197'), ('890', '197'), ('891', '99'), ('892', '199'), ('893', '299'), ('894', '399'), ('895', '499'), ('896', '599'), ('897', '699'), ('898', '799'), ('900', '108'), ('901', '59'), ('902', '59'), ('903', '309'), ('904', '155'), ('905', '509'), ('906', '156'), ('907', '709'), ('908', '157'), ('910', '118'), ('911', '119'), ('912', '219'), ('913', '319'), ('914', '419'), ('915', '519'), ('916', '619'), ('917', '719'), ('918', '819'), ('920', '128'), ('921', '129'), ('922', '164'), ('923', '329'), ('924', '69'), ('925', '529'), ('926', '166'), ('927', '729'), ('928', '167'), ('930', '138'), ('931', '139'), ('932', '239'), ('933', '339'), ('934', '439'), ('935', '539'), ('936', '639'), ('937', '739'), ('938', '839'), ('940', '148'), ('941', '149'), ('942', '174'), ('943', '349'), ('944', '175'), ('945', '549'), ('946', '79'), ('947', '749'), ('948', '177'), ('950', '158'), ('951', '159'), ('952', '259'), ('953', '359'), ('954', '459'), ('955', '559'), ('956', '659'), ('957', '759'), ('958', '859'), ('960', '168'), ('961', '169'), ('962', '184'), ('963', '369'), ('964', '185'), ('965', '569'), ('966', '186'), ('967', '769'), ('968', '89'), ('970', '178'), ('971', '179'), ('972', '279'), ('973', '379'), ('974', '479'), ('975', '579'), ('976', '679'), ('977', '779'), ('980', '188'), ('981', '189'), ('982', '194'), ('983', '389'), ('984', '195'), ('985', '589'), ('987', '789'), ('988', '197'), ('990', '99'), ('991', '199'), ('992', '299'), ('993', '399'), ('994', '499'), ('995', '599'), ('996', '699'), ('997', '799'), ('998', '899')]