Draw a fuzzy grid

3

1

Print the ASCII version of a random grid.

################################################################################
#    #   #  #    #   #   #     #     #   #  #    #   #     #   #   #   #  #   # 
#    #   #  #    #   #   #     #     #   #  #    #   #     #   #   #   #  #   # 
#    #   #############   #     #     #   #  #    #   #     #   #   #   #  #   # 
##########   #   #   #####################  #    #   #     #   #####   ######## 
#    #   #   #   #   #   #   #   #       #######################   #####   #  ##
#    #   #   #   #   #   #   #   #       #  #   #     #   #    #   #   #   #  # 
#    #   #   #   #   #   #####   #       #  #   #     #   #    #   #   #########
##########################   #######################################   #    #  #
#    #    #   #   #  #   #   #    #      #   #   #   #   #     #   #####    #  #
#    #    #   #   #  #   #   #    #      #   #   #   #   #     #   #   #    ####
###############   #  #   #####    #      #   #   #   #   #     #   #   #    #  #
#    #   #    ########   #   ###################################   #   ######  #
#    #   #    #   #  #####   #     #    #  #    #   #   #      #########    #  #
######   #    #   #  #   #   #     #    #  #    #   #   #      #   #   #    #  #

The picture should illustrate the constraints:

  • # is solid, is empty.
  • Print 80 columns, at least 80 rows.
  • On the first and last columns and first and last rows there is some freedom, but at least the printout must be extendible to a legal grid.
  • Boxes contain empty areas between 1x1 and 7x7.
  • Constraints: Boxes are rectangular, no lonely corners (1), no empty boxes (2), no broken lines(3) or gaps (4), when in doubt refer to the image above.
  • A grid is considered "random", if the first 80 rows contain: 1.) 60 unique rows and 60 unique columns. 2.) At least one box with inner area of size (2, 2), (3, 2), (4, 2), (5, 2), (2, 3), (3, 3), (4, 3), (5, 3), (2, 4), (3, 4), (4, 4), (5, 4), (2, 5), (3, 5), (4, 5), (5, 5) each. You can verify the randomness and some constraints with this julia script.
  • The program should nondeterministically produce a minimum number of 1000 grids fulfilling the constraints with different first 80 rows, where rotations, circular shifts and reflections counted as same and the majority of produced grids should be "random" as specified above.
    #####4########################
    #                #   #    #    
    #    #       #   #   #    3    
    #    #       #########   #    
    #########1   #   #   #########
    #    #   #   #   ##2##   #   #
    #    #   #   #   #####   #   #
    #    #   #   #   #   #   #####

Code golf!

mschauer

Posted 2019-11-09T23:37:48.907

Reputation: 1 348

7

You need to specify exactly what you mean by random. "Do not systematically produce homogeneous rows of boxes..." also needs to be made objective.

– xnor – 2019-11-10T00:28:44.620

@xnor I created a rule specifying "randomness". – mschauer – 2019-11-10T11:22:28.547

You say "at least 80 rows" but - specifically - "80 columns". Is that indended? Also, your program gives a warning for more than 80 rows. – dzaima – 2019-11-10T12:39:23.240

The program expects you to submit the first 80 rows of your output, the remainder can be anything, as long as it is a valid labyrinth. – mschauer – 2019-11-10T13:03:20.667

I added a requirement discouraging to encode a hand drawn valid grid as 80*80 bit number ;-) – mschauer – 2019-11-10T13:13:51.660

@dzaima Yeah, it has to be non-deterministic... made a change. This is super tricky to specify. – mschauer – 2019-11-10T13:33:50.473

@Veskah, yes, I'll fix that. – mschauer – 2019-11-11T15:45:23.603

Hey OP - I've found it really difficult and stressful for handling the cascade of queries and objections on new code challenges. Just so you know, you're not alone. – AJFaraday – 2019-11-11T16:50:03.770

@AJFaraday No worries, maybe maybe the next time I use the sandbox... ;-) – mschauer – 2019-11-11T17:47:30.447

Answers

1

Julia, 254 bytes

Not very golfed, just to keep it going;

l=length
function f(M,r,s)
l(r)<7&&return l(s)>6&&g(M,r,s)
h,j=rand([f,g],2)
a,c=extrema(r)
b=rand(a+1:c-1)
M[b,s].=2
h(M,b+1:c,s)
j(M,a:b-1,s)
end
g(M,r,s)=f(M',s,r)
n=80
M=fill(1,n,n)
f(M,1:n,1:n)
for i∈1:n
print.(getindex.(" #",M[i,:]))
println()
end

Verification, try it yourself

mschauer

Posted 2019-11-09T23:37:48.907

Reputation: 1 348