From the spec:
Take care to left-align the bottom-left corner of the left-hand half-pyramid with the left-hand edge of your terminal window.
In other words, the last line must start in the first "column" of the screen.
(+1 for editing the code format :)
Assuming "more comfortable" version and your sample is for ...
If you read the man page of the crypt function it says in one point:
The return value
points to static data whose content is overwritten by
So the first time you call crypt, and assign its return value (which is a pointer to a string) to the coded variable, the coded variable contains the correct encrypted password. But ...
No, the hacker edition is available for everyone doing the course, though, those of us taking it through edx cannot submit the work done under the Hacker Edition for credit, we still can do it.
If your'e doing the edx one, under the courseware head, in the right bar, there are several weeks shown, just click any one of those weeks, and you'll see a section ...
The hacker edition problems have now become the "more comfortable" problems in a problem set. For example, in pset1, mario (less comfortable) involves printing one pyramid, while mario (more comfortable) is the previously named "hacker edition," which prints two pyramids with a gap between.
You must do the standard problem sets to get a certificate; Hacker Edition problem sets are completely optional and have no effect on grading or certificates in edX.
The CS50x 2014 syllabus covers this question in the section on Problem Sets:
Both editions essentially cover the same material. But the Hacker
Edition typically presents that material from ...
The Hacker version is listed on the same page as the Standard version.
For example, for Problem Set 1:
Courseware Page for problem set 1
Notice there are 2 headings, Standard and Hacker, and an HTML link for each.
First, char is NOT int. I mean if you have
string s = "1234";
and then you wrote something like
int sum = 0;
// iterate over s and sum the chars up
for (int i = 0, n = strlen(s); i < n; i++)
sum += s[i];
sum won't be 10!
Second, you have to start with the number's second-to-the-last digit. See this answer for more info!
Lastly, you may the ...
In the GNU C library, RAND_MAX, the default maximum return value of rand() is the largest signed integer value. And so, sometimes, if the rand() returns a high enough value and you multiply it by "i", it makes it "overflow" to represent a NEGATIVE value. You should define a lower RAND_MAX value.
As I see, you want to randomly swap tiles, but: u might end up ...
Like most soi-disant "random" functions, rand() isn't really random. It generates pseudorandom numbers using a deterministic algorithm. This algorithm will always produce the same results if it is "seeded" with the same default value. You can obtain a more random-ish pseudorandom number by seeding rand() with a different value, such as a time stamp.
The problem lies here:
int j = rand() * i;
The call to rand() returns a very large number. From there on, it just gets propogated through the code, used in other calculations, and pushed further on. Anywhere downstream that uses j or another var based on j, is getting a really large integer. Finally, when the code tries to use one of those downstream ...
I'd suggest a different method of turning your long long into an array:
(1) Declare a char array with char s; (20 digits should be enough for a long long),
(2) Use sprintf to pass num into char array s.
Otherwise, you've got your function names the wrong way round, and you've forgotten to have one call the other.
Oh and your code is not technically ...
Interesting. I ran your code and it passed check50. I was unable to duplicate the problem. However, I do see the issue.
You were on the right track, but your attempts to correct had errors. The problem is indeed in processing the end of the string. If the last character is a space, there is no next char to process. So, changing the for loop as follows ...
I would pick small numbers for h (e.g., 1 and 2), determine what the expected results should look like and follow the logic of my code using a pencil and a paper.
for example, when h == 1, I should get:
let's see what happens following the logic of your code!
first, if (h < 0) seems to be redundant because the condition of the for loop basically ...
Classic error. The function isdigit() takes a single character as input. You are attempting to feed it an entire string, so it chokes, causing a seg fault. If you want to verify that every character in the string is a digit, you need to loop through it and test each character, one at a time.
If this answers your question, please click on the check mark to ...