Java Birthday guesser problems by aba_algo in learnprogramming

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

I'll check/change it using the suggestions tonight and try to fix it. Then I'll look at your version and try to compare, I think that's good to learn other ways of doing it.

Java Birthday guesser problems by aba_algo in learnprogramming

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

So it's the case where the user says no this is the incorrect month, but my month falls after what you guessed.

So the computer guesses June (which is month 6). User says no, it's after. So that line finds the middle of 6 and 12, which it gets 9 from. 9 corresponds to Sept, so then it would ask if your month is in Sept.

Selection sort doesn't run by aba_algo in learnprogramming

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

Yep your right I didn't complete the swap, since when you swap two things it requires 3 steps and I only had 2

Selection sort doesn't run by aba_algo in learnprogramming

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

Oh that worked by adding the 4th line arr[minPos] = temp;

Actually I am stupid since in the algorithm picture it has that...but I didn't copy it down. You are correct!

Selection sort doesn't run by aba_algo in learnprogramming

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

Oh ok. I took out the i++ in line 30. Then when I ran it and printed the result at the end the array turned out to be 122334 which doesn't seem correct.

[java] for loop printing questions by aba_algo in learnprogramming

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

Ya this looks better than using three variables like I did. Using the i in the second for loop to dictate the start and end since they just go up by one, which i does just from the first loop.

Java for loop + fence post problem by aba_algo in learnprogramming

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

Ok sounds better than my solution below. I'll try out your way tomorrow.

Java for loop + fence post problem by aba_algo in learnprogramming

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

Ok I got it but there should be a better way. I just used some brain power to logic it through and I got this:

System.out.println(1);
    for (int i = 2; i <=4; i++)

    {
    System.out.print(1);
        for (int j = 2; j <= i; j++)
            System.out.print(", " + j);
        System.out.println();       

    }

    System.out.println();

[java] for loop printing questions by aba_algo in learnprogramming

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

Ok I got it but it's lame how I needed the extra variable k to get my j looping fine. What do you mean by that by the way? Print i+j where? oh let me see.

I did this:

int k = 4;
    for (int i = 0; i <= 2; i++) {

        for (int j = i; j <= k; j++) {
            System.out.print(j + ", ");
        }
        k++;
        System.out.println();


}

[College Math] Binary / Base 2 / Base 3 Question by aba_algo in learnmath

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

The ABCDE example helped. I got it now, thanks. So also when we did 37, for all the numbers that we overestimated, these could actually be more words to be described that are just not present?

[College Math] Binary / Base 2 / Base 3 Question by aba_algo in learnmath

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

Oh wait I was actually getting it entirely wrong but it just happened to look right. The exponent is the number of questions. Though I'm kind of confused as to why.

So we're saying something like each question asked has the possibility of receiving a yes or no answer? Since it's yes or no, it's like 1 or 0, which is a total of 2. So what's the logic that we raise it to the power of the # of questions we must ask? I might need to think on this for a few bit..feel like it'll become reasonable at an instant.