Skip to main content
Commonmark migration
Source Link

#MATL, 11 bytes

MATL, 11 bytes

tZy1$rEki*+ 

Uses floating point random numbers.

Try it online!

Explanation

t % implicit input (array). Duplicate Zy % size (array specifying number of rows and columns) 1$r % random vector between 0 and 1 with that size Ek % duplicate, round down: gives 0 or 1 with the same probability i % input (number K to be added) * % multiply: gives either 0 or K for each element + % add element-wise 

#MATL, 11 bytes

tZy1$rEki*+ 

Uses floating point random numbers.

Try it online!

Explanation

t % implicit input (array). Duplicate Zy % size (array specifying number of rows and columns) 1$r % random vector between 0 and 1 with that size Ek % duplicate, round down: gives 0 or 1 with the same probability i % input (number K to be added) * % multiply: gives either 0 or K for each element + % add element-wise 

MATL, 11 bytes

tZy1$rEki*+ 

Uses floating point random numbers.

Try it online!

Explanation

t % implicit input (array). Duplicate Zy % size (array specifying number of rows and columns) 1$r % random vector between 0 and 1 with that size Ek % duplicate, round down: gives 0 or 1 with the same probability i % input (number K to be added) * % multiply: gives either 0 or K for each element + % add element-wise 
deleted 1 character in body
Source Link
Luis Mendo
  • 106.7k
  • 10
  • 139
  • 382

#MATL, 11 bytes

tZy1$rEki*+ 

Uses floating point random numbers.

Try it online!

Explanation

t % implicit input (array). Duplicate Zy % size (array specifying number of rows and columns) 1$r % random vector between 0 and 1 with that size Ek % duplicate, round down: gives 0 andor 1 with the same probability i % input (number K to be added) * % multiply: gives either K0 or 0K for each element + % add element-wise 

#MATL, 11 bytes

tZy1$rEki*+ 

Uses floating point random numbers.

Try it online!

Explanation

t % implicit input (array). Duplicate Zy % size (array specifying number of rows and columns) 1$r % random vector between 0 and 1 with that size Ek % duplicate, round down: gives 0 and 1 with the same probability i % input (number K to be added) * % multiply: gives either K or 0 for each element + % add element-wise 

#MATL, 11 bytes

tZy1$rEki*+ 

Uses floating point random numbers.

Try it online!

Explanation

t % implicit input (array). Duplicate Zy % size (array specifying number of rows and columns) 1$r % random vector between 0 and 1 with that size Ek % duplicate, round down: gives 0 or 1 with the same probability i % input (number K to be added) * % multiply: gives either 0 or K for each element + % add element-wise 
added 414 characters in body
Source Link
Luis Mendo
  • 106.7k
  • 10
  • 139
  • 382

#MATL#MATL, 11 bytes

tZy1$rEki*+ 

Uses floating point random numbers.

Try it online!

Explanation

t % implicit input (array). Duplicate Zy % size (array specifying number of rows and columns) 1$r % random vector between 0 and 1 with that size Ek % duplicate, round down: gives 0 and 1 with the same probability i % input (number K to be added) * % multiply: gives either K or 0 for each element + % add element-wise 

#MATL, 11 bytes

tZy1$rEki*+ 

Uses floating point random numbers.

Try it online!

#MATL, 11 bytes

tZy1$rEki*+ 

Uses floating point random numbers.

Try it online!

Explanation

t % implicit input (array). Duplicate Zy % size (array specifying number of rows and columns) 1$r % random vector between 0 and 1 with that size Ek % duplicate, round down: gives 0 and 1 with the same probability i % input (number K to be added) * % multiply: gives either K or 0 for each element + % add element-wise 
Source Link
Luis Mendo
  • 106.7k
  • 10
  • 139
  • 382
Loading