Questions tagged [pset2]

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

Filter by
Sorted by
Tagged with
0 votes
2 answers
317 views

crypt key char concatenation (pset2/crack)

I have created a series of for loops to iterate through every combination of a 4 letter long password (i j k l). I wish to enter each iteration into the crypt function but what I have been trying has ...
0 votes
2 answers
70 views

On running as ./a.out <keyword>

On running as above the program shows segmentation fault. Why is it so? The program is for pset2 vigenere.c . What I am doing is storing the key in a string and then storing the integer value of key ...
0 votes
1 answer
84 views

Please help!! pset 2 cannot successfully create a loop for "k"

#include <cs50.h> #include <stdio.h> #include <string.h> int main (int argc, string argv[]) { string k= argv[1]; string p = argv[2]; if (argc==2) { p=GetString(); ...
0 votes
2 answers
78 views

Still struggling with vigenere

I have been futzing with this for a couple of weeks. I actually put it away while I did pset3 but, having come back to it, I'm still stuck. I spent an entire day on it this weekend and tried adding a ...
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 ...
0 votes
1 answer
111 views

Pset2: Vigenere Cipher, wrong output

In the following code there is no compiling error, but it does something wrong, as it gives me a wrong output. What it is supposed to do is: when the key is 'a' and the plaintext is 'a', output 'a', ...
0 votes
1 answer
94 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
1 answer
99 views

Vigenere.c: got stucked with this program

I got stucked with Vigenere.c problemset2. With this program the user must prompt a command line keyword that will be used to encrypt a plaintext that the user will later enter. In particular for ...
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 ...
0 votes
1 answer
104 views

pset2 How to get rid of spaces in the end of the milo banana_ _ _ _ (input)?

How to get rid of spaces in the end of the input? My code works perfectly with _ _ milla_ _ _ banana But I have issues with the case if _ _ _ milla_ _ banana_ _ _ when I have spaces in the end How ...
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]!='\...
0 votes
1 answer
150 views

CS50 pset2 caesar

I am busy with CS50 pset2. I am trying to interpret the error message received: :( encrypts "BaRFoo" as "FeVJss" using 4 as key \ expected output, but not "ciphertext: FeVJss" My programme ...
0 votes
1 answer
376 views

Approach to pset 2?

I'm having problems with pset2 initials. My approach to it is to ask the user for input, and store that input into an array and print the individual initials from there. However, when I use the argv[] ...
0 votes
1 answer
135 views

CS50x - Problem Set 2 - Initials (less)

I've managed to whip up a solution in Python 3 that seems to work. name = input("") initials = name[0] for i in range(0, len(name)): if (name[i].isspace()): initials += name[i + 1] ...
0 votes
1 answer
144 views

PSET2 Initials task

My code has a bug in it which make it output the first initial after the second, would someone please be able to help me and describe what is wrong without having to change my whole code as it all ...
0 votes
1 answer
186 views

My caesar cypher is not cyphering right, can anyone please help?

The code executes but simply prints out the wrong output. For example, when I provide a key of 'a' and then ask for 'aaaa' to be converted, the code prints out 'cccc' instead of 'aaaa'. I can't figure ...
0 votes
1 answer
134 views

Pset2 Caesar won't compile

My code won't compile and I can't tell why. All of the error messages I'm receiving are regarding my "for" statement and my use of the variable i. I also get an error message about my use of "string" ...
0 votes
1 answer
244 views

I've use array pointer method in pset2 (initials.c) but it return "Segmentation Fault (Core Dump) Why?

I'm working on pset2 using array pointer method, but unfortunately, the program return "Segmentation Fault (Core Dump)" I've post a picture of my code below.Can I use this method? or I have to use if ...
0 votes
1 answer
146 views

Pset 2 Initials less comf my code works and passes the test but I would like to know how differenlty could have been implemented

I got initials less comf. pretty quickly thankfully but I would like to know how you guys have implemented the code differently than me. https://gist.github.com/a50582c43587cd3c45d38e9e0c4f956a
0 votes
1 answer
161 views

Pset2 vigenere formula

My formula for vigenere is not quite right, and I'm not sure which part is wrong, could someone leave me some bread crumbs please int j = 0; int upperk = key[j % klen] - 'A'; int lowerk = key[j % ...
0 votes
1 answer
72 views

pset2 vigenere. My code handles text inconsistently

I've got it working nearly perfectly. It works if the text is in lowercase, but I see that it's not working quite right when using uppercase. In check50 it only fails with lowercase: encrypts "BaRFoo"...
0 votes
2 answers
63 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. ...
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 ...
0 votes
1 answer
59 views

no rule to make target pset2

I am currently working on the readability problem in pst2. I followed the 'getting started' instructions to create and open the file in the readability directory, however, I am still getting a "make: *...
1 vote
1 answer
243 views

CS50P - Error in pset2 (Coke)

In pset2 (Loops), 2nd problem ("Coke"), I believe there's an error in the 4th test that check50 performs: it requires an output of $0.50 after the user entered $0.30. The full price is $0.50,...
0 votes
1 answer
2k views

Pset 2 - Substitution

I hope you are all well. Just had a quick question about CS50 Pset2's substituion problem. Please see my code below. #include <stdio.h> #include <cs50.h> #include <string.h> #...
0 votes
1 answer
30 views

pset2: "vigenere" missing output

when i use isString function or any function which containing "isalpha" function. My code provide missing output. When i remove isString function it works well. But i don't understand ...
0 votes
1 answer
178 views

Week 2 crack compiles, seemingly doesn't do anything

Crack compiles, but when I run it, nothing happens (I know the code isn't pretty, but I couldn't find the fault). It doesn't return anything, doesn't even stop. Thanks in advance! p.s. Sorry for the ...
0 votes
1 answer
161 views

Pset 2 Initials - Function Help

I've written a successful program to complete the Initials section of Pset2 without the use of any functions. However, seeing as I needed to copy/paste a good chunk of code in my program I've decided ...
0 votes
1 answer
99 views

Caesar pset2:Should I convert every letter of plaintext to uppercase after user input?

What if the user inputs both upper and lower case in the command line .should I convert them to upper case and print in upper case ? In the Caesar pset 2
0 votes
2 answers
1k views

Caesar - Validating key using isdigit

I keep getting this error: caesar.c:17:13: error: subscript of pointer to function type 'int (int)' if (isdigit[i] == 0) This is my code: #include <cs50.h> #include <ctype.h> #...
0 votes
1 answer
99 views

My solution outputs the correct values but it gives me onesebb/n on the last output

#include<stdio.h> #include<cs50.h> #include<string.h> #include<ctype.h> #include<stdlib.h> int main(int argc, string argv[]) { int k =0; if (argc != 2) { printf("...
0 votes
2 answers
796 views

PSET 2 Crack.c Hackers edition

I'm stuck on pset2's Hacker Edition crack.c. I made this code after exploring various ideas for hours and it really makes sense to me but apparently the dumb computer can't really understand what I'm ...
0 votes
1 answer
109 views

i cannot increase my key correctly :(

#include <stdio.h> #include <cs50.h> #include <stdlib.h> #include <string.h> #include <ctype.h> //Declare variables //check user's input value ...
0 votes
1 answer
150 views

Applying wrapping key

I have been stumbling over vigenere problem from pset2. I am trying to iterate wrapping around text, compiler systematically yells at me. #include <stdio.h> #include <cs50.h> #include &...
0 votes
1 answer
100 views

am on pset2(morecomfortable), the code gives me the desired result but it doesnt pass the check

#include <cs50.h> #include <stdio.h> #include <string.h> #include <ctype.h> int main(void) { string name = GetString(); for (int i = 0, n = strlen(name); i < n; i++)...
0 votes
1 answer
71 views

Vigenere Cipher: Cant get whats wrong

I am not able to guess what is wrong i never was able to understand is alpha thing but i tried to do some debugging and it is printing the non alphabetical characters twice. #include <stdio.h> #...
0 votes
1 answer
159 views

Pset2 Vigenere text is not encrypted properly

My code seems not able to cipher the text correctly, tried to figure out the problem but failed... Can any help me? Below is my code, thank you. #include <stdio.h> #include <cs50.h> #...
0 votes
2 answers
55 views

check50 says i have no output on pset2 substitution, but my code does output correctly

On my end my code seems to output exactly what check50 wants, yet it says that ive outputted nothing. e.g :( encrypts "A" as "Z" using ZYXWVUTSRQPONMLKJIHGFEDCBA as key Cause ...
0 votes
1 answer
15 views

When i try to make this string lowercase, it does it to both the one i want and another one

string key = argv[1]; string low = key; for(int i = 0; i < strlen(low); i++) { low[i] = tolower(low[i]); } through the debugger i can see that this is correctly making &...
0 votes
0 answers
141 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 ...
0 votes
0 answers
49 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 ...
0 votes
1 answer
37 views

encrypts "a" as "b" using 1 as key output not valid ASCII text

I have been trying to figure out what the issue is in my Caesar code. When I run check50, I see 2 errors - encrypts "a" as "b" using 1 as key output not valid ASCII text & ...
0 votes
0 answers
31 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 ...
1 vote
3 answers
66 views

Segmentation error on pset2 substitution

I'm trying to work on "substitution" problem set, but I'm getting an error of "Segmentation Fault" when I run the program below: In this part of the program I just want to check if ...
0 votes
1 answer
125 views

Why doesn't my Caesar code not return an output for the cipher text?

Can anyone help me out why my code won't return any cipher text, think it has something to do with the formula ci = (pi + k) % 26 I have done. Any help much appreciated. // Libraries #include <...
1 vote
1 answer
28 views

pset2, problem SUBSTITUTION, Is there more than 1 way to check for repeated characters in the 26-character key?

I have a question concerning pset2, SUBSTITUTION. I finalized the 3 initial filters of this problem: character count argument count non-alphabetical characters. now I'm moving to the fourth ...
0 votes
2 answers
33 views

pset2 substitution checking if all the characters in the key are different

I have almost finished substitution. Just that I have not yet been able to come up with a elegant way to check if all the characters in the key are distinct hence I used the following way to check if ...
0 votes
1 answer
31 views

How to solve "error: expected expression" while doing Caesar.c

I'm trying to solve Caesar but i keep getting this error: caesar.c:37:20: error: expected expression s[i] = char(int(text[i]+k-97)%26+97); \\ the arrow points to the 'c' in char #include <ctype.h&...
0 votes
1 answer
42 views

Pset 2 - Validating the Key

I'm very new to all this and so am struggling a bit with the for loop. Here is my code: #include <stdio.h> #include <stdlib.h> #include <cs50.h> #include <string.h> #include &...

1 2 3
4
5
26