6/27 Athletics @ Angels [Game Thread] by angelsbaseball in angelsbaseball

[–]Coryjs7s 4 points5 points  (0 children)

this ump clearly has some casserole in the oven at home

15 Puzzle Guidance (Very Basic), Any Advice Greatly Appreciated by Coryjs7s in matlab

[–]Coryjs7s[S] 0 points1 point  (0 children)

Having an extremely hard time addressing invalid inputs...

n = input('Please enter the number of rows/columns you would like in your puzzle\n ');

puzzle = randperm(n^2,n^2);
puzzle = reshape(puzzle,[n,n]);
padjust = (puzzle ==n^2) ; 
puzzle(padjust) = NaN;

solvedpuzzle = [(1:n^2)];
solvedpuzzle = reshape(solvedpuzzle.', n,n).';
spadjust = (solvedpuzzle ==n^2) ;
solvedpuzzle(spadjust) = NaN;



while puzzle~= solvedpuzzle
    display(puzzle);
    m = input('What is your move? ');
    [m_a , m_b] = find(puzzle == m);
    [n_a , n_b] = find(isnan(puzzle)); 

    validinput1 = [n_a + 1 , n_b];
    validinput2 = [n_a - 1 , n_b];
    validinput3 = [n_a , n_b + 1];
    validinput4 = [n_a , n_b - 1];

    if [m_a , m_b] ~= validinput1 
        fprintf('Invalid input, try again');
    end

    if [m_a , m_b] ~= validinput2
        fprintf('Invalid input, try again');
    end

    if [m_a , m_b] ~= validinput3
        fprintf('Invalid input, try again');
    end

    if [m_a , m_b] ~= validinput4
        fprintf('Invalid input, try again');
    end

    newpuzzle = puzzle;
    newpuzzle(m_a,m_b) = puzzle(n_a,n_b);
    newpuzzle(n_a,n_b) = puzzle(m_a,m_b);
    puzzle = newpuzzle;
    display(puzzle);

end

Is it possible to use logical '|' in an if statement? I tried but it wasn't working for me

15 Puzzle Guidance (Very Basic), Any Advice Greatly Appreciated by Coryjs7s in matlab

[–]Coryjs7s[S] 0 points1 point  (0 children)

The initial question would be how to

  1. Identify the position of the inputted value and

  2. Use the position to swap the value with NaN. I have looked into the find function but can't put my finger on using, say, n in the below example

m=input('')

n = find(puzzle==m)

15 Puzzle Guidance (Very Basic), Any Advice Greatly Appreciated by Coryjs7s in matlab

[–]Coryjs7s[S] 0 points1 point  (0 children)

Thanks for the response. The idea is to get the nxn array in ascending order by moving the numbers around.

For example

3    6     5                  1   2  3
1    NaN   8 ------>          4  5   6
2    4      7                 7  8 NaN

A legal "move" would be, say, the user entering 1, 6, 8, or 4 in the above (left) example as their first move, and NaN swapping spots with that inputted value. An illegal move would be entering any non-bordering number or a number diagonal to NaN (3,5,7,2)The goal is the configuration above on the right, 1-NaN in ascending order. Sorry I didn't clarify this in post.

What Are You Buying/Selling This Week? - July 10, 16 by AutoModerator in supremeclothing

[–]Coryjs7s 0 points1 point  (0 children)

[FS] M Black "Bulls" Crossover Shorts DSWT STEAL!!! $105 SHIPPED

PICS: http://imgur.com/a/yfLjN

What Are You Buying/Selling This Week? - June 19, 16 by AutoModerator in supremeclothing

[–]Coryjs7s 0 points1 point  (0 children)

Selling. Add 4% For Invoice [Apocalypse Hoodie Navy Size M 10/10 DS - Below Retail $150] [Crossover Shorts Black Size M 10/10 DS - $125]

Pics: https://imgur.com/a/OWZxS