-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
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
Create an elixir quine #1
Comments
"fn x->IO.puts ~s(\#{inspect x}|>\#{x}) end.()"|>fn x->IO.puts ~s(#{inspect x}|>#{x}) end.()
or
"fn x->IO.puts~s(\#{inspect x}|>\#{x}) end.()"|>fn x->IO.puts~s(#{inspect x}|>#{x}) end.() 90 chars, by @Phani_Mahesh |
3 chars. Meets the requirements listed. Enter that in iex and it's exactly what you'll get back. I don't think that's really what you were asking for, so I'll keep trying. |
@CoderDennis Unfortunately, a value that is echoed in a REPL is not considered a quine. And if it is, for the record, I submit |
@CoderDennis ha ha nice try... that is certainly a creative thought however a "... Quine is a computer program..." which implies an algorithm rather than returning a type such as a string or integer. Also as @phanimahesh mentions the REPL is doing the hardwork here. |
@emson thanks for laughing! That was my intent. As an Elixir newbie (installed it for the first time less than a month ago) this is a hard one to figure out using the REPL. The 2 times I thought I was getting close were when the REPL was using a previously bound variable and then when I realized it was just giving me back the string as-is. I've got lots of programming experience, but have never participated in a code golf challenge before. Since solutions are being posted publicly as comments, is it kosher to borrow from entries already given? |
@CoderDennis sure no problem at all. The Elixir community is very friendly and the whole purpose I set up elixirgolf is to help people learn elixir, and the more people become familiar with the language the better. |
84 chars. It requires a few extra parenthesis and some ampersands, but removes Also works without the spaces for 82:
|
Hey @CoderDennis that's great. Yes it's ok to be influenced by other people's solutions. Well done in citing @phanimahesh. Previous winners have persevered with their solutions and been influenced by others. We make sure both get a mention on the web site. Thanks again. |
q=<<"q=~p;:io.format q,[q]">>;:io.format q,[q] |
@CoderDennis cool. I wonder why I haven't thought of that! If you observe, my solution was itself inspired by the ruby quine in the post. |
@rubysolo that is great well done! |
Write an elixir quine. A Quine is a computer program which takes no input and produces a copy of its own source code as its only output. They are “self-replicating” or “self-reproducing” programs, and your task is to either create the shortest or the most creative elixir quine.
http://elixirgolf.com/articles/elixir-quine-self-replicating-program/
Please add your solutions as comments to this Github issue (+ your Twitter handle)... Thanks!
When the puzzle is over I'll write them up on http://elixirgolf.com and link back to your Twitter handle
The text was updated successfully, but these errors were encountered: