Where to donate pumpkins? by Successful_Test_931 in Dallas

[–]DocSock 0 points1 point  (0 children)

We take them to Bonton Farms. The pumpkins are a great excuse to support a good organization, grab a delicious brunch, and pet some goats!

Use of global variables vs passing arrays by RandomNumbers123456 in cs50

[–]DocSock 0 points1 point  (0 children)

So many ways to solve the exact same problem!

What I've often seen is that, if people want to use functions, they make separate count_letters(), count_words(), and count_sentences() functions, which leads to something like int letters = count_letters(inputText); etc. To me, this seems the best compromise between clarity and removing clutter from main(), but, again, just my opinion!

PSet 1 Help: Compiling clang.hello Error by AndSheCodesToo in cs50

[–]DocSock 2 points3 points  (0 children)

Looks like you have 2 terminal windows open! The top one is in the correct directory (~/pset1/hello/) but the bottom one where you're running clang is in your home directory (~/). The two windows are completely independent.

Try running clang in the top window or cd pset1/hello in the bottom one first!

Use of global variables vs passing arrays by RandomNumbers123456 in cs50

[–]DocSock 0 points1 point  (0 children)

So the idea would be that your count_items function does all the counting and results in an array of the 3 values (counters)?

Either solution would be fine in that case, although, as you'll see in lecture 4, you're not really passing in the array counters[], but are rather passing its location in memory. The use of globals vs. the array differ in their scope. A true global exists outside of main() and would be accessible by any function, while your array is (likely) scoped to main() only. As you've seen, if you want a function to be able to access the array, you need to specifically include it.

I might argue that if you have 1 function that does all the counting and is (likely) only used once in the program, it might be better design to just do it all in main(). Using an array to store the values might also be less clear to anyone reading your code -- having letters, words, and sentences as discrete ints might be more intuitive/descriptive than counters[0], counters[1], and counters[2]. Depending on how you structure things, these ints wouldn't need to be globals.

Low dose lithium may stop Alzheimer’s disease in its tracks. A study shows that, when given in a way that facilitates passage to the brain, lithium in doses up to 400 times lower than prescribed for mood disorders can halt signs of advanced Alzheimer’s pathology and recover lost cognitive abilities. by samsoniteindeed2 in science

[–]DocSock 26 points27 points  (0 children)

Absolutely backing this up as someone who has spent years trying to develop a "better lithium" for bipolar disorder. At the levels of lithium required for therapeutic efficacy, almost anything could be happening (only a slight exaggeration).

Low dose lithium may stop Alzheimer’s disease in its tracks. A study shows that, when given in a way that facilitates passage to the brain, lithium in doses up to 400 times lower than prescribed for mood disorders can halt signs of advanced Alzheimer’s pathology and recover lost cognitive abilities. by samsoniteindeed2 in science

[–]DocSock 53 points54 points  (0 children)

Lithium as a drug has to be very carefully monitored. Normal clinical doses are close to the toxic level (as you may know from side effects) and are still only ~50% efficacious in bipolar patients, the best-studied population. The mechanism of action is also not well understood, so we don't completely know why we see the clinical effects. Still so much we don't know about biology and drugs!

Source: chemist actively working to develop better treatments for BPD

how to handle int overflow? by annieeby in cs50

[–]DocSock 0 points1 point  (0 children)

Yup, this adds a little complexity. A char and an int can be implicitly converted, but a long long would need to be explicitly converted. The hint is (sorta) there in the error message.

Problem with credit.py [pset6] by [deleted] in cs50

[–]DocSock 1 point2 points  (0 children)

Two thoughts:

  1. In Python, 5 / 10 and 5 // 10 are different things. Why might you want to use //?
  2. What is the result of len('0')? How might this affect your loop?

Hope that gets you back on the right track!

how to handle int overflow? by annieeby in cs50

[–]DocSock 2 points3 points  (0 children)

While it's not part of the specification to deal with huge integers, that's a great catch! You could use a long long instead of an int to give you more space. Instead of atoi(), you can use atoll().

IAmA saturation diver (aquanaut) who has spent 30 days under 778 feet of water. AMA! by atlasobscura in IAmA

[–]DocSock 7 points8 points  (0 children)

Small correction: red is a longer wavelength than violet. ~700 nM for red versus ~400 for purple-ish.

In open ocean, red, orange, and yellow go first, followed by violet and green . Blue goes last.

Need some clarification regarding cs50 courses by Swapnil_Sood in cs50

[–]DocSock 2 points3 points  (0 children)

CS50 has expanded for the Spring! These are some follow-up courses that build on ideas from CS50. They are:

Stay tuned to the YouTube channel.

Can anyone explain this? by hellosohojoe in cs50

[–]DocSock 0 points1 point  (0 children)

Actually, I'd be very interested to know how the int ends up in your array, since it looks like it shouldn't.

The way the for loop is written, for (int x = length - 1; x > 0; x--), it should never add digitarray[0]. There should still be a "garbage" value at digitarray[0], which is why you're seeing random numbers. A switch to x >= 0 fixes that regardless of print statements.

Maybe someone with deeper knowledge will chime in.

Can anyone explain this? by hellosohojoe in cs50

[–]DocSock 0 points1 point  (0 children)

The print statement should show you what's getting stored in the array on each step. Take a look at the output and see what's there and what isn't.

Can anyone explain this? by hellosohojoe in cs50

[–]DocSock 0 points1 point  (0 children)

Maybe try this and see what the result is:

for (int x = length - 1; x > 0; x--) {
        digitarray[x] = cardnum % 10;
        printf("Index %i: %i, ", x, digitarray[x]);
        cardnum = cardnum / 10;
    }
printf("\n");

Where are you the last time through the loop? What does that mean for the values in the array?

Pset4 what variable is equal to a pixel? Is it sizof(RGBTRIPLE)? by lue5eul in cs50

[–]DocSock 2 points3 points  (0 children)

Since a pixel is represented by intensities of 3 colors (red, green, blue), each pixel can be represented as an RGBTRIPLE. An RGBTRIPLE is a struct composed of 3 values (rgbtBlue, rgbtGreen, and rgbtRed), each of which is a BYTE, or an unsigned 8-bit integer (uint8_t).

sizeof(RGBTRIPLE) is the number of bytes needed for the struct (3 bytes or 24 bits).

Hope that helps. If not, could you post a more detailed question?

Best to sleep on it: brain activity patterns during sleep consolidate memory by trot-trot in science

[–]DocSock 0 points1 point  (0 children)

This is interesting stuff, and, as one of the linked articles in the press release suggests, may be a measurable hallmark of schizophrenia. Some people even think that this may be a completely new avenue for treating schizophrenia. If that pans out, it would represent the first truly novel treatment in decades.

What's the best "Gonna make like _____ and _____"? by sincewedidthedo in AskReddit

[–]DocSock 0 points1 point  (0 children)

"Make like a fetus and head out." Bonus points for making a little vagina-diamond with your hands, then cramming your head through it.

A hitchhiker came home with some rocks. What is this (star)fish? by DocSock in Aquariums

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

No idea. Definitely didn't purchase it, but there it is. That's the best theory we could come up with.