We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#Fabian Garrido #Elixir defmodule WeeklyChallenge2022 do @spec main() :: :ok def main do draw_polygon(10, :square) draw_polygon(15, :triangle) draw_polygon(12, :diamond) end @spec draw_polygon(integer(), atom()) :: :ok defp draw_polygon(size, type) when is_integer(size) and size >= 2 do total_size = if type == :diamond, do: size * 2, else: size 1..total_size |> Enum.each(fn value -> case {type, value} do {:square, _} -> IO.puts(String.duplicate("* ", total_size)) {:triangle, _} -> IO.puts(String.duplicate("* ", value)) {:diamond, _} when value <= size -> IO.puts(String.duplicate("* ", value)) {:diamond, _} -> spaces = String.duplicate(" ", value - size) stars = String.duplicate("* ", total_size - value) IO.puts("#{spaces}#{stars}") end end) IO.puts("") end end WeeklyChallenge2022.main() ```
The text was updated successfully, but these errors were encountered:
No branches or pull requests
The text was updated successfully, but these errors were encountered: