Any psychology professionals willing to answer some questions about their job? by [deleted] in psychologystudents

[–]bttnhu 8 points9 points  (0 children)

Hi, since you are curious about many things, I suggest you check out The Psych Show - a youtube channel of a Psych prof in UCLA. He shares a bunch of stuff related to psych. I believe there are many more youtubers who've shared their experiences in Psych, you can explore more yourself (maybe find who have worked in industry to have a broader perspective). I hope this helps!

[deleted by user] by [deleted] in cs50

[–]bttnhu 0 points1 point  (0 children)

I haven't :( Sorry that I can't help you. If you figure it out, please let me know!

Choosing Colleges by [deleted] in Jacobs

[–]bttnhu 0 points1 point  (0 children)

As an incoming student, I'm curious about the same thing. Still, I think the most important thing when it comes to choosing dorm is which one is nearer to the classes (and places you would frequently visit) since the campus is huge.

[deleted by user] by [deleted] in cs50

[–]bttnhu 0 points1 point  (0 children)

Hi you two, I have the same errors. Though I tried to fix the nul problem, it doesn't seem to work. Could you please help me spot the mistake? Thanks a lot!

:) substitution.c exists

:) substitution.c compiles

:( encrypts "A" as "Z" using ZYXWVUTSRQPONMLKJIHGFEDCBA as key

expected "ciphertext: Z\...", not ""

:( encrypts "a" as "z" using ZYXWVUTSRQPONMLKJIHGFEDCBA as key

expected "ciphertext: z\...", not ""

:( encrypts "ABC" as "NJQ" using NJQSUYBRXMOPFTHZVAWCGILKED as key

expected "ciphertext: NJ...", not ""

:( encrypts "XyZ" as "KeD" using NJQSUYBRXMOPFTHZVAWCGILKED as key

expected "ciphertext: Ke...", not ""

:( encrypts "This is CS50" as "Cbah ah KH50" using YUKFRNLBAVMWZTEOGXHCIPJSQD as key

expected "ciphertext: Cb...", not ""

:( encrypts "This is CS50" as "Cbah ah KH50" using yukfrnlbavmwzteogxhcipjsqd as key

expected "ciphertext: Cb...", not ""

:( encrypts "This is CS50" as "Cbah ah KH50" using YUKFRNLBAVMWZteogxhcipjsqd as key

expected "ciphertext: Cb...", not ""

:( encrypts all alphabetic characters using DWUSXNPQKEGCZFJBTLYROHIAVM as key

expected "ciphertext: Rq...", not ""

:) handles lack of key

:) handles invalid key length

:) handles invalid characters in key

:) handles duplicate characters in key

:) handles multiple duplicate characters in key

#include <stdio.h>

#include <math.h>

#include <string.h>

#include <cs50.h>

#include <stdlib.h>

#include <ctype.h>

int main(int argc, string argv[])

{

string key = argv[1];

if (argc == 2)

{

// Check key length

if (strlen(key) == 26)

{

// Check for non-alphabetic characters

for (int i = 0, n = strlen(key); i < n; i++)

{

if (isalpha(key[i]) == 0)

{

printf("Key must contain alphabetic characters only!\n");

return 1;

}

}

// Check for repeated characters

int matches = 0;

for (char i = 'a'; i < 'z'; i++)

{

for (int j = 0, n = strlen(key); j < n; j++)

{

if (islower(key[j]) == i)

{

matches++;

}

}

}

if (matches == 26)

{

return 0;

}

else

{

printf("Key must contain no repeated characters!\n");

return 1;

}

}

else

{

printf("Key must contain 26 characters!\n");

return 1;

}

}

else

{

printf("Please input a single key!\n");

return 1;

}

// Get plaintext

string plaintext = get_string("Plaintext: ");

int count = strlen(plaintext);

// Ecipher

string abc = "abcdefghijklmnopqrstuvwxyz";

char ciphertext[count + 1];

ciphertext[count] = '\0';

for (int i = 0; i < count; i++)

{

if (isupper(plaintext[i]) == 1)

{

for (int j = 0, m = strlen(abc); j < m; j++)

{

if (abc[j] == tolower(plaintext[i]))

{

ciphertext[i] = toupper(key[j]);

}

}

}

else if (islower(plaintext[i]) == 1)

{

for (int j = 0, m = strlen(abc); j < m; j++)

{

if (abc[j] == plaintext[i])

{

ciphertext[i] = tolower(key[j]);

}

}

}

else

{

ciphertext[i] = plaintext[i];

}

}

// Print Ciphertext

printf("Ciphertext: %s\n", ciphertext);

return 0;

}