Skip to content

Instantly share code, notes, and snippets.

@akovalenko
Created July 29, 2014 18:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akovalenko/ea8033d65e9948f94e6c to your computer and use it in GitHub Desktop.
Save akovalenko/ea8033d65e9948f94e6c to your computer and use it in GitHub Desktop.
(defvar *ru-vowels* "аоуыэяёюие")
(defun vowelp (character) (position character *ru-vowels*))
(defun move-vowels (n &optional (input *standard-input*) (output *standard-output*))
(let ((vowels 0))
(loop
(let ((character (read-char input nil :eof)))
(when (eq :eof character)
(return))
(if (alpha-char-p character)
(when (vowelp character)
(incf vowels))
(unless (< vowels n)
(unread-char character input)
(return)))
(write-char character output)))))
(defun format-cake (string &optional (output *standard-output*))
(with-input-from-string (input string)
(dolist (n '(9 8 9 8))
(move-vowels n input output)
(terpri output))))
#| Test:
(with-output-to-string (*standard-output*)
(format-cake "не пил не ел не спал однажды и невозможно похудел но не однажды а всё время такой олег олег олег и так"))
==> "не пил не ел не спал однажды
и невозможно похудел
но не однажды а всё время
такой олег олег олег
"
|#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment