0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

paiza.ioでelixir その351

Posted at

概要

paiza.ioでelixirやってみた。
atcoder、見つけたので、やってみた。

参考にしたページ

練習問題

ABC 049 C - Daydream
文字列Sが与えられ、始め空の文字列Tの末尾に "dream", "dreamer", "erase", "eraser"を追加する処理を行って、S=Tにできるか判定する問題です。

投入するソース

erasedream

期待値

YES

サンプルコード

defmodule Main do
	def proper_list?([]) do 
	    true 
	end
	def proper_list?(["m", "a", "e", "r", "d" | tl]) do 
	    proper_list?(tl) 
	end
	def proper_list?(["r", "e", "m", "a", "e", "r", "d" | tl]) do 
	    proper_list?(tl) 
	end
	def proper_list?(["e", "s", "a", "r", "e" | tl]) do 
	    proper_list?(tl) 
	end
	def proper_list?(["r", "e", "s", "a", "r", "e" | tl]) do 
	    proper_list?(tl) 
	end
	def proper_list?(_) do 
	    false 
	end
	def main do
		a = IO.gets("") 
		    |> String.trim() 
		    |> String.split("", trim: true)
		if proper_list?(a |> Enum.reverse) do
			IO.puts("YES")
		else
			IO.puts("NO")
		end
	end
end

実行結果

YES

成果物

以上。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?