Create an elixir quine #1

Open
emson opened this Issue Nov 27, 2015 · 11 comments

Comments

Projects
None yet
4 participants
@emson
Owner

emson commented Nov 27, 2015

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

@phanimahesh

This comment has been minimized.

Show comment
Hide comment
@phanimahesh

phanimahesh Nov 27, 2015

"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

"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

@CoderDennis

This comment has been minimized.

Show comment
Hide comment
@CoderDennis

CoderDennis Nov 30, 2015

Contributor

"x"

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.

http://twitter.com/CoderDennis

Contributor

CoderDennis commented Nov 30, 2015

"x"

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.

http://twitter.com/CoderDennis

@phanimahesh

This comment has been minimized.

Show comment
Hide comment
@phanimahesh

phanimahesh Dec 1, 2015

@CoderDennis Unfortunately, a value that is echoed in a REPL is not considered a quine. And if it is, for the record, I submit 0, which shaves a whooping 66% off yours. :neckbeard:

@CoderDennis Unfortunately, a value that is echoed in a REPL is not considered a quine. And if it is, for the record, I submit 0, which shaves a whooping 66% off yours. :neckbeard:

@emson

This comment has been minimized.

Show comment
Hide comment
@emson

emson Dec 1, 2015

Owner

@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.
However I like you creative thinking, we haven't had many solutions and in the spirit of fun... I'll give you and honourable mention!

Owner

emson commented Dec 1, 2015

@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.
However I like you creative thinking, we haven't had many solutions and in the spirit of fun... I'll give you and honourable mention!

@CoderDennis

This comment has been minimized.

Show comment
Hide comment
@CoderDennis

CoderDennis Dec 1, 2015

Contributor

@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?

Contributor

CoderDennis commented Dec 1, 2015

@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?

@emson

This comment has been minimized.

Show comment
Hide comment
@emson

emson Dec 1, 2015

Owner

@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.
Also, TBH this puzzle hasn't been very popular, but any contributions are warmly welcomed! Thanks and good luck.

Owner

emson commented Dec 1, 2015

@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.
Also, TBH this puzzle hasn't been very popular, but any contributions are warmly welcomed! Thanks and good luck.

@CoderDennis

This comment has been minimized.

Show comment
Hide comment
@CoderDennis

CoderDennis Dec 1, 2015

Contributor
"(&(IO.puts~s(\#{inspect &1}|>\#{&1}))).()"|>(&(IO.puts~s(#{inspect &1}|>#{&1}))).()

84 chars. It requires a few extra parenthesis and some ampersands, but removes fn x-> and end chars. Again, I'm hoping it's OK to borrow from already posted solutions. I wouldn't have come up with this without seeing the solution @phanimahesh posted.

Also works without the spaces for 82:

"(&(IO.puts~s(\#{inspect&1}|>\#{&1}))).()"|>(&(IO.puts~s(#{inspect&1}|>#{&1}))).()

@CoderDennis

Contributor

CoderDennis commented Dec 1, 2015

"(&(IO.puts~s(\#{inspect &1}|>\#{&1}))).()"|>(&(IO.puts~s(#{inspect &1}|>#{&1}))).()

84 chars. It requires a few extra parenthesis and some ampersands, but removes fn x-> and end chars. Again, I'm hoping it's OK to borrow from already posted solutions. I wouldn't have come up with this without seeing the solution @phanimahesh posted.

Also works without the spaces for 82:

"(&(IO.puts~s(\#{inspect&1}|>\#{&1}))).()"|>(&(IO.puts~s(#{inspect&1}|>#{&1}))).()

@CoderDennis

@emson

This comment has been minimized.

Show comment
Hide comment
@emson

emson Dec 1, 2015

Owner

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.

Owner

emson commented Dec 1, 2015

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.

@rubysolo

This comment has been minimized.

Show comment
Hide comment
@rubysolo

rubysolo Dec 2, 2015

q=<<"q=~p;:io.format q,[q]">>;:io.format q,[q]

@rubysolo

rubysolo commented Dec 2, 2015

q=<<"q=~p;:io.format q,[q]">>;:io.format q,[q]

@rubysolo

@phanimahesh

This comment has been minimized.

Show comment
Hide comment
@phanimahesh

phanimahesh Dec 3, 2015

@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 You, sir, are a genius! I never even considered the beautiful :io.format. Elixir spoiled me.

@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 You, sir, are a genius! I never even considered the beautiful :io.format. Elixir spoiled me.

@emson

This comment has been minimized.

Show comment
Hide comment
@emson

emson Dec 4, 2015

Owner

@rubysolo that is great well done!

Owner

emson commented Dec 4, 2015

@rubysolo that is great well done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment