Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ×/¨1<⊂|⍳
- ×/¨1<⊂|⍳ Right argument: h w
- ⍳ Generate all index pairs (1-based) of a h×w array.
- ⊂ Enclose (h w), so it depth matches the one of the index array.
- | For each pair (i j) compute the remainders of the division by (h w).
- 1< Compare all remainders with 1.
- ×/¨ Reduce each pair of Booleans by multiplication.
- 2$l3XyZ+3=
- % Grab two input parameters implicitly
- 2$l % Create a matrix of ones that has the dimensions specified as inputs
- 3 % Number literal 3
- Xy % Create a 3x3 identity matrix
- Z+ % Perform 2D convolution (preserving size)
- 3= % Create a logical matrix where values == 3 are 1 and 0 otherwise (boundary)
- % Implicitly display output.
- @(x)conv2(ones(x),eye(3),'s')>2
- @(x)imagesc(conv2(ones(x),eye(3),'s')>8)
- ans([6,9])
- 2$lO6Lt4$(
- 2$l % Implicit inputs M, N. Generate M×N array of ones
- O % Push number 0
- 6Lt % Push [2 -1] twice, corresponding to index "2:end-1"
- 4$( % Fill the center of the array with value 0. Implicit display
- 2$Ol6Lt4$(1YG
- >> matl 2$Ol6Lt4$(1YG
- > 5
- > 7
- p%€,>1P€G
- p%€,>1P€sG Main link. Arguments: h (height), w (width)
- p Cartesian product; return all pairs in [1, ..., h] × [1, ..., w].
- , Yield the pair [h, w].
- %€ For each pair [i, j] in the product, compute [i % h, j % w].
- >1 Compare all resulting moduli with 1.
- P€ Compute the product of each pair of Booleans.
- s Split the resulting flat list into rows of length w.
- G Display the results in a 2D grid.
- julia> f(n,m)=[n>i>1<j<m for i=1:n,j=1:m]
- f (generic function with 1 method)
- julia> f(4,4)
- 4x4 Array{Bool,2}:
- false false false false
- false true true false
- false true true false
- false false false false
- julia> f(1,1)
- 1x1 Array{Bool,2}:
- false
- julia> f(2,5)
- 2x5 Array{Bool,2}:
- false false false false false
- false false false false false
- l~S*a*{3a.f|W%z}4*N*
- l~ e# Read and evaluate input, dumping h and w on the stack.
- S* e# Create a string of w spaces.
- a* e# Create an array of h copies of that string.
- { e# Repeat this block 4 times...
- 3a.f| e# For each character in the first row, take its bitwise OR with 3, turning
- e# spaces into # and leaving # unchanged.
- W%z e# Reverse and transpose the grid, rotating it by 90 degrees.
- }4*
- N* e# Join the lines of the result with linefeeds.
- jQ]Uajt%!RQt%!|
- - Q = eval_input()
- j - j = eval_input()
- jQ] - [Q,j]
- U - create a 3d array sized Q by j with coords
- a - for each coord (2d for)
- jt%! - not (coord_1 % j-1)
- | - ^ or V
- Qt%! - not (coord_2 % Q-1)
- jQ]Uajt%RQt%&
- (n,m)=>Array(n).fill(' '.repeat(m).replace(/^ | $/g,0)).join`
- `.replace(/^.+|.+$/g,'0'.repeat(m))
- d+
- $*
- S_`1(?=.* (1+))|.
- T`1`#`^.+|.+$|.?¶.
- d+
- $*
- S_`1(?=.* (1+))|.
- T`1`#`^.+|.+$|.?¶.
- ;'#*;))¬' *'#;)@+(+nXX(
- ;'#*;))¬' *'#;)@+(+nXX(
- (implicit) push all input to stack
- ;'#* push a string containing X #s
- ;)) dupe, and push both to bottom of stack
- ¬' * push a string containing (X-2) spaces
- '#;)@+(+ add a # to the front and the back of the string
- nXX make (Y-2) copies
- ( bring one of the "#"*X strings back to the top
- (implicit) pop and print each stack item, separated by newlines
- ->x,y{h=?#;puts t=h*x,y>1?[[h+(x<2?'':' '*(x-2)+h)]*(y-2),t]:p}
- INPUT x,y
- FOR i=1TO y
- FOR j=1TO x
- ?i MOD y<2OR j MOD x<2;
- NEXT
- ?
- NEXT
- ? 5,3
- -1 -1 -1 -1 -1
- -1 0 0 0 -1
- -1 -1 -1 -1 -1
- INPUT x,y
- SCREEN 9
- FOR i=1TO y
- FOR j=1TO x
- PSET(j*3,i*3),i MOD y<2OR j MOD x<2
- NEXT
- NEXT
- DECLARE @ INT=3,@y INT=5
- PRINT REPLICATE(1,@)+ISNULL('
- '+REPLICATE('1'+ISNULL(SPACE(@-2),'')+'1
- ',@y-2)+REPLICATE(1,@),'')
- P3G$PG@PS@S$B$T1B@T1B$T1B@
- P3 Paint current square with 3
- G$P Get: sets $ from input P
- G@P Get: sets @ from input P
- S@ Subtract 1 from @
- S$ Subtract 1 from $
- B$ Brush $ more square[s]
- T1 Turn 1 right angle clockwise
- B@ Brush @ more square[s]
- T1 Turn 1 right angle clockwise
- B$ Brush $ more square[s]
- T1 Turn 1 right angle clockwise
- B@ Brush @ more square[s]
- x0y9P3G$PG@PS@S$B$T1B@T1B$T1B@
Add Comment
Please, Sign In to add comment