You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm facing error that I don't understand (in Eclipse - all tests OK).
My approach to this exercise is to process the same input with 3 different algoritms. Problem is caused by 3rd one (I've marked it with some comments) - one step is executed wrongly on Exercism (in Eclipse it is working correctly). I noticed that after checking this loop with console.log help.
CLASSzcl_book_store DEFINITION PUBLIC FINAL CREATE PUBLIC .
PUBLIC SECTION.
"! ID of book to buy from 1 to 5TYPES book_id TYPE i.
TYPES basket_type TYPE SORTED TABLE OF book_id
WITH NON-UNIQUE KEYtable_line.
TYPES total TYPE pLENGTH3DECIMALS2.
METHODS calculate_total
IMPORTING basket TYPE basket_type
RETURNINGVALUE(total) TYPE total.
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.
CLASSzcl_book_store IMPLEMENTATION.
METHODcalculate_total.
" add solution heredata summ type pLENGTH3DECIMALS2.
types summ type pLENGTH3DECIMALS2.
data summ_table type table of summ.
data temp_table type table of string.
data temp type string.
data ind type i.
data max_rows type table of i.
append11 to max_rows.
append8 to max_rows.
data: quantity_1 type i,
quantity_5 type i.
loop at basket ASSIGNINGFIELD-SYMBOL(<c>).
case<c>.
when1.
quantity_1 = quantity_1 +1.
when5.
quantity_5 = quantity_5 +1.
ENDCASE.
endloop.
data basket_p type table of book_id.
basket_p = basket.
if quantity_5 > quantity_1.
sort basket_p DESCENDING.
endif.
loop at max_rows ASSIGNINGFIELD-SYMBOL(<max_stack>).
loop at basket_p ASSIGNINGFIELD-SYMBOL(<a>).
temp =<a>.
iflines( temp_table ) =0.
append temp to temp_table.
CONTINUE.
else.
loop at temp_table ASSIGNINGFIELD-SYMBOL(<existing_row>).
ind =sy-tabix.
ifstrlen( <existing_row> ) <<max_stack>.
if<existing_row>CS temp.
if ind =lines( temp_table ).
append temp to temp_table.
exit.
else.
CONTINUE.
endif.
else.
temp_table[ ind ] = temp_table[ ind ] && temp.
exit.
endif.
else.
if ind =lines( temp_table ).
append temp to temp_table.
exit.
else.
CONTINUE.
endif.
endif.
ENDLOOP.
endif.
ENDLOOP.
loop at temp_table ASSIGNINGFIELD-SYMBOL(<b>).
casestrlen( <b> ).
when10.
summ = summ +'30'.
when8.
summ = summ +'25.6'.
when6.
summ = summ +'21.6'.
when4.
summ = summ +'15.2'.
when2.
summ = summ +'8'.
ENDCASE.
endloop.
append summ to summ_table.
clear summ.
clear temp_table.
endloop.
" this loop is not working as it should loop at basket_p ASSIGNING<a>.
temp =<a>.
iflines( temp_table ) =0.
append temp to temp_table.
CONTINUE.
else.
loop at temp_table ASSIGNING<existing_row>.
ind =sy-tabix.
if temp NE basket_p[ 1 ]. " this step is executing block below it when temp = 1 and test = 1, when it should skip to else statement if ind NElines( temp_table ).
ifstrlen( <existing_row> ) >=strlen( temp_table[ ind +1 ] ).
CONTINUE.
else.
if<existing_row>CS temp.
CONTINUE.
else.
temp_table[ ind ] = temp_table[ ind ] && temp.
exit.
endif.
endif.
else.
temp_table[ ind ] = temp_table[ ind ] && temp.
exit.
endif.
else.
append temp to temp_table. " this step should create a 2nd row with 1exit.
endif.
ENDLOOP.
endif.
ENDLOOP.
loop at temp_table ASSIGNING<b>.
casestrlen( <b> ).
when10.
summ = summ +'30'.
when8.
summ = summ +'25.6'.
when6.
summ = summ +'21.6'.
when4.
summ = summ +'15.2'.
when2.
summ = summ +'8'.
ENDCASE.
endloop.
append summ to summ_table.
sort summ_table ascending.
total = summ_table[ 2 ]. " this index should be 1 instead of 2 - value 2 is set up to pass rest of tests - to leave only test 9 failingENDMETHOD.
ENDCLASS.
The text was updated successfully, but these errors were encountered:
Hello,
I'm facing error that I don't understand (in Eclipse - all tests OK).
My approach to this exercise is to process the same input with 3 different algoritms. Problem is caused by 3rd one (I've marked it with some comments) - one step is executed wrongly on Exercism (in Eclipse it is working correctly). I noticed that after checking this loop with console.log help.
The text was updated successfully, but these errors were encountered: