Lua String Prefix

SQL-Fighter

Hi,

I was wondering if I could get some help with string manipulation. If i'm provided with the following example

Create a function add_prefix(arr, prefix) that takes an array of strings arr and a string prefix as an input. It should output a comma-separated list of all elements in the array with the prefix before each element.

  • Example call: print(add_prefix( {'firstname', 'lastname', 'city'}, 'person.'))
  • Should show: person.firstname, person.lastname, person.city

 

I provided initially the solution

Code removed by moderator

 

which I can understand that would fail for the if we provide an "empty" array. So a second solution I thought of was like so.

Code removed by moderator

 

I have used all 3 attempts on the exercise here and it has not displayed the solution for me to compare, so hence I have posted here to get thoughts please.

 

 

1 ACCEPTED SOLUTION

Moderator
Moderator

Hi,

thank you for your contribution! Please have a look at the Training FAQ: https://community.exasol.com/t5/training-forum/training-faq/td-p/548

I may quote myself here:

Q: My code doesn't get validated as correct although it solves the given task - why is that?

A: Some of the hands-on labs ask you to write code that is then parsed by our platform for validation. This parsing is not perfect. It may not validate your code even though it solves the task. Please apply some common sense and check if you have really fulfilled the task as required and run some basic test cases as well. If your code turns out to be absolutely fine: Bear with us! You found a solution that we didn't expect that way, apparently. That's of course fine. We still think these kind of labs are better than having only multiple choice quizzes, even if we may sometimes fail to validate your correct code.

Going forward, please avoid posting solutions to the labs here as that makes the labs somewhat pointless. Your solution looks good to me, btw 😀

View solution in original post

3 REPLIES 3

Padawan

Hi all,
I have had the same issue with the validation. It seems to be possible with code validation instead of output validation. I had something like that with an ADVA's excercise.
Uwe, thanks for the comments.

Alexey

Moderator
Moderator

Hi,

thank you for your contribution! Please have a look at the Training FAQ: https://community.exasol.com/t5/training-forum/training-faq/td-p/548

I may quote myself here:

Q: My code doesn't get validated as correct although it solves the given task - why is that?

A: Some of the hands-on labs ask you to write code that is then parsed by our platform for validation. This parsing is not perfect. It may not validate your code even though it solves the task. Please apply some common sense and check if you have really fulfilled the task as required and run some basic test cases as well. If your code turns out to be absolutely fine: Bear with us! You found a solution that we didn't expect that way, apparently. That's of course fine. We still think these kind of labs are better than having only multiple choice quizzes, even if we may sometimes fail to validate your correct code.

Going forward, please avoid posting solutions to the labs here as that makes the labs somewhat pointless. Your solution looks good to me, btw 😀

View solution in original post

SQL-Fighter

Hi exa-Uwe,

Thanks for pointing me to the Q&A. That's fine, it was a graded question hence why I was super keen to get it answered correctly, but doesn't matter, you win some and loose some. It's the journey that is important.

I was thinking that it may be executing the code and checking the answer as opposed to the actual syntax alone.

I see your point about the potential answers rendering the labs pointless, I will refrain from doing so in the future.