Questions tagged [pset2]

The problem set for Week 2 continues with the C programming language used in problem set 1.

231 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
2
votes
1answer
203 views

pset2 Initials Design Improvements

I was hoping you might be able to help me improve the design of my code. I've solved the initials problem, and it passes check50 on both normal and hacker edition (the hacker edition was incidental), ...
1
vote
0answers
62 views

CS50, pset2, crack, suggested dictionary file

I am taking cs50 on edx and I am currently on pset2, crack. I want to find a dictionary file that has a fair (maybe over 50,000?) amount of words in it to encrypt and compare them with the hashed ...
1
vote
0answers
88 views

PSET 2 - Crack - A way to improve?

To give a bit of context I am taking CS50 through EdX in 2019. I worked on pset2 (crack) the last few days. I got it "right" though I wonder if there are some ways to improve (1) the efficiency and (...
1
vote
1answer
165 views

Pset2 Crack - works for one password 50i2t3sOSAZtk--->(lol), but not for other passwords - why?

this version of crack works for lol, and prints the following: new hash = 50i2t3sOSAZtktr [what is the 'tr' at the end???] lol for other passwords, the program never returns a decoded pw, just ...
1
vote
1answer
286 views

How can I find pythons equivilant of C's crypt function?

I am current working on 'sentimental'. However, I am having trouble finding the equivalent function of crypt used with "crypt.h" in C? I already have an algorithm for enumerating all possible ...
1
vote
1answer
112 views

Creating an array of unknown indexes. pset-2

I'm working on crack and while I've been able to iterate over an array to create possibilities to test (i.e aaaa, aaab aaac etc.) I can only do it knowing the amount of indexes the array has, I tried ...
1
vote
0answers
58 views

Getting all the possible combinations

After I have failed finishing the hacker2 brute force challenge, I have decided to try again. But I need some help with the pseudo code of storing all the possibles combination of set of numbers. For ...
1
vote
1answer
299 views

pset2 vigenere; isalpha is accepting numbers in argv[1]

I'm using the construct if(isalpha(argv[1][i]) == 0) to determine if the chars are alphabetical in argv[1] with a for loop. The program compiles, however, isalpha is not working. If I enter, for ...
1
vote
1answer
172 views

Initials and Vigenere pass CS50 but received 0 in Gradebook

I submitted pset2 after completing all programs, manually checking for correct functionality and ensuring all programs passed check50. However, I received 0 on both initials and vigenere. I waited 2 ...
1
vote
1answer
117 views

Vigenere print error

I've got my code to cycle through the plaintext index p and the key index. However I keep getting an error when I am printing and can't figure it out. When I use the test spec using bacon as the key ...
1
vote
0answers
75 views

Vigenere - Incorrect output

I have made a mistake in the equation for the new output. char newmsg = (((plain[i] - 97 + key[j % klength]) % 26) + 97); Can someone please give me a clue as to what I did wrong here? ...
1
vote
1answer
736 views

Vigenere fails check50 test "encrypts "BaRFoo" as "CaQGon" using "BaZ" as keyword"

I successfully completed the Vigenere program and I was recently testing it with Check50. My problem is that there is only one test that fails, and I don't know why: :( encrypts "BaRFoo" as "CaQGon" ...
1
vote
3answers
1k views

Can't run the staff implementation

i can't run the staff implementation for any problem set, i always get the same error, it's always something like : bash: ~cs50/pset4/breakout: No such file or directory
1
vote
1answer
811 views

Pset2 - Crack: How to iterate through all combinations of alphabet

Probably a silly question, but please bear with me as I'm pretty new to this. I'm stuck with Crack in Pset2. Can't wrap my head around how to go about iterating through all combinations of alphabet. ...
0
votes
1answer
6 views

PSET2 Substitution: Trouble only in encrypts all alphabetic characters using DWUSXNPQKEGCZFJBTLYROHIAVM as key

so this is my code. All problems are compiled successfully except this one. The output is "Segmentation fault" this is my code: #include <stdio.h> #include <cs50.h> #include <...
0
votes
0answers
8 views

error: address of stack memory associated with local variable

I have the following function: string encipher( string plaintext, string key) { int size = strlen(plaintext); char ciphertext[size]; // For each alphabetic charaters determine what letter ...
0
votes
1answer
22 views

CS50 Pset2 Readability Second Argument Not Compiling

#include<stdio.h> #include<math.h> #include<cs50.h> #include<ctype.h> //prototype for a custome function int letters, words, sentences(string text); int main(void) { // ...
0
votes
1answer
20 views

Pset 2, readability: is everything a float and rounding problems

I' at the very end of readability and am having trouble getting the math correct and rounding it. I'm getting the correct letters, words and sentences, but am getting wildly wrong values for the grade ...
0
votes
1answer
40 views

Caesar works as intended but check50 says it doesn't

I've tested all the possibilities where check50 says my code isn't working as intended and I always get the expected result. I can't seem to figure out what I did wrong. Here's check50: :) caesar.c ...
0
votes
1answer
26 views

Hello everyone, i have a problem with my code for caesar

So when i run the following code in the caesar.c that is located in the caesar folder, it seems to run only for the very first character of the given plaintext and then the next characters are missing....
0
votes
1answer
23 views

Can't check CAESAR pset2

I solved the Caesar problem and it works flawlessly. But I can not check it properly. The results are correct but ''' check50 cs50/problems/2021/x/caesar ''' says it is incorrect. If I view the ...
0
votes
1answer
26 views

Check50 problem with Readability

When I submit my readability code check50 says: Expected Output: Before Grade 1 Actual Output: Before Grade 1 Expected Output: Grade 16+ Actual Output: Grade 16+ Since my program outputs what is ...
0
votes
0answers
29 views

All my functions work individually for Substitution (pset2), but when I put them together the programme doesn't work!

Hey guys :) I've been wracking my brain for ages on my code for pset2 (Substitution) and would really appreciate some help. I've created a function to convert a string into its uppercase variant, ...
0
votes
1answer
18 views

Caesar scoping. variable len not defined, yet it works

The code is following: #include <stdio.h> #include <cs50.h> #include <math.h> #include <string.h> #include <stdlib.h> #include <ctype.h> bool key_validity(string s)...
0
votes
1answer
37 views

:( handles lack of key failed to execute program due to segmentation fault

The following piece of code I've written for pset2/caesar produces a "segmentation error" when there is a lack of key (when no command-line argument is provided). I don't know which line or ...
0
votes
1answer
33 views

cs50 Pset2 *Spoiler*

#include <cs50.h> #include <stdio.h> #include <ctype.h> #include <string.h> #include <stdlib.h> int main(int argc, char *argv[]) { //create key string key = ...
0
votes
1answer
27 views

I've been trying to submit ceaser and it won't compile can someone help?

#include <stdio.h> #include <cs50.h> #include <math.h> #include <string.h> #include <ctype.h> #include <stdlib.h> //atoi ? bool is_valid_key( string s); // ...
0
votes
2answers
41 views

substitution behaves randomly strange

I am working on the main part of the problem. The previous checks all pass ( checking if two arguments, if key is 26 lenght, if key is only alphabetical chars and if every char is only once). But the ...
0
votes
1answer
47 views

why am i getting a non numeric key error? cs50 caesar

i have been trying to do this for a month and i am finaly down to my last error message when i run my check 50.the error message is :( handles non-numeric key timed out while waiting for program to ...
0
votes
0answers
18 views

In pset2: why i am able to iterate through the for loop for just one ? and also the program is processing after looping once?

#include <stdio.h> #include <ctype.h> #include <stdlib.h> #include <string.h> int main(void) { string str= "Hello"; int l =strlen(str); string str2[l-1]; ...
0
votes
1answer
40 views

Pset2 Readability error: expected identifier or '('

I've been trying to compile this code but always get this error "error: expected identifier or '(' " for the line 13 (which is the first one starting with "for") COuld someone help ...
0
votes
1answer
23 views

Pset2 Readability error with "else" statement

readability.c:28:9: error: expected expression else: Shown above is the error I am getting. If anyone would point me to what exactly I am doing wrong. that would be great. Bellow, I will add my ...
0
votes
0answers
8 views

не получается справиться с этими объявлениями-ошибками

:) caesar.c exists. :) caesar.c compiles. :( encrypts "a" as "b" using 1 as key expected prompt for input, found none :( encrypts "barfoo" as "yxocll" using 23 ...
0
votes
1answer
35 views

pset2 mathematical IF statement : attempt

#include <stdio.h> #include <string.h> #include <string.h> #include <stdlib.h> #include <math.h> #include <ctype.h> #include <cs50.h> int main ( int argc, ...
0
votes
1answer
59 views

Pset2 Readability Not Working

I need help in executing the program here. This is my program and when I execute it, it asks me for a text. I copy-pasted the first HOW TO TEST YOUR CODE "One fish. Two fish. Red fish. Blue fish.&...
0
votes
1answer
31 views

pset2 Readability: reading index being calculated incorrectly even though hard sentence, word and letter numbers are correct

The indexes come out sometimes too low,some times too high and I don't really understand why if the variable calculations come out right every time. Here's my code for it: //calculates average letters ...
0
votes
2answers
39 views

PSET2: Readability code giving wrong grades

My Readability code keeps on creating the outputs of the wrong grade when I try to execute it. When inputting the text, 'When he was nearly thirteen, my brother Jem got his arm badly broken at the ...
0
votes
1answer
66 views

Caesar Cipher - output not valid ASCII text

I am using character array and none of the test cases matches the result. Please help me find what is missing. :) caesar.c exists. :) caesar.c compiles. :( encrypts "a" as "b" ...
0
votes
2answers
38 views

PSet2 / Substitution

I am trying to make an upper case key and a lower case key of the one typed by the user but when I use the toupper and tolower functions they turn all my chars into lower or upper. Not just the one I ...
0
votes
1answer
47 views

Pset2 Readability undeclared identifier error message

I am attempting to make my program but everytime I try, it tells me I have not identified my variable "i" eventhough I identified it as an integer above. Does anyone know what I'm doing ...
0
votes
1answer
79 views

check50 in pset2

I won't post my code, because, as far as I could tell, it works fine, but I keep on getting this when I run check50 and I don't know know exactly what it means or how to fix it. My code runs perfectly ...
0
votes
2answers
48 views

Can't pass the test on readability

So, I think function 'round' in one case does rounding to the Grade 8, instead of Grade 7. But, if I remove it, another text getting wrong grade. in both cases the grade of either one text is wrong. ...
0
votes
0answers
367 views

CS50 - PSET2 - Substitution Segmentation fault

I keep getting 'Segmentation fault' every time I run the code(mentioned below). The code is compiling just fine. It's asking for input and is returning required message when the command line argument ...
0
votes
0answers
79 views

CS50x pset2 substitution, check50 test returns negative even though output is correct

My code fails only one of the test in check50 even though the output is correct and passes other ones. The test it fails: :( encrypts all alphabetic characters using DWUSXNPQKEGCZFJBTLYROHIAVM as key ...
0
votes
2answers
48 views

Why the if statements don't work when I put them into loops? Caesar PSET2

Help, please. The program works fine until I want to add the loops and when I do that the if statements inside it won't work and it will just ask for the key and will output the same text as the input ...
0
votes
2answers
58 views

How to invoke command line argument functions outside of main? caesar.c

Let us say I want to create a separate function for lines 11-25 (check comment for reference) in my code as a separate "argument checker" function. Something similar to how I have my decrypt ...
0
votes
1answer
60 views

Having problems producung the correct result using the text extracts provided by CS%). I cant see where it goes wrong when finding the correct grade

CODE: #include <cs50.h> #include <stdio.h> #include <ctype.h> #include <string.h> #include <math.h> int main(void) { // DECLARE LETTER, WORD & SENTENCE COUNT int ...
0
votes
1answer
59 views

PSET2 caesar. I am having trouble checking to make sure that the key is an integer and that it has two arguments in the command line

#include <stdio.h> #include <cs50.h> #include <math.h> #include <stdlib.h> #include <ctype.h> #include <string.h> int main(int argc, string argv[]) { //are there ...
0
votes
2answers
148 views

Caesar doesnt pass "non-numeric key" check

I've read all the other answers I can find about people having a similar problem, but mine doesn't seem to be the same issue. Everyone says to use isdigit first, then use atoi, which is what I've ...
0
votes
1answer
276 views

pset2 readability. im getting 8 instead of 7th gread

Anyone knows why i get this error? :) readability.c exists :) readability.c compiles :( handles single sentence with multiple words expected "Grade 7\n", not "Grade 8\n" :) handles punctuation ...

1
2 3 4 5