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 ...
3ヶ月 前
解決済み
Set some matrix elements to zero
First get the maximum of each *row*, and afterwards set all the other elements to zero. For example, this matrix:
1 2 3 ...
First non-zero element in each column
For a given matrix, calculate the index of the first non-zero element in each column. Assuming a column with all elements zero i...
3ヶ月 前
解決済み
Divide by 4
Given the variable x as your input, divide it by four and put the result in y.
3ヶ月 前
解決済み
Matlab Basics II - squares
Write a function that takes matrix A, and squares each element in the matrix
example:
A = [1 2 3]
output = [1 4 9]
3ヶ月 前
解決済み
Y=X
Given an input variable x, output a variable y that is equal in value to x.
Example:
Input x = 1
Output y is 1
Inp...
3ヶ月 前
解決済み
Remove the two elements next to NaN value
The aim is to *remove the two elements next to NaN values* inside a vector.
For example:
x = [6 10 5 8 9 NaN 23 9 7 3 21 ...
3ヶ月 前
解決済み
Check if sorted
Check if sorted.
Example:
Input x = [1 2 0]
Output y is 0
Get all prime factors
List the prime factors for the input number, in decreasing order. List each factor. If the prime factor occurs twice, list it as...
Beginner's Problem - Squaring
Try out this test problem first.
Given the variable x as your input, square it by two and put the result in y.
Examples:
...
3ヶ月 前
解決済み
All your base are belong to us
Find the base _b_ logarithm of the input decimal number _x_. Express the output as a decimal number. The first argument is the n...
3ヶ月 前
解決済み
Roll the Dice!
Description
Return two random integers between 1 and 6, inclusive, to simulate rolling 2 dice.
Example
[x1,x2] = rollDice(...
3ヶ月 前
解決済み
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...
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...