Back to basics 8 - Matrix Diagonals
Covering some basic topics I haven't seen elsewhere on Cody.
Given an input vector of numbers, output a square array with the...
4年弱 前
解決済み
Divide by 4
Given the variable x as your input, divide it by four and put the result in y.
4年弱 前
解決済み
Back to basics 6 - Column Vector
Covering some basic topics I haven't seen elsewhere on Cody.
Given an input vector, output true or false whether it is a colu...
Add two numbers
Calculate the sum of two numbers.
Example
input = [2 3]
output = 5
4年弱 前
解決済み
Back to basics 21 - Matrix replicating
Covering some basic topics I haven't seen elsewhere on Cody.
Given an input matrix, generate an output matrix that consists o...
4年弱 前
解決済み
Sorted highest to lowest?
Return 1 if the input is sorted from highest to lowest, 0 if not.
Example:
1:7 -> 0
[7 5 2] -> 1
4年弱 前
解決済み
Sum of diagonal of a square matrix
If
x = [1 2 4; 3 4 5; 5 6 7]
then y should be the sum of the diagonals of the matrix
y = 1 + 4 + 7 = 12
4年弱 前
解決済み
Tell me the slope
Tell me the slope, given a vector with horizontal run first and vertical rise next.
Example input:
x = [10 2];
4年弱 前
解決済み
Bottles of beer
Given an input number representing the number of bottles of beer on the wall, output how many are left if you take one down and ...
4年弱 前
解決済み
De-dupe
Remove all the redundant elements in a vector, but keep the first occurrence of each value in its original location. So if
a =...
4年弱 前
解決済み
Distance walked 1D
Suppose you go from position 7 to 10 to 6 to 4. Then you have walked 9 units of distance, since 7 to 10 is 3 units, 10 to 6 is 4...
Which values occur exactly three times?
Return a list of all values (sorted smallest to largest) that appear exactly three times in the input vector x. So if
x = [1 2...
4年弱 前
解決済み
Check if sorted
Check if sorted.
Example:
Input x = [1 2 0]
Output y is 0
Pi Estimate 1
Estimate Pi as described in the following link:
<http://www.people.virginia.edu/~teh1m/cody/Pi_estimation1.pdf>
4年弱 前
解決済み
Calculate area of sector
A=function(r,seta)
r is radius of sector, seta is angle of sector, and A is its area. Area of sector A is defined as 0.5*(r^2...
4年弱 前
解決済み
Pizza!
Given a circular pizza with radius _z_ and thickness _a_, return the pizza's volume. [ _z_ is first input argument.]
Non-scor...
4年弱 前
解決済み
Make roundn function
Make roundn function using round.
x=0.55555
y=function(x,1)
y=1
y=function(x,2)
y=0.6
y=function(x,3)
...
4年弱 前
解決済み
Rounding off numbers to n decimals
Inspired by a mistake in one of the problems I created, I created this problem where you have to round off a floating point numb...
4年弱 前
解決済み
Matlab Basics - Rounding III
Write a script to round a large number to the nearest 10,000
e.g. x = 12,358,466,243 --> y = 12,358,470,000
4年弱 前
解決済み
Matlab Basics - Rounding II
Write a script to round a variable x to 3 decimal places:
e.g. x = 2.3456 --> y = 2.346