Getting logical indexes
This is a basic MATLAB operation. It is for instructional purposes.
---
Logical indexing works like this.
thresh = 4...
3年以上 前
解決済み
Return unique values without sorting
If the input vector A is [42 1 1],
the output value B must be the unique values [42 1]
The values of B are in the same order a...
3年以上 前
解決済み
Sum of big primes without primes
Inspired by Project Euler n°10 (I am quite obviously a fan).
With problem n°250 by Doug, you can find some global methods to ...
Project Euler: Problem 5, Smallest multiple
2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.
What is the smalle...
Project Euler: Problem 7, Nth prime
By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13.
What is the Nth prime nu...
3年以上 前
解決済み
Make a Palindrome Number
Some numbers like 323 are palindromes. Other numbers like 124 are not. But look what happens when we add that number to a revers...
3年以上 前
解決済み
Indexed Probability Table
This question was inspired by a Stack Overflow question forwarded to me
by Matt Simoneau.
Given a vector x, make an indexed pro...
3年以上 前
解決済み
Find the peak 3n+1 sequence value
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...
Test for balanced parentheses
Given the input inStr, give the boolean output out indicating whether all
the parentheses are balanced.
Examples:
* If ...
3年以上 前
解決済み
Generate this matrix
For a given odd integer n, generate a matrix as follows:
Input: n = 5;
Output:
[ 2 1 0 0 0
1 ...
3年以上 前
解決済み
Pascal's pyramid
In Pascal's triangle each number is the sum of the two nearest numbers in the line above:
1
1 1
...