?d == 100
.z
evaluates to at least "", which is a truthy value allowing the print to run.- Remainder
<1
saves 1 character over==0
. - Operator precedence used here:
==
or<
, then&&
, then||
. - Omitting brackets on
IO.puts
saves 1 character. ,do:
is 1 character shorter thando end
.
#ElixirGolf FizzBuzz https://twitter.com/elixirgolf/status/665139870818574336
# for x<-1..?d,do: IO.puts(if rem(x,3)==0 or rem(x,5)==0,do: (if rem(x,3)==0,do: "Fizz",else: "")<>(if rem(x,5)==0,do: "Buzz",else: ""),else: x) | |
# for x<-1..?d,do: IO.puts(if rem(x,3)>0 and rem(x,5)>0,do: x,else: (if rem(x,3)>0,do: "",else: "Fizz")<>(if rem(x,5)>0,do: "",else: "Buzz")) | |
# for x<-1..?d,do: IO.puts(if rem(x,3)>0&&rem(x,5)>0,do: x,else: (if rem(x,3)>0,do: "",else: "Fizz")<>(if rem(x,5)>0,do: "",else: "Buzz")) | |
# for x<-1..?d,do: IO.puts if rem(x,3)>0&&rem(x,5)>0,do: x,else: (if rem(x,3)>0,do: "",else: "Fizz")<>(if rem(x,5)>0,do: "",else: "Buzz") | |
# for x<-1..?d,do: IO.puts if rem(x,3)>0&&rem(x,5)>0,do: x,else: "#{(if rem(x,3)<1,do: "Fizz")}#{(if rem(x,5)<1,do: "Buzz")}" | |
# for x<-1..?d,do: IO.puts if rem(x,3)>0&&rem(x,5)>0,do: x,else: "#{rem(x,3)<1&&"Fizz"||""}#{rem(x,5)<1&&"Buzz"||""}" | |
# for x<-1..?d,do: IO.puts if rem(x,3)>0&&rem(x,5)>0,do: x,else: (rem(x,3)<1&&"Fizz"||"")<>(rem(x,5)<1&&"Buzz"||"") | |
# for x<-1..?d,do: IO.puts rem(x,3)>0&&rem(x,5)>0&&x||(rem(x,3)<1&&"Fizz"||"")<>(rem(x,5)<1&&"Buzz"||"") | |
# for x<-1..?d,do: IO.puts (z=(rem(x,3)<1&&"Fizz"||"")<>(rem(x,5)<1&&"Buzz"||""))&&z==""&&x||z | |
# Current best, 89 characters: | |
for x<-1..?d,z=(rem(x,3)<1&&"Fizz"||"")<>(rem(x,5)<1&&"Buzz"||""),do: IO.puts z==""&&x||z |
This comment has been minimized.
This comment has been minimized.
87!
|
This comment has been minimized.
This comment has been minimized.
oh wow... I'll have to update FizzBuzz ... meh ;o) |
This comment has been minimized.
This comment has been minimized.
I love the |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This comment has been minimized.
88! Using a twist on your own
<1
trick: