#PHP exercise
274 messages · Page 1 of 1 (latest)
You need to use the provided function arguments to calculate the times and not return just numbers, try reading the documentation on function arguments and arithmetic operators, that should give you the information you need to solve this exercise.
https://www.php.net/manual/en/functions.arguments.php
https://www.php.net/manual/en/language.operators.arithmetic.php
Some of PHP's documentation has been translated to other languages apart from English, so you might find another language in there that's easier to understand.
Sharing code blocks (instead of screenshots) will increase your chance of getting help (and is a part of community etiquette, which is also recommended in error messages). Thanks for your understanding!
You enclose the beginning and end of the code with triple backticks (`).
Note, use backticks (`), not single quotation marks (').
For example, you can type the following:
The ``` must be on their own line.
```
not wrapped
```
Discord will render that as:
wrapped!
Happy coding!
Can you share your code in a codeblock?
Increase your chance of getting help and look like a pro by sharing codeblocks not images. For example, you can type the following. Note, the ``` must be on their own line.
```
for number in range(10):
total += number;
```
Discord will render that as so:
for number in range(10):
total += number;
Click here to learn more about codeblocks: https://exercism.org/docs/community/being-a-good-community-member/writing-support-requests and http://bit.ly/howto-ask
@near knoll Does that help?
the screenshot show
I'll a re-write coding
Images are harder for me to read. Text is easier.
class Lasagna
{
public function expectedCookTime()
{
return 40;
}
public function remainingCookTime($elapsed_minutes)
{
return 20;
}
public function totalPreparationTime($layers_to_prep)
{
return 10;
return ;
}
What's the last return line do in the last function?
What tests fail? What's the output (as a codeblock)?
disconsider last return;
the test fail question are the screenshot because the reason
i need a returns how many minutes more the lasagna must be in the oven when it is 30 minutes in the oven already
but the return need be a interger value in the function
Could you share the failure as NOT screenshot? Text in a codeblock?
You're describing the failure in vague terms. The exact test details would help
Asking questions well increases your chance of getting help. Learn how to write good support requests in this article: http://bit.ly/howto-ask
yes i can
one moment please
the error are i can't return for interger value
the question talsks are returns how many minutes the lasagna must be in the oven when it is 30 minutes in the oven already
the function ($layers_to_prep, $elapsed_minutes)
you can understand ?
Can you copy/paste the full test output?
Run test -> Test Failure -> Select All -> Copy -> Discord -> ``` + paste + ```
can i message dm you?
No thank you. You can copy/paste the test output here
That way anyone can help out, not just me
basically i have a return many minutes remaining
but interger value
LasagnaTest::testAnotherRemainingCookTime
Failed asserting that 20 matches expected 10.
/mnt/exercism-iteration/LasagnaTest.php:51
Can you also copy paste the test "CODE RUN"?
sorry mate
was me mistake
Ideally in a codeblock, but... 🤷♂️
1. Do you understand what the test is doing?
2. Do you understand what the test is expecting and why?
3. Do you understand what your code returns and how it differs?
4. Do you understand why your code is returning what it returns?
1. Você entende o que o teste está fazendo?
2. Você entende o que o teste espera e por quê?
3. Você entende o que seu código retorna e como ele difere?
4. Você entende por que seu código está retornando o que retorna?
$lasagna = new Lasagna();
$this->assertEquals(10, $lasagna->remainingCookTime(30));
Do you understand what the test is doing? <> Você entende o que o teste está fazendo?
yes i can understand
the test need a return many minutes the lasagna need stay in the oven after being in the oven for 30 minutes
Do you understand what this test expects the result to be, and why? Você entende o que este teste espera que seja o resultado e por quê?
yes , sim entendo
after 30 minutes the answer its 10 because the total time are a definied in the top of the program = 40
but i can't return this value as a interger
Why not?
What is the logic?
i have 2 parameters layers and elapsed
layers are defined before its a 10
and the previous question the elapsedtime this is equal 20
The number of layers here does not matter
The function needs to determine how many minutes remain based on the elapsed minutes.
If 30 minutes elapsed, how many minutes remain?
Each unit test is independent from all the other unit tests
in this case it's 10 because the total cooked time it's 40
but total cookie time parameter aren't in this function
As I said previously, you should look at the PHP documentation as well to learn the syntax, the introduction for this PHP exercise also contains all you need to solve the exercise.
https://www.php.net/manual/en/functions.user-defined.php
https://exercism.org/tracks/php/exercises/lasagna
The total time is always the same
How do you get 10? Can you explain the logic/steps?
@near knoll ?
it's true
total its 40
but already 30 minutes in the oven
remaining 10 to 40
@turbid surge be patient kkkk I'm a learning
did you only make me ask
i need to explain a solve this task
You need math to solve this task, yes
yes, but you only make asks, not expalin how solve this task
some explain me solve this task
?
Yes. I know how to solve this task. I am helping you figure out how to solve this task.
total its 40
but already 30 minutes in the oven
remaining 10 to 40
Can you show this using math?
yes, its true
the value always the same you was talking before
the values I put as an answer in the previous questions and exercism showed that it was right, that's why I thought the variable had a defined value
sorry, I understood that the variable had defined values based on previous answers
again
total cookie time = 40
but he's in the oven 30 minutes
remain 10 minutes to 40 total time
this is my think
Can you do that using math operators? Plus minus times divide? + = * /?
operator -
What's the full equation?
40-30
i need a solve task
How many minutes remains after $elapsed_minutes time? Using math?
i dont know
no idea
If 30 minutes elapsed, how much time is left (using math)?
If
30minutes elapsed, how many minutes remain?
=>40 - 30
If$elapsed_minutesminutes elapsed, how many minutes remain?
=> ???
See the pattern?
wait
i need the answer low
i thinking know the wrong way
i dont make any operation in this code
i put on return the value direct, dont math operator
return = 10
You need math since the elapsed time can change
seems like the value return always undefined ?
interger
its true
?
but i nedd define the variable math before?
need*
The variable is passed into the function. It is $elapsed_minutes. The value of that variable changes depending how the function is called.
new Lasagna()->remainingCookTime(10);
new Lasagna()->remainingCookTime(20);
new Lasagna()->remainingCookTime(30);
and after the parameter with a math cointained a variable
Yes
the function need solve its ElapsedTIme
now i understand better
$elapsed_minutes
ElapsedTime and $elapsed_minutes are not the same thing 🙂
you're a really patient with me
I try 😄 Thank you
how is called what do you make here?
I don't understand
Did it work?
If not, can you share your code and the test output?
yes
i'm trying it
public function totalElapsedTime($layers_to_prep, $elapsed_minutes)
{
new Lasagna()->remainingCookTime(10);
new Lasagna()->remainingCookTime(20);
new Lasagna()->remainingCookTime(30);
return $elapsed_minutes(40) - $remaingCookTime(30);
}
$lasagna = new Lasagna();
$this->assertEquals(40, $lasagna->expectedCookTime());
``````´
What is the test failure message?
one moment
LasagnaTest::testExpectedCookTime
ParseError: syntax error, unexpected token "->"
/mnt/exercism-iteration/Lasagna.php:23
Excuse me for interrupting. I translated how to create code blocks into Portuguese.
Compartilhar blocos de código (em vez de capturas de tela) aumentará suas chances de obter ajuda (e faz parte da etiqueta da comunidade, que também é recomendada em mensagens de erro).
Você envolve o início e o fim do código com três acentos graves (`).
Observação: use acentos graves (`), não aspas simples (').
Por exemplo, você pode digitar o seguinte:
O ``` deve estar em sua própria linha.
```
não envolvido
```
O Discord irá renderizar isso como:
envolvido!
Feliz codificação!
What is the totalElapsedTime function supposed to do?
sorry
i go to the sleep
lol
Sleep is important!
contaim inside () 2 variables
public function totalElapsedTime($layers_to_prep, $elapsed_minutes)
to be honest what a need its the remain time when stay at 30 minutes in the oven
but what's the fucntion to do i'm a loser
sorry
Step one: understand what the function is supposed to do
You can't solve without knowing what you are solving
public function totalElapsedTime($layers_to_prep, $elapsed_minutes)
{
new Lasagna()->remainingCookTime(10);
new Lasagna()->remainingCookTime(20);
new Lasagna()->remainingCookTime(30);
return $elapsed_minutes(40) - $remaingCookTime(30);
}
yes the function need total time - remain cooking time consider stay 30 minutes already, on this case how many remaining minutes need return
Yes, you have to calculate how many minutes are left considering that there are already 30 minutes in the oven
No. 30 is not part of the problem. There might be 5 minutes or 15 or 30 in the oven.
It varies.
It asks you to compute the total elapsed time. What math would you use to calculate elapsed time?
no idea
Did you read the instructions? Did you understand them?
because there would have to be the total recipe time minus mathematical operation, the remaining time
I couldn't think straight
yes
i'm read again
now it's clear
the function have a 2 arguments
number of layers and minutes in the oven , on this case this number 30
yes because the function need rreturn total time cooking lasagna
would be sum the prepare minutes + cookink time minutes
just which next step?
the problem in the language spoke are a solve
but i transformer this in a code
need change these variables?
could me explain better?
Teamates
We've been chatting here with you for 2 days and so far I can't
please give me the solution and explain how to do it, I want to move on to the next task
How did you solve the first function? Can you do something similar with this one?
Write it as math and use variables where numbers go
in the first function I put 40 and the code worked
because it asked for a simple return like interger
but I can't do this
return 40;
my first function and the exercism is allright
Sorry. What about the second function?
you ask me solve the first function
class Lasagna
{
public function expectedCookTime()
{
return 40;
}
it's the correct the exercism show this
the first function solve this
Did you solve the second function?
Using a variable?
but the value 20
yes
You're second function is return 20?
public function remainingCookTime($elapsed_minutes)
{
return 20;
}
yes
That passes the test? That doesn't look right.
yes
i'm not lie
ask me again ?
Do you understand what a variable is?
yes i know the function but i'm a still learning
What should remainingCookTime(10) return?
in the function remaining cookinh time
return 20
here
i put
10 its a layers i put
If 10 minutes elapsed, then 20 is the wrong result
10 its a layers_to_prep
yes i agree
public function remainingCookTime($elapsed_minutes)
{
return 20;
}
10 is $elapsed_minutes
Functions are supposed to return a value which changes based on the inputs
this i can understand
but 10 in my code are layers_to_prep
this is because i didn't understand you explain here
if elapsed = 10 because return = 20
stiill i can't understand
i know, but not totally familiar
@turbid surge in the code show elapsed = 20
why you say elapsed = 10?
i'm not understand the reason elapsed 10 value
Elapsed is a variable. It can hold any value. It's value is set when the function is called.
remainingCookTime(5) --> elapsed time is 5
remainingCookTime(30) --> elapsed time is 30
remainingCookTime(13) --> elapsed time is 13
just in return i put the variable elapsed it's correct?
What should the remaining time be if elapsed is 10?
If remaining time is y,
y = ?
not understand
isaac i want to finished this tasks
this night
do you have an solution for this code?
i answer wait a moment
Yes. But you won't learn by copy pasting a solution
yes, if i don't learning
What's the purpose of doing the exercise, if not learning?
remaining time is a variable
not a fix value
yes i agree
If I know the elapsed time, how can I find out the remaining time? What do I need to do?
need a math calculate the diference among expectedcookietime(first function) - elapsed minutes
the rest are the result
Oooh! Very good
That almost looks like code!
expectedcookietime() - elapsed minutes
but i haven't anyone in the code variabel cookie time only a function
Which function? What's the function name?
here expectectcookietime is a function, but i haven't variable the cookietime
understand?
i need make pass the function as a parameter
->
If you call me a troll, I could always ban you for being unappreciative of my time 😛
There is no function expectedcookietime() in your code. Look closer.
sorry
I was referring
public function expectedCookTime()
{
return 40;
}
i know it's a function, not a variable
What's the exact function name?
I thought I needed the expected cooking time variable
expectedCookTime
So
expectedCookTime() - elapsed minutes
And what's the exact spelling of the elapsed minutes?
$elapsed_minutes
So that give this, right?
expectedCookTime() - $elapsed_minutes
And what is your function supposed to do with that value?
For the remainingCookTime()?
This gives the remaining cook time:
expectedCookTime() - $elapsed_minutes
i didn't understand
Do you understand what this code does?
expectedCookTime() - $elapsed_minutes
morning mate
yes the function are transforming as a variable-> just i cal that variable on return in the end of the code
seems like
expectedCookTime()->$elapsed_minutes
return $elapsed_minutes
firts transformer or pass the function as a variable
after called the variable
Hi Morning
Some can help me this a task
still giving error
someone can help me please
i need
@turbid surge you are here?
public function totalElapsedTime($layers_to_prep, $elapsed_minutes)
{
expectedCookTime()->$elapsed_minutes;
return $elapsed_minutes;
}
I don't understand PHP, so I can't help you, but what are you trying to make the computer calculate in this function?
You might want to read up on the basics of functions. Or the basics of programming.
I know, but haven't you been helping until now with your good will?
So I really want to learn and not the "ready" answer
I've helped as much as I can. You seem to be missing some fundamental basics. You need to learn those first and I can't teach you all the basics.
I can already do some basic crud alone, but here in this exercise statement I'm stuck and alone I can't go anywhere in this code
You're unable to do this exercise because you're missing basic concepts.
Do you want to solve the exercises or do you want to learn programming?
for me this is a a part of the learning process
this is the reason for entry the exercism site for a practice code
learn programming
Then start with the basics.
Bro what the basic concepts need i study?
now i'm stay in the php doc site
Exercism doesn't teach the basics
then what''s the need I study?
An intro programming course
You seem to be having trouble with the concept of functions and parameters and parameterized return values.