Last active
August 29, 2015 14:10
-
-
Save jonelf/9d67da670ddba9639a8a to your computer and use it in GitHub Desktop.
Diamond
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
first, last = "A".ord, "D".ord; | |
rows = (first...last).to_a + last.downto(first).to_a | |
cols = last.downto(first).to_a + (first + 1..last).to_a | |
rows.each do |row| | |
line = cols.map do |col| | |
col == row ? col.chr : "-" | |
end | |
puts line.join | |
end |
let c=['A'..'C'];d=reverse c in mapM_ putStrLn$chunksOf 5$(\x y->if(x==y)then x else '-')<$>c++tail d<*>d++tail c
(Although it requires a few imports, so is perhaps cheating ;-) But pretty much everything in Haskell needs a few imports...
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A,Z=65,90;((A...Z).to_a+Z.downto(A).to_a).map{|r|puts (Z.downto(A).to_a+(A+1..Z).to_a).map{|c|c==r ?c.chr: " "}*""}