GithubHelp home page GithubHelp logo

pasqualerossi / 42-school-exam-rank-02 Goto Github PK

View Code? Open in Web Editor NEW
556.0 6.0 97.0 579 KB

First 42 School Exam

C 100.00%
42 42adelaide 42cursus 42exam 42exams 42school examrank rank02 42-exam exam-practice

42-school-exam-rank-02's Introduction

42-school-exam-rank-02's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

42-school-exam-rank-02's Issues

ft_atoi_base condition should exclude max_digit

  8 int get_digit(char c, int digits_in_base)
  9 {
 10         int max_digit;
 11         if (digits_in_base <= 10)
 12                 max_digit = digits_in_base + '0';
 13         else
 14                 max_digit = digits_in_base - 10 + 'a';
 15         if (c >= '0' && c <= '9' && c <= max_digit)
 16                 return (c - '0');
 17         else if (c >= 'a' && c <= 'f' && c <= max_digit)
 18                 return (10 + c - 'a');
 19         else
 20                 return (-1);
 21 }

In the line 15 and line 17, the condition is wrong. In any base $b$, the digits must be in the range of 0 to $b-1$. For example, the valid digits are 0 and 1 if we are talking about base 2. So the condition should exceed the maximum allowable digits.

Enhancing FizzBuzz Program

The current FizzBuzz program has been enhanced to make it more interactive by allowing users to specify the range of numbers to consider. However, there's room for further improvement and refinement.

location : Level 1/ Fizzbuzz / fizzbuzz.c

tab_mult handeling negative numbers

inside tab_mult the functions ft_atoi & ft_putnbr are handeling cases where the given number (parameter) is negative which is not asked in subject and could be removed to improve readability. Also could add a checker if the number is <= 238609183, as this is the highest number to be multiplied by 9 and still fit in an int.

Subject.txt:

Write a program that displays a number's multiplication table.

The parameter will always be a strictly positive number that fits in an int,
and said number times 9 will also fit in an int.

If there are no parameters, the program displays \n.

Diffrent type cast in function

Hi, in level 2 the max function, you are using type cast (int) in result;

I Didn't pass in the exam because of that, it wont work, moullinete wont pass.

Switch (int) type cast in Result to Unsigned int, and it will pass.

.

(ignore)

ft_range

there is a problem in ft_range function in line 10 and 12

ft_rrange.c

when end is smaller than start, your function returns array that contains ints from start to end, but shouldn't it return from end to start? In example of subject ft_rrange(0, -3) should return {-3 , -2, -1 , 0}, but it returns {0, -1, -2, -3}.

fprime fprime doesn't compile

Can you help me? I saw that the repository code has syntax errors. I fixed it, but I'm already in sext grademe and it still gives a compilation problem.

![image](
Captura de tela 2022-12-09 205853

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char **argv)
{
	int i;
	int num;

	i = 2;
	num = atoi(argv[1]);
	
	if (argc == 2)
	{
		if (num == 1)
			printf("1");
		while(i <= num)
		{
			if (num % i == 0)
			{
				printf("%d", i);
				if (num == i)
					break;
				printf("*");
				num = num / i;
				i = 2;
			}
			i++;
		}
	}
	printf("\n");
}

ft_range

-ft_range dosn't work.
-When start = 0 and end = [-negative number]

Screenshot 2022-08-12 at 15 35 06

Exam Rank 02 - pgcd.c

Hey there, I was just reviewing some code before the exam and I believe I crossed somethingthat is probably wrong.
You got an undefined variable named "number 2" in the pgcd.c file, so the program doesnt even compile :)

Check it out and let me know whats up!

Wont pass official exam (rank 2) ft_atoi_base

This code gets success in grademe but not in the official exam.

int ft_atoi_base(const char *str, int str_base)
{
int result;
int i;
int sign;

i = 0;
sign = 1;
result = 0;
if (str[i] == '-' || str[i] == '+')
{
	if (str[i] == '-')
		sign = -1;
	i++;
}
while (str[i] != '\0')
{
	if (str[i] >= '0' && str[i] <= '9')
		result = result * str_base + str[i] - '0';
	else if (str[i] >= 'a' && str[i] <= 'f')
	{
		result = result * str_base;
		result = result + str[i] - 'a' + 10;
	}
	else if (str[i] >= 'A' && str[i] <= 'F')
	{
		result = result * str_base;
		result = result + str[i] - 'A' + 10;
	}
	else
		return (result * sign);
	
	i++;
}
return (result * sign);

}

Else condition after while

while(...)
    ....
 else
 {
    res[i] = start;
    start--;
    i++;
 }
 

You have a "else" after a while. In my knowledge that is a syntax error

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.