Check if sorted
Check if sorted.
Example:
Input x = [1 2 0]
Output y is 0
約3年 前
解決済み
Area of an equilateral triangle
Calculate the area of an equilateral triangle of side x.
<<https://i.imgur.com/jlZDHhq.png>>
Image courtesy of <http://up...
約3年 前
解決済み
Length of a short side
Calculate the length of the short side, a, of a right-angled triangle with hypotenuse of length c, and other short side of lengt...
約3年 前
解決済み
Rotate Matrix @180 degree
Rotate Matrix @180 degree
Example
A=[8 1 6; 3 5 7; 4 9 2], then answer would be
[2 9 4;...
Matrix Quadrants
Write a function that takes N as the input, and outputs a matrix whose upper-left (NxN) quadrant contains all ones, the lower-ri...
約3年 前
解決済み
Square root
Given x (a matrix), give back another matrix, where all the elements are the square roots of x's elements.
約3年 前
解決済み
2倍してみよう - ここからスタート!
初めにこの問題を試してみよう。
入力としてxを与え、それを2倍して結果をyに代入せよ。
Examples:
Input x = 2
Output y is 4
Input x = 17
Output y is 34
...
約3年 前
解決済み
Flip the vector from right to left
Flip the vector from right to left.
Examples
x=[1:5], then y=[5 4 3 2 1]
x=[1 4 6], then y=[6 4 1];
Request not ...
約3年 前
解決済み
Doubling elements in a vector
Given the vector A, return B in which all numbers in A are doubling. So for:
A = [ 1 5 8 ]
then
B = [ 1 1 5 ...
約3年 前
解決済み
Vector creation
Create a vector using square brackets going from 1 to the given value x in steps on 1.
Hint: use increment.
約3年 前
解決済み
Most nonzero elements in row
Given the matrix a, return the index r of the row with the most nonzero elements. Assume there will always be exactly one row th...
Summing digits
Given n, find the sum of the digits that make up 2^n.
Example:
Input n = 7
Output b = 11
since 2^7 = 128, and 1 + ...
約3年 前
解決済み
Create a vector
Create a vector from 0 to n by intervals of 2.
約3年 前
解決済み
Find max
Find the maximum value of a given vector or matrix.
約3年 前
解決済み
Return the 3n+1 sequence for n
A Collatz sequence is the sequence where, for a given number n, the next number in the sequence is either n/2 if the number is e...
Remove any row in which a NaN appears
Given the matrix A, return B in which all the rows that have one or more <http://www.mathworks.com/help/techdoc/ref/nan.html NaN...
Who Has the Most Change?
You have a matrix for which each row is a person and the columns represent the number of quarters, nickels, dimes, and pennies t...
Fibonacci sequence
Calculate the nth Fibonacci number.
Given n, return f where f = fib(n) and f(1) = 1, f(2) = 1, f(3) = 2, ...
Examples:
Input...
約3年 前
解決済み
Make a checkerboard matrix
Given an integer n, make an n-by-n matrix made up of alternating ones and zeros as shown below. The a(1,1) should be 1.
Example...