ZABAVY 2006 SELDECR EN

Заметка из ABAPEDIA.

Перейти к: навигация, поиск

zelboccd delracd aceldr cnadarpas nolidelou getlitroc raccnaborelr

Содержание

ZABAVY_2006_SELDECR

Given character sequence in enciphered table dataset search program.

Character string from 20 up to 40 ASCII-chars length (excluding lowercase letters, see C_SENT_CHARS) is inserted on selection screen. Transparent table ZABAPEDIA_SELDEC with key field ID contains about 2 millions of lines.

The program should determine all entries coordinates of Caesar-ciphered string in the table field SEQUENCE and place results into internal table GT_RESULTS. Table key GT_RESULTS-ID and first string char offset within GT_RESULTS-POS are chosen to be coordinates. Ciphered string could be disposed both in single line of the table and in two adjacent lines (starting at the end of one line and ending at the beginning of the next according to the key ID); furthermore first and last 5 chars of the looked for string are unbroken. The fact that ciphered string contains only uppercase letters simplifies the problem, but some fraud strings in test data set are intended to embarrass the task.

Caesar cipher is cyclic code which shifts in alphabet every latin letter by fixed amount (Ceasar code), i.e. with code equals 3 letter A becomes D and Z becomes C.

Coded strings found in test dataset should be filtered according to a special rule. This rule will be published at March 10.

Solutions value will be stated according to next criteria:

  • number of 1st type errors (wrong strings found) and number of 2nd type errors (right positions

lost);

  • running time;
  • algorithm elegancy and style of coding (in case of code comments and algorithm description, i.e.

flow block or wordy written).

Possibility of simplified test datasets uploading is under consideration. It is intended to simplify elaboration and testing of your programs.

Starting at March 10 you can send preliminary versions of your programs which will be tested and some hint for your will be given, in particular:

  • is there any activation and compilation errors;
  • number of 1sd and second type errors.

Dataset table ZABAPEDIA_SELDEC

Definition and technical settings are shown at screens shots. No auxiliary indexes are created.

[[Изображение:ZABAPEDIA_SELDEC_1.png|thumb|Table definition]]

[[Изображение:ZABAPEDIA_SELDEC_2.png|thumb|Technical settings]]

Program and results representation agreement

Template program ZABAVY_2006_SELDECR_000 should be copied and suffix '000' should be replaced with your own number, which could be requested. Otherwise it will be given when the first variant will be received.

Changes in includes ZABAVY_2006_SELDECR_data, ZABAVY_2006_SELDECR_sscr, ZABAVY_2006_SELDECR_form are forbidden. All private code should be placed in ZABAVY_2006_SELDECR_000 after the given mark.

ZABAVY_2006_SELDECR_000

  1.  
  2. report ZABAVY_2006_SELDECR_000 .
  3.  
  4. * -- standard part (don't change)
  5. include: ZABAVY_2006_SELDECR_data
  6. , ZABAVY_2006_SELDECR_sscr
  7. , ZABAVY_2006_SELDECR_form
  8. .
  9.  
  10. start-of-selection .
  11. perform check_sentence .
  12. perform initialization .
  13. perform build .
  14.  
  15. end-of-selection .
  16. perform end .
  17.  
  18. * -- write your code below
  19.  
  20. form build .
  21.  
  22. endform .

ZABAVY_2006_SELDECR_data

  1. tables: ZABAPEDIA_SELDEC .
  2.  
  3. constants: C_MIN type i value 32
  4. , C_MAX type i value 126 " minimal and maximal chars of dataset correspondingly
  5. , C_CHARSET_LENGTH type int2 value 95 " length of dataset
  6. , C_SENT_MIN type i value 65 " minimal letter in search string
  7. , C_SENT_MAX type i value 90 " maximal letter in search string
  8. , C_SENT_CHARS(27) value ' ABCDEFGHIJKLMNOPQRSTUVWXYZ' " chars available in search string
  9. .
  10.  
  11. data: gt_results type sorted table of ZABAPEDIA_SELDEC with unique key table_line with header line
  12. , g_starttime type f " time stamp at start
  13. , g_endtime type f " time stamp at finish
  14. , g_charset(C_CHARSET_LENGTH)
  15. .
  16.  
  17. *

ZABAVY_2006_SELDECR_sscr

  1. parameters: sentence(40) obligatory .

ZABAVY_2006_SELDECR_form

  1.  
  2. form check_sentence .
  3. data: sentence_length type i .
  4. sentence_length = strlen( sentence ) .
  5. if not ( sentence_length >= 20 and sentence co C_SENT_CHARS ) .
  6. message e005(zabapedia) .
  7. endif .
  8. endform .
  9.  
  10. form initialization .
  11. * start, time stamp
  12. clear: gt_results[], g_charset .
  13. data: i type i, x type x, xs type xstring, rs type string .
  14. do C_CHARSET_LENGTH times .
  15. i = sy-index - 1 .
  16. x = sy-index + C_MIN - 1 .
  17. xs = x .
  18. CALL FUNCTION 'NLS_STRING_CONVERT_TO_SYS'
  19. EXPORTING
  20. LANG_USED = sy-langu
  21. SOURCE = xs
  22. IMPORTING
  23. RESULT = rs
  24. .
  25. g_charset+i(1) = rs .
  26. enddo .
  27.  
  28. write: / g_charset .
  29. get run time field g_starttime .
  30. endform .
  31.  
  32. form end .
  33. * end, time stamp
  34. get run time field g_endtime .
  35. data: g_repid type sy-repid .
  36. g_repid = sy-repid .
  37.  
  38. data: dt type i .
  39. dt = g_endtime - g_starttime .
  40. write: / 'Search done, work duration =', dt .
  41. * perform external_procedure tables gt_rezults[] using g_repid dt .
  42. endform .

Standard output and answers

Value of g_charset

After start of the stated above template program g_charset gets value [ !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~] (color emphasized, first char - space), see screen shot.

[[Изображение:ZABAVY_2006_SELDECR_000_zapusk.png]]

[[Zабавы-2006/ABAP|Current state and list of the works]]

--[[Участник:Sibrin|Sibrin]] 09:45, 06 March 2006 (MSK) English translation

[[Категория:Zабавы-2006]]

Личные инструменты
Популярные категории
Прочее