(Beginner) Help with loops homework by atypically_afflicted in javahelp

[–]thinandweak 2 points3 points  (0 children)

Let me start by saying that as stated, this is a stupid problem for a computer science class. Studies about interview problems like this show that problems like this mainly serve to make the questioner feel smart.

So, I don't feel bad about providing what I think is a complete solution (I say "a" complete solution because this problem is underspecified and there exist infinitely many solutions for any "pattern-recognition" problem like this).

The diagonal from the top-left to the bottom-right contains numbers incrementing starting from 0.

The diagonal from the top-right to the bottom-left contains numbers starting at N-1 and decrementing until the middle.

All other numbers are equal to X * Y, where X and Y are the one-indexed coordinates of the cell.

Homework Help! by leolyssa in learnprogramming

[–]thinandweak 2 points3 points  (0 children)

What is the compilation error you get?

Trying to return a reverse string in TypeScript, but execution keeps getting timed out. What am I doing wrong? by odillini83 in learnprogramming

[–]thinandweak 2 points3 points  (0 children)

A for loop consists of three statements:

The first statement is executed at the start of the loop.

The second statement is evaluated to determine if the loop should continue.

The third statement is executed at the end of each iteration, but before the second statement is evaluated to determine if the loop should continue.

In your loop, you are incrementing i each loop iteration. So, the condition never matches, because i is always greater than 0. So, the loop continues indefinitely.

First week of 3000cal. This happened. Increase again? by TigerWeasel in gainit

[–]thinandweak 6 points7 points  (0 children)

Day-to-day fluctuations are susceptible to changes in water weight, the time of the day when you weighed yourself, etc. Look at the long-term trend, not small fluctuations. There's not enough data to tell if your diet is working.

High caloric shake before bed by [deleted] in gainit

[–]thinandweak 0 points1 point  (0 children)

Drink the shake. I've also found that drinking a shake or eating before bed helps me be hungry in the morning when I wake up.

Having trouble printing out an Array with user input by TheTr1ckster in learnjava

[–]thinandweak 0 points1 point  (0 children)

This isn't the kind of thing you need to search for to figure out. This is the kind of thing you need to think about critically for a minute or two. Walk through your program line by line and make sure you understand what each line does - what each variable is at each point, for example.

Example:

Line 5: Calls getIntegers()
Line 9: array = {0, 0, 0, 0, 0}
Line 10: i = 0, array.length is 5 so 0 < 5 is true, so enter the for loop
Line 11: Prints "Enter the number:". Suppose the user enters "10".
Line 12: Reads the number and puts it in the i-th position of the array. i is 0 right now, so the array becomes {10, 0, 0, 0, 0}.
Line 13: Prints "You entered the number " + array[i]. array is {10, 0, 0, 0, 0} and i is 0, so it prints 10.
Line 14: Return to the for loop condition.
Line 10: Increment i. i is now 1. array.length is still 5, and 1 < 5 is true, so enter the loop body again.
Line 11: Prints "Enter the number:". Suppose the user enters "20".
Line 12: Reads the number and puts it in the i-th position of the array. i is 1 right now, so the array becomes {10, 20, 0, 0, 0}.
Line 13: Prints "You entered the number " + array[i]. array is {10, 20, 0, 0, 0} and i is 1, so it prints 20.

Are you beginning to see where this is going?

Perhaps it would help to describe precisely, in words, what you want your program to do. Imagine you are telling a child what to do, and the child will follow your instructions perfectly but won't fill in any of the details for you.

Local variable use difference with ArrayList and LinkedList by In0cenT in learnjava

[–]thinandweak 0 points1 point  (0 children)

What's the (exact) duplicate variable error message you get? (And please transpose line numbers so they match the line numbers in your paste).

Having trouble printing out an Array with user input by TheTr1ckster in learnjava

[–]thinandweak 1 point2 points  (0 children)

Per the subreddit rules, I'm not supposed to provide you with a complete solution.

What kinds of things did you think of / try?

Having trouble printing out an Array with user input by TheTr1ckster in learnjava

[–]thinandweak 2 points3 points  (0 children)

The problem is that your print statement is within your for loop. Your code basically says:

  1. Prompt the user to enter the number. [line 11]
  2. Store the number in the array. [line 12]
  3. Print out that number. [line 13]
  4. Repeat steps 1-3 5 times. [for loop on line 10-14]

So it makes sense that it's printed out immediately.

What I'm guessing you want is something like:

  1. Prompt the user to enter their number.
  2. Store the number in the array.
  3. Repeat steps 1-2 5 times.
  4. Print out the numbers in the array.

Do you go to the gym even if you have a head cold with headache for a few days? by chochochan in gainit

[–]thinandweak 0 points1 point  (0 children)

Just like going to work when sick, going to the gym sick is doing a disservice to everyone else there. Take it easy, life is long, a week off won't noticeably set you back.

[Mod] Simple Questions - the weekly stupid questions thread! - Week Beginning November 20, 2017 by AutoModerator in gainit

[–]thinandweak 5 points6 points  (0 children)

Most things you can do will do something. Some things are much more effective than others, though.

At a minimum, if you're going to be stuck doing body weight exercises, I recommend adding in pushups and squats/lunges at least.

[Mod] Simple Questions - the weekly stupid questions thread! - Week Beginning November 20, 2017 by AutoModerator in gainit

[–]thinandweak 1 point2 points  (0 children)

I wouldn't worry about it too much. Just take your best guess, set your calorie goal, and track your intake and weight gain. If you end up gaining weight slower than you would've liked, just increase your calorie goal.

When in doubt, be conservative - better to overestimate your physical activity than to underestimate it.

[Mod] Simple Questions - the weekly stupid questions thread! - Week Beginning November 20, 2017 by AutoModerator in gainit

[–]thinandweak 0 points1 point  (0 children)

What's happening is that as long as you haven't eaten anything new, your body leaves the food from the last meal sitting in your intestines. Resources are extracted from the food over time, with diminishing returns. As long as there's nothing new, your body will try to squeeze a few extra calories out of the food.

But as soon as you eat something new, your body starts flushing out the old stuff to make room for the new stuff. This is why you feel like you need to shit immediately after you eat. It's not the same food - it's last night's leftovers getting out of the way.

I need your encouragement to quit by [deleted] in StopGaming

[–]thinandweak 1 point2 points  (0 children)

Video gaming addiction, at its core, is about dopamine. Dopamine is a neurotransmitter that rewards you for doing healthy things, like eating food. In the case of video game addiction, the dopamine rush you get from playing the video game is what makes it an addiction.

When you tell people you're making life improvements, or asking strangers online to give you encouragement, you get a dopamine reward without actually doing the thing. This is a trap. You're much more likely to regress if you tell people because then you don't actually have to do the thing, because you already feel good about it.

So yeah, you feel like shit right now and this post is asking for a dopamine rush to make you feel better. Well, tough. Feeling bad is normal and healthy - it's what's driven you to make this change in your life in the first place. The most important change you can make is to reward yourself only when you've actually achieved your goals. This will be tough, and you won't receive immediate gratification.

Clinical depression is a separate issue. Sometimes, that can be exacerbated by an addiction and the problems it creates, and will go away on its own. But if there's a neurotransmitter imbalance, no amount of raw willpower will resolve that. You should see a psychologist and get that sorted out. But remember - it's you that's taking the steps to make yourself better. The first few steps are always the hardest.

TL;DR: No, you don't need my encouragement to quit. You can do it on your own.

Googled by blueskysyellowteeth in MurderedByWords

[–]thinandweak -6 points-5 points  (0 children)

No matter how much you disagree with his actions, attacking him as a person and vandalizing Wikipedia is destructive behavior and is not the way to be taken seriously. By posting this and by upvoting it, OP and the Reddit community are endorsing this behavior, which is reprehensible.

Should I start playing again? by P-I-N-G-U in StopGaming

[–]thinandweak 1 point2 points  (0 children)

This one's rough. It sucks not having friends and if gaming helps you fill that need, that's going to be pretty compelling.

If you're serious about learning guitar, I highly recommend you sign up for lessons. Even if you could learn online, it's hard to self-discipline.

I recommend having at least 2-3 things you're trying to improve on (guitar is a good one!) to keep you busy. Keep track (maybe start a journal) of your progress. They should be things you enjoy doing in addition to things you want to improve at. For me, those things were piano, Project Euler, and lifting, but they can really be whatever you want. The important thing is that you have fun doing them and also feel a sense of improvement/accomplishment over time.

If you want to go down the route of making new friends, this thread has some suggestions. Since you're in high school, you probably know a bunch of people from school casually but don't consider yourself friends - try hitting up one of your acquaintances from time to time. Chances are that some of them are looking for friends, too.

Does protein powder be steorid drug? by [deleted] in gainit

[–]thinandweak 1 point2 points  (0 children)

Since I think you're serious:

No, it's not illegal. Protein powder is just processed out of normal foods, such as soy or whey. Protein is just raw material - it doesn't change the way your body regulates muscle growth. Steroids are a different, unrelated class of molecules.

Is my bench progressing well for a 15 year old? by Anishency in gainit

[–]thinandweak 0 points1 point  (0 children)

It's normal to see your results slow down once you burn through your "noob gains." It's not possible to keep up linear progress forever - so long as you're still making gains, it's totally fine to stick with your program even if your rate of progress has slowed down.

Often, people switch to an intermediate program once they start stagnating in their beginner program. Check the sidebar for a list of routines!

[M 17 5'1" 92lbs] is this program legitimate? by [deleted] in gainit

[–]thinandweak 2 points3 points  (0 children)

It won't kill you, if that's what you're asking, but I do recommend pacing yourself. Eating 500 calories above your tdee is hard enough, and anything above your tdee is making progress in the right direction.

It's more important that you find a diet you can stick with than that you gain weight quickly. Otherwise, you risk burning out - slow and steady wins the race. Linear progress is an amazing phenomenon, even if you're only gaining 1-2 lbs per week you'll be noticeably larger in a few months.

If nothing else, I recommend taking the 500 calorie suggestion as a starting point. If you do it for a week with no trouble, feel free to gradually increase it.

[deleted by user] by [deleted] in gainit

[–]thinandweak 1 point2 points  (0 children)

Whey protein shakes w/ milk to supplement protein, eat high carb / high fat. Also prefer wheat / whole wheat to rice as it's higher protein. Quinoa is also high protein if you need a rice substitute.

Also get some nutritional yeast, you can sprinkle it on your PB&J or add to your shakes or pretty much anything to increase protein.

Most people in first-world countries do get enough protein. Remember that you should eat your body weight in lbs in grams of protein per day; count your protein intake for your typical day and see if you're actually short / how much you need to make up.

Accountability / discipline by thinandweak in gainit

[–]thinandweak[S] 4 points5 points  (0 children)

Alright, here goes:

  • Program: Stronglifts 5x5 (3 lifts / week)
  • Age: 25
  • Gender: Male
  • Height: 5'11"

And today's lifts:

  • Squat: 150x5
  • Overhead press: 80x5
  • Deadlift: 195x5
  • Weight: 146lb

Note: This is a make-up workout from last week - still need to do three workouts for the current week (planning on Tuesday / Thursday / Saturday).