MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn moreOpportunities for recent engineering grads.

Apply TodayWrite a function posX=findPosition(x,y) where x is a vector and y is the number that you are searching for.

Examples:

findPosition([1 3 5 4 2], 2) posX is 5

findPosition([1 5 8 6 7 6 0], 8) posX is 3

1566 correct solutions
730 incorrect solutions

Last solution submitted on Nov 24, 2014

2 players like this problem

1 player likes this solution

1 Comment

Jon Agustsson
on 6 Sep 2012

It is funny that this
feval(@eval, '[~, ans] = max(x==y);')
has smaller size than this
[~, ans] = max(x==y);

1 Comment

Andrew
on 13 Feb 2012

...I cheated to find out if you really were checking the conditions. Which you aren't. Shame.

1 Comment

Roberto Montagna
on 12 Feb 2012

I know, I know, sorry about this...

1 Comment

RĂ©mi
on 31 Jan 2012

cheater

1 Comment

Jan Simon
on 28 Jan 2012

What about the detail "without using the find function"?!

1 Comment

Brandon Kuczenski
on 4 Jun 2012

how does this solve the problem? assert(strfind~=find)=false.

1 Comment

Jan Simon
on 28 Jan 2012

What about the detail "without using the find function"?!

1 Comment

Jan Simon
on 28 Jan 2012

What about the detail "without using the find function"?!

1 Comment

Jan Simon
on 28 Jan 2012

What about the detail "without using the find function"?!

7 Comments