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

challenge84_easy

challenge85_easy

challenge85_easybonus

challenge86_easy

challenge87_easy

challenge88_easy

challenge88_easybonus

challenge89_easy

challenge91_easy

challenge92_easy

challenge93_easy

challenge94_easy

challenge95_easy

challenge96_easy

challenge97_easy

challenge98_easy

challenge99_easy

challenge100_easy

challenge100_easybonus

challenge101_easy

challenge101_easybonus

challenge102_easy

challenge103_easy

challenge104_easy

challenge105_easy

challenge106_easy

challenge107_easy

challenge108_easy

challenge109_easy

challenge110_easy

challenge111_easy2

challenge112_easy

challenge113_easy

challenge114_easy

challenge115_easy

challenge116_easy

challenge117_easy

challenge118_easy

challenge119_easy

challenge121_easy

challenge122_easy

challenge125_easy

challenge126_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

challenge58_easy

''' As computer programmers are well aware, it can be very useful to
write numbers using numerical bases other than the familiar
base 10 notation we use in everyday life. In computer programming,
base 2 and base 16 are especially handy. In base 2,
the number 1234 becomes 10011010010 and in base 16 it becomes 4D2.

Because there are only 10 regular digits, when numbers are written in base 16,
the first few letters of the alphabet are added to represent the remaining
required digits, so 'A' stands in for 10, 'B' for 11, 'C' for 12,
'D' for 13, 'E' for 14 and 'F' for 15.

Of course, this trick of adding letters to stand in for numbers
allows us to represent higher bases than 16; if you can use all
letters of the alphabet, you can represent bases up to base 36
(because there are ten regular digits and 26 "letter-digits").
So for instance, 12345678 becomes 1L2FHE in base 23 and 4IDHAA in base 19.

Write a program that will take a number and convert it to any
base between 2 and 36. Have the program print out 19959694 in
base 35 and 376609378180550 in base 29.

NOTE: Many languages have this built in as a library function.
For instance, in Java, the function Integer.toString(i, radix)
does exactly this. However, the entire point of this challenge
is to write the program yourself, so you are not allowed to use
any library functions like this.

BONUS: A number is said to be "palindromic in base N" if, when
written in base N the number is the same backwards and forwards. So,
for instance, the number 16708 is palindromic in base 27,
because in base 27 the number is written as MOM, obviously a palindrome.
The number 12321 is a palindrome in in base 10, because 12321 written
backwards is 12321. Some numbers are palindromic in several bases, the
number 15167 for instance is palindromic in bases 9, 27, 28, 35 and 36.

In what bases is the number 10858 palindromic?
'''

dikt = {'0': '0', '1': '1', '2': '2', '3': '3', '4': '4', '5': '5', '6': '6',
        '7': '7', '8': '8', '9': '9', '10': 'A', '11': 'B', '12': 'C',
        '13': 'D', '14': 'E', '15': 'F', '16': 'G', '17': 'H', '18': 'I',
        '19': 'J', '20': 'K', '21': 'L', '22': 'M', '23': 'N', '24': 'O',
        '25': 'P', '26': 'Q', '27': 'R', '28': 'S', '29': 'T', '30': 'U',
        '31': 'V', '32': 'W', '33': 'X', '34': 'Y', '35': 'Z'}

def num_bases(num, base):
    global dikt
    strng = ''
    while num != 0:
        out = num % base
        strng += dikt[str(out)]
        num = num // base
    return (strng[::-1])

def palindrome(strng):
    if strng == strng[::-1]:
        return True
    return  False

if __name__ == '__main__':
    print(num_bases(19959694, 35))
    print(num_bases(376609378180550, 29))

    palins = ''
    num = 10858
    for x in range(2, 36):
        check = num_bases(num, x)
        if palindrome(check):
            palins += str(check) + ' '

    print('Palindromes of 10858: ', palins)

Result

DAILY
PROGRAMMER
Palindromes of 10858:  2221222 25152 G1G CQC AJA 8U8