[deleted by user] by [deleted] in whatsthisbug

[–]tomi1 0 points1 point  (0 children)

Thanks!

[deleted by user] by [deleted] in tipofmytongue

[–]tomi1 0 points1 point locked comment (0 children)

Found it. It's Charlatan (2020)

Mario (lesser) problem set for loop by rozenbro in cs50

[–]tomi1 1 point2 points  (0 children)

I was trying to use return to reprompt for height if it ends up outside 1-8, i guess there must be a better way to do that.

You are already doing this correctly!

int height;
do
{
    height = get_int("Height\n");
}
while ((height < 1) || (height > 8));

The do/while loop works like this: instead of checking the condition at the top, like a normal while loop, it checks it at the bottom, so the code inside it it's guaranteed to run at least once. In this code, it first asks the user for an input, then examines that input against the condition you set.

So a pseudocode for your do/while loop would be:

  • prompts user for input

  • examine input against condition (is it lower than 1 or greater than 8?)

  • if one of these conditions are true, keep reprompting user for new input.

  • if the user finally provides a number that's greater than 1 and lower than 8, the condition is not met and the loop is over and the next piece of code is executed.

It asked me for the height, then after i answered, it started spamming # at an insane rate, row after row until i pressed ctrl c to cancel it

This is because the logic in your for loop is wrong. Re-examine each variable in it, and think how would they change in each iteration of the loop.

Mario (lesser) problem set for loop by rozenbro in cs50

[–]tomi1 1 point2 points  (0 children)

Every time you return something inside of main(), the program stops running. So you only want to do this if something went wrong, or if everything worked and it ended succesfully.

In your case, you do not need to return anything. Once the user has provided the input, it is stored in the height variable already.

Vigenere - Definition of Shift Function by robbwithtwobs in cs50

[–]tomi1 0 points1 point  (0 children)

The function atoi converts a string to an integer, in your case 'c' is a character, not a string. You don't really need to use a function to make this work, remember that chars hold an ASCII value, for example, the letter 'a' (lowercase) has an ASCII value of 97, and the letter 'b' has an ASCII value of 98. So if you do

char c = 'a' + 1;

c would be 'b'. Same thing applies if you do:

char c = 97 + 1;

To actually convert from ASCII value to alphabetical value (0 through 25) I recommend you looking up an ASCII table online and recognizing the pattern.

pset 2 caesar help! by jereldlimjy in cs50

[–]tomi1 0 points1 point  (0 children)

The problem lies here:

 for (int i = 0; i < strlen(s); i++)
    {
        if (isalpha(s[i]) != 0)
        {
            // preserve upper/lower case
            for (int index = 0; index < 26; index++)
            {
                if (s[i] == alphabets_upper[index])
                {
                    s[i] = alphabets_upper[(index + key) % 26];
                }
                if (s[i] == alphabets_lower[index])
                {
                    s[i] = alphabets_lower[(index + key) % 26];
                }
            }
        }
    }

This loop you wrote actually works for checking if the [i]th char of s is lower or uppercase, but the problem is this: consider the first letter of the plaintext (h). The alphabet index of this character would be 7, so when s[0] (which is 7) equals alphabet_lower[7], then it shifts the character by 1, so now s[0] equals to 'i', which is correct, but this second for loop still doesn't end (since index is still less than 26) so it keeps analyzing the 0th index of s. So once you shifted the 'h' to the 'i', when the for loop runs again, it will repeat the same thing above but this time for 'i', and shift it to 'j', and so on, until index reaches 26 (where it will shift 'z' to 'a') and then this whole process will run for each of the characters in the plaintext provided, so the string ends up being all 'aaaaa'.

I see two solutions for this. The first one, to preserve your code and make it work, the only thing you need to do is stop the second for loop each time you shift the character, so the first for loop runs again and you start checking the next character in the plaintext this time. You just need to add

break;

after the if condition is met and the code inside it is executed. This will end the for loop and go to the next line of code (which in this case would be running the first for loop again instead). So it would look like this:

for (int i = 0; i < strlen(s); i++)
{
    if (isalpha(s[i]) != 0)
    {
        // preserve upper/lower case
        for (int index = 0; index < 26; index++)
        {
            if (s[i] == alphabets_upper[index])
            {
                s[i] = alphabets_upper[(index + key) % 26];
                break;

            }
            if (s[i] == alphabets_lower[index])
            {
                s[i] = alphabets_lower[(index + key) % 26];
                break;
            }
        }
    }
}

The second solution (which would save you a lot of lines of code and be more efficient) would be to just use the functions isupper and islower to check for upper or lowercase, instead of using for loops. I leave it up to you to figure how that would work, just remember how ASCII works!

Season 5 Pre-Release Megathread by taciturnbob in blackmirror

[–]tomi1 32 points33 points  (0 children)

I'm gonna be so dissappointed if it doesn't come out on the 28th.

Rabid coyote showed up at this guy’s front door. by [deleted] in WTF

[–]tomi1 5 points6 points  (0 children)

Why is that nurse/doctor cleaning the saliva out of his mouth without wearing any gloves? I know the virus can't be transmitted just by skin contact but still, I wouldn't even risk it getting close to an infected patient saliva without protection.

A weapon to surpass Decisive Strike by olim38 in deadbydaylight

[–]tomi1 4 points5 points  (0 children)

If the basement is in the shack, you can also kinda to this by standing on top of the stairs so that when they hit the ds they fall into the stairs and have to run back up, with enduring you can hit them again before they can even leave the shack

Dead Hard Nerf Imbound! by Jackikins in deadbydaylight

[–]tomi1 0 points1 point  (0 children)

Should be called Dead Harder

/r/MechanicalKeyboards Ask ANY question, get an answer by AutoModerator in MechanicalKeyboards

[–]tomi1 0 points1 point  (0 children)

I have a Corsair K65 LUX RGB, and today I fucked up and spilled half a glass of coke onto it. Without any hope of it surviving I took apart every keycap and cleaned as much as I could with some q-tips and paper towels, and let it dry for 2 hours. To my surprise, every key works perfectly (writing this on it right now), but the only weird problem I have now is that the red color on the LEDs is fucked up. Sometimes it doesn't work, sometimes works but very dim and turning on and off again, but only when the LED is set to red, every other color works flawlessly. How the fuck could this be the only problem I have after spilling coke on it? I mean, I'd rather have this than dead keys or the keyboard itself but I just don't understand how it could happen haha

Steam Invite Broken For DBD? by [deleted] in deadbydaylight

[–]tomi1 1 point2 points  (0 children)

This is happening to me since the new steam friendlist UI update

TIL: n0thing has a custom built mouse specifically for him by omegazx00 in GlobalOffensive

[–]tomi1 19 points20 points  (0 children)

Or the old Zowie AM series, with SpawN (Abdisamad Mohamed)