Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
a192a79
[Sync Iteration] abap/hello-world/1
exercism-solutions-syncer[bot] Apr 23, 2026
d23575d
[Sync Iteration] abap/two-fer/1
exercism-solutions-syncer[bot] Apr 23, 2026
3a042f6
[Sync Iteration] abap/reverse-string/1
exercism-solutions-syncer[bot] Apr 23, 2026
49234f7
[Sync Iteration] abap/leap/1
exercism-solutions-syncer[bot] Apr 23, 2026
7f75c2f
[Sync Iteration] abap/resistor-color/1
exercism-solutions-syncer[bot] Apr 23, 2026
4a1a169
[Sync Iteration] abap/clock/1
exercism-solutions-syncer[bot] Apr 23, 2026
6788ce4
[Sync Iteration] abap/hamming/1
exercism-solutions-syncer[bot] Apr 23, 2026
1e94014
[Sync Iteration] abap/atbash-cipher/1
exercism-solutions-syncer[bot] Apr 23, 2026
e5b667a
[Sync Iteration] abap/isogram/1
exercism-solutions-syncer[bot] Apr 23, 2026
266ec47
[Sync Iteration] abap/raindrops/1
exercism-solutions-syncer[bot] Apr 23, 2026
8b77de0
[Sync Iteration] abap/anagram/1
exercism-solutions-syncer[bot] Apr 23, 2026
3d6dda4
[Sync Iteration] abap/run-length-encoding/1
exercism-solutions-syncer[bot] Apr 23, 2026
e829ef6
[Sync Iteration] abap/matrix/1
exercism-solutions-syncer[bot] Apr 23, 2026
9a37717
[Sync Iteration] abap/darts/1
exercism-solutions-syncer[bot] Apr 23, 2026
ff992fa
[Sync Iteration] abap/prime-factors/1
exercism-solutions-syncer[bot] Apr 23, 2026
ca54cc3
[Sync Iteration] abap/high-scores/1
exercism-solutions-syncer[bot] Apr 23, 2026
86ddfa8
[Sync Iteration] abap/kindergarten-garden/1
exercism-solutions-syncer[bot] Apr 23, 2026
f4d9576
[Sync Iteration] abap/scrabble-score/1
exercism-solutions-syncer[bot] Apr 23, 2026
3f3c713
[Sync Iteration] abap/minesweeper/1
exercism-solutions-syncer[bot] Apr 23, 2026
a6cbd2d
[Sync Iteration] abap/beer-song/1
exercism-solutions-syncer[bot] Apr 23, 2026
cae27f9
[Sync Iteration] abap/nth-prime/1
exercism-solutions-syncer[bot] Apr 23, 2026
a7bc1a0
[Sync Iteration] abap/elyses-enchantments/1
exercism-solutions-syncer[bot] Apr 23, 2026
59d300b
[Sync Iteration] abap/phone-number/1
exercism-solutions-syncer[bot] Apr 23, 2026
169e00e
[Sync Iteration] abap/custom-signs/1
exercism-solutions-syncer[bot] Apr 23, 2026
d186eb2
[Sync Iteration] abap/word-count/1
exercism-solutions-syncer[bot] Apr 23, 2026
867d1ea
[Sync Iteration] abap/grains/1
exercism-solutions-syncer[bot] Apr 23, 2026
bbac252
[Sync Iteration] abap/itab-basics/1
exercism-solutions-syncer[bot] Apr 23, 2026
92be572
[Sync Iteration] abap/itab-aggregation/1
exercism-solutions-syncer[bot] Apr 23, 2026
d014d28
[Sync Iteration] abap/itab-combination/1
exercism-solutions-syncer[bot] Apr 23, 2026
1a47c04
[Sync Iteration] abap/itab-nesting/1
exercism-solutions-syncer[bot] Apr 23, 2026
f122b31
[Sync Iteration] abap/secret-handshake/1
exercism-solutions-syncer[bot] Apr 23, 2026
10fcba9
[Sync Iteration] abap/book-store/1
exercism-solutions-syncer[bot] Apr 23, 2026
cb12420
[Sync Iteration] abap/acronym/1
exercism-solutions-syncer[bot] Apr 23, 2026
7986116
[Sync Iteration] abap/armstrong-numbers/1
exercism-solutions-syncer[bot] Apr 23, 2026
0400b28
[Sync Iteration] abap/collatz-conjecture/1
exercism-solutions-syncer[bot] Apr 23, 2026
2779dc0
[Sync Iteration] abap/crypto-square/1
exercism-solutions-syncer[bot] Apr 23, 2026
e613483
[Sync Iteration] abap/state-of-tic-tac-toe/1
exercism-solutions-syncer[bot] Apr 23, 2026
3eedf71
[Sync Iteration] abap/etl/1
exercism-solutions-syncer[bot] Apr 23, 2026
560eb00
[Sync Iteration] abap/affine-cipher/1
exercism-solutions-syncer[bot] Apr 23, 2026
2d6849c
[Sync Iteration] abap/difference-of-squares/1
exercism-solutions-syncer[bot] Apr 23, 2026
d99e5bd
[Sync Iteration] abap/triangle/1
exercism-solutions-syncer[bot] Apr 23, 2026
c59e56a
[Sync Iteration] abap/rna-transcription/1
exercism-solutions-syncer[bot] Apr 23, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions solutions/abap/acronym/1/zcl_acronym.clas.abap
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
CLASS zcl_acronym DEFINITION
PUBLIC
FINAL
CREATE PUBLIC .

PUBLIC SECTION.
METHODS parse IMPORTING phrase TYPE string
RETURNING VALUE(acronym) TYPE string.
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.
CLASS zcl_acronym IMPLEMENTATION.
METHOD parse.
TRANSLATE phrase USING '- _ '.
SPLIT condense( phrase ) AT ' ' INTO TABLE DATA(words).
LOOP AT words ASSIGNING FIELD-SYMBOL(<word>).
acronym &&= to_upper( <word>(1) ).
ENDLOOP.
ENDMETHOD.
ENDCLASS.
106 changes: 106 additions & 0 deletions solutions/abap/affine-cipher/1/zcl_affine_cipher.clas.abap
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
CLASS zcl_affine_cipher DEFINITION
PUBLIC
FINAL
CREATE PUBLIC.

PUBLIC SECTION.
TYPES: BEGIN OF key,
a TYPE i,
b TYPE i,
END OF key.

METHODS:
encode IMPORTING phrase TYPE string
key TYPE key
RETURNING VALUE(cipher) TYPE string
RAISING cx_parameter_invalid,
decode IMPORTING cipher TYPE string
key TYPE key
RETURNING VALUE(phrase) TYPE string
RAISING cx_parameter_invalid.
PROTECTED SECTION.
METHODS: check_coprime IMPORTING key TYPE key
RETURNING VALUE(coprime) TYPE c.

PRIVATE SECTION.
ENDCLASS.



CLASS zcl_affine_cipher IMPLEMENTATION.
METHOD encode.

IF check_coprime( key ) IS INITIAL.
RAISE EXCEPTION TYPE cx_parameter_invalid.
ENDIF.

DATA nb_letters TYPE i.
DATA(alphabet) = to_lower( sy-abcde ).
phrase = replace( val = phrase regex = '[^a-zA-Z0-9 ]' with = '' occ = 0 ).

CONDENSE phrase NO-GAPS.
DO strlen( phrase ) TIMES.
IF nb_letters = 5.
cipher = |{ cipher } |.
nb_letters = 0.
ENDIF.

DATA(offset) = sy-index - 1.
FIND FIRST OCCURRENCE OF to_lower( phrase+offset(1) ) IN alphabet MATCH OFFSET DATA(pos).
IF sy-subrc NE 0.
cipher = |{ cipher }{ phrase+offset(1) }|.
ELSE.
pos = ( key-a * pos + key-b ) MOD 26.
cipher = |{ cipher }{ alphabet+pos(1) }|.
ENDIF.
nb_letters += 1.
ENDDO.
ENDMETHOD.

METHOD decode.
DATA : i TYPE i.
IF check_coprime( key ) IS INITIAL.
RAISE EXCEPTION TYPE cx_parameter_invalid.
ENDIF.

DATA(alphabet) = to_lower( sy-abcde ).
cipher = replace( val = cipher regex = '[^a-zA-Z0-9 ]' with = '' occ = 0 ).

WHILE i < 26.
IF ( key-a * i ) MOD 26 = 1.
DATA(mmi) = i.
EXIT.
ENDIF.
i += 1.
ENDWHILE.

CONDENSE cipher NO-GAPS.
DO strlen( cipher ) TIMES.
DATA(offset) = sy-index - 1.
FIND FIRST OCCURRENCE OF to_lower( cipher+offset(1) ) IN alphabet MATCH OFFSET DATA(pos).
IF sy-subrc NE 0.
phrase = |{ phrase }{ cipher+offset(1) }|.
ELSE.
pos = mmi * ( pos - key-b ) MOD 26.
phrase = |{ phrase }{ alphabet+pos(1) }|.
ENDIF.
ENDDO.

ENDMETHOD.

METHOD check_coprime.

coprime = abap_true.

DATA(i) = 2.
WHILE i <= key-a.
IF key-a MOD i = 0 AND 26 MOD i = 0.
coprime = abap_false.
RETURN.
ELSE.
i += 1.
ENDIF.
ENDWHILE.
ENDMETHOD.

ENDCLASS.
49 changes: 49 additions & 0 deletions solutions/abap/anagram/1/zcl_anagram.clas.abap
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
* Dedicated to Shree DR.MDD
CLASS zcl_anagram DEFINITION
PUBLIC
FINAL
CREATE PUBLIC .

PUBLIC SECTION.
METHODS anagram
IMPORTING
input TYPE string
candidates TYPE string_table
RETURNING
VALUE(result) TYPE string_table.
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.

CLASS zcl_anagram IMPLEMENTATION.
METHOD anagram.
DATA candidate_list TYPE string_table.
DATA source TYPE string.
DATA current_char TYPE c LENGTH 1.

candidate_list = candidates[].
source = input.

DO strlen( source ) TIMES.
LOOP AT candidate_list ASSIGNING FIELD-SYMBOL(<entry>).
current_char = source(1).

REPLACE FIRST OCCURRENCE OF to_lower( current_char ) IN <entry> WITH ` `.
IF sy-subrc <> 0.
REPLACE FIRST OCCURRENCE OF to_upper( current_char ) IN <entry> WITH ` `.
IF sy-subrc <> 0.
<entry> = '-'.
ENDIF.
ENDIF.
ENDLOOP.
SHIFT source LEFT.
ENDDO.

LOOP AT candidate_list TRANSPORTING NO FIELDS WHERE table_line CO ` `.
READ TABLE candidates ASSIGNING FIELD-SYMBOL(<cand_entry>) INDEX sy-tabix.
IF sy-subrc = 0 AND to_upper( <cand_entry> ) <> to_upper( input ).
APPEND <cand_entry> TO result.
ENDIF.
ENDLOOP.
ENDMETHOD.
ENDCLASS.
22 changes: 22 additions & 0 deletions solutions/abap/armstrong-numbers/1/zcl_armstrong_numbers.clas.abap
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
CLASS zcl_armstrong_numbers DEFINITION
PUBLIC
FINAL
CREATE PUBLIC .
PUBLIC SECTION.
METHODS is_armstrong_number IMPORTING num TYPE i
RETURNING VALUE(result) TYPE abap_bool.
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.
CLASS zcl_armstrong_numbers IMPLEMENTATION.
METHOD is_armstrong_number.
DATA test TYPE i.
DATA offset TYPE i.
DATA(s) = |{ num }|.
DO strlen( s ) TIMES.
test += s+offset(1) ** strlen( s ).
offset += 1.
ENDDO.
result = boolc( test = num ).
ENDMETHOD.
ENDCLASS.
57 changes: 57 additions & 0 deletions solutions/abap/atbash-cipher/1/zcl_atbash_cipher.clas.abap
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
* Dedicated to Shree DR.MDD
CLASS zcl_atbash_cipher DEFINITION
PUBLIC
FINAL
CREATE PUBLIC.

PUBLIC SECTION.

METHODS decode
IMPORTING
!cipher_text TYPE string
RETURNING
VALUE(plain_text) TYPE string.
METHODS encode
IMPORTING
!plain_text TYPE string
RETURNING
VALUE(cipher_text) TYPE string.
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.

CLASS zcl_atbash_cipher IMPLEMENTATION.

METHOD decode.
plain_text = replace(
val = encode( cipher_text )
sub = ` `
with = ``
occ = 0 ).
ENDMETHOD.

METHOD encode.
CONSTANTS abc_set TYPE string VALUE 'abcdefghijklmnopqrstuvwxyz'.
DATA(clean_text) = replace( val = to_lower( plain_text )
regex = `[ .,]`
with = ``
occ = 0 ).
DATA(pos_idx) = 0.
WHILE pos_idx < strlen( clean_text ).
DATA(char_pos) = 25 - find( val = abc_set
sub = clean_text+pos_idx(1) ).
IF char_pos BETWEEN 0 AND 25.
cipher_text = cipher_text && substring( val = abc_set
off = char_pos
len = 1 ).
ELSE.
cipher_text = cipher_text && clean_text+pos_idx(1).
ENDIF.
pos_idx = pos_idx + 1.
IF pos_idx MOD 5 = 0 AND pos_idx < strlen( clean_text ).
cipher_text = cipher_text && ` `.
ENDIF.
ENDWHILE.
ENDMETHOD.

ENDCLASS.
61 changes: 61 additions & 0 deletions solutions/abap/beer-song/1/zcl_beer_song.clas.abap
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
* Dedicated to Shree DR.MDD
CLASS zcl_beer_song DEFINITION
PUBLIC
FINAL
CREATE PUBLIC.

PUBLIC SECTION.

METHODS recite
IMPORTING
!initial_bottles_count TYPE i
!take_down_count TYPE i
RETURNING
VALUE(result) TYPE string_table.

PROTECTED SECTION.
PRIVATE SECTION.

METHODS bottles
IMPORTING
!count TYPE i
!prefix TYPE c DEFAULT 'n'
!wall TYPE c DEFAULT 'y'
RETURNING
VALUE(result) TYPE string.
ENDCLASS.

CLASS zcl_beer_song IMPLEMENTATION.

METHOD bottles.
DATA(bottle_word) = |bottle{ COND #( WHEN count <> 1 THEN `s` ) } of beer|.
DATA(number_part) = COND #( WHEN count = 0 THEN |{ prefix }o more| ELSE |{ count }| ).
DATA(wall_part) = COND #( WHEN wall = 'y' THEN ' on the wall' ELSE '' ).
result = |{ number_part } { bottle_word }{ wall_part }|.
ENDMETHOD.

METHOD recite.

DATA(first_line) = |{ bottles( count = initial_bottles_count prefix = 'N' ) },| &&
| { bottles( count = initial_bottles_count wall = 'N' ) }.|.
INSERT first_line INTO TABLE result.

IF initial_bottles_count = 0.
DATA(store_line) = |Go to the store and buy some more, { bottles( 99 ) }.|.
INSERT store_line INTO TABLE result.
ELSE.
DATA(take_line) = |Take { COND #( WHEN initial_bottles_count = 1 THEN `it` ELSE `one` ) } down and pass it around,| &&
| { bottles( initial_bottles_count - 1 ) }.|.
INSERT take_line INTO TABLE result.
ENDIF.

IF take_down_count > 1.
INSERT || INTO TABLE result.
DATA(next_lines) = recite(
initial_bottles_count = initial_bottles_count - 1
take_down_count = take_down_count - 1 ).
INSERT LINES OF next_lines INTO TABLE result.
ENDIF.

ENDMETHOD.
ENDCLASS.
73 changes: 73 additions & 0 deletions solutions/abap/book-store/1/zcl_book_store.clas.abap
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
" Dedicated to Shree DR.MDD

CLASS zcl_book_store DEFINITION PUBLIC FINAL CREATE PUBLIC.
PUBLIC SECTION.
TYPES book_id TYPE i.
TYPES basket_type TYPE SORTED TABLE OF book_id WITH NON-UNIQUE KEY table_line.
TYPES total TYPE p LENGTH 3 DECIMALS 2.
METHODS calculate_total
IMPORTING basket TYPE basket_type
RETURNING VALUE(total) TYPE total.
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.

CLASS zcl_book_store IMPLEMENTATION.
METHOD calculate_total.
TYPES: BEGIN OF line_agg,
id TYPE book_id,
qty TYPE i,
END OF line_agg.
TYPES: BEGIN OF disc_group,
unique_count TYPE i,
rate TYPE total,
END OF disc_group.

DATA: basket_ref TYPE REF TO line_agg,
aggregated_basket TYPE TABLE OF line_agg WITH NON-UNIQUE SORTED KEY qty COMPONENTS qty,
line_ref TYPE REF TO book_id,
active_basket TYPE TABLE OF line_agg,
grp_ref TYPE REF TO disc_group,
discount_table TYPE TABLE OF disc_group,
current_total TYPE total.

discount_table = VALUE #( ( unique_count = 5 rate = '0.25' )
( unique_count = 4 rate = '0.20' )
( unique_count = 3 rate = '0.10' )
( unique_count = 2 rate = '0.05' )
( unique_count = 1 rate = 0 ) ).
total = 999.
DATA(max_unique) = 5.
DO 5 TIMES.
current_total = 0.
aggregated_basket = VALUE #( ( id = 1 )
( id = 2 )
( id = 3 )
( id = 4 )
( id = 5 ) ).

LOOP AT basket REFERENCE INTO line_ref.
aggregated_basket[ id = line_ref->* ]-qty = aggregated_basket[ id = line_ref->* ]-qty + 1.
ENDLOOP.

LOOP AT discount_table REFERENCE INTO grp_ref WHERE unique_count <= max_unique.
DO.
CLEAR active_basket.
LOOP AT aggregated_basket REFERENCE INTO basket_ref WHERE qty > 0.
APPEND basket_ref->* TO active_basket.
ENDLOOP.
IF lines( active_basket ) < grp_ref->unique_count.
EXIT.
ENDIF.
SORT aggregated_basket BY qty DESCENDING.
DO grp_ref->unique_count TIMES.
aggregated_basket[ sy-index ]-qty = aggregated_basket[ sy-index ]-qty - 1.
ENDDO.
current_total = current_total + grp_ref->unique_count * 8 * ( 1 - grp_ref->rate ).
ENDDO.
ENDLOOP.
total = nmin( val1 = total val2 = current_total ).
max_unique = max_unique - 1.
ENDDO.
ENDMETHOD.
ENDCLASS.
Loading