Skip to main content
removed another char
Source Link
freekvd
  • 929
  • 6
  • 13

R, 3231 - 3 = 2928

b=reprev(b<-rep(a<-scan(),a);rev(b)%*%t(b) 
  a<-scan()  # take numeric input and store as vector a b=rep b<-rep( ,a)  # repeat each numeric input by itself and store as vector ; b rev(b)  )  # the reverse of vector b %*%  %*% # matrix multiplication t(b)  t(b) # the transposed of vector b 

R, 32 - 3 = 29

b=rep(a<-scan(),a);rev(b)%*%t(b) 
 a<-scan() # take numeric input b=rep( ,a) # repeat each numeric input by itself and store as vector ; rev(b) # the reverse of vector b %*% # matrix multiplication t(b) # the transposed of vector b 

R, 31 - 3 = 28

rev(b<-rep(a<-scan(),a))%*%t(b) 
  a<-scan()  # take numeric input and store as vector a  b<-rep( ,a)  # repeat each numeric input by itself and store as vector b rev(  )  # the reverse of vector b   %*% # matrix multiplication   t(b) # the transposed of vector b 
removed one char
Source Link
freekvd
  • 929
  • 6
  • 13

R, 3332 - 3 = 3029

a=scanb=rep();b=repa<-scan(a),a);rev(b)%*%t(b) 

Explanation:

a=scan a<-scan()  # take numeric input b=rep(a ,a) # repeat each numeric input by itself and store as vector ; rev(b)  # the reverse of vector b %*%  # matrix multiplication t(b)  # the transposed of vector b 

This also works for more than two numbers. For example, the output for (5,3,2) looks like this:

 [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,] 10 10 10 10 10 6 6 6 4 4 [2,] 10 10 10 10 10 6 6 6 4 4 [3,] 15 15 15 15 15 9 9 9 6 6 [4,] 15 15 15 15 15 9 9 9 6 6 [5,] 15 15 15 15 15 9 9 9 6 6 [6,] 25 25 25 25 25 15 15 15 10 10 [7,] 25 25 25 25 25 15 15 15 10 10 [8,] 25 25 25 25 25 15 15 15 10 10 [9,] 25 25 25 25 25 15 15 15 10 10 [10,] 25 25 25 25 25 15 15 15 10 10 

R, 33 - 3 = 30

a=scan();b=rep(a,a);rev(b)%*%t(b) 

Explanation:

a=scan() # take numeric input b=rep(a,a) # repeat each numeric input by itself and store as vector rev(b) # the reverse of vector b %*% # matrix multiplication t(b) # the transposed of vector b 

This also works for more than two numbers. For example, the output for (5,3,2) looks like this:

 [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,] 10 10 10 10 10 6 6 6 4 4 [2,] 10 10 10 10 10 6 6 6 4 4 [3,] 15 15 15 15 15 9 9 9 6 6 [4,] 15 15 15 15 15 9 9 9 6 6 [5,] 15 15 15 15 15 9 9 9 6 6 [6,] 25 25 25 25 25 15 15 15 10 10 [7,] 25 25 25 25 25 15 15 15 10 10 [8,] 25 25 25 25 25 15 15 15 10 10 [9,] 25 25 25 25 25 15 15 15 10 10 [10,] 25 25 25 25 25 15 15 15 10 10 

R, 32 - 3 = 29

b=rep(a<-scan(),a);rev(b)%*%t(b) 

Explanation:

 a<-scan()  # take numeric input b=rep( ,a) # repeat each numeric input by itself and store as vector ; rev(b)  # the reverse of vector b %*%  # matrix multiplication t(b)  # the transposed of vector b 

This also works for more than two numbers. For example, the output for (5,3,2) looks like this:

 [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,] 10 10 10 10 10 6 6 6 4 4 [2,] 10 10 10 10 10 6 6 6 4 4 [3,] 15 15 15 15 15 9 9 9 6 6 [4,] 15 15 15 15 15 9 9 9 6 6 [5,] 15 15 15 15 15 9 9 9 6 6 [6,] 25 25 25 25 25 15 15 15 10 10 [7,] 25 25 25 25 25 15 15 15 10 10 [8,] 25 25 25 25 25 15 15 15 10 10 [9,] 25 25 25 25 25 15 15 15 10 10 [10,] 25 25 25 25 25 15 15 15 10 10 
added 47 characters in body
Source Link
freekvd
  • 929
  • 6
  • 13

R, 33 - 3 = 30

a=scan();b=rep(a,a);rev(b)%*%t(b) 

Long versionExplanation:

a=scan() # take numeric input b=rep(a,a) # repeat each numeric input by itself and store as vector rev(b)%*%t( # the reverse of vector b)  %*% # matrix multiplication   of reversed vector and  t(b) # the transposed of vector b 

This also works for more than two numbers. For example, the output for (5,3,2) looks like this:

 [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,] 10 10 10 10 10 6 6 6 4 4 [2,] 10 10 10 10 10 6 6 6 4 4 [3,] 15 15 15 15 15 9 9 9 6 6 [4,] 15 15 15 15 15 9 9 9 6 6 [5,] 15 15 15 15 15 9 9 9 6 6 [6,] 25 25 25 25 25 15 15 15 10 10 [7,] 25 25 25 25 25 15 15 15 10 10 [8,] 25 25 25 25 25 15 15 15 10 10 [9,] 25 25 25 25 25 15 15 15 10 10 [10,] 25 25 25 25 25 15 15 15 10 10 

R, 33 - 3 = 30

a=scan();b=rep(a,a);rev(b)%*%t(b) 

Long version:

a=scan() # take numeric input b=rep(a,a) # repeat each numeric input by itself and store as vector rev(b)%*%t(b) # matrix multiplication of reversed vector and the transposed vector 

This also works for more than two numbers. For example, the output for (5,3,2) looks like this:

 [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,] 10 10 10 10 10 6 6 6 4 4 [2,] 10 10 10 10 10 6 6 6 4 4 [3,] 15 15 15 15 15 9 9 9 6 6 [4,] 15 15 15 15 15 9 9 9 6 6 [5,] 15 15 15 15 15 9 9 9 6 6 [6,] 25 25 25 25 25 15 15 15 10 10 [7,] 25 25 25 25 25 15 15 15 10 10 [8,] 25 25 25 25 25 15 15 15 10 10 [9,] 25 25 25 25 25 15 15 15 10 10 [10,] 25 25 25 25 25 15 15 15 10 10 

R, 33 - 3 = 30

a=scan();b=rep(a,a);rev(b)%*%t(b) 

Explanation:

a=scan() # take numeric input b=rep(a,a) # repeat each numeric input by itself and store as vector rev(b) # the reverse of vector b  %*% # matrix multiplication     t(b) # the transposed of vector b 

This also works for more than two numbers. For example, the output for (5,3,2) looks like this:

 [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,] 10 10 10 10 10 6 6 6 4 4 [2,] 10 10 10 10 10 6 6 6 4 4 [3,] 15 15 15 15 15 9 9 9 6 6 [4,] 15 15 15 15 15 9 9 9 6 6 [5,] 15 15 15 15 15 9 9 9 6 6 [6,] 25 25 25 25 25 15 15 15 10 10 [7,] 25 25 25 25 25 15 15 15 10 10 [8,] 25 25 25 25 25 15 15 15 10 10 [9,] 25 25 25 25 25 15 15 15 10 10 [10,] 25 25 25 25 25 15 15 15 10 10 
Source Link
freekvd
  • 929
  • 6
  • 13
Loading