Skip to Content
Technical Articles
Author's profile photo Michael Keller

little algorithm riddle

Dear community, a little bit of fun today. I recently saw an algorithm that really surprised me by his effectivity. Mankind has known this algorithm for some time. I tried an implementation in ABAP out of interest. I hope the implementation works 😉 What is the name?

I put the answer in mirror writing under the source code. Hold a mirror to your screen. Instead of a mirror a smartphone screen is sufficient to “decode”, too 🙂

If someone also has a little algorithm riddle, feel free to write a blog. If the implementation doesn’t work properly, no problem. I guess there are some members here who can fix this 😉

[..]
CLASS-METHODS do_something
   IMPORTING
     x             TYPE i
     y             TYPE i
   RETURNING
     VALUE(result) TYPE i.
[..]
METHOD do_something.
  IF x = 1.
    result = y.
  ELSE.
    IF x MOD 2 > 0.
      result = y + do_something( x = x DIV 2
                                 y = y + y ).
    ELSE.
      result = do_something( x = x DIV 2
                             y = y + y ).
    ENDIF.
  ENDIF.
ENDMETHOD.
[..]

Here ist the answer:

ƨɒ nwonÊž oƨlÉ’ ,”noiɈɒɔilqiɈlÏ…m Ɉnɒƨɒɘq nÉ’iƨƨυЯ” ɘʜɈ ʇo noiɈɒɈnɘmɘlqmi nÉ’ ƨi ɈI
.”noiɈɒɔilqiɈlÏ…m nÉ’iqoiʜɈƎ” É¿o “noiɈɒɔilqiɈlÏ…m nÉ’iɈqγϱƎ ɈnɘiÉ”nA”

 

Best regards and thanks for reading

Michael

 

 

 

 

Assigned Tags

      2 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Matthew Billingham
      Matthew Billingham

      A link to an implementation in quite a few languages. I've put it through tiny.cc so as not to give the game away http://tiny.cc/qyfsiz

      Author's profile photo Michael Keller
      Michael Keller
      Blog Post Author

      I like your sense of humor: "quite a few languages" ... there are 112 implementations 🙂