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

challenge54_easy

''' A transposition cipher we'll call the "matrix cipher" can be defined as follows:
write each character in the text that you want to encrypt in a matrix of some specified width,
where the width is the key of the cipher. So, for instance, if you wanted to encrypt
"The cake is a lie!" with the key 3, you would write it like so (the spaces are
replaced with underscores for clarity):

T h e
_ c a
k e _
i s _
a _ l
i e !

Then to get the ciphertext, you simply read off the columns one by one. So in this case, the ciphertext would be
"T_kiaihces_eea__l!", or "T kiaihces eea  l!" if you put the spaces back in.

If the text doesn't fit the matrix perfectly, you add in random letters to fill in the last row. So, if we
wanted to encode "The cake is a lie!" with key 7, we'd construct this matrix:

T h e _ c a k
e _ i s _ a _
l i e ! v m z

Here "v", "m" and "z" have been added in to fill the last row, and the ciphertext is "Telh ieie s!c vaamk z".

Write an implementation of the matrix cipher that can both encode and decode text given the correct key.

BONUS: One of the major tricks code-crackers have used throughout history is the fact that the first parts
of many messages often follow a regular pattern. They start with "Hello" or "Greetings", "Transmission from"
or something like that (Allied codebreakers during World War II took advantage of the fact that Nazi
messages often began with "Heil Hitler").

Use this trick to construct a way to automatically crack messages encrypted with the matrix cipher. That is,
given a certain ciphertext to crack and the first few characters of the cleartext, figure out what the entire
message is without human input. Your code should just return the correct answer and optionally the key, but nothing else.

Try your code-cracker on this text, using the clue that the message starts with "It seems"
(or "It_seems", if you use the underscore):

I_rso_wotTe,taef_h__hl__socaeihtemonraaheamd_svemsp_l_ems_ayiN___Anofeadt.yueo_o
h_..__leaA_.iaastnY.snw__do__d_nyeuhl_foor_eiaotushlvrr.'oapee.avnv_d__he,ey_gOf
___oiunrbpaunieeer_r_l_geos_ctoingoloyfq_rcam__ilainpotlimadufhjv_llt_emiw_aevsd
nrsdriengieysr_p_tc_,tlfteuc_uitwrrawavzo_irhlez_ftrelszloyyry_bir__e_huv_no_ead
eauuyvsbs_mtoe_l.rb_urat_eeh_y_pOsreg_fjnp,rocucee___otn_cpgbmujltaayprgiayr_uep
fb_btt,velyahe_s,eogeraq__ue__ncysr.hcdzoo__ar_duftTcioi'tahkmnarwxeeeegeae_r__j

As you can see, there's plenty of punctuation in this text, but there are no new-lines, it is just one chunk of text.
And again, all spaces have been replaced with underscores for clarity, but you should remove those to make the
cleartext readable. If you do solve it, please put four spaces before the cleartext if you post it here, to
hide it for people who want to solve it themselves.
'''
code = "I_rso_wotTe,taef_h__hl__socaeihtemonraaheamd_svemsp_l_ems_ayiN___Anofeadt.yueo_o\
h_..__leaA_.iaastnY.snw__do__d_nyeuhl_foor_eiaotushlvrr.'oapee.avnv_d__he,ey_gOf\
___oiunrbpaunieeer_r_l_geos_ctoingoloyfq_rcam__ilainpotlimadufhjv_llt_emiw_aevsd\
nrsdriengieysr_p_tc_,tlfteuc_uitwrrawavzo_irhlez_ftrelszloyyry_bir__e_huv_no_ead\
eauuyvsbs_mtoe_l.rb_urat_eeh_y_pOsreg_fjnp,rocucee___otn_cpgbmujltaayprgiayr_uep\
fb_btt,velyahe_s,eogeraq__ue__ncysr.hcdzoo__ar_duftTcioi'tahkmnarwxeeeegeae_r__j"

n = 6
text = 'The way to Hungarton is to the east!'
print(len(text))
x = 0
# Loop while x is less than text
while x <= len(text):
    # print from starting position x to position x + n
    print(text[x:x + n])
    # increase x
    x += n

x = 0
cyphertext = ''
while x <= n - 1:
    for i in text[x::n]:
        cyphertext += i
    x += 1
print('cyphertext: ', cyphertext)

x = 0
text2 = ''
while x <= n - 1:
    for i in cyphertext[x::n]:
        text2 += i
    x += 1
print('text2: ',text2)


x = 0
text3 = ''
while x <= n + 1:
    for i in code[x::n + 2]:
        text3 += i
    x += 1
print(text3)

Result

36
The wa
y to H
ungart
on is 
to the
 east!

cyphertext:  Tyuot h nnoeetg  a oaitsw rshtaHt e!
text2:  The way to Hungarton is to the east!
It_seems_that_you've_been_living_two_lives._One_life,_you're_Thomas_A._Anderson,_program_writer_for_a_respectable_software_company._You_have_a_social_security_number,_pay_your_taxes,_and_you..._help_your_landlady_carry_out_her_garbage._The_other_life_is_lived_in_computers,_where_you_go_by_the_hacker_alias_Neo_and_are_guilty_of_virtually_every_computer_crime_we_have_a_law_for._One_of_these_lives_has_a_future,_and_one_of_them_does_not.ahfregiqiljmdnpftzzzbudbltpjcnjgpvsqczdiagj