/* It was just a bug (code golf) in Picat. https://codegolf.stackexchange.com/questions/129523/it-was-just-a-bug """ It was just a bug Inspired by the bugged output in @Carcigenicate's Clojure answer for the Print this diamond challenge. Print this exact text: 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1234567890 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 (From the middle outward in both directions, each digit is separated by one more space than the previous line.) Challenge rules: There will be no input (or an empty unused input). Trailing spaces are optional. A single trailing new-line is optional. Leading spaces or new-lines are not allowed. Returning a string-array isn't allowed. You should either output the text, or have a function which returns a single string with correct result. General rules: This is code-golf, so shortest answer in bytes wins. Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language. Standard rules apply for your answer, so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters and return-type, full programs. Your call. Default Loopholes are forbidden. If possible, please add a link with a test for your code. Also, please add an explanation if necessary. """ This program was created by Hakan Kjellerstrand, hakank@gmail.com See also my Picat page: http://www.hakank.org/picat/ */ import util. main => go. % 101 chars go=>T=(1..9++[0]).map(to_string),foreach(I in-8..8)T.join(cond(I==0,'',[' ':_ in 1..I.abs])).println end. % Ungolfed go_ungolfed ?=> T = (1..9++[0]).map(to_string), foreach(I in -8..8) % Darn, ['':_ in 0..0] give strange result. Fixed with cond/2 T.join(cond(I==0,'',[' ':_ in 1..I.abs])).println end. % Same idea but using list comprehension instead of a for loop. % It is actually one line since Picat supports function chaining. % 99 chars go2=>[(1..9++[0]).map(to_string).join(cond(I==0,'',[' ':_ in 1..I.abs])):I in-8..8].join("\n").println. % Not correct. Doesn't print anything since "1234567890".join(...) does not work. %% go3=>["1234567890".join(cond(I==0,'',[' ':_ in 1..I.abs])):I in-8..8].join("\n").println.