Questions tagged [init]

The tag has no usage guidance.

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

How do you delete a line depending on its first character?

When trying to delete all of the comments in positive-words.txt I have tried iterating over the lines and checking if the line startswith ';' however I do not know how to delete the line if it does. ...
0
votes
1answer
41 views

game of fifteen problem with initialisation of my 2D array

I have been working on this program more than a week and even started once again from the beginning. I created init() function and draw() function in a separate file (they both are in main function ...
0
votes
1answer
67 views

Pset 6 sentiments init function

I'm working on the init function is sentiments and I'm struggling a bit on what to put in the for loop. This is what I have so far, can someone tell me if this is correct or how to fix it? def ...
0
votes
1answer
35 views

Game of Fifteen Draw function outputting only zeros

I am currently trying to solve a bug that prevents me from printing my wanted values. When I initialize the board and try to assign the value it appears to assign only zeros from the for loops even ...
0
votes
1answer
36 views

The tile doesnt swap or move when i use this code!

I have been stuck on this for two days now. Would really appreciate some fast help! every time i run this it and put in Tile to move:3 all the numbers on the board change can u give me ideas on how to ...
0
votes
1answer
34 views

Is my implementation of init() function in fifteen.c [pset3] true?

I am starting to do Game of Fifteen [pset3] today. I've just written init() function. I want to make sure it works before forging ahead to draw() function. Please, take a look at my implementation. /*...
0
votes
1answer
68 views

My game of fifteen doesn't work

void init(void) { // TODO int fill = ((d * d) - 1); int brow = d; //fill entire grid except the bottom for(int i = 1; i <= d; i ++) { for(int j = 1; j <= d; j ++)...
0
votes
1answer
73 views

CS50 > Pset3 > Game of fifteen > init function :

Can anybody please explain why is the rule: 1 and 2 has to be swapped when the dimensions are even? Why is it necessary? what is happening behind the screen?
1
vote
1answer
242 views

PSET6 2016 Analyzer.py - Says all is neutral

When I tested tweets after implementing Analyzer.py, I found that it said that every single tweet was neutral (The twitter account I used was @realDonaldTrump). I believe it has something to do with ...
0
votes
1answer
32 views

pset3 'fifteen' - init function only works for small grids

My init() code works beautifully for grids of 3, 4, or 5, but chokes with larger grid of 6, 7, 8, and 9. It looks almost like an integer overflow or floating point imprecision problem, but I can't see ...
0
votes
2answers
561 views

Pset3 - Game of Fifteen - init function

I am trying to complete the first step of game of fifteen - writing the INIT function. I've partially written a function that I think should work. The thing that is bothering me is this: I want to run ...
0
votes
1answer
107 views

pset3 - swap in function Init

I've been working on Game of Fifteen in Pset3 and I'm having a hard time understanding why I can't seem to find a way to swap the last 2 elements in the Init() function if the dimensions of the board ...
0
votes
1answer
107 views

fifteen expected file length

If I run my program, it seems te run just fine. But when I run check50 I get this response :( init initializes 3x3 board correctly \ expected file to be of length 18, not 19 :( init initializes 4x4 ...
0
votes
1answer
23 views

Why is the code after the for loop not executed?

I don't understand why the second part of this code doesn't get executed. It within the init function and I expect it to run after the loop. The last tile still returns 0 and with odd number of tiles ...
0
votes
2answers
170 views

Pset3/Fifteen/Init Function - Problem with 1 and 2 swap

void init(void) { int start_tile = (d * d) - 1; for (int i = 0; i < d; i++) { for (int j = 0; j < d; j++) { board[i][j] = start_tile; ...
1
vote
2answers
158 views

Pset3, Error in init function

This is the error I get: :( init initializes 3x3 board correctly \ expected file to be of length 18, not 19 :( init initializes 4x4 board correctly \ expected file to be of length 38, not 39 ...
0
votes
1answer
38 views

I am facing problem in init function. It shows up same error everytime that incorrect length 26, should be 18. I am using latest version of cs50

void init(void) // define a counter and populate the array int c = 1; for (int i = 0; i < d; i++) { for (int j = 0; j < d; j++) { // fill the tiles in descending order board[i][...
0
votes
1answer
1k views

pset3: fifteen - “init” and “draw”

So I've written the code for two of the functions in "fifteen", but after I compiled and started the program it prints a bunch of zeros. I'm hoping for a tip from you guys. The code for the two ...
0
votes
1answer
225 views

fifteen.c fails to initialize correctly

so my Pset3 program, fifteen.c, isn't working. This is the error message that shows up from check50: :( init initializes 3x3 board correctly \ expected log.txt to exist :( init initializes 4x4 ...
0
votes
1answer
119 views

Init fails to intialize any of the boards for fifteen on check50

I'm receiving a segementation fault with the code below. I've played with the code a little bit. I'm assuming there are problems in the move and won functions as well, but I'm unable to check them, ...
0
votes
2answers
131 views

init and draw not working properly in pset3 fifteen

I can not find my mistake, but there is something wrong obviously either with init or with draw: My code for init is: void init(void) { if (d%2 != 0) { for (int i = 0; i < d; i++) ...
1
vote
1answer
135 views

Am I going about Init() correctly?

I'm wondering if I'm going about Init() correctly. It took me quite some time to understand what I was supposed to do. I realized drawing out the actual board on paper helped a lot. Anyways, here is ...
0
votes
2answers
640 views

Pset3 Fifteen: Draw and/or Init Function Problem

I cannot figure out why this code is not working. The output appears to be random. Any help is greatly appreciated. Thanks! My Init code: void init(void) { int MAX = (d*d)-1; int below = 0; ...
0
votes
1answer
59 views

What's the difference between these two lines of code? Pset3. Init

I noticed that my in my init function, that the '1' and '2' variables weren't switching correctly. After playing around with my code, I have noticed that this works: void init(void) { // ...
0
votes
1answer
617 views

pset3 Game of Fifteen check50

My code runs fine, but check50 gives this error: :) fifteen.c exists :) fifteen.c compiles :( init initializes 3x3 board correctly \ expected file to be of length 18, not 27 :( init ...
0
votes
1answer
3k views

error: array type 'int [9]' is not assignable - init

I'm in the middle of implementing the init function in fifteen, but I ran into the error "error: array type 'int [9]' is not assignable" while compiling the program. What exactly does that mean? Here ...
0
votes
1answer
478 views

Pset 3 Fifteen: “use of undeclared identifier 'new'”

I've been working on Fifteen, and I want to insert the values into an array (in init) but for some reason, it doesn't know what 'new' is. When I try #include <new>, it says it cannot find said ...
0
votes
1answer
107 views

check 50 says 4x4 wont initialize properly

When I run check50 on this code it says it wont work, but it seems to look fine when I just run the script. It says "expected "1" character 3 of line 4, not "2" " Can you spot what I'm doing wrong? ...
1
vote
1answer
141 views

Inint funtion in fifteen.c working but check50 is unhappy

My fifteen.c is working properly but check50 says it's not initialising right... It says: :( init initializes 3x3 board correctly \ expected file to be of length 18, not 19 :( init initializes 4x4 ...
0
votes
1answer
197 views

getting error from check 50 fifteen\ expected “8” character 1 line 1, not “0” exp. file to be of length 38, not 32

Having trouble with my code here, cant get the numbers to appear at all, much less in a 2d array, outputs 9 "_" chars separated by new line every time. I apologize for my lack of understanding of how ...
0
votes
1answer
380 views

PSET3 check 50 error on init()

I am using the cs50 2015 code template and my code gives the correct output on my system but gives a check50 error :) fifteen.c exists :) fifteen.c compiles :( init initializes 3x3 board correctly ...
-2
votes
2answers
840 views

How to set up the board using init and draw functions

I am working on PSET3 Fifteen and am really unsure of what I am doing with the init function. I have a nested for loop – but I don't know what to do with the values. I then move on down to draw and I ...
2
votes
2answers
264 views

Why Aren't My Last Two Tiles Swapping?

I'm trying to come up with something to change the tile numbers in the last two array slots, containing numbers 1 and 2 when I have an odd number of tiles. I thought this would work, but when I print ...