読者です 読者をやめる 読者になる 読者になる

Let's write β

趣味で書いたこととか、RustとLispが好き

ICPC2004 Problem A

Hanafuda Shuffle
もちろんLisp

(defun create-deck (num)
  (loop for card from num downto 1
       collect card))
(defun cut (cards p c)
  (let
      ((head (loop for idx from 1 upto (1- p)
		collect (nth (1- idx) cards)))
       (selected (loop for idx from p upto (1- (+ p c))
		    collect (nth (1- idx) cards)))
       (tail (loop for idx from (+ p c) upto (length cards)
		collect (nth (1- idx) cards))))
    `(,@selected ,@head ,@tail)
    ))

(defun main ()
  (loop
     for n = (read)
     for deck = (create-deck n)
     for r = (read)
     until (and (zerop n) (zerop r))
     do
       (loop for i from 1 upto r
	    do
	    (setf deck (cut deck (read) (read)))
	    finally (format t "~A~%" (car deck))
	    )))

僕が働いているAzit.incでは一緒に働けるエンジニアを募集しています!
採用情報 — 株式会社アジット|Azit Inc.