Øêîëà179: /Èíôîðìàòèêà//Èíôîðìàòèêà / Àðõèâ/2014//Èíôîðìàòèêà / Àðõèâ / 2014 / 8 Á 1/ñaesarcipher ...

 
Ýòî ñòàðàÿ âåðñèÿ Èíôîðìàòèêà/Àðõèâ/2014/8Á1/ñaesarcipher çà 2013-12-21 13:56:31..

Çàäà÷à 1.
Íàïèñàòü ôóíêöèþ encrypt_caesar_cipher(key, key_string, text), ïðèíèìàþùóþ òðè ïàðàìåòðà: êëþ÷; íàáîð ñèìâîëîâ, â êîòîðûõ ïðîèçâîäèòñÿ öèêëè÷åñêàÿ ïåðåñòàíîâêà; è ñòðîêó, êîòîðóþ íåîáõîäèìî çàøèôðîâàòü øèôðîì öåçàðÿ.
Àëãîðèòì òàêîé: áåð¸ì î÷åðåäíóþ áóêâó èç text, èùåì å¸ â key_string. Åñëè îíà íå íàéäåíà, òî âûäà¸ì å¸ áåç èçìåíåíèé. Åñëè íàéäåíà, è å¸ íîìåð ðàâåí i, òî âûäà¸ì áóêâó key_string[i+key%len], ãäå len – äëèíà key_string.
Ïðîãðàììà äîëæíà âûäàòü çàøèôðîâàííóþ ñòðî÷êó.

print(encrypt_caesar_cipher(int(input()), input(), input()))


Ïðèìåðû.

0
ABCDEF
A + B = C

A + B = C

3
ABCDEF
A + B = C

D + E = F

11
ABCDEFGHIJKLMNOPQRSTUVWXYZ
HELLO, WORLD!

SPWWZ, HZCWO!

71
àáâãäå¸æçèéêëìíîïðñòóôõö÷øùüûúýþÿÀÁÂÃÄŨÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÜÛÚÝÞßabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890 .,!?:;+=-'
Îí çäåñü áûâàë: åùå íå â ãàëèôå — â ïàëüòî èç äðàïà; ñäåðæàííûé, ñóòóëûé. Àðåñòîì çàâñåãäàòàåâ êàôå ïîêîí÷èâ ïîçæå ñ ìèðîâîé êóëüòóðîé, îí ýòèì êàê áû îòîìñòèë (íå èì, íî Âðåìåíè) çà áåäíîñòü, óíèæåíüÿ, çà ñêâåðíûé êîôå, ñêóêó è ñðàæåíüÿ â äâàäöàòü îäíî, ïðîèãðàííûå èì.
1tÜnjkxGÜgHhfrßÜkFkÜtkÜhÜifroAkÜ—Üh Üvfr Gyu Üon Üjwfvfa Üxjkwmftt Hp Ú Üxzyzr Hp ÛÜ Mwkxyus Ünfhxkijfyfkh Üqf Ak Üvuqut Doh Üvunmk Üx Üsowuhup Üqzr Gyzwup Ú Üut Ü Jyos Üqfq Üg H Üuyusxyor Ü?(tkÜosÚÜtuÜOwkskto)Ünf Ügkjtuxy GÚ Üztomkt GLÚ Ünf Üxqhkwt Hp Üqu Ak Ú Üxqzqz Üo Üxwfmkt GL Üh Üjhfj Cfy G Üujtu Ú Üvwuoiwftt Hk Üos Û?

Çàäà÷à 2.
Ðàñøèôðîâàòü øèôðîâàííûé òåêñò, åñëè èçâåñòíî, ÷òî key_string = «àáâãäå¸æçèéêëìíîïðñòóôõö÷øùüûúýþÿÀÁÂÃÄŨÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÜÛÚÝÞßabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890, ;.!?'»,
à øèôðîâàííûé òåêñò òàêîé:


ö7W9SZS61XL0S 19S5ML07?16X66â5LñS6 X51975LôSL7TãX3 1U670 áLî4SL1LW7T9SMLT74á67L,5X6MLV9S6áL87? 7L 78?X'á Q Lù SL 41 L 879 SQ Ló 14 â 2 Lê S 576 MLV 4 ¸ 6 á ML 6 SL?? 7L978àX'áOLö97 1ULU16âL?áX2ML6XL391?1ML0 9S0 áL7T,¸4SQLùâL41L0LZX6âL Sà 1 'á LUL 67??1L?S0 áL7WX¸4SQLù78?X'á ML 391???áOLç4SV7L6XLV9XX ROLô7LTX0L4,?SML? 7L61L8X9X?áML0X5¸L6XL09XX OLö,0 7L9X?X',T1 LU0åLUX9,ROLèL.4XTXML? 7LX'áML567V7L4áML03SZ1MLU1WX4L84XUX4,QLRî47LU.7W1 LUL?X0 áL9S06â.,Lö S 6? X76âQLRî47L1LW7T97L8S97åL9,3L?S0 7L0WSX 0¸OLêXUXL9SU67LU0XML? 7LU739,VL S411LUáX 0¸OLþ,åML05,àX6MLU74åL39,Z1 áL8 1!XLWU,V4SU72OOORLòXU72MLêS576MLWX4L6XL0UX9'1 áML0WX4S66â.L89SU72OLRùS3OLô7LULV97T,ML,0375LUX4á51ML09X áL0XT¸L6SVSMLTâU'1LU7L4T,L8¸WX2L0X51M-Lä 7L41LT4SV7QLôâ6?XL0 7åOLîSU 9SML8X6¸2ML4¸V,L3747W72ROLê,',L0U7åMLW9,VML6XL9SU6¸2L0L51472L89197W72PLí106áL6XL5XWS4áMLU1W6S¸L6S5L047U75L1LTå0 75OLèLZ1061LX0 áLWS4áMLT4103S¸L06S5ML?,ZWS¸L?,U0 US5L04â5L1LT4SV15MLVWXL61L67V72Lç7VL1L0U7T7WSOLþ 7LW7LT7V16áMLULWXUXL6SV72L0915LS6 187WSOLñSTâL6XL S3MLTâ41L0X2?S0LU743S51LUL0 SXOLéX9TL6SL8¸ S3LTâ4LTâL,L6S0ML9X'3SL-LULñ1 SXOLø84åà141LTL47TOLèLTX0W6,L07'47LTL0746!XLêSU1WSOLçâ4LTâL87 78OLç9S41LTâLULV97TLS0LS4;SU1 SOLö7467MLêS576OLè0åW,L0U72L9,Tá ML 0 U 72 L 1 X 97 V 41?;OLýS9áLø747576L09X61X5LUV4,Tá L? S3L41L,97W41UQLø 9S0 1L6XL9S X2LUL67?áL6XLU79,å OLö7467L0 19S áLV9S61L0 9S0 X2OLùS3L6XLU7åå OLí106áL6XL5XWS4áOLó19L-L6XL?X3S6LWU,.L7T797 7UOLèLZ1061LX0 áLWS4áML ¸6,àSLS6L8 1!LZX4 797 â.OLè1W67MLTXZ1 LV9,Tâ.L 9 S 5 X 6 L 5 SX? 670 áL8 1?á¸OLó,W9â2ML3S3LZ1WML514â2LêS576MLU7 L XTXL891 ?,WOLò7U1 MLV4¸W1'áML0 9SZLV747W9S6!SOLè79SL08S0, L67V1ML âL561'áQLù74á37L8970 9S60 U7PLù7 LZXL8970 79L89¸?X LT4SV1.LñX0S9¸L37812ML0 971 L' S? X9MLV9XX L6SV1.MLUL00SW16,L379812L34SWX ML3S3L.4XTL34SWX LUL,0 SML87 ?,¸L0197 OLèL7U?12LUX9 X8L89¸?X Lú 910? SL-L.X9L XTXMLï97WOLæ0LU70WSX :L0S0 1 L9STS5L8X94âLUL37976XOLè74åLWSX MLWSUL87L97VS5MLTX472L3797UXOLèL0X54¸.L1LW6¸.L UX9Wâ2L9,TXZL!S90 U1åL34SWX OLèLZSW6â.L8X03S.ML05X9 1L8975XZMLWX4SX L34SWX0áOLñX0S9¸L57àáL378á¸L7L84SàL67à1L10, 81 MLU7160 U,L97àMLU7160 U,L?Sà L?!1;972L,0, 81 OLñ74áL6XL891'1 L3L5X0, ML 7LZS áL0 S47L41L,'1QLø,'SL0 9S'1 L-L579X5LTXZS áL57ZX'áL7 L0,'1OLþ 7LX0 áLW41672LT41037L09SU61 áL0L8S.7 72Ló4X?672QLñLWXUXL7W672L0X9W!XL0 9X51 áL-L? 7LTX0376X?6X2QLþ 7L6XL9S0?X0 X91LZWS áL847WL10L, 97TâLW74á'XML?X5L0WX0áLV9S61L0 19S áLT4SVSL1L047TâOLèLV9X'672LW,'XL374áL6S 79X4LUL0379T6,LV7W16,ML561'áML? 7L,ZXL519L7T709X4QLê9S.5,LXW16,OLö9SU7MLêS576ML09¸L âL09SU614OLèâ'47L8X?S4á67OLê9,VML,TXZWX6:L âLU7075614L0.7W0 U7L04,?S267OLë0 áLUL9,TXZXL05X9 675L6SW9âUML0 9S'67LW7LW,91OLø4ST72LW,'XL05X9 áLX0 áL8910âUL3LTXV0 U,L3LôS, 9XOLùS3L41L âML5614MLT,WX'áLULV97T, 7¸60 U7OLæ6L874,?14L04,åL0,Wá T?,:LUX?67XL0 9S60 U7OLïàX'áMLV4¸Z,ML8, áL3L9,TXZ,L0L?X967V7L.7WSOLê9,VML6XL0,Z,OLç74á'XL03SZ,:Lç 7 V L?-L6XL89197WSOLê9,VML6XLT710áOL¨L6XLV97Z,OLøL51975L9S0079å0áOLé4¸Wå?1LUUâ0áMLT74á'XL03SZ,:Lç 7 VL 1 L 6 XL 07 UX 0? áOLõ6L-L1.L U79X!OLô76XL897UX9áML514â2L891¸ X4áML3 7L6S5:LWU79X!L-LZ1061L8915X9L-L141L070WS X4áQLèâ'XL4áLV4SUSLWX6áL7 7LW6¸L0L8X9X?6¸L3756S QLÄ 1L047USL8,0 áL7 L5X6¸Lñ,'6X9L0S87561 OLö,0 áL( 7L6XL0,W)L8756¸ áLW61MLVWXL6XL08S0, L?X0 670 áL1L3,à1OLîSV6S66â2L0UX9áL0 S, 2L8XU!SL0L!7374¸L0T9701 ML1T7ML87UX9áML61à1L0X9W!SL0L5X9 U7V7L08970¸ OLî4SL1LW7T9SML514â2LêS576MLV9S6áL87? 7L 78?X'á Q Lù SL 41 L 879 SQ Lç 74 á 67 L?,5X6OLé4¸6áML6SL? 7L978àX'áOLù7ML? 7LU?X9SLW,.LUX0X4¸ML676XL,ZL847.7QLùSL41L879SQLùSL41L0X54¸QLùSL41Lä87.SQLê9,VML6XL07? 1Lä 1.L047UX0LR0L8,'31L87L5,.S5ROLêX47L897? 1L-L03S0S67LX0 ,.75L8áå LT4SV7WS áRL-L,09¸ MLU6X541ML!S90 U7L6XTX067OLþ 7LZL7 WSUS áL15L6SL0X541L!S90 U7L4åTX067QLù7L41L6XL0 âWQLæ6L7 WSX5OLç4SV7ML6XL81àX2OLùS3L1L847W1 L-L3STâLUWU7X5P-L61àXV7L61à12OLö,0 7L UX9W1' 7?L1L á5SL-LU97WXLWUSLT9S SROLøS5L1L847W1'áOL÷X0U70 áL,5SL.,ZXL9S0U9S SOLèL 75- 7L1L0, ?X6âL0,Tâ O Lô XL 7 TX 00?, 7L1LV9X.OLé9X.L6XL89X4åTâOLø8S áL6XL4åT¸L0, áL?X8,.SOLó67V7L57 1U,OLé9X.L6SL0XT¸OLôX, LV9X.SLT41Z61.L897 1U,OLø379T67L41LX0 áLW,',L X90S áQLø379T67L41LSàXLV9X'6,åLWX0 áL6SLW,',LU0¸ áQLøS.S9,L04SàXOLñS¸ á0¸L561'áML0.15,L8916¸ áML4T75LWSL7L8S8X9 áOLö704XLV4¸W1'áML08X9XW1LV4SWáMLTX4S¸L03S X9 áOLç7VSL,09X4PLø0SW1L7W6SL5X43S¸L07'3SOLèLä 75ML870 9X4MLT4SV70 áLU1W6SOLùS3L1L08S0X'á0¸OLù7ZL379ST4åLULT,9åL3S6S4L6,ZX6LW4¸LTXV0 7V7L09XW0 USOLñS3L61LV9X'1ML57Z67L,.US L0?10 1 áL7 L0SZ1OLèâ3,8LW,'1LT4SV75L?9XUS OLê9S.5SLU0XL SLZXPLö7467MLêS576ML? 7L0SL 703SL89SUWSLWU,41?á¸OL¨L, 754X6OLæ4á;SL4åW03SL-LW,.SLUX41?áXOLê,.L-LT4SV7WS áL UX9W1L1672L3LV790 7?3XL89S.SMLWSTâL6XL06S áLULV416XL0X5672L05X9 67V7L0 9S.SOLê,.L-Lä 7L61 áL0L6XT75L0U¸0S áLV416âL,97W0 U7MLWSTâL41'1 áL5X0 L70¸0S áL6S'XL0197 0 U7OLô1 3,L879UX'áL76â.LàXW97 L-L3S20¸L6SLUX X9OLñS¸ á0¸L 7LZLZWS áML? 7TâL 7 LT4SV75L7 UX 14ML37XV7LSZMLT74á67L,5X6MLUâ 743S4LULV9,W1OLó67V7L6XLWS'áLä 15MLêS576ML;79âLï,WXOLéWXL9S0W7Tâ áMLó,0S-0X0 9SML X47ML9S05X975L57V,àXLTâ áLî4SL1Lê7T9SLUL519XL8915X975QLø374áL61L39,Z,LU07975L0U715LU0åW,L87L0UX, MLU0XL6XL04XZ,L9SU67V7L15LUL519XL89XW5X, OLø19X?áML0,Z,,:LV9,Wáå L 072 W¸ 0 á MLWUX Lä? 1.Lø14âML?,ZWâL87TXWML9,T¸ 0¸LUL89S.ML 7?67L3S8,0 SOLè13 79SL6X OLù7- 7L1L0 9S.:LV4SU6âXL?,U0 USLUL?X9672L0X54XL5X9 Uâ L 4 XZS? LUL97àXL!UX, àX2OLó74?SLUWS41LU9S6âL39,ZS LZ1061LV9¸W,àX2OLü5X9L8S974áMLUXW'12L6S0L?9X0L?S0 âL X6X SOLRòáX 0¸L7 374áML8746S¸L04X0ML84S?,àSL67 SQLþX2L S5L.79S4LUL0X54åLUXWX L?S0 áL89XU70.7W6,QRLù7 ML3 7L X9¸4ML 7 L1L87X L8X06åL7 .7W6,OLñ 7L7T4SWS4ML57ZX L87W6¸ áL84S?L87L,976,OLRñ 7L870 9SWS4QRL÷S0UXL876¸ áLä 7LêS576,QLýS9áLU7LV4SUXML57Z67L8970 1 áMLUX3L6XL67?,X OLó7V,à12LWUXLTX0W6âLU5X0 1 áL 9X áåL87?,X PLö,0 7L9¸W1 áML419SML89SUXZOLó,0SL,0 S4SOLè0XL89X39S 1 áPLó6XL6XU X98XZOLøX9W!SL6XL0 S47OLø879à13L572LVWXQLèL736S.L61L0V1OLö,0 7L6SL39X04XOLêS áL87LTS4WXML? 7TâL570V1LV79475L874X041PLø14âL,'41OLéWXL572Lñ91 76QLéWXLX5,LWX á0¸QLè1Z,:LUWS41L3LWXUXLêS576LUL08S4á6åL39SWX 0¸OLø6XVL,L39â4X!L04XWL8797'1 OLú1 97L,0 9714PLçXW6â2L?X96X!OLRö47 áL6XLV9X'1 ROLù7L1L,0U714OLè897?X5MLT7VS OLê9S.5,L¸ 0 â 3 LWX 9 Z 1? L8914XZ67OLù7L4áL6S,VSWL3LWXUXL897613MLWX20 U,¸L6XZ67ML 7L41L6SLW67Lò7 âLV4¸W1 L0LT79 SL379â âOOOLè1Z,L7W67:L0L3X5- 7L0 71 MLV,Tâ L 9 S 039 â? âOLôXL9S0V4¸WX áL-LWXUSML0 S913Q-LUL 7?670 1L413SOLþ 7L, L0379TX áQLè7 L1LW70 1VL0.7W0 USLUX413SOLè7 L XTXL5X0 ,LWUSL0S2!SOLùà1'á0¸L9S0?X0 áML514â2ML87W1ML0L3X5L73S0S40¸QLêX20 U,2L05X4X2PLç74á67L,5X6OLè5X0 7L7 UX S:L0 7¸ L U7X2LW9S.5âMLêS576MLWXUSL1LòX SOLþX UX9 áL410 SOLøUX?1L 9XàS OLùX61L8X9X?, OLø57 91 L0UX0WSLUL8746â2L,'S OLóâ'1LàXTX?, OLç97015L8X97OLúS¸ áLV4,8!SL-Lä 7L41LW7T4X0 áQLùS3L41L.1 97QLê9XU6¸LUX6!SL015L6XL087W7T4å0áOLõT9S0âML897?áPLþS',L0LU1675PLþX0 U,X5LW9XU61.OLö70W6¸¸L67?áOLø6XVL0SL73675LULU1WXLWX9XUáXUO


Çàäà÷à 3.
Ðàñøèôðîâàòü øèôðîâàííûé òåêñò, åñëè èçâåñòíî òîëüêî òî, ÷òî èñïîëüçîâàëñÿ îïèñàííûé âûøå øèôð, à òàêæå ñàìà øèôðîâêà:


 
Ôàéëîâ íåò.[Ïîêàçàòü ôàéëû/ôîðìó]