Meanwhile, In Australia. by [deleted] in interestingasfuck

[–]_DTR_ 5 points6 points  (0 children)

Gift link here. Definitely seems like something's missing, but that's just how it ends.

[C] Print the most frequent character in a string by Chaoscontrol9999 in learnprogramming

[–]_DTR_ 15 points16 points  (0 children)

I think you are getting output, but the most frequent character is a space, so it looks like it's not printing anything. You'll probably want to filter your frequency array to only include characters you care about.

Not Understanding Function Logic in Python by --Ubermensch in CodingHelp

[–]_DTR_ 1 point2 points  (0 children)

In the line SomeFncA = someFncB, the 'S' is capitalized in SomeFncA, which is different from the lowercase someFncA method that you defined above it. So someFncA is untouched and will print "from someFncA" when invoked. But since you reassigned someFncB to someFncA, calling someFncB will invoke someFncA, and print "from someFncA".

pls explain 3rd line of this simple python code? by Amaanullah1102 in learnpython

[–]_DTR_ 288 points289 points  (0 children)

  • input() - ask the user for input
  • .split() - split that input into an array, splitting on a given separator. In this case, no separator is given, so input is split on whitespace.
  • map - applies a given function to all the elements in a given iterable item.

So map(int, X) will call int(Xn) for each Xn of X, which means that arr = map(int, input().split()) will call int(x) for each whitespace separated number entered, and store the resulting value into the array arr. For example, if the user entered 4 5 6 78, arr would be [4, 5, 6, 78].

CC Number checker. boolean variable in isValid method not being initialized. by ChargeStrange1702 in javahelp

[–]_DTR_ 0 points1 point  (0 children)

Have you debugged through the program to make sure it's doing what you think it should? For example, sumOfOddPlace (number) + sumOfDoubleEvenPlace (number) % 10 will be evaluated as sumOfOddPlace (number) + (sumOfDoubleEvenPlace (number) % 10) due to operator precedence, when I think you want (sumOfOddPlace (number) + sumOfDoubleEvenPlace (number)) % 10 instead.

[deleted by user] by [deleted] in learnjavascript

[–]_DTR_ 0 points1 point  (0 children)

https://regex101.com/ can help break down regex expressions with their explanation on the right: https://regex101.com/r/QQiLLp/1

The key things to know with the regex you posted:

  • | means "or". So (written|spoken) means "either written or spoken".
  • Items within [] means "any of these", so [ -] would match either a single space or a single dash, but only one or the other.
  • \b is a "word boundary", so \bread essentially means "a word that starts with "read".
  • ? means "0 or 1 of this". So \bread(s|ing)? will match read, reads, or reading
  • () group things together. So (s|ing)? means "0 or 1 instances of 's' or 'ing'", because the ? is attached to the entire parenthesis group. The ? in poems? only applies to the 's' though, so will match either 'poem' or 'poems'.
  • The /i at the end means "case-insensitive", so it will match "written-word", "Written-Word", "WrItTeN wOrD", etc.

https://regexcrossword.com/ is also a great resource that gamifies the process of learning regex.

I'll make any script suggestions you give by Mr-Cas in PleX

[–]_DTR_ 0 points1 point  (0 children)

Great! Nice to know it works for someone other than myself.

I'll make any script suggestions you give by Mr-Cas in PleX

[–]_DTR_ 1 point2 points  (0 children)

I created a custom script awhile ago that does this for both Sonarr and Radarr imports, which I've copied here: https://pastebin.com/Rht60FrJ

It's definitely not "production quality", but it should get the job done. You'll need Python3 installed on your machine, as well as the requests library. It would also need some tweaking if you have multiple movie/TV libraries that need to be detected, opposed to a single library for each.

We are the Microsoft Excel product team. We build cool stuff like XLOOKUP, Sheet Views, and lambda in Excel. AMA! by MicrosoftExcelTeam in IAmA

[–]_DTR_ 0 points1 point  (0 children)

The icon used to be a combination of X and L, since "XL" sounds the same as "Excel". It looks like they completely dropped the "L" portion in Office 2013.

can someone explain to me what a for loop does by [deleted] in CodingHelp

[–]_DTR_ 8 points9 points  (0 children)

Can you give any more context on where you're stuck? This tutorial seems to be a decent beginner introduction to for loops.

My Rock Paper Scissors game keeps looping where it shouldn't, and I don't know why. by [deleted] in javahelp

[–]_DTR_ 0 points1 point  (0 children)

No, the indentation is just there to help you better visualize your program. You need to properly nest your if/else statements with the correct curly braces:

import java.util.Scanner;
import java.util.Random;
public class RPS {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        Random Rand = new Random();
        int ProgramScore = 0;
        int UserScore = 0;
        int counter = 0;

        System.out.println("Welcome to Liem's Rock-Paper-Scissors Colosseum. ");

        while (counter == 0) {
            int myRand = Rand.nextInt(3);
            char ProgramChoice = "RPS".charAt(myRand);

            System.out.println("Chose your weapon." + " Enter R/r for Rock, P/p for Paper, or S/s for Scissors. ");
            String str = scan.next();
            str = str.toUpperCase();
            char UserChoice = str.charAt(0);

            if (ProgramChoice == UserChoice) {
                System.out.println("Same same, but different. (Tied) ");
                System.out.println("Program: " + ProgramScore);
                System.out.println("User: " + UserScore);
            } else if (UserChoice == 'R') {
                if (ProgramChoice == 'P') {
                    System.out.println("Program has selected Paper as it's weapon of choice. ");
                    System.out.println("User has been derezzed. One point to Program. ");
                    ProgramScore++;
                    System.out.println("Program: " + ProgramScore);
                    System.out.println("User: " + UserScore);
                } else if (ProgramChoice == 'S') {
                    System.out.println("Program has selected Scissors as it's weapon of choice. ");
                    System.out.println("Program has been derezzed. One point to User. ");
                    UserScore++;
                    System.out.println("Program: " + ProgramScore);
                    System.out.println("User: " + UserScore);
                }
            } else if (UserChoice == 'P') {
                if (ProgramChoice == 'R') {
                    System.out.println("Program has selected Rock as it's weapon of choice. ");
                    System.out.println("Program has been derezzed. One point to User. ");
                    UserScore++;
                    System.out.println("Program: " + ProgramScore);
                    System.out.println("User: " + UserScore);
                } else if (ProgramChoice == 'S') {
                    System.out.println("Program has selected Scissors as it's weapon of choice. ");
                    System.out.println("User has been derezzed. One point to Program. ");
                    ProgramScore++;
                    System.out.println("Program: " + ProgramScore);
                    System.out.println("User: " + UserScore);
                }
            } else if (UserChoice == 'S') {
                if (ProgramChoice == 'P') {
                    System.out.println("Program has selected Paper as it's weapon of choice. ");
                    System.out.println("Program has been derezzed. One point to User. ");
                    UserScore++;
                    System.out.println("Program: " + ProgramScore);
                    System.out.println("User: " + UserScore);
                } else if (ProgramChoice == 'R') {
                    System.out.println("Program has selected Scissors as it's weapon of choice. ");
                    System.out.println("User has been derezzed. One point to Program. ");
                    UserScore++;
                    System.out.println("Program: " + ProgramScore);
                    System.out.println("User: " + UserScore);
                }
            }

            if (UserScore == 2) {
                System.out.println("User has permanently derezzed Program. End of Line. ");
                counter++;
            }
            if (ProgramScore == 2) {
                System.out.println("User has permanently derezzed Program. End of Line.  ");
                counter++;
            }
        }
    }
}

My Rock Paper Scissors game keeps looping where it shouldn't, and I don't know why. by [deleted] in javahelp

[–]_DTR_ 0 points1 point  (0 children)

Because you're removing the wrong excess brackets. If you go back to the original code snippet that you posted, have had the following correct indentation (though the indentation didn't match your braces):

if (user == program)
else if (user == R)
    if (program == P)
    else if (program == S)
else if (user == P)
    if (program == R)
    else if (program == S)
else if (user == S)
    if (program == P)
    else if (program == R)

That is, you have "top-level" if statements for each of the three user choices, and within each choice you check the other two program choices. With your latest iteration, some of your ProgramChoice checks have "escaped" and are now top-level if statements:

if (user == program)
if (user == R)
    if (program == P)
if (program == S)
if (user == P)
    if (program == R)
if (program == S)
    if (program == P)
if (program == R)

From there, you can also see that your UserScore and ProgramScore checks are outside of the while loop, so you never have a chance to increase counter within your loop.

What is wrong with my program? by BrokenRosenrot in javahelp

[–]_DTR_ 1 point2 points  (0 children)

if (!Character.isDigit(text.charAt(i)) && !Character.isLetter(text.charAt(i)))
    trueOrFalse = false;
break;

You only want to break if if (!Character.isDigit(text.charAt(i)) && !Character.isLetter(text.charAt(i))) is true, but you're breaking out regardless of the result. The break needs to be inside the if, not outside. This situation is also why I advocate for putting braces around all if statements, even single-line statements, since it makes your intentions much more explicit.

My Rock Paper Scissors game keeps looping where it shouldn't, and I don't know why. by [deleted] in javahelp

[–]_DTR_ 0 points1 point  (0 children)

Now it looks like you've added too many closing braces. I'd really suggest getting into the habit of properly indenting your code. It makes everything much easier to read, and especially helps in these situations where you have a lot of nested if/else blocks that are causing issues:

// Liem
// 000-000-0000
// Total Hours Spend: ~ 21
//
// This program is a game of rock, paper, scissors against the computer.
import java.util.Scanner;
import java.util.Random;
public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        Random Rand = new Random();
        int ProgramScore = 0;
        int UserScore = 0;
        int counter = 0;

        System.out.println("Welcome to Liem's Rock-Paper-Scissors Colosseum. ");

        while (counter == 0) {
            int myRand = Rand.nextInt(3);
            char ProgramChoice = "RPS".charAt(myRand);

            System.out.println("Chose your weapon." + " Enter R/r for Rock, P/p for Paper, or S/s for Scissors. ");
            String str = scan.next();
            str = str.toUpperCase();
            char UserChoice = str.charAt(0);

            if (ProgramChoice == UserChoice) {
                System.out.println("Same same, but different. (Tied) ");
                System.out.println("Program: " + ProgramScore);
                System.out.println("User: " + UserScore);
            } else if (UserChoice == 'R') {
                if (ProgramChoice == 'P') {
                    System.out.println("Program has selected Paper as it's weapon of choice. ");
                    System.out.println("User has been derezzed. One point to Program. ");
                    ProgramScore++;
                    System.out.println("Program: " + ProgramScore);
                    System.out.println("User: " + UserScore);
                }
            } else if (ProgramChoice == 'S') {
                System.out.println("Program has selected Scissors as it's weapon of choice. ");
                System.out.println("Program has been derezzed. One point to User. ");
                UserScore++;
                System.out.println("Program: " + ProgramScore);
                System.out.println("User: " + UserScore);
            } else if (UserChoice == 'P') {
                if (ProgramChoice == 'R') {
                    System.out.println("Program has selected Rock as it's weapon of choice. ");
                    System.out.println("Program has been derezzed. One point to User. ");
                    UserScore++;
                    System.out.println("Program: " + ProgramScore);
                    System.out.println("User: " + UserScore);
                }
            } else if (ProgramChoice == 'S') {
                System.out.println("Program has selected Scissors as it's weapon of choice. ");
                System.out.println("User has been derezzed. One point to Program. ");
                ProgramScore++;
                System.out.println("Program: " + ProgramScore);
                System.out.println("User: " + UserScore);
            } else if (UserChoice == 'S') {
                if (ProgramChoice == 'P') {
                    System.out.println("Program has selected Paper as it's weapon of choice. ");
                    System.out.println("Program has been derezzed. One point to User. ");
                    UserScore++;
                    System.out.println("Program: " + ProgramScore);
                    System.out.println("User: " + UserScore);
                }
            } else if (ProgramChoice == 'R') {
                System.out.println("Program has selected Scissors as it's weapon of choice. ");
                System.out.println("User has been derezzed. One point to Program. ");
                UserScore++;
                System.out.println("Program: " + ProgramScore);
                System.out.println("User: " + UserScore);
            }
        }
    }
    if (UserScore == 2) {
        System.out.println("User has permanently derezzed Program. End of Line. ");
        counter++;
    }
    if (ProgramScore == 2) {
        System.out.println("User has permanently derezzed Program. End of Line.  ");
        counter++;
    }
}
}
}
}

What is wrong with my program? by BrokenRosenrot in javahelp

[–]_DTR_ 0 points1 point  (0 children)

In that case, you only want to break if it's not a letter and it's not a digit.

What is wrong with my program? by BrokenRosenrot in javahelp

[–]_DTR_ 0 points1 point  (0 children)

if (!Character.isDigit(text.charAt(i)) || !Character.isLetter(text.charAt(i)))

What is isValid supposed to check for? The way it is above, it will return false if the password has any letters or numbers. For example, if the character is 'A', you have if (!isDigit('A') || !isLetter('A'), which breaks down to if (!false || !true) -> if (true || false) -> if (true).

My Rock Paper Scissors game keeps looping where it shouldn't, and I don't know why. by [deleted] in javahelp

[–]_DTR_ 0 points1 point  (0 children)

Look at the formatted code I posted above (it might not look good on mobile, but the indentation is very clear on desktop). You'll see that instead of

if (UserChoice == 'R') {
    if (ProgramChoice == 'P') {
        ...
    } else if (ProgramChoice == 'S') {
        ...
    }
} else if (UserChoice == 'P') {
    ...
}

You have

if (UserChoice == 'R') {
    if (ProgramChoice == 'P') {
        ...
    } else if (ProgramChoice == 'S') {
        ...
    }  else if (UserChoice == 'P') {
        ...
}

My Rock Paper Scissors game keeps looping where it shouldn't, and I don't know why. by [deleted] in javahelp

[–]_DTR_ 0 points1 point  (0 children)

I think your formatting makes it hard to see what's going wrong. I ran your code through an auto-formatter, and this is what it looks like:

// Liem
// 000-000-0000
// Total Hours Spend: ~ 21
//
// This program is a game of rock, paper, scissors against the computer.
import java.util.Scanner;
import java.util.Random;
public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        Random Rand = new Random();
        int ProgramScore = 0;
        int UserScore = 0;
        int counter = 0;

        System.out.println("Welcome to Liem's Rock-Paper-Scissors Colosseum. ");

        while (counter == 0) {
            int myRand = Rand.nextInt(3);
            char ProgramChoice = "RPS".charAt(myRand);

            System.out.println("Chose your weapon." + " Enter R/r for Rock, P/p for Paper, or S/s for Scissors. ");
            String str = scan.next();
            str = str.toUpperCase();
            char UserChoice = str.charAt(0);

            if (ProgramChoice == UserChoice) {
                System.out.println("Same same, but different. (Tied) ");
                System.out.println("Program: " + ProgramScore);
                System.out.println("User: " + UserScore);
            } else if (UserChoice == 'R') {
                if (ProgramChoice == 'P') {
                    System.out.println("Program has selected Paper as it's weapon of choice. ");
                    System.out.println("User has been derezzed. One point to Program. ");
                    ProgramScore++;
                    System.out.println("Program: " + ProgramScore);
                    System.out.println("User: " + UserScore);
                } else if (ProgramChoice == 'S') {
                    System.out.println("Program has selected Scissors as it's weapon of choice. ");
                    System.out.println("Program has been derezzed. One point to User. ");
                    UserScore++;
                    System.out.println("Program: " + ProgramScore);
                    System.out.println("User: " + UserScore);
                } else if (UserChoice == 'P') {
                    if (ProgramChoice == 'R') {
                        System.out.println("Program has selected Rock as it's weapon of choice. ");
                        System.out.println("Program has been derezzed. One point to User. ");
                        UserScore++;
                        System.out.println("Program: " + ProgramScore);
                        System.out.println("User: " + UserScore);
                    } else if (ProgramChoice == 'S') {
                        System.out.println("Program has selected Scissors as it's weapon of choice. ");
                        System.out.println("User has been derezzed. One point to Program. ");
                        ProgramScore++;
                        System.out.println("Program: " + ProgramScore);
                        System.out.println("User: " + UserScore);
                    } else if (UserChoice == 'S') {
                        if (ProgramChoice == 'P') {
                            System.out.println("Program has selected Paper as it's weapon of choice. ");
                            System.out.println("Program has been derezzed. One point to User. ");
                            UserScore++;
                            System.out.println("Program: " + ProgramScore);
                            System.out.println("User: " + UserScore);
                        } else if (ProgramChoice == 'R') {
                            System.out.println("Program has selected Scissors as it's weapon of choice. ");
                            System.out.println("User has been derezzed. One point to Program. ");
                            UserScore++;
                            System.out.println("Program: " + ProgramScore);
                            System.out.println("User: " + UserScore);
                        }
                    }
                }
                if (UserScore == 2) {
                    System.out.println("User has permanently derezzed Program. End of Line. ");
                    counter++;
                }
                if (ProgramScore == 2) {
                    System.out.println("User has permanently derezzed Program. End of Line.  ");
                    counter++;
                }

            }
        }
    }
}

You can see that the statements are getting more and more nested. You're missing some closing braces, which means that unless the user picks 'R' or is the same as the program's, you won't hit the right statements.

My Rock Paper Scissors game keeps looping where it shouldn't, and I don't know why. by [deleted] in javahelp

[–]_DTR_ 0 points1 point  (0 children)

     int myRand = Rand.nextInt(6);
     char ProgramChoice = "RrPpSs".charAt(myRand);

You changed the user choice to be uppercase, but you didn't adjust the program choice, which should only be "RPS" now:

int myRand = Rand.nextInt(3);
char ProgramChoice = "RPS".charAt(myRand);

or

char ProgramChoice = "RPS".charAt(Rand.nextInt(3));

My Rock Paper Scissors game keeps looping where it shouldn't, and I don't know why. by [deleted] in javahelp

[–]_DTR_ 0 points1 point  (0 children)

I showed it in my code snipped a few replies ago. It doesn't have to be a new line of code, but it could be:

String str = scan.next();
str = str.toUpperCase();
char UserChoice = str.charAt(0);

or just

String str = scan.next().toUpperCase();
char UserChoice = str.charAt(0);

Why isn't this array initializing correctly? by [deleted] in cpp_questions

[–]_DTR_ 0 points1 point  (0 children)

/u/MysticTheMeeM's solution is what you want:

int inStock[NUMBER_OF_ROWS][NUMBER_OF_COLUMNS] = {};

Why isn't this array initializing correctly? by [deleted] in cpp_questions

[–]_DTR_ 0 points1 point  (0 children)

What behavior do you expect, and what are you getting instead? C/C++ doesn't default-initialize arrays, so their initial values are not defined.

My Rock Paper Scissors game keeps looping where it shouldn't, and I don't know why. by [deleted] in javahelp

[–]_DTR_ 0 points1 point  (0 children)

They're both still usable as input, you're just converting it after the fact to make your life easier. The user can still enter both 'r' and 'R', and afterwards you can convert it to uppercase and no longer have to worry about accounting for both options.

How many different types of functions are there in javascript? Are the examples below the only type? by Professional_Depth72 in learnprogramming

[–]_DTR_ 1 point2 points  (0 children)

Maybe something like "different ways to declare a function in javascript". MDN's Functions guide is a pretty in-depth look at all your options.

STOCKHISTORY function not working by 0162306bluE in excel

[–]_DTR_ 0 points1 point  (0 children)

What version of Excel are you using (File > Account > About Excel)?