MATL, (削除) 30 (削除ここまで) (削除) 29 (削除ここまで) 25 bytes
2ZG:i:!J*+2&!-|i<so2&!1YG
Input format:
- Colormap as a matrix of values between 0 and 255, where each row defines a color
- W
- H
- Column vector of 1-based center coordinates as complex values (x is the real part, y is the imaginary part)
- Column vector of radii.
Try at MATL Online! MATL Online! Or verify the last test case verify the last test case. (The interpreter is still experimental. You may need to refresh the page and try again if it doesn't work).
Explanation
The code uses complex numbers to define the grid of points and to compute distances, and makes heavy use of array operations with broadcasting.
2ZG % Implicitly input matrix of colors. Set as colormap
: % Implicitly input W. Push [1 2 ... W]
i: % Input H. Push [1 2 ... H]
!J* % Transpose, multiply by 1i
+ % Add element-wise with broadcast. Gives ×ばつW grid of points as
% complex numbers, 1-based
2&! % Permute first dimension with the third. Gives a ×ばつH array
-| % Implicitly input center coordinates. Subtract grid from them,
% element-wise with broadcast. Gives a ×ばつW array, where C is the
% number of circles
i % Input column vector of circle radii
< % Less than, element-wise with broadcast
so % Sum along first dimension, modulo 2. Gives a ×ばつH array
2&! % Permute first dimension with the third. Gives a a ×ばつW array
1YG % Display as scaled image
MATL, (削除) 30 (削除ここまで) (削除) 29 (削除ここまで) 25 bytes
2ZG:i:!J*+2&!-|i<so2&!1YG
Input format:
- Colormap as a matrix of values between 0 and 255, where each row defines a color
- W
- H
- Column vector of 1-based center coordinates as complex values (x is the real part, y is the imaginary part)
- Column vector of radii.
Try at MATL Online! Or verify the last test case. (The interpreter is still experimental. You may need to refresh the page and try again if it doesn't work).
Explanation
The code uses complex numbers to define the grid of points and to compute distances, and makes heavy use of array operations with broadcasting.
2ZG % Implicitly input matrix of colors. Set as colormap
: % Implicitly input W. Push [1 2 ... W]
i: % Input H. Push [1 2 ... H]
!J* % Transpose, multiply by 1i
+ % Add element-wise with broadcast. Gives ×ばつW grid of points as
% complex numbers, 1-based
2&! % Permute first dimension with the third. Gives a ×ばつH array
-| % Implicitly input center coordinates. Subtract grid from them,
% element-wise with broadcast. Gives a ×ばつW array, where C is the
% number of circles
i % Input column vector of circle radii
< % Less than, element-wise with broadcast
so % Sum along first dimension, modulo 2. Gives a ×ばつH array
2&! % Permute first dimension with the third. Gives a a ×ばつW array
1YG % Display as scaled image
MATL, (削除) 30 (削除ここまで) (削除) 29 (削除ここまで) 25 bytes
2ZG:i:!J*+2&!-|i<so2&!1YG
Input format:
- Colormap as a matrix of values between 0 and 255, where each row defines a color
- W
- H
- Column vector of 1-based center coordinates as complex values (x is the real part, y is the imaginary part)
- Column vector of radii.
Try at MATL Online! Or verify the last test case. (The interpreter is still experimental. You may need to refresh the page and try again if it doesn't work).
Explanation
The code uses complex numbers to define the grid of points and to compute distances, and makes heavy use of array operations with broadcasting.
2ZG % Implicitly input matrix of colors. Set as colormap
: % Implicitly input W. Push [1 2 ... W]
i: % Input H. Push [1 2 ... H]
!J* % Transpose, multiply by 1i
+ % Add element-wise with broadcast. Gives ×ばつW grid of points as
% complex numbers, 1-based
2&! % Permute first dimension with the third. Gives a ×ばつH array
-| % Implicitly input center coordinates. Subtract grid from them,
% element-wise with broadcast. Gives a ×ばつW array, where C is the
% number of circles
i % Input column vector of circle radii
< % Less than, element-wise with broadcast
so % Sum along first dimension, modulo 2. Gives a ×ばつH array
2&! % Permute first dimension with the third. Gives a a ×ばつW array
1YG % Display as scaled image
#MATL , (削除) 30 (削除ここまで)(削除) 29 (削除ここまで) 25 bytes
MATL , (削除) 30 (削除ここまで)(削除) 29 (削除ここまで) 25 bytes
2ZG:i:!J*+2&!-|i<so2&!1YG
Input format:
- Colormap as a matrix of values between 0 and 255, where each row defines a color
- W
- H
- Column vector of 1-based center coordinates as complex values (x is the real part, y is the imaginary part)
- Column vector of radii.
Try at MATL Online! Or verify the last test case. (The interpreter is still experimental. You may need to refresh the page and try again if it doesn't work).
###Explanation
Explanation
The code uses complex numbers to define the grid of points and to compute distances, and makes heavy use of array operations with broadcasting.
2ZG % Implicitly input matrix of colors. Set as colormap
: % Implicitly input W. Push [1 2 ... W]
i: % Input H. Push [1 2 ... H]
!J* % Transpose, multiply by 1i
+ % Add element-wise with broadcast. Gives ×ばつW grid of points as
% complex numbers, 1-based
2&! % Permute first dimension with the third. Gives a ×ばつH array
-| % Implicitly input center coordinates. Subtract grid from them,
% element-wise with broadcast. Gives a ×ばつW array, where C is the
% number of circles
i % Input column vector of circle radii
< % Less than, element-wise with broadcast
so % Sum along first dimension, modulo 2. Gives a ×ばつH array
2&! % Permute first dimension with the third. Gives a a ×ばつW array
1YG % Display as scaled image
#MATL , (削除) 30 (削除ここまで)(削除) 29 (削除ここまで) 25 bytes
2ZG:i:!J*+2&!-|i<so2&!1YG
Input format:
- Colormap as a matrix of values between 0 and 255, where each row defines a color
- W
- H
- Column vector of 1-based center coordinates as complex values (x is the real part, y is the imaginary part)
- Column vector of radii.
Try at MATL Online! Or verify the last test case. (The interpreter is still experimental. You may need to refresh the page and try again if it doesn't work).
###Explanation
The code uses complex numbers to define the grid of points and to compute distances, and makes heavy use of array operations with broadcasting.
2ZG % Implicitly input matrix of colors. Set as colormap
: % Implicitly input W. Push [1 2 ... W]
i: % Input H. Push [1 2 ... H]
!J* % Transpose, multiply by 1i
+ % Add element-wise with broadcast. Gives ×ばつW grid of points as
% complex numbers, 1-based
2&! % Permute first dimension with the third. Gives a ×ばつH array
-| % Implicitly input center coordinates. Subtract grid from them,
% element-wise with broadcast. Gives a ×ばつW array, where C is the
% number of circles
i % Input column vector of circle radii
< % Less than, element-wise with broadcast
so % Sum along first dimension, modulo 2. Gives a ×ばつH array
2&! % Permute first dimension with the third. Gives a a ×ばつW array
1YG % Display as scaled image
MATL , (削除) 30 (削除ここまで)(削除) 29 (削除ここまで) 25 bytes
2ZG:i:!J*+2&!-|i<so2&!1YG
Input format:
- Colormap as a matrix of values between 0 and 255, where each row defines a color
- W
- H
- Column vector of 1-based center coordinates as complex values (x is the real part, y is the imaginary part)
- Column vector of radii.
Try at MATL Online! Or verify the last test case. (The interpreter is still experimental. You may need to refresh the page and try again if it doesn't work).
Explanation
The code uses complex numbers to define the grid of points and to compute distances, and makes heavy use of array operations with broadcasting.
2ZG % Implicitly input matrix of colors. Set as colormap
: % Implicitly input W. Push [1 2 ... W]
i: % Input H. Push [1 2 ... H]
!J* % Transpose, multiply by 1i
+ % Add element-wise with broadcast. Gives ×ばつW grid of points as
% complex numbers, 1-based
2&! % Permute first dimension with the third. Gives a ×ばつH array
-| % Implicitly input center coordinates. Subtract grid from them,
% element-wise with broadcast. Gives a ×ばつW array, where C is the
% number of circles
i % Input column vector of circle radii
< % Less than, element-wise with broadcast
so % Sum along first dimension, modulo 2. Gives a ×ばつH array
2&! % Permute first dimension with the third. Gives a a ×ばつW array
1YG % Display as scaled image
- 106.7k
- 10
- 139
- 382
#MATL, (削除) 30 (削除ここまで) (削除) 29 (削除ここまで) 25 bytes
2ZG:i:!J*+2&!-|i<so2&!1YG
Input format:
- Colormap as a matrix of values between 0 and 255, where each row defines a color
- W
- H
- Column vector of 1-based center coordinates as complex values (x is the real part, y is the imaginary part)
- Column vector of radii.
Try at MATL Online! Or verify the last test case. (The interpreter is still experimental. You may need to refresh the page and try again if it doesn't work).
###Explanation
ThisThe code uses complex numbers to define the grid of points and to compute distances, and makes heavy use of array operations with broadcasting.
2ZG % Implicitly input matrix of colors. Set as colormap
: % Implicitly input W. Push [1 2 ... W]
i: % Input H. Push [1 2 ... H]
!J* % Transpose, multiply by 1i
+ % Add element-wise with broadcast. Gives ×ばつW grid of points as
% complex numbers, 1-based
2&! % Permute first dimension with the third. Gives a ×ばつH array
-| % Implicitly input center coordinates. Subtract grid from them,
% element-wise with broadcast. Gives a ×ばつW array, where C is the
% number of circles
i % Input column vector of circle radii
< % Less than, element-wise with broadcast
so % Sum along first dimension, modulo 2. Gives a ×ばつH array
2&! % Permute first dimension with the third. Gives a a ×ばつW array
1YG % Display as scaled image
#MATL, (削除) 30 (削除ここまで) (削除) 29 (削除ここまで) 25 bytes
2ZG:i:!J*+2&!-|i<so2&!1YG
Input format:
- Colormap as a matrix of values between 0 and 255, where each row defines a color
- W
- H
- Column vector of 1-based center coordinates as complex values (x is the real part, y is the imaginary part)
- Column vector of radii.
Try at MATL Online! Or verify the last test case. (The interpreter is still experimental. You may need to refresh the page and try again if it doesn't work).
###Explanation
This uses complex numbers to define the grid of points and compute distances, and makes heavy use of array operations with broadcasting.
2ZG % Implicitly input matrix of colors. Set as colormap
: % Implicitly input W. Push [1 2 ... W]
i: % Input H. Push [1 2 ... H]
!J* % Transpose, multiply by 1i
+ % Add element-wise with broadcast. Gives ×ばつW grid of points as
% complex numbers, 1-based
2&! % Permute first dimension with the third. Gives a ×ばつH array
-| % Implicitly input center coordinates. Subtract grid from them,
% element-wise with broadcast. Gives a ×ばつW array, where C is the
% number of circles
i % Input column vector of circle radii
< % Less than, element-wise with broadcast
so % Sum along first dimension, modulo 2. Gives a ×ばつH array
2&! % Permute first dimension with the third. Gives a a ×ばつW array
1YG % Display as scaled image
#MATL, (削除) 30 (削除ここまで) (削除) 29 (削除ここまで) 25 bytes
2ZG:i:!J*+2&!-|i<so2&!1YG
Input format:
- Colormap as a matrix of values between 0 and 255, where each row defines a color
- W
- H
- Column vector of 1-based center coordinates as complex values (x is the real part, y is the imaginary part)
- Column vector of radii.
Try at MATL Online! Or verify the last test case. (The interpreter is still experimental. You may need to refresh the page and try again if it doesn't work).
###Explanation
The code uses complex numbers to define the grid of points and to compute distances, and makes heavy use of array operations with broadcasting.
2ZG % Implicitly input matrix of colors. Set as colormap
: % Implicitly input W. Push [1 2 ... W]
i: % Input H. Push [1 2 ... H]
!J* % Transpose, multiply by 1i
+ % Add element-wise with broadcast. Gives ×ばつW grid of points as
% complex numbers, 1-based
2&! % Permute first dimension with the third. Gives a ×ばつH array
-| % Implicitly input center coordinates. Subtract grid from them,
% element-wise with broadcast. Gives a ×ばつW array, where C is the
% number of circles
i % Input column vector of circle radii
< % Less than, element-wise with broadcast
so % Sum along first dimension, modulo 2. Gives a ×ばつH array
2&! % Permute first dimension with the third. Gives a a ×ばつW array
1YG % Display as scaled image