Questions tagged [pset3]

The problem set for Week 3 asks students to write code for a classic puzzle game in the C programming language.

Filter by
Sorted by
Tagged with
0
votes
1answer
3k views

pset3, tideman, cs50 2020

I worked with pset3 and I think there are nothing wrong with my code, but check 50 says it has four problems on my code. it raises four problems, :( add_pairs generates correct pair count when ...
0
votes
0answers
274 views

Runoff - is_tie

Well I wrote my code and I don't know I am really stuck here with my code and can't get my head around it. Check50 returns only this error: :( is_tie detects tie after some candidates have been ...
0
votes
1answer
270 views

Week 3 - Plurality Code Will Not Compile on CS50 Check

I'm having an issue with CS50's check50 utility. My week 3 Plurality code is working, but when I submit it to be checked I get these results: Results for cs50/problems/2020/x/plurality generated by ...
0
votes
1answer
113 views

what is the significance of break; in tabulate function?

I know break statements are pretty basic, but it's got me here: This is my function: for (int i = 0; i < voter_count; i++) { for (int j = 0; j < candidate_count; j++) { if (...
0
votes
1answer
138 views

i can't get the vote function in runoff right

Here's the function i wrote: bool vote(int voter, int rank, string name) { int t = 0; int a = 0; for (int i = 0; i < candidate_count; i++) { int x = strcmp(candidates[i]....
0
votes
1answer
37 views

Recovered Images not clear

I having trouble generating clear images. I am able to generate the 50 JPEGs but they are just random colors or pixelated. I am however, not receiving an "Invalid or unsupported" file format error. I ...
0
votes
1answer
736 views

Pset3: Tideman sort_pairs not work

I have been trying to implement sort_pairs function using selection sort algorithm. After testing for every case, the sort_pairs is returning right answer but check50 is marking it as wrong. for (int ...
0
votes
1answer
147 views

Plurality segmentation fault

I am getting a segmentation fault despite knowing that the size of the candidates[] array is the same as the value stored in the variable candidate_count and I am iterating through the array from 0 to ...
0
votes
1answer
195 views

check50 claiming pairs are sorted incorrectly

On Problem Set 3, check50 has flagged my program as not having sorted the pairs correctly. However, the pairs array appears to be sorted in every case I've tried. I used insertion sort and had ...
0
votes
1answer
405 views

tabulate doesn't count votes when multiple candidates are eliminated

for (int i = 0; i < voter_count; i++) { // vote for top-preferred candidate if possible if (candidates[preferences[i][0]].eliminated == false) { candidates[preferences[i][0]]....
1
vote
2answers
6k views

cs50 pset3 runoff tabulate

i have completed the problem set however when i check, this is the only problem. :) tabulate counts votes when all candidates remain in election :) tabulate counts votes when one candidate is ...
0
votes
1answer
214 views

pset 3: 2 problems in runoff pointed by check50

My functions codes git link Here are my errors and my function codes in a git link (thanks folks for the feedbacks). I just don´t get what´s going on here, maybe i´m missing a detail, but it does ...
0
votes
1answer
1k views

PSET3 Runoff - Tabulate

my tabulate function is storing votes from the preferences array, but problem arising when multiple candidates are eliminated check50 shows error there. Please help me with this, and tell me what is ...
1
vote
1answer
349 views

pset 3 plurality help: not sure how vote function is implemented

would like to get some clarification on how the vote function in pset 3 is being implemented. As the vote function has already been implemented for us in main and we are only required to amend the ...
0
votes
0answers
1k views

lock_pairs skips middle pair if it creates a cycle

I am doing tideman and I can't find the source of this error.below are my code=> bool isCircle(int from,int edgevalue,int paircount){ for(int i=0;i<paircount;i++) { if(pairs[i]....
0
votes
1answer
349 views

pset3: code failed to compile

Now I am doing tideman and I already test and all are working well and get the expected result.but when I check with Check50,I got this msg :( tideman compiles code failed to compile I just ...
0
votes
1answer
150 views

Pset 3 runoff Randomly Increasing Votecount

I'm close to solving pset 3 runoff but I've run into this interesting problem in my tabulate function. Whenever I run the program with the debugger, my vote counts keep increasing by very large ...
0
votes
1answer
411 views

Pset3 Runoff - How to record name and rank in the Preferences Array?

Hi if anyone can guide me in the right direction to record name & rank in the preferences array? I don't have any clue how to even utilize the int vote and int rank in the bool parentheses of the ...
0
votes
1answer
455 views

Problem Set 3 Runoff print_winner working, but I'm getting a Check50 error

My print winner function works and prints the correct winner. I might be overlooking something simple, but I have no idea what it could be. bool print_winner(void) { // TODO for (int i = 0; i ...
1
vote
1answer
187 views

Pset3 Runoff bool function

I don't understand what the parenthesis after bool vote function is for. bool vote(int voter, int rank, string name) It could have been (void), what purpose does it serve here? Please make my ...
0
votes
1answer
209 views

pset3 (runoff) check50 is giving an error for print_winner

I can't find what's wrong with my code but check50 keeps telling me :( print_winner prints name when someone has a majority print_winner did not print winner of election :( print_winner returns ...
0
votes
1answer
143 views

Plurality - check50 issue

Hoping for some insight on this.. code works perfectly fine, prints correctly when testing in terminal, but for some reason check50 outputs errors once it starts printing winners. Would love to find ...
0
votes
2answers
927 views

PSET 3 runoff record preference problem

I am going through the problem set 3 and I am currently stuck at the record preference (vote) function. I have built a code down as below, but running it gives me a segmentation fault error message. ...
0
votes
1answer
951 views

Problem set 3 Plurality ISSUE cs50

I've been trying to solve the new problem set 3 plurality step by step, and here where I got stuck, but somehow I'm sure about my answer bool vote(string name) { bool v = false for (int i = 0 ; i &...
0
votes
1answer
105 views

How to set rank for all preferences?

Any thoughts on that to set rank for all preferences?
0
votes
1answer
173 views

pset3 runoff segmentation fault problem

I am doing the 2020 version of CS50's pset3 and I am already stuck (again) at the runoff voter function. My code below resulted in segmentation fault. I don't know how to fix this though. So here's ...
0
votes
1answer
348 views

Plurality fails to compiles

I always work on Psets on my local machine and replace string with char * so I don't have to use the CS50 library in my header files. This is the only explanation I have for why my code doesn't ...
1
vote
0answers
689 views

pset3 (runoff) keep getting print_winner error when using check50

I keep getting these errors when running check50 on my runoff program: print_winner prints name when someone has a majority print_winner did not print winner of election print_winner returns ...
0
votes
2answers
1k views

RUNOFF PSET3 - bool is_tie(int min) function gives an error in Check50 unable to remove

I have tried a number of ways to execute the code in bool is_tie function; however, I always seem to receive the same error in check50. I have run the code through debug50 and it seems to work ...
0
votes
2answers
2k views

PSET3 runoff 2020

I have some trouble with PSET3 2020 runoff: in Specification: Complete the implementation of runoff.c in such a way that it simulates a runoff election. You should complete the implementations of ...
0
votes
1answer
125 views

why does it not return a value for bool?

So my code does not compile because it does not return a value. I don't know how to make it work and return true and false as it is in the if statement // Update vote totals given a new vote bool ...
0
votes
1answer
389 views

Plurality is being failed by check50 when it works in my terminal (PSET3)

Plurality Check50: https://submit.cs50.io/check50/dfe0d69252268f63eddb40057eada6979586a661 However, code works when I run it in my terminal: https://imgur.com/a/xEp0EnH Code: void print_winner(void)...
1
vote
2answers
4k views

PSET3 -Tideman - Locking Pairs

I'm looking for a little help to check my logic on this problem set. My program currently passes all the check50 tests up until I have to lock in the pairs to the locked array. You must lock all ...
0
votes
1answer
61 views

pset 3 Recover Segmentation fault

So, after some manipulations with my code I`ve got to Segmentation fault. Here is my code so far #include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]) { // ensure ...
0
votes
2answers
83 views

recover.c images recovering correctly, but 049.jpg test case failing

The title explains the issue, not really sure why the test case is failing because the logic seems to work. I'm assuming it has to do with reading some unnecessary bytes near the end, but I haven't ...
0
votes
0answers
35 views

Pset3 Resize more- Random colours

Absolutely lost on this, checked the header and its correct but when I look at the resulting image from my code its just a bunch of random colors. Also, i'm trying to use the nearest neighbor ...
0
votes
1answer
34 views

jpegs don't process correctly nor do they have correct names

my recover.c goes through the raw file and then opens up new jpg files but only the first one has the correct name 001.jpg the rest have long code names such as 8767661.jpg. Additionally, none of them ...
0
votes
0answers
21 views

pset3 resize more comfortable stuck for scaling down

Been spending a few days tackling scaling down the image. Below is my code. Can anyone help point me towards the right direction or find errors in my code? // Copies a BMP file #include <stdio.h&...
1
vote
2answers
34 views

Resize less fails when trying to resize small.bmp when n is not multiple of 4 or is 1(probably padding issue)

int oldHeight = bi.biHeight; int oldWidth = bi.biWidth; bi.biWidth *= n; bi.biHeight *= n; int padding = (4 - (bi.biWidth * sizeof(RGBTRIPLE)) % 4) % 4; bi.biSizeImage = ((sizeof(RGBTRIPLE) * bi....
0
votes
1answer
45 views

Pset3-resize explaination

I am struggling to understand how to approach resize problem. I see there are alot of codes available for me to use directly. I do understand the problem, Zymal's pesudocode, but the lack of clarity ...
0
votes
1answer
23 views

pset3 resize less comfortable problem - mixed colour

I have been struggling with cs50 resize for quite some time. Can't figure out why my code is wrong. The output seems to have a right size but it is in a bunch of random colour. // Copies a BMP file ...
0
votes
1answer
50 views

PSET3 -I am getting segmentation fault

I am getting seg fault over and over again. Could anyone help out please. I am pretty sure the functional part of the code, the while loop, should be working properly. Thanks in advance. #include &...
0
votes
0answers
12 views

pset3 Resize - How to do vertical scaling by copying the outfile?

Recopy method I'm using an array of data type BYTE to copy lines in outfile and paste them back, allowing me to do vertical scaling in the most efficient manner. However, this method causes garbage ...
0
votes
1answer
48 views

PSET 3 still stuck

I'm still so very stuck on this one. Below I have a cobbled together "solution" that at least increases the size of the image. I have no clue what I'm doing when it comes to copying the value of ...
0
votes
1answer
37 views

Segmentation fault on PSET3 recover

My program compiles, but wherever it runs I recieve a segmentation fault error. However i cannot see where the source of the problem is: #include <stdio.h> #include <stdlib.h> #include &...
0
votes
1answer
19 views

Pset3: Resize (less) loops seems to add extra bytes to headers

I'm working on the CS50 pset3 problem resize (less comfortable). It looks like the resize is working, but I seem to be adding a lot of extra bytes to the header. Looking at the image itself it looks ...
0
votes
1answer
57 views

pset 3 recover - JPEGs don't match

#include <stdio.h> include include int main(int argc, char *argv[]) { //ensure proper usage if (argc != 2) { fprintf(stderr, "Usage: /recover infile\n"); return ...
0
votes
1answer
24 views

pset3 resize (less) - double free or corruption (fasttop)

the code is working with small.bmp, but not with large.bmp and i can't understand why. Even resizing smiley.bmp, when n is too big it's not working. Here's the code: // Copies a BMP file include ...
0
votes
1answer
70 views

Recover: Problem when writing info into image

I'm having trouble when creating the JPG files. The amount of images created and the name is fine, but the content of the image is wrong. Here is my code: int main(int argc, char *argv[]) { if( ...
0
votes
1answer
32 views

Unexpected results on resize(less). I could not figure out how is not working the way it suppose to be. Please help

// Copies a BMP file #include <stdio.h> #include <stdlib.h> #include "bmp.h" int main(int argc, char *argv[]) { // ensure proper usage if (argc != 4) { fprintf(...

1 2
3
4 5
25