Pull to refresh

Comments 6

Скажу так. Меня жутко бесит синтаксис Го. Это моё сугубо личное ИМХО, не для холивара.

Но! Этот код выглядит мило)))
hellman, обязательно постараюсь подобрать проблему по-сложнее в следующий раз!
UFO landed and left these words here
SpyceR, большое спасибо за замечание! И как я такое допустил...
Жалко там J нет. Потому что такое на J писать — самое то.

NB. Explicit definition. Can be converted by 13 : '...' -- but it will give lots of [:
e=: 3 : 'FF-.~,|:'' '',~(c,~>.l%c=.>.%:l=.#t)$!.FF t=.'' ''-.~y'

NB. Tacit definition, step by step
t=: -.&' '          NB. text: without blanks
c=: >.@%:@#         NB. number of cols
d=: (>.@(%~#),[)~c  NB. dimension: rows,cols
m=: (d $!.FF ])@t   NB. matrix of letters
w=: ,@|:@(' ',~m)   NB. new words with blanks between them
h=: FF-.~w          NB. hackerrank encryption

NB. or the same in one line ;)
h=: FF-.~,@|:@(' ',~(((>.@(%~#),[)~>.@%:@#)$!.FF]))@(-.&' ')

echo (e ,: h) 'if man was meant to stay on the ground god would have given us roots'
NB.            imtgdvs fearwer mayoogo anouuio ntnnlvt wttddes aohghn sseoau

echo (e ,: h) 'hello dear world!'
NB.            horl edwd leo! lar

Для "квадратных" текстов двойное шифрование восстанавливает текст:

echo h h 'now is the time for all good men'
NB.  -->  nowis theti mefor allgo odmen
Sign up to leave a comment.

Articles