Questions tagged [pset2]

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

241 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
2 votes
1 answer
208 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), ...
user avatar
  • 27
1 vote
0 answers
532 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 ...
user avatar
  • 13
1 vote
0 answers
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 ...
user avatar
1 vote
0 answers
93 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 (...
user avatar
1 vote
1 answer
168 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 ...
user avatar
  • 11
1 vote
1 answer
290 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 ...
user avatar
1 vote
1 answer
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 ...
user avatar
  • 11
1 vote
0 answers
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 ...
user avatar
1 vote
2 answers
96 views

Initials.c isnt working properly

This is my code #include <cs50.h> #include <stdio.h> #include <ctype.h> int main(){ int i=0; printf(""); char* str = GetString(); printf("%c",*str); while(str[i]!='\...
user avatar
  • 13
1 vote
1 answer
310 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 ...
user avatar
1 vote
1 answer
173 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 ...
user avatar
1 vote
1 answer
122 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 ...
user avatar
1 vote
0 answers
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? ...
user avatar
  • 47
1 vote
1 answer
737 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" ...
user avatar
1 vote
3 answers
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
user avatar
1 vote
1 answer
884 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. ...
user avatar
0 votes
1 answer
9 views

Error when calling seconnd function - expected expression

I'm trying to call my encryption function and am getting an undeclared identifier error. Not sure where i'm going wrong. Code: #include <cs50.h> #include <stdio.h> #include <ctype.h> ...
user avatar
  • 1
0 votes
1 answer
26 views

CS50 Readability solution unsolvable to me

I coded this solution myself, but I really can't figure out where I did wrong, I've spent days on this, and I would really appreciate any help!! Please, 😭 #include <cs50.h> #include <stdio.h&...
user avatar
  • 1
0 votes
0 answers
22 views

Ciphertext is not working

#include <cs50.h> #include <stdio.h> #include <ctype.h> #include <string.h> #include <stdlib.h> int main(int argc, string argv[]) { //program can only run with one ...
user avatar
0 votes
1 answer
3 views

PSET2 "linker command failed with exit code 1"

So I was working on the Caesars problem trying to check that every character in argv[1] is a digit when i get this error trying to compile it: `/usr/bin/ld: /tmp/caesar-d6b46b.o: in function 'main': /...
user avatar
0 votes
0 answers
24 views

How do I return my array of chars in a function to a string in main()

I'm having difficulty implementing the two sections of code for the caesar pset. Individually I have made both my main() and my rotating algorithm caesar() work, but am having trouble combining them, ...
user avatar
0 votes
1 answer
22 views

Help with cipher text in Pset2 substitution

I think I am getting close on Pset2 substitution. But every time I run this code it outputs my ciphertext as void. There's obviously something wrong with my loops converting plaintext to ciphertext ...
user avatar
0 votes
0 answers
103 views

How do you call a boolean function in main?

In problem set two it asks to use a separate function outside of main to determine if the string argv[1] has digits. I believe I've done this correctly in that function, but I'm struggling to call it ...
user avatar
0 votes
1 answer
37 views

PSET2 -CAESAR - compiler doesn't see the rest of program

i have a problem with this pset. My program compiles properly, but when i'm launching it with key, it stops before get_string... When i'm using the only_digits function which is commented in bottom of ...
user avatar
0 votes
0 answers
48 views

pset 2, SUBSTITUTION, working according to specs EXCEPT for UPPER LOWER case spec, code review request

Could anyone please review my code? Specifically the last lines, concerning the case assignment. I got all the other specs to work, except for that last part. I can't figure out what is it that I've ...
user avatar
0 votes
0 answers
30 views

PSET2 SUBSTITUTION works fine ONLY if plaintext is UNDER 9 CHAR

I was approaching the end of the substitution problem of PSET2 when I hit a snag I could not solve. I have already written the code to check the key for the various conditions they provide. My problem ...
user avatar
0 votes
1 answer
81 views

Question CS50 2021 Caesar - where is the bug?

I'm currently struggling with a bug in caesar pset2. If i use check 50 everything is green except: :( encrypts "a" as "b" using 1 as key output not valid ASCII text :( ...
user avatar
0 votes
2 answers
43 views

Caesar project: error: redefinition of 'i'

#include<stdio.h> #include<cs50.h> #include<string.h> int main(void) { string name = get_string("Enter: "); printf("%s\n",name); int n = strlen(name); printf(&...
user avatar
0 votes
1 answer
20 views

substitution question segmentation fault issue

I am doing the substitution question and I keep running into this segmentation fault issue but i do not understand what exactly is causing the memory access issue. once j=4, the memory fails to be ...
user avatar
0 votes
1 answer
22 views

Pset 2 ceaser problem

it,s compiling but it is not checking the words are digits or alphabets neither it is printing I included all the header files I don,t know what is going on.
user avatar
0 votes
0 answers
30 views

pset2 readability critique - how does my code look?

after struggling for days on end with scrabble, I decided to really spend my time consuming all the information possible from notes/lectures/shorts etc. Just finished readability only taking a few ...
user avatar
0 votes
0 answers
27 views

One last error in pset2 Caesar regarding key 65 (barfoo) - lost for how to fix!

I have read just about every question and answer to exist on the internet about this problem, rewatched lecture segments and walkthroughs, and done additional research on the functions used to try and ...
user avatar
0 votes
0 answers
32 views

Readability Pset2 - check50 multiple test fail

This is the code for readability problem set 2. The code is working but not properly as it's failing test cases. the output grade is either +-1 from the expected result. Is there something wrong while ...
user avatar
0 votes
1 answer
35 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 <...
user avatar
0 votes
0 answers
30 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 ...
user avatar
  • 1
0 votes
1 answer
28 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) { // ...
user avatar
0 votes
1 answer
42 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 ...
user avatar
0 votes
1 answer
70 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 ...
user avatar
  • 1
0 votes
1 answer
46 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....
user avatar
  • 1
0 votes
1 answer
38 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 ...
user avatar
0 votes
1 answer
44 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 ...
user avatar
0 votes
1 answer
23 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)...
user avatar
  • 1
0 votes
1 answer
60 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 ...
user avatar
0 votes
1 answer
42 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 = ...
user avatar
0 votes
2 answers
61 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 ...
user avatar
  • 3
0 votes
1 answer
94 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 ...
user avatar
0 votes
1 answer
96 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 ...
user avatar
0 votes
1 answer
33 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 ...
user avatar
  • 1
0 votes
1 answer
39 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, ...
user avatar
  • 1
0 votes
1 answer
77 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.&...
user avatar
  • 1

1
2 3 4 5