You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
1.3 KiB
24 lines
1.3 KiB
(with-temp-buffer |
|
;; enter original char matrix |
|
(insert-file-contents "input-test") |
|
(let* ((rows (-map 'string-to-list (split-string (buffer-substring-no-properties (point-min) (point-max))))) |
|
(rshifted-rows (-map-indexed (lambda (index el) (-concat (-repeat index ?-) el)) rows)) |
|
(lshifted-rows (reverse (-map-indexed (lambda (index el) (-concat (-repeat index ?-) el)) (reverse rows))))) |
|
(insert "!@#\n") |
|
;insert transposed |
|
(insert (mapconcat 'identity |
|
(--map (apply 'string it) (-unzip-lists rows )) "\n")) |
|
(insert "123\n") |
|
(insert (mapconcat 'identity |
|
(--map (apply 'string it) (apply '-zip-lists-fill ?- rshifted-rows)) "\n")) |
|
(insert "αρσ\n") |
|
(insert (mapconcat 'identity |
|
(--map (apply 'string it) (apply '-zip-lists-fill ?- lshifted-rows)) "\n")) |
|
(insert "abc\n")) |
|
(write-file "transposed") |
|
(goto-char (point-min)) |
|
(+ (length (-unfold (lambda (x) (if (search-forward "XMAS" nil t) '(t) (goto-char (point-min)) nil)) nil)) |
|
(length (-unfold (lambda (x) (when (search-forward "SAMX" nil t) '(t))) nil)))) |
|
|
|
; how to map the l-shifted coordinates to the r-shifted coordinates? |
|
; The column is the same; row - column
|
|
|