Clock (transliterate) Cipher












12














Introduction:



I have loads of different ciphers stored in a document I once compiled as a kid, I picked a few of the ones I thought were best suitable for challenges (not too trivial, and not too hard) and transformed them into challenges. Most of them are still in the sandbox, and I'm not sure yet whether I'll post all of them, or only a few. Here is the third and easiest one (after the Computer Cipher and Trifid Cipher I posted earlier).





With a Clock Cipher we use the following image to encipher text:



enter image description here

So a sentence like this is a clock cipher would become:



t  h i s     i s     a     c l  o  c k     c i p  h e r    (without additional spaces of course, but added as clarification)
19:7:8:18:00:8:18:00:AM:00:2:11:14:2:10:00:2:8:15:7:4:17


Challenge:



Given a string sentence_to_encipher, encipher it as described above.



Challenge rules:




  • You can assume the sentence_to_encipher will only contain letters and spaces.

  • You can use either full lowercase or full uppercase (please state which one you've used in your answer).

  • You are not allowed to add leading zeros for the single-digit enciphered letters b through j, but two zeros 00 are mandatory for spaces.

  • You should use : as separator, and an additional leading or trailing : is not allowed.

  • You are allowed to use lowercase am and pm instead of uppercase AM and PM, as long as it's consistent.


General rules:




  • This is code-golf, so shortest answer in bytes wins.

    Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language.


  • Standard rules apply for your answer with default I/O rules, so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters and return-type, full programs. Your call.


  • Default Loopholes are forbidden.

  • If possible, please add a link with a test for your code (i.e. TIO).

  • Also, adding an explanation for your answer is highly recommended.


Test cases:



Input:  "this is a clock cipher"
Output: "19:7:8:18:00:8:18:00:AM:00:2:11:14:2:10:00:2:8:15:7:4:17"

Input: "test"
Output: "19:4:18:19"

Input: "what time is it"
Output: "22:7:AM:19:00:19:8:12:4:00:8:18:00:8:19"

Input: "acegikmoqsuwy bdfhjlnprtvxz"
Output: "AM:2:4:6:8:10:12:14:16:18:20:22:24:00:1:3:5:7:9:11:13:15:17:19:21:23:PM"

Input: "easy peazy"
Output: "4:AM:18:24:00:15:4:AM:PM:24"









share|improve this question
























  • Related
    – Kevin Cruijssen
    yesterday










  • Is it allowed to output [7, ":", 8, ":", "00", ":", 1, ":", 14, ":", 1] for hi bob, or must one join the result? By the way, neat cipher!
    – Mr. Xcoder
    yesterday










  • @Mr.Xcoder Sorry, for the sake of the cipher theme I'd say it should be joined to a single string (or the entire thing as a list of characters like ['7', ':', '8', ':', '0', '0', ':', '1', ':', '1', '4', ':', '1']).
    – Kevin Cruijssen
    yesterday


















12














Introduction:



I have loads of different ciphers stored in a document I once compiled as a kid, I picked a few of the ones I thought were best suitable for challenges (not too trivial, and not too hard) and transformed them into challenges. Most of them are still in the sandbox, and I'm not sure yet whether I'll post all of them, or only a few. Here is the third and easiest one (after the Computer Cipher and Trifid Cipher I posted earlier).





With a Clock Cipher we use the following image to encipher text:



enter image description here

So a sentence like this is a clock cipher would become:



t  h i s     i s     a     c l  o  c k     c i p  h e r    (without additional spaces of course, but added as clarification)
19:7:8:18:00:8:18:00:AM:00:2:11:14:2:10:00:2:8:15:7:4:17


Challenge:



Given a string sentence_to_encipher, encipher it as described above.



Challenge rules:




  • You can assume the sentence_to_encipher will only contain letters and spaces.

  • You can use either full lowercase or full uppercase (please state which one you've used in your answer).

  • You are not allowed to add leading zeros for the single-digit enciphered letters b through j, but two zeros 00 are mandatory for spaces.

  • You should use : as separator, and an additional leading or trailing : is not allowed.

  • You are allowed to use lowercase am and pm instead of uppercase AM and PM, as long as it's consistent.


General rules:




  • This is code-golf, so shortest answer in bytes wins.

    Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language.


  • Standard rules apply for your answer with default I/O rules, so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters and return-type, full programs. Your call.


  • Default Loopholes are forbidden.

  • If possible, please add a link with a test for your code (i.e. TIO).

  • Also, adding an explanation for your answer is highly recommended.


Test cases:



Input:  "this is a clock cipher"
Output: "19:7:8:18:00:8:18:00:AM:00:2:11:14:2:10:00:2:8:15:7:4:17"

Input: "test"
Output: "19:4:18:19"

Input: "what time is it"
Output: "22:7:AM:19:00:19:8:12:4:00:8:18:00:8:19"

Input: "acegikmoqsuwy bdfhjlnprtvxz"
Output: "AM:2:4:6:8:10:12:14:16:18:20:22:24:00:1:3:5:7:9:11:13:15:17:19:21:23:PM"

Input: "easy peazy"
Output: "4:AM:18:24:00:15:4:AM:PM:24"









share|improve this question
























  • Related
    – Kevin Cruijssen
    yesterday










  • Is it allowed to output [7, ":", 8, ":", "00", ":", 1, ":", 14, ":", 1] for hi bob, or must one join the result? By the way, neat cipher!
    – Mr. Xcoder
    yesterday










  • @Mr.Xcoder Sorry, for the sake of the cipher theme I'd say it should be joined to a single string (or the entire thing as a list of characters like ['7', ':', '8', ':', '0', '0', ':', '1', ':', '1', '4', ':', '1']).
    – Kevin Cruijssen
    yesterday
















12












12








12







Introduction:



I have loads of different ciphers stored in a document I once compiled as a kid, I picked a few of the ones I thought were best suitable for challenges (not too trivial, and not too hard) and transformed them into challenges. Most of them are still in the sandbox, and I'm not sure yet whether I'll post all of them, or only a few. Here is the third and easiest one (after the Computer Cipher and Trifid Cipher I posted earlier).





With a Clock Cipher we use the following image to encipher text:



enter image description here

So a sentence like this is a clock cipher would become:



t  h i s     i s     a     c l  o  c k     c i p  h e r    (without additional spaces of course, but added as clarification)
19:7:8:18:00:8:18:00:AM:00:2:11:14:2:10:00:2:8:15:7:4:17


Challenge:



Given a string sentence_to_encipher, encipher it as described above.



Challenge rules:




  • You can assume the sentence_to_encipher will only contain letters and spaces.

  • You can use either full lowercase or full uppercase (please state which one you've used in your answer).

  • You are not allowed to add leading zeros for the single-digit enciphered letters b through j, but two zeros 00 are mandatory for spaces.

  • You should use : as separator, and an additional leading or trailing : is not allowed.

  • You are allowed to use lowercase am and pm instead of uppercase AM and PM, as long as it's consistent.


General rules:




  • This is code-golf, so shortest answer in bytes wins.

    Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language.


  • Standard rules apply for your answer with default I/O rules, so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters and return-type, full programs. Your call.


  • Default Loopholes are forbidden.

  • If possible, please add a link with a test for your code (i.e. TIO).

  • Also, adding an explanation for your answer is highly recommended.


Test cases:



Input:  "this is a clock cipher"
Output: "19:7:8:18:00:8:18:00:AM:00:2:11:14:2:10:00:2:8:15:7:4:17"

Input: "test"
Output: "19:4:18:19"

Input: "what time is it"
Output: "22:7:AM:19:00:19:8:12:4:00:8:18:00:8:19"

Input: "acegikmoqsuwy bdfhjlnprtvxz"
Output: "AM:2:4:6:8:10:12:14:16:18:20:22:24:00:1:3:5:7:9:11:13:15:17:19:21:23:PM"

Input: "easy peazy"
Output: "4:AM:18:24:00:15:4:AM:PM:24"









share|improve this question















Introduction:



I have loads of different ciphers stored in a document I once compiled as a kid, I picked a few of the ones I thought were best suitable for challenges (not too trivial, and not too hard) and transformed them into challenges. Most of them are still in the sandbox, and I'm not sure yet whether I'll post all of them, or only a few. Here is the third and easiest one (after the Computer Cipher and Trifid Cipher I posted earlier).





With a Clock Cipher we use the following image to encipher text:



enter image description here

So a sentence like this is a clock cipher would become:



t  h i s     i s     a     c l  o  c k     c i p  h e r    (without additional spaces of course, but added as clarification)
19:7:8:18:00:8:18:00:AM:00:2:11:14:2:10:00:2:8:15:7:4:17


Challenge:



Given a string sentence_to_encipher, encipher it as described above.



Challenge rules:




  • You can assume the sentence_to_encipher will only contain letters and spaces.

  • You can use either full lowercase or full uppercase (please state which one you've used in your answer).

  • You are not allowed to add leading zeros for the single-digit enciphered letters b through j, but two zeros 00 are mandatory for spaces.

  • You should use : as separator, and an additional leading or trailing : is not allowed.

  • You are allowed to use lowercase am and pm instead of uppercase AM and PM, as long as it's consistent.


General rules:




  • This is code-golf, so shortest answer in bytes wins.

    Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language.


  • Standard rules apply for your answer with default I/O rules, so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters and return-type, full programs. Your call.


  • Default Loopholes are forbidden.

  • If possible, please add a link with a test for your code (i.e. TIO).

  • Also, adding an explanation for your answer is highly recommended.


Test cases:



Input:  "this is a clock cipher"
Output: "19:7:8:18:00:8:18:00:AM:00:2:11:14:2:10:00:2:8:15:7:4:17"

Input: "test"
Output: "19:4:18:19"

Input: "what time is it"
Output: "22:7:AM:19:00:19:8:12:4:00:8:18:00:8:19"

Input: "acegikmoqsuwy bdfhjlnprtvxz"
Output: "AM:2:4:6:8:10:12:14:16:18:20:22:24:00:1:3:5:7:9:11:13:15:17:19:21:23:PM"

Input: "easy peazy"
Output: "4:AM:18:24:00:15:4:AM:PM:24"






code-golf string cipher encoding






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited yesterday

























asked yesterday









Kevin Cruijssen

35.9k554188




35.9k554188












  • Related
    – Kevin Cruijssen
    yesterday










  • Is it allowed to output [7, ":", 8, ":", "00", ":", 1, ":", 14, ":", 1] for hi bob, or must one join the result? By the way, neat cipher!
    – Mr. Xcoder
    yesterday










  • @Mr.Xcoder Sorry, for the sake of the cipher theme I'd say it should be joined to a single string (or the entire thing as a list of characters like ['7', ':', '8', ':', '0', '0', ':', '1', ':', '1', '4', ':', '1']).
    – Kevin Cruijssen
    yesterday




















  • Related
    – Kevin Cruijssen
    yesterday










  • Is it allowed to output [7, ":", 8, ":", "00", ":", 1, ":", 14, ":", 1] for hi bob, or must one join the result? By the way, neat cipher!
    – Mr. Xcoder
    yesterday










  • @Mr.Xcoder Sorry, for the sake of the cipher theme I'd say it should be joined to a single string (or the entire thing as a list of characters like ['7', ':', '8', ':', '0', '0', ':', '1', ':', '1', '4', ':', '1']).
    – Kevin Cruijssen
    yesterday


















Related
– Kevin Cruijssen
yesterday




Related
– Kevin Cruijssen
yesterday












Is it allowed to output [7, ":", 8, ":", "00", ":", 1, ":", 14, ":", 1] for hi bob, or must one join the result? By the way, neat cipher!
– Mr. Xcoder
yesterday




Is it allowed to output [7, ":", 8, ":", "00", ":", 1, ":", 14, ":", 1] for hi bob, or must one join the result? By the way, neat cipher!
– Mr. Xcoder
yesterday












@Mr.Xcoder Sorry, for the sake of the cipher theme I'd say it should be joined to a single string (or the entire thing as a list of characters like ['7', ':', '8', ':', '0', '0', ':', '1', ':', '1', '4', ':', '1']).
– Kevin Cruijssen
yesterday






@Mr.Xcoder Sorry, for the sake of the cipher theme I'd say it should be joined to a single string (or the entire thing as a list of characters like ['7', ':', '8', ':', '0', '0', ':', '1', ':', '1', '4', ':', '1']).
– Kevin Cruijssen
yesterday












13 Answers
13






active

oldest

votes


















6















Python 2, 74 72 bytes





lambda s:':'.join(['AM','PM','00',`ord(c)-97`]['az '.find(c)]for c in s)


Try it online!



Takes input as all lowercase






share|improve this answer





























    5















    05AB1E, 22 21 bytes



    „AM24L„PM00)˜Að«s‡':ý


    Try it online!
    or as a Test Suite



    Some alternate 21 byte solutions:



    ':ýAð«24L„AMš„PMª00ª‡
    00„AM24L„PM)˜AIk>è':ý





    share|improve this answer























    • Nice answer, I managed to get 23 bytes through multiple approaches (one of which was my currently deleted answer). That's a neat way to arrange your stack to save a byte!
      – Mr. Xcoder
      yesterday






    • 1




      An alternate 22 byter combining our answers: Try it Online!
      – Mr. Xcoder
      yesterday










    • @Mr.Xcoder: My first idea actually looked like that, but 2 bytes worse because I didn't remember that ª had changed :)
      – Emigna
      yesterday










    • I've found a 20 byter using a portion of @Mr.Xcoder's approach, but I'll let you figure it out yourself before I reveil it. :)
      – Kevin Cruijssen
      yesterday








    • 1




      @KevinCruijssen: I'll let you know after I've looked some more ;)
      – Emigna
      yesterday



















    4















    Perl 6, 47 bytes





    *.ords>>.&{<<00 AM{1..24}PM>>[$_%32]}.join(":")


    Try it online!



    Anonymous Whatever lambda that takes a string of either case and returns the encrypted string.



    Explanation:



    *.ords>>.&{                         } # Map the ordinal values to
    << >>[$_%32] # The index in the list
    00 AM{1..24}PM # 00, AM, the numbers 1 to 24 and PM
    .join(":") # And join with colons





    share|improve this answer































      3














      Pyth, 25 bytes



      j:m@+++"AM"S24"PM""00"xG


      Try it online here, or verify all the test cases at once here.



      j:m@+++"AM"S24"PM""00"xGdQ   Implicit: Q=eval(input()), G=lowercase alphabet
      Trailing dQ inferred
      S24 [1-24]
      +"AM" Prepend "AM"
      + "PM" Append "PM"
      + "00" Append "00" - this is the dictionary
      m Q Map each element of Q, as d, using:
      xGd Get the index of d in G, -1 if not present (i.e. space)
      @ Get the element from the dictionary at the above index
      j: Join the result on ":", implicit print





      share|improve this answer





























        3















        JavaScript (Node.js), 72 bytes



        Takes input in lowercase.





        s=>[...s].map(c=>c<1?'00':(x=Buffer(c)[0]-1&31)>24?'PM':x||'AM').join`:`


        Try it online!






        share|improve this answer





























          3















          C# (Visual C# Interactive Compiler), 72 bytes





          s=>string.Join(":",s.Select(a=>a<33?"00":a<66?"AM":a>89?"PM":a%32-1+""))


          Takes input as a string of lowercase letters. First checks if the char is a space, and if it is, converts it to 00. Next, it checks for if the char is an A, and converts it to AM. It checks again for Z and converts it to PM if it is. Lastly, if the char passes all the checks, it gets converted to its alphabetic order-1.



          Try it online!



          // Input taking a string
          s =>
          // Join the following IEnumerable<char> with a ":" character
          string.Join(":",
          // Map all the characters in the string
          s.Select(a =>
          // Is the char less than 33, aka a space?
          a < 33 ?
          // If so, it's a "00"
          "00"
          // Else, is this an 'A'?
          : a < 66 ?
          // If so, convert it to "AM"
          "AM" :
          // If it's not 'A' or a space, could it be a 'Z'?
          a > 89 ?
          // If it is, turn the character into "PM"
          "PM" :
          // If it fails all of the checks above, get the characters position in the alphabet and subtract one from that.
          a % 32 - 1 + ""))





          share|improve this answer





















          • How about this? a%32-1 => a%65? Nice submission :)
            – dana
            17 hours ago



















          3















          Java (JDK), 95 bytes





          s->{int a=0;for(var c:s)System.out.print((a++<1?"":":")+(c<33?"00":c<66?"AM":c>89?"PM":c-65));}


          Try it online!



          Credits




          • -1 byte thanks to Kevin Cruijssen






          share|improve this answer























          • One easy golf: char to var. :)
            – Kevin Cruijssen
            yesterday










          • Thanks! So obvious now that you show it to me...
            – Olivier Grégoire
            yesterday



















          2















          Ruby, 49 bytes





          ->a{a.map{|c|["00",:AM,*1..24,:PM][c.ord%32]}*?:}


          Try it online!



          Port of Jo King's Perl answer.
          Takes input as an array of chars, returns a string with AM/PM in uppercase.






          share|improve this answer





























            2















            Red, 124 121 110 109 bytes



            func[s][replace/all form collect[forall s[keep switch/default
            c: -97 + s/1[0['AM]25['PM]-65["00"]][c]]]sp":"]


            Try it online!






            share|improve this answer































              1















              Tcl, 100 bytes



              proc C s {join [lmap c [split $s ""] {scan $c %c v
              expr $v==65?"AM":$v==90?"PM":$v==32?00:$v-65}] :}


              Try it online!






              share|improve this answer































                1















                05AB1E, 20 bytes



                ':ýð00:A24L„AMš„PMª‡


                Greatly inspired by @Mr.Xcoder's 22-byter in the comment of the existing 05AB1E answer by @Emigna.



                Takes the input as a list of lowercase characters (would be 21 bytes with a leading S if I take the input as a string).



                Try it online or verify all test cases.



                Explanation:





                ':ý            '# Join the (implicit) input list of characters by ":"
                # i.e. ["e","a","s","y"," ","p","e","a","z","y"] → "e:a:s:y: :p:e:a:z:y"
                ð00: # Replace all spaces " " with "00"
                # i.e. "e:a:s:y: :p:e:a:z:y" → "e:a:s:y:00:p:e:a:z:y"
                A # Push the lowercase alphabet
                24L # Push a list in the range [1,24]
                „AMš # Prepend "AM" at the start of this list
                „PMª # And append "PM" at the end of the list
                ‡ # Transliterate; mapping letters to the list-items at the same indices
                # (and output the result implicitly)
                # i.e. "e:a:s:y:00:p:e:a:z:y" → "4:AM:18:24:00:15:4:AM:PM:24"





                share|improve this answer

















                • 1




                  Ah yes. Replacing the space separately saves a byte. I should have tried that. Nice :)
                  – Emigna
                  23 hours ago



















                1















                C# (Visual C# Interactive Compiler), 98 bytes





                s=>string.Join(':',s.Select(c=>"az ".Contains(c)?new{"AM","PM","00"}["az ".IndexOf(c)]:c-97+""))


                Takes input as a (lowercase) char array. Try it online!






                share|improve this answer





















                • 82 bytes: s=>string.Join(':',s.Select(c=>new{c-97+"","AM","PM","00"}["az ".IndexOf(c)+1])).
                  – dana
                  1 hour ago



















                1















                Charcoal, 26 bytes



                UB:Fθ«→≡ι ×0²a¦AM¦z¦PMI⌕βι


                Try it online! Link is to verbose version of code. Takes input in lower case (can trivially be changed to upper case). Explanation:



                UB:


                Set the background character to :. This fills in the gaps between the output values created by the right movement.



                Fθ«→


                Loop over each character, leaving a gap each time. (The first move has no effect as the canvas is still empty at this point.)



                ≡ι ×0²a¦AM¦z¦PM


                Switch on the character and if it's space, a or z then output the appropriate code. I use ×0² instead of 00 here as the latter would cost two bytes in additional separators.



                I⌕βι


                Otherwise output the letter's 0-indexed position in the lower case alphabet as a string.






                share|improve this answer





















                  Your Answer





                  StackExchange.ifUsing("editor", function () {
                  return StackExchange.using("mathjaxEditing", function () {
                  StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
                  StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
                  });
                  });
                  }, "mathjax-editing");

                  StackExchange.ifUsing("editor", function () {
                  StackExchange.using("externalEditor", function () {
                  StackExchange.using("snippets", function () {
                  StackExchange.snippets.init();
                  });
                  });
                  }, "code-snippets");

                  StackExchange.ready(function() {
                  var channelOptions = {
                  tags: "".split(" "),
                  id: "200"
                  };
                  initTagRenderer("".split(" "), "".split(" "), channelOptions);

                  StackExchange.using("externalEditor", function() {
                  // Have to fire editor after snippets, if snippets enabled
                  if (StackExchange.settings.snippets.snippetsEnabled) {
                  StackExchange.using("snippets", function() {
                  createEditor();
                  });
                  }
                  else {
                  createEditor();
                  }
                  });

                  function createEditor() {
                  StackExchange.prepareEditor({
                  heartbeatType: 'answer',
                  autoActivateHeartbeat: false,
                  convertImagesToLinks: false,
                  noModals: true,
                  showLowRepImageUploadWarning: true,
                  reputationToPostImages: null,
                  bindNavPrevention: true,
                  postfix: "",
                  imageUploader: {
                  brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                  contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                  allowUrls: true
                  },
                  onDemand: true,
                  discardSelector: ".discard-answer"
                  ,immediatelyShowMarkdownHelp:true
                  });


                  }
                  });














                  draft saved

                  draft discarded


















                  StackExchange.ready(
                  function () {
                  StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f178356%2fclock-transliterate-cipher%23new-answer', 'question_page');
                  }
                  );

                  Post as a guest















                  Required, but never shown

























                  13 Answers
                  13






                  active

                  oldest

                  votes








                  13 Answers
                  13






                  active

                  oldest

                  votes









                  active

                  oldest

                  votes






                  active

                  oldest

                  votes









                  6















                  Python 2, 74 72 bytes





                  lambda s:':'.join(['AM','PM','00',`ord(c)-97`]['az '.find(c)]for c in s)


                  Try it online!



                  Takes input as all lowercase






                  share|improve this answer


























                    6















                    Python 2, 74 72 bytes





                    lambda s:':'.join(['AM','PM','00',`ord(c)-97`]['az '.find(c)]for c in s)


                    Try it online!



                    Takes input as all lowercase






                    share|improve this answer
























                      6












                      6








                      6







                      Python 2, 74 72 bytes





                      lambda s:':'.join(['AM','PM','00',`ord(c)-97`]['az '.find(c)]for c in s)


                      Try it online!



                      Takes input as all lowercase






                      share|improve this answer













                      Python 2, 74 72 bytes





                      lambda s:':'.join(['AM','PM','00',`ord(c)-97`]['az '.find(c)]for c in s)


                      Try it online!



                      Takes input as all lowercase







                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered yesterday









                      TFeld

                      14.3k21240




                      14.3k21240























                          5















                          05AB1E, 22 21 bytes



                          „AM24L„PM00)˜Að«s‡':ý


                          Try it online!
                          or as a Test Suite



                          Some alternate 21 byte solutions:



                          ':ýAð«24L„AMš„PMª00ª‡
                          00„AM24L„PM)˜AIk>è':ý





                          share|improve this answer























                          • Nice answer, I managed to get 23 bytes through multiple approaches (one of which was my currently deleted answer). That's a neat way to arrange your stack to save a byte!
                            – Mr. Xcoder
                            yesterday






                          • 1




                            An alternate 22 byter combining our answers: Try it Online!
                            – Mr. Xcoder
                            yesterday










                          • @Mr.Xcoder: My first idea actually looked like that, but 2 bytes worse because I didn't remember that ª had changed :)
                            – Emigna
                            yesterday










                          • I've found a 20 byter using a portion of @Mr.Xcoder's approach, but I'll let you figure it out yourself before I reveil it. :)
                            – Kevin Cruijssen
                            yesterday








                          • 1




                            @KevinCruijssen: I'll let you know after I've looked some more ;)
                            – Emigna
                            yesterday
















                          5















                          05AB1E, 22 21 bytes



                          „AM24L„PM00)˜Að«s‡':ý


                          Try it online!
                          or as a Test Suite



                          Some alternate 21 byte solutions:



                          ':ýAð«24L„AMš„PMª00ª‡
                          00„AM24L„PM)˜AIk>è':ý





                          share|improve this answer























                          • Nice answer, I managed to get 23 bytes through multiple approaches (one of which was my currently deleted answer). That's a neat way to arrange your stack to save a byte!
                            – Mr. Xcoder
                            yesterday






                          • 1




                            An alternate 22 byter combining our answers: Try it Online!
                            – Mr. Xcoder
                            yesterday










                          • @Mr.Xcoder: My first idea actually looked like that, but 2 bytes worse because I didn't remember that ª had changed :)
                            – Emigna
                            yesterday










                          • I've found a 20 byter using a portion of @Mr.Xcoder's approach, but I'll let you figure it out yourself before I reveil it. :)
                            – Kevin Cruijssen
                            yesterday








                          • 1




                            @KevinCruijssen: I'll let you know after I've looked some more ;)
                            – Emigna
                            yesterday














                          5












                          5








                          5







                          05AB1E, 22 21 bytes



                          „AM24L„PM00)˜Að«s‡':ý


                          Try it online!
                          or as a Test Suite



                          Some alternate 21 byte solutions:



                          ':ýAð«24L„AMš„PMª00ª‡
                          00„AM24L„PM)˜AIk>è':ý





                          share|improve this answer















                          05AB1E, 22 21 bytes



                          „AM24L„PM00)˜Að«s‡':ý


                          Try it online!
                          or as a Test Suite



                          Some alternate 21 byte solutions:



                          ':ýAð«24L„AMš„PMª00ª‡
                          00„AM24L„PM)˜AIk>è':ý






                          share|improve this answer














                          share|improve this answer



                          share|improve this answer








                          edited 23 hours ago

























                          answered yesterday









                          Emigna

                          45.5k432138




                          45.5k432138












                          • Nice answer, I managed to get 23 bytes through multiple approaches (one of which was my currently deleted answer). That's a neat way to arrange your stack to save a byte!
                            – Mr. Xcoder
                            yesterday






                          • 1




                            An alternate 22 byter combining our answers: Try it Online!
                            – Mr. Xcoder
                            yesterday










                          • @Mr.Xcoder: My first idea actually looked like that, but 2 bytes worse because I didn't remember that ª had changed :)
                            – Emigna
                            yesterday










                          • I've found a 20 byter using a portion of @Mr.Xcoder's approach, but I'll let you figure it out yourself before I reveil it. :)
                            – Kevin Cruijssen
                            yesterday








                          • 1




                            @KevinCruijssen: I'll let you know after I've looked some more ;)
                            – Emigna
                            yesterday


















                          • Nice answer, I managed to get 23 bytes through multiple approaches (one of which was my currently deleted answer). That's a neat way to arrange your stack to save a byte!
                            – Mr. Xcoder
                            yesterday






                          • 1




                            An alternate 22 byter combining our answers: Try it Online!
                            – Mr. Xcoder
                            yesterday










                          • @Mr.Xcoder: My first idea actually looked like that, but 2 bytes worse because I didn't remember that ª had changed :)
                            – Emigna
                            yesterday










                          • I've found a 20 byter using a portion of @Mr.Xcoder's approach, but I'll let you figure it out yourself before I reveil it. :)
                            – Kevin Cruijssen
                            yesterday








                          • 1




                            @KevinCruijssen: I'll let you know after I've looked some more ;)
                            – Emigna
                            yesterday
















                          Nice answer, I managed to get 23 bytes through multiple approaches (one of which was my currently deleted answer). That's a neat way to arrange your stack to save a byte!
                          – Mr. Xcoder
                          yesterday




                          Nice answer, I managed to get 23 bytes through multiple approaches (one of which was my currently deleted answer). That's a neat way to arrange your stack to save a byte!
                          – Mr. Xcoder
                          yesterday




                          1




                          1




                          An alternate 22 byter combining our answers: Try it Online!
                          – Mr. Xcoder
                          yesterday




                          An alternate 22 byter combining our answers: Try it Online!
                          – Mr. Xcoder
                          yesterday












                          @Mr.Xcoder: My first idea actually looked like that, but 2 bytes worse because I didn't remember that ª had changed :)
                          – Emigna
                          yesterday




                          @Mr.Xcoder: My first idea actually looked like that, but 2 bytes worse because I didn't remember that ª had changed :)
                          – Emigna
                          yesterday












                          I've found a 20 byter using a portion of @Mr.Xcoder's approach, but I'll let you figure it out yourself before I reveil it. :)
                          – Kevin Cruijssen
                          yesterday






                          I've found a 20 byter using a portion of @Mr.Xcoder's approach, but I'll let you figure it out yourself before I reveil it. :)
                          – Kevin Cruijssen
                          yesterday






                          1




                          1




                          @KevinCruijssen: I'll let you know after I've looked some more ;)
                          – Emigna
                          yesterday




                          @KevinCruijssen: I'll let you know after I've looked some more ;)
                          – Emigna
                          yesterday











                          4















                          Perl 6, 47 bytes





                          *.ords>>.&{<<00 AM{1..24}PM>>[$_%32]}.join(":")


                          Try it online!



                          Anonymous Whatever lambda that takes a string of either case and returns the encrypted string.



                          Explanation:



                          *.ords>>.&{                         } # Map the ordinal values to
                          << >>[$_%32] # The index in the list
                          00 AM{1..24}PM # 00, AM, the numbers 1 to 24 and PM
                          .join(":") # And join with colons





                          share|improve this answer




























                            4















                            Perl 6, 47 bytes





                            *.ords>>.&{<<00 AM{1..24}PM>>[$_%32]}.join(":")


                            Try it online!



                            Anonymous Whatever lambda that takes a string of either case and returns the encrypted string.



                            Explanation:



                            *.ords>>.&{                         } # Map the ordinal values to
                            << >>[$_%32] # The index in the list
                            00 AM{1..24}PM # 00, AM, the numbers 1 to 24 and PM
                            .join(":") # And join with colons





                            share|improve this answer


























                              4












                              4








                              4







                              Perl 6, 47 bytes





                              *.ords>>.&{<<00 AM{1..24}PM>>[$_%32]}.join(":")


                              Try it online!



                              Anonymous Whatever lambda that takes a string of either case and returns the encrypted string.



                              Explanation:



                              *.ords>>.&{                         } # Map the ordinal values to
                              << >>[$_%32] # The index in the list
                              00 AM{1..24}PM # 00, AM, the numbers 1 to 24 and PM
                              .join(":") # And join with colons





                              share|improve this answer















                              Perl 6, 47 bytes





                              *.ords>>.&{<<00 AM{1..24}PM>>[$_%32]}.join(":")


                              Try it online!



                              Anonymous Whatever lambda that takes a string of either case and returns the encrypted string.



                              Explanation:



                              *.ords>>.&{                         } # Map the ordinal values to
                              << >>[$_%32] # The index in the list
                              00 AM{1..24}PM # 00, AM, the numbers 1 to 24 and PM
                              .join(":") # And join with colons






                              share|improve this answer














                              share|improve this answer



                              share|improve this answer








                              edited yesterday

























                              answered yesterday









                              Jo King

                              21k248110




                              21k248110























                                  3














                                  Pyth, 25 bytes



                                  j:m@+++"AM"S24"PM""00"xG


                                  Try it online here, or verify all the test cases at once here.



                                  j:m@+++"AM"S24"PM""00"xGdQ   Implicit: Q=eval(input()), G=lowercase alphabet
                                  Trailing dQ inferred
                                  S24 [1-24]
                                  +"AM" Prepend "AM"
                                  + "PM" Append "PM"
                                  + "00" Append "00" - this is the dictionary
                                  m Q Map each element of Q, as d, using:
                                  xGd Get the index of d in G, -1 if not present (i.e. space)
                                  @ Get the element from the dictionary at the above index
                                  j: Join the result on ":", implicit print





                                  share|improve this answer


























                                    3














                                    Pyth, 25 bytes



                                    j:m@+++"AM"S24"PM""00"xG


                                    Try it online here, or verify all the test cases at once here.



                                    j:m@+++"AM"S24"PM""00"xGdQ   Implicit: Q=eval(input()), G=lowercase alphabet
                                    Trailing dQ inferred
                                    S24 [1-24]
                                    +"AM" Prepend "AM"
                                    + "PM" Append "PM"
                                    + "00" Append "00" - this is the dictionary
                                    m Q Map each element of Q, as d, using:
                                    xGd Get the index of d in G, -1 if not present (i.e. space)
                                    @ Get the element from the dictionary at the above index
                                    j: Join the result on ":", implicit print





                                    share|improve this answer
























                                      3












                                      3








                                      3






                                      Pyth, 25 bytes



                                      j:m@+++"AM"S24"PM""00"xG


                                      Try it online here, or verify all the test cases at once here.



                                      j:m@+++"AM"S24"PM""00"xGdQ   Implicit: Q=eval(input()), G=lowercase alphabet
                                      Trailing dQ inferred
                                      S24 [1-24]
                                      +"AM" Prepend "AM"
                                      + "PM" Append "PM"
                                      + "00" Append "00" - this is the dictionary
                                      m Q Map each element of Q, as d, using:
                                      xGd Get the index of d in G, -1 if not present (i.e. space)
                                      @ Get the element from the dictionary at the above index
                                      j: Join the result on ":", implicit print





                                      share|improve this answer












                                      Pyth, 25 bytes



                                      j:m@+++"AM"S24"PM""00"xG


                                      Try it online here, or verify all the test cases at once here.



                                      j:m@+++"AM"S24"PM""00"xGdQ   Implicit: Q=eval(input()), G=lowercase alphabet
                                      Trailing dQ inferred
                                      S24 [1-24]
                                      +"AM" Prepend "AM"
                                      + "PM" Append "PM"
                                      + "00" Append "00" - this is the dictionary
                                      m Q Map each element of Q, as d, using:
                                      xGd Get the index of d in G, -1 if not present (i.e. space)
                                      @ Get the element from the dictionary at the above index
                                      j: Join the result on ":", implicit print






                                      share|improve this answer












                                      share|improve this answer



                                      share|improve this answer










                                      answered yesterday









                                      Sok

                                      3,587722




                                      3,587722























                                          3















                                          JavaScript (Node.js), 72 bytes



                                          Takes input in lowercase.





                                          s=>[...s].map(c=>c<1?'00':(x=Buffer(c)[0]-1&31)>24?'PM':x||'AM').join`:`


                                          Try it online!






                                          share|improve this answer


























                                            3















                                            JavaScript (Node.js), 72 bytes



                                            Takes input in lowercase.





                                            s=>[...s].map(c=>c<1?'00':(x=Buffer(c)[0]-1&31)>24?'PM':x||'AM').join`:`


                                            Try it online!






                                            share|improve this answer
























                                              3












                                              3








                                              3







                                              JavaScript (Node.js), 72 bytes



                                              Takes input in lowercase.





                                              s=>[...s].map(c=>c<1?'00':(x=Buffer(c)[0]-1&31)>24?'PM':x||'AM').join`:`


                                              Try it online!






                                              share|improve this answer













                                              JavaScript (Node.js), 72 bytes



                                              Takes input in lowercase.





                                              s=>[...s].map(c=>c<1?'00':(x=Buffer(c)[0]-1&31)>24?'PM':x||'AM').join`:`


                                              Try it online!







                                              share|improve this answer












                                              share|improve this answer



                                              share|improve this answer










                                              answered yesterday









                                              Arnauld

                                              72.6k689306




                                              72.6k689306























                                                  3















                                                  C# (Visual C# Interactive Compiler), 72 bytes





                                                  s=>string.Join(":",s.Select(a=>a<33?"00":a<66?"AM":a>89?"PM":a%32-1+""))


                                                  Takes input as a string of lowercase letters. First checks if the char is a space, and if it is, converts it to 00. Next, it checks for if the char is an A, and converts it to AM. It checks again for Z and converts it to PM if it is. Lastly, if the char passes all the checks, it gets converted to its alphabetic order-1.



                                                  Try it online!



                                                  // Input taking a string
                                                  s =>
                                                  // Join the following IEnumerable<char> with a ":" character
                                                  string.Join(":",
                                                  // Map all the characters in the string
                                                  s.Select(a =>
                                                  // Is the char less than 33, aka a space?
                                                  a < 33 ?
                                                  // If so, it's a "00"
                                                  "00"
                                                  // Else, is this an 'A'?
                                                  : a < 66 ?
                                                  // If so, convert it to "AM"
                                                  "AM" :
                                                  // If it's not 'A' or a space, could it be a 'Z'?
                                                  a > 89 ?
                                                  // If it is, turn the character into "PM"
                                                  "PM" :
                                                  // If it fails all of the checks above, get the characters position in the alphabet and subtract one from that.
                                                  a % 32 - 1 + ""))





                                                  share|improve this answer





















                                                  • How about this? a%32-1 => a%65? Nice submission :)
                                                    – dana
                                                    17 hours ago
















                                                  3















                                                  C# (Visual C# Interactive Compiler), 72 bytes





                                                  s=>string.Join(":",s.Select(a=>a<33?"00":a<66?"AM":a>89?"PM":a%32-1+""))


                                                  Takes input as a string of lowercase letters. First checks if the char is a space, and if it is, converts it to 00. Next, it checks for if the char is an A, and converts it to AM. It checks again for Z and converts it to PM if it is. Lastly, if the char passes all the checks, it gets converted to its alphabetic order-1.



                                                  Try it online!



                                                  // Input taking a string
                                                  s =>
                                                  // Join the following IEnumerable<char> with a ":" character
                                                  string.Join(":",
                                                  // Map all the characters in the string
                                                  s.Select(a =>
                                                  // Is the char less than 33, aka a space?
                                                  a < 33 ?
                                                  // If so, it's a "00"
                                                  "00"
                                                  // Else, is this an 'A'?
                                                  : a < 66 ?
                                                  // If so, convert it to "AM"
                                                  "AM" :
                                                  // If it's not 'A' or a space, could it be a 'Z'?
                                                  a > 89 ?
                                                  // If it is, turn the character into "PM"
                                                  "PM" :
                                                  // If it fails all of the checks above, get the characters position in the alphabet and subtract one from that.
                                                  a % 32 - 1 + ""))





                                                  share|improve this answer





















                                                  • How about this? a%32-1 => a%65? Nice submission :)
                                                    – dana
                                                    17 hours ago














                                                  3












                                                  3








                                                  3







                                                  C# (Visual C# Interactive Compiler), 72 bytes





                                                  s=>string.Join(":",s.Select(a=>a<33?"00":a<66?"AM":a>89?"PM":a%32-1+""))


                                                  Takes input as a string of lowercase letters. First checks if the char is a space, and if it is, converts it to 00. Next, it checks for if the char is an A, and converts it to AM. It checks again for Z and converts it to PM if it is. Lastly, if the char passes all the checks, it gets converted to its alphabetic order-1.



                                                  Try it online!



                                                  // Input taking a string
                                                  s =>
                                                  // Join the following IEnumerable<char> with a ":" character
                                                  string.Join(":",
                                                  // Map all the characters in the string
                                                  s.Select(a =>
                                                  // Is the char less than 33, aka a space?
                                                  a < 33 ?
                                                  // If so, it's a "00"
                                                  "00"
                                                  // Else, is this an 'A'?
                                                  : a < 66 ?
                                                  // If so, convert it to "AM"
                                                  "AM" :
                                                  // If it's not 'A' or a space, could it be a 'Z'?
                                                  a > 89 ?
                                                  // If it is, turn the character into "PM"
                                                  "PM" :
                                                  // If it fails all of the checks above, get the characters position in the alphabet and subtract one from that.
                                                  a % 32 - 1 + ""))





                                                  share|improve this answer













                                                  C# (Visual C# Interactive Compiler), 72 bytes





                                                  s=>string.Join(":",s.Select(a=>a<33?"00":a<66?"AM":a>89?"PM":a%32-1+""))


                                                  Takes input as a string of lowercase letters. First checks if the char is a space, and if it is, converts it to 00. Next, it checks for if the char is an A, and converts it to AM. It checks again for Z and converts it to PM if it is. Lastly, if the char passes all the checks, it gets converted to its alphabetic order-1.



                                                  Try it online!



                                                  // Input taking a string
                                                  s =>
                                                  // Join the following IEnumerable<char> with a ":" character
                                                  string.Join(":",
                                                  // Map all the characters in the string
                                                  s.Select(a =>
                                                  // Is the char less than 33, aka a space?
                                                  a < 33 ?
                                                  // If so, it's a "00"
                                                  "00"
                                                  // Else, is this an 'A'?
                                                  : a < 66 ?
                                                  // If so, convert it to "AM"
                                                  "AM" :
                                                  // If it's not 'A' or a space, could it be a 'Z'?
                                                  a > 89 ?
                                                  // If it is, turn the character into "PM"
                                                  "PM" :
                                                  // If it fails all of the checks above, get the characters position in the alphabet and subtract one from that.
                                                  a % 32 - 1 + ""))






                                                  share|improve this answer












                                                  share|improve this answer



                                                  share|improve this answer










                                                  answered 21 hours ago









                                                  Embodiment of Ignorance

                                                  55014




                                                  55014












                                                  • How about this? a%32-1 => a%65? Nice submission :)
                                                    – dana
                                                    17 hours ago


















                                                  • How about this? a%32-1 => a%65? Nice submission :)
                                                    – dana
                                                    17 hours ago
















                                                  How about this? a%32-1 => a%65? Nice submission :)
                                                  – dana
                                                  17 hours ago




                                                  How about this? a%32-1 => a%65? Nice submission :)
                                                  – dana
                                                  17 hours ago











                                                  3















                                                  Java (JDK), 95 bytes





                                                  s->{int a=0;for(var c:s)System.out.print((a++<1?"":":")+(c<33?"00":c<66?"AM":c>89?"PM":c-65));}


                                                  Try it online!



                                                  Credits




                                                  • -1 byte thanks to Kevin Cruijssen






                                                  share|improve this answer























                                                  • One easy golf: char to var. :)
                                                    – Kevin Cruijssen
                                                    yesterday










                                                  • Thanks! So obvious now that you show it to me...
                                                    – Olivier Grégoire
                                                    yesterday
















                                                  3















                                                  Java (JDK), 95 bytes





                                                  s->{int a=0;for(var c:s)System.out.print((a++<1?"":":")+(c<33?"00":c<66?"AM":c>89?"PM":c-65));}


                                                  Try it online!



                                                  Credits




                                                  • -1 byte thanks to Kevin Cruijssen






                                                  share|improve this answer























                                                  • One easy golf: char to var. :)
                                                    – Kevin Cruijssen
                                                    yesterday










                                                  • Thanks! So obvious now that you show it to me...
                                                    – Olivier Grégoire
                                                    yesterday














                                                  3












                                                  3








                                                  3







                                                  Java (JDK), 95 bytes





                                                  s->{int a=0;for(var c:s)System.out.print((a++<1?"":":")+(c<33?"00":c<66?"AM":c>89?"PM":c-65));}


                                                  Try it online!



                                                  Credits




                                                  • -1 byte thanks to Kevin Cruijssen






                                                  share|improve this answer















                                                  Java (JDK), 95 bytes





                                                  s->{int a=0;for(var c:s)System.out.print((a++<1?"":":")+(c<33?"00":c<66?"AM":c>89?"PM":c-65));}


                                                  Try it online!



                                                  Credits




                                                  • -1 byte thanks to Kevin Cruijssen







                                                  share|improve this answer














                                                  share|improve this answer



                                                  share|improve this answer








                                                  edited 20 hours ago

























                                                  answered yesterday









                                                  Olivier Grégoire

                                                  8,80711843




                                                  8,80711843












                                                  • One easy golf: char to var. :)
                                                    – Kevin Cruijssen
                                                    yesterday










                                                  • Thanks! So obvious now that you show it to me...
                                                    – Olivier Grégoire
                                                    yesterday


















                                                  • One easy golf: char to var. :)
                                                    – Kevin Cruijssen
                                                    yesterday










                                                  • Thanks! So obvious now that you show it to me...
                                                    – Olivier Grégoire
                                                    yesterday
















                                                  One easy golf: char to var. :)
                                                  – Kevin Cruijssen
                                                  yesterday




                                                  One easy golf: char to var. :)
                                                  – Kevin Cruijssen
                                                  yesterday












                                                  Thanks! So obvious now that you show it to me...
                                                  – Olivier Grégoire
                                                  yesterday




                                                  Thanks! So obvious now that you show it to me...
                                                  – Olivier Grégoire
                                                  yesterday











                                                  2















                                                  Ruby, 49 bytes





                                                  ->a{a.map{|c|["00",:AM,*1..24,:PM][c.ord%32]}*?:}


                                                  Try it online!



                                                  Port of Jo King's Perl answer.
                                                  Takes input as an array of chars, returns a string with AM/PM in uppercase.






                                                  share|improve this answer


























                                                    2















                                                    Ruby, 49 bytes





                                                    ->a{a.map{|c|["00",:AM,*1..24,:PM][c.ord%32]}*?:}


                                                    Try it online!



                                                    Port of Jo King's Perl answer.
                                                    Takes input as an array of chars, returns a string with AM/PM in uppercase.






                                                    share|improve this answer
























                                                      2












                                                      2








                                                      2







                                                      Ruby, 49 bytes





                                                      ->a{a.map{|c|["00",:AM,*1..24,:PM][c.ord%32]}*?:}


                                                      Try it online!



                                                      Port of Jo King's Perl answer.
                                                      Takes input as an array of chars, returns a string with AM/PM in uppercase.






                                                      share|improve this answer













                                                      Ruby, 49 bytes





                                                      ->a{a.map{|c|["00",:AM,*1..24,:PM][c.ord%32]}*?:}


                                                      Try it online!



                                                      Port of Jo King's Perl answer.
                                                      Takes input as an array of chars, returns a string with AM/PM in uppercase.







                                                      share|improve this answer












                                                      share|improve this answer



                                                      share|improve this answer










                                                      answered yesterday









                                                      Kirill L.

                                                      3,6751319




                                                      3,6751319























                                                          2















                                                          Red, 124 121 110 109 bytes



                                                          func[s][replace/all form collect[forall s[keep switch/default
                                                          c: -97 + s/1[0['AM]25['PM]-65["00"]][c]]]sp":"]


                                                          Try it online!






                                                          share|improve this answer




























                                                            2















                                                            Red, 124 121 110 109 bytes



                                                            func[s][replace/all form collect[forall s[keep switch/default
                                                            c: -97 + s/1[0['AM]25['PM]-65["00"]][c]]]sp":"]


                                                            Try it online!






                                                            share|improve this answer


























                                                              2












                                                              2








                                                              2







                                                              Red, 124 121 110 109 bytes



                                                              func[s][replace/all form collect[forall s[keep switch/default
                                                              c: -97 + s/1[0['AM]25['PM]-65["00"]][c]]]sp":"]


                                                              Try it online!






                                                              share|improve this answer















                                                              Red, 124 121 110 109 bytes



                                                              func[s][replace/all form collect[forall s[keep switch/default
                                                              c: -97 + s/1[0['AM]25['PM]-65["00"]][c]]]sp":"]


                                                              Try it online!







                                                              share|improve this answer














                                                              share|improve this answer



                                                              share|improve this answer








                                                              edited yesterday

























                                                              answered yesterday









                                                              Galen Ivanov

                                                              6,37711032




                                                              6,37711032























                                                                  1















                                                                  Tcl, 100 bytes



                                                                  proc C s {join [lmap c [split $s ""] {scan $c %c v
                                                                  expr $v==65?"AM":$v==90?"PM":$v==32?00:$v-65}] :}


                                                                  Try it online!






                                                                  share|improve this answer




























                                                                    1















                                                                    Tcl, 100 bytes



                                                                    proc C s {join [lmap c [split $s ""] {scan $c %c v
                                                                    expr $v==65?"AM":$v==90?"PM":$v==32?00:$v-65}] :}


                                                                    Try it online!






                                                                    share|improve this answer


























                                                                      1












                                                                      1








                                                                      1







                                                                      Tcl, 100 bytes



                                                                      proc C s {join [lmap c [split $s ""] {scan $c %c v
                                                                      expr $v==65?"AM":$v==90?"PM":$v==32?00:$v-65}] :}


                                                                      Try it online!






                                                                      share|improve this answer















                                                                      Tcl, 100 bytes



                                                                      proc C s {join [lmap c [split $s ""] {scan $c %c v
                                                                      expr $v==65?"AM":$v==90?"PM":$v==32?00:$v-65}] :}


                                                                      Try it online!







                                                                      share|improve this answer














                                                                      share|improve this answer



                                                                      share|improve this answer








                                                                      edited 23 hours ago

























                                                                      answered yesterday









                                                                      sergiol

                                                                      2,5001925




                                                                      2,5001925























                                                                          1















                                                                          05AB1E, 20 bytes



                                                                          ':ýð00:A24L„AMš„PMª‡


                                                                          Greatly inspired by @Mr.Xcoder's 22-byter in the comment of the existing 05AB1E answer by @Emigna.



                                                                          Takes the input as a list of lowercase characters (would be 21 bytes with a leading S if I take the input as a string).



                                                                          Try it online or verify all test cases.



                                                                          Explanation:





                                                                          ':ý            '# Join the (implicit) input list of characters by ":"
                                                                          # i.e. ["e","a","s","y"," ","p","e","a","z","y"] → "e:a:s:y: :p:e:a:z:y"
                                                                          ð00: # Replace all spaces " " with "00"
                                                                          # i.e. "e:a:s:y: :p:e:a:z:y" → "e:a:s:y:00:p:e:a:z:y"
                                                                          A # Push the lowercase alphabet
                                                                          24L # Push a list in the range [1,24]
                                                                          „AMš # Prepend "AM" at the start of this list
                                                                          „PMª # And append "PM" at the end of the list
                                                                          ‡ # Transliterate; mapping letters to the list-items at the same indices
                                                                          # (and output the result implicitly)
                                                                          # i.e. "e:a:s:y:00:p:e:a:z:y" → "4:AM:18:24:00:15:4:AM:PM:24"





                                                                          share|improve this answer

















                                                                          • 1




                                                                            Ah yes. Replacing the space separately saves a byte. I should have tried that. Nice :)
                                                                            – Emigna
                                                                            23 hours ago
















                                                                          1















                                                                          05AB1E, 20 bytes



                                                                          ':ýð00:A24L„AMš„PMª‡


                                                                          Greatly inspired by @Mr.Xcoder's 22-byter in the comment of the existing 05AB1E answer by @Emigna.



                                                                          Takes the input as a list of lowercase characters (would be 21 bytes with a leading S if I take the input as a string).



                                                                          Try it online or verify all test cases.



                                                                          Explanation:





                                                                          ':ý            '# Join the (implicit) input list of characters by ":"
                                                                          # i.e. ["e","a","s","y"," ","p","e","a","z","y"] → "e:a:s:y: :p:e:a:z:y"
                                                                          ð00: # Replace all spaces " " with "00"
                                                                          # i.e. "e:a:s:y: :p:e:a:z:y" → "e:a:s:y:00:p:e:a:z:y"
                                                                          A # Push the lowercase alphabet
                                                                          24L # Push a list in the range [1,24]
                                                                          „AMš # Prepend "AM" at the start of this list
                                                                          „PMª # And append "PM" at the end of the list
                                                                          ‡ # Transliterate; mapping letters to the list-items at the same indices
                                                                          # (and output the result implicitly)
                                                                          # i.e. "e:a:s:y:00:p:e:a:z:y" → "4:AM:18:24:00:15:4:AM:PM:24"





                                                                          share|improve this answer

















                                                                          • 1




                                                                            Ah yes. Replacing the space separately saves a byte. I should have tried that. Nice :)
                                                                            – Emigna
                                                                            23 hours ago














                                                                          1












                                                                          1








                                                                          1







                                                                          05AB1E, 20 bytes



                                                                          ':ýð00:A24L„AMš„PMª‡


                                                                          Greatly inspired by @Mr.Xcoder's 22-byter in the comment of the existing 05AB1E answer by @Emigna.



                                                                          Takes the input as a list of lowercase characters (would be 21 bytes with a leading S if I take the input as a string).



                                                                          Try it online or verify all test cases.



                                                                          Explanation:





                                                                          ':ý            '# Join the (implicit) input list of characters by ":"
                                                                          # i.e. ["e","a","s","y"," ","p","e","a","z","y"] → "e:a:s:y: :p:e:a:z:y"
                                                                          ð00: # Replace all spaces " " with "00"
                                                                          # i.e. "e:a:s:y: :p:e:a:z:y" → "e:a:s:y:00:p:e:a:z:y"
                                                                          A # Push the lowercase alphabet
                                                                          24L # Push a list in the range [1,24]
                                                                          „AMš # Prepend "AM" at the start of this list
                                                                          „PMª # And append "PM" at the end of the list
                                                                          ‡ # Transliterate; mapping letters to the list-items at the same indices
                                                                          # (and output the result implicitly)
                                                                          # i.e. "e:a:s:y:00:p:e:a:z:y" → "4:AM:18:24:00:15:4:AM:PM:24"





                                                                          share|improve this answer













                                                                          05AB1E, 20 bytes



                                                                          ':ýð00:A24L„AMš„PMª‡


                                                                          Greatly inspired by @Mr.Xcoder's 22-byter in the comment of the existing 05AB1E answer by @Emigna.



                                                                          Takes the input as a list of lowercase characters (would be 21 bytes with a leading S if I take the input as a string).



                                                                          Try it online or verify all test cases.



                                                                          Explanation:





                                                                          ':ý            '# Join the (implicit) input list of characters by ":"
                                                                          # i.e. ["e","a","s","y"," ","p","e","a","z","y"] → "e:a:s:y: :p:e:a:z:y"
                                                                          ð00: # Replace all spaces " " with "00"
                                                                          # i.e. "e:a:s:y: :p:e:a:z:y" → "e:a:s:y:00:p:e:a:z:y"
                                                                          A # Push the lowercase alphabet
                                                                          24L # Push a list in the range [1,24]
                                                                          „AMš # Prepend "AM" at the start of this list
                                                                          „PMª # And append "PM" at the end of the list
                                                                          ‡ # Transliterate; mapping letters to the list-items at the same indices
                                                                          # (and output the result implicitly)
                                                                          # i.e. "e:a:s:y:00:p:e:a:z:y" → "4:AM:18:24:00:15:4:AM:PM:24"






                                                                          share|improve this answer












                                                                          share|improve this answer



                                                                          share|improve this answer










                                                                          answered 23 hours ago









                                                                          Kevin Cruijssen

                                                                          35.9k554188




                                                                          35.9k554188








                                                                          • 1




                                                                            Ah yes. Replacing the space separately saves a byte. I should have tried that. Nice :)
                                                                            – Emigna
                                                                            23 hours ago














                                                                          • 1




                                                                            Ah yes. Replacing the space separately saves a byte. I should have tried that. Nice :)
                                                                            – Emigna
                                                                            23 hours ago








                                                                          1




                                                                          1




                                                                          Ah yes. Replacing the space separately saves a byte. I should have tried that. Nice :)
                                                                          – Emigna
                                                                          23 hours ago




                                                                          Ah yes. Replacing the space separately saves a byte. I should have tried that. Nice :)
                                                                          – Emigna
                                                                          23 hours ago











                                                                          1















                                                                          C# (Visual C# Interactive Compiler), 98 bytes





                                                                          s=>string.Join(':',s.Select(c=>"az ".Contains(c)?new{"AM","PM","00"}["az ".IndexOf(c)]:c-97+""))


                                                                          Takes input as a (lowercase) char array. Try it online!






                                                                          share|improve this answer





















                                                                          • 82 bytes: s=>string.Join(':',s.Select(c=>new{c-97+"","AM","PM","00"}["az ".IndexOf(c)+1])).
                                                                            – dana
                                                                            1 hour ago
















                                                                          1















                                                                          C# (Visual C# Interactive Compiler), 98 bytes





                                                                          s=>string.Join(':',s.Select(c=>"az ".Contains(c)?new{"AM","PM","00"}["az ".IndexOf(c)]:c-97+""))


                                                                          Takes input as a (lowercase) char array. Try it online!






                                                                          share|improve this answer





















                                                                          • 82 bytes: s=>string.Join(':',s.Select(c=>new{c-97+"","AM","PM","00"}["az ".IndexOf(c)+1])).
                                                                            – dana
                                                                            1 hour ago














                                                                          1












                                                                          1








                                                                          1







                                                                          C# (Visual C# Interactive Compiler), 98 bytes





                                                                          s=>string.Join(':',s.Select(c=>"az ".Contains(c)?new{"AM","PM","00"}["az ".IndexOf(c)]:c-97+""))


                                                                          Takes input as a (lowercase) char array. Try it online!






                                                                          share|improve this answer













                                                                          C# (Visual C# Interactive Compiler), 98 bytes





                                                                          s=>string.Join(':',s.Select(c=>"az ".Contains(c)?new{"AM","PM","00"}["az ".IndexOf(c)]:c-97+""))


                                                                          Takes input as a (lowercase) char array. Try it online!







                                                                          share|improve this answer












                                                                          share|improve this answer



                                                                          share|improve this answer










                                                                          answered 22 hours ago









                                                                          someone

                                                                          472416




                                                                          472416












                                                                          • 82 bytes: s=>string.Join(':',s.Select(c=>new{c-97+"","AM","PM","00"}["az ".IndexOf(c)+1])).
                                                                            – dana
                                                                            1 hour ago


















                                                                          • 82 bytes: s=>string.Join(':',s.Select(c=>new{c-97+"","AM","PM","00"}["az ".IndexOf(c)+1])).
                                                                            – dana
                                                                            1 hour ago
















                                                                          82 bytes: s=>string.Join(':',s.Select(c=>new{c-97+"","AM","PM","00"}["az ".IndexOf(c)+1])).
                                                                          – dana
                                                                          1 hour ago




                                                                          82 bytes: s=>string.Join(':',s.Select(c=>new{c-97+"","AM","PM","00"}["az ".IndexOf(c)+1])).
                                                                          – dana
                                                                          1 hour ago











                                                                          1















                                                                          Charcoal, 26 bytes



                                                                          UB:Fθ«→≡ι ×0²a¦AM¦z¦PMI⌕βι


                                                                          Try it online! Link is to verbose version of code. Takes input in lower case (can trivially be changed to upper case). Explanation:



                                                                          UB:


                                                                          Set the background character to :. This fills in the gaps between the output values created by the right movement.



                                                                          Fθ«→


                                                                          Loop over each character, leaving a gap each time. (The first move has no effect as the canvas is still empty at this point.)



                                                                          ≡ι ×0²a¦AM¦z¦PM


                                                                          Switch on the character and if it's space, a or z then output the appropriate code. I use ×0² instead of 00 here as the latter would cost two bytes in additional separators.



                                                                          I⌕βι


                                                                          Otherwise output the letter's 0-indexed position in the lower case alphabet as a string.






                                                                          share|improve this answer


























                                                                            1















                                                                            Charcoal, 26 bytes



                                                                            UB:Fθ«→≡ι ×0²a¦AM¦z¦PMI⌕βι


                                                                            Try it online! Link is to verbose version of code. Takes input in lower case (can trivially be changed to upper case). Explanation:



                                                                            UB:


                                                                            Set the background character to :. This fills in the gaps between the output values created by the right movement.



                                                                            Fθ«→


                                                                            Loop over each character, leaving a gap each time. (The first move has no effect as the canvas is still empty at this point.)



                                                                            ≡ι ×0²a¦AM¦z¦PM


                                                                            Switch on the character and if it's space, a or z then output the appropriate code. I use ×0² instead of 00 here as the latter would cost two bytes in additional separators.



                                                                            I⌕βι


                                                                            Otherwise output the letter's 0-indexed position in the lower case alphabet as a string.






                                                                            share|improve this answer
























                                                                              1












                                                                              1








                                                                              1







                                                                              Charcoal, 26 bytes



                                                                              UB:Fθ«→≡ι ×0²a¦AM¦z¦PMI⌕βι


                                                                              Try it online! Link is to verbose version of code. Takes input in lower case (can trivially be changed to upper case). Explanation:



                                                                              UB:


                                                                              Set the background character to :. This fills in the gaps between the output values created by the right movement.



                                                                              Fθ«→


                                                                              Loop over each character, leaving a gap each time. (The first move has no effect as the canvas is still empty at this point.)



                                                                              ≡ι ×0²a¦AM¦z¦PM


                                                                              Switch on the character and if it's space, a or z then output the appropriate code. I use ×0² instead of 00 here as the latter would cost two bytes in additional separators.



                                                                              I⌕βι


                                                                              Otherwise output the letter's 0-indexed position in the lower case alphabet as a string.






                                                                              share|improve this answer













                                                                              Charcoal, 26 bytes



                                                                              UB:Fθ«→≡ι ×0²a¦AM¦z¦PMI⌕βι


                                                                              Try it online! Link is to verbose version of code. Takes input in lower case (can trivially be changed to upper case). Explanation:



                                                                              UB:


                                                                              Set the background character to :. This fills in the gaps between the output values created by the right movement.



                                                                              Fθ«→


                                                                              Loop over each character, leaving a gap each time. (The first move has no effect as the canvas is still empty at this point.)



                                                                              ≡ι ×0²a¦AM¦z¦PM


                                                                              Switch on the character and if it's space, a or z then output the appropriate code. I use ×0² instead of 00 here as the latter would cost two bytes in additional separators.



                                                                              I⌕βι


                                                                              Otherwise output the letter's 0-indexed position in the lower case alphabet as a string.







                                                                              share|improve this answer












                                                                              share|improve this answer



                                                                              share|improve this answer










                                                                              answered 19 hours ago









                                                                              Neil

                                                                              79.5k744177




                                                                              79.5k744177






























                                                                                  draft saved

                                                                                  draft discarded




















































                                                                                  If this is an answer to a challenge…




                                                                                  • …Be sure to follow the challenge specification. However, please refrain from exploiting obvious loopholes. Answers abusing any of the standard loopholes are considered invalid. If you think a specification is unclear or underspecified, comment on the question instead.


                                                                                  • …Try to optimize your score. For instance, answers to code-golf challenges should attempt to be as short as possible. You can always include a readable version of the code in addition to the competitive one.
                                                                                    Explanations of your answer make it more interesting to read and are very much encouraged.


                                                                                  • …Include a short header which indicates the language(s) of your code and its score, as defined by the challenge.



                                                                                  More generally…




                                                                                  • …Please make sure to answer the question and provide sufficient detail.


                                                                                  • …Avoid asking for help, clarification or responding to other answers (use comments instead).






                                                                                  Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                                                                                  Please pay close attention to the following guidance:


                                                                                  • Please be sure to answer the question. Provide details and share your research!

                                                                                  But avoid



                                                                                  • Asking for help, clarification, or responding to other answers.

                                                                                  • Making statements based on opinion; back them up with references or personal experience.


                                                                                  To learn more, see our tips on writing great answers.




                                                                                  draft saved


                                                                                  draft discarded














                                                                                  StackExchange.ready(
                                                                                  function () {
                                                                                  StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f178356%2fclock-transliterate-cipher%23new-answer', 'question_page');
                                                                                  }
                                                                                  );

                                                                                  Post as a guest















                                                                                  Required, but never shown





















































                                                                                  Required, but never shown














                                                                                  Required, but never shown












                                                                                  Required, but never shown







                                                                                  Required, but never shown

































                                                                                  Required, but never shown














                                                                                  Required, but never shown












                                                                                  Required, but never shown







                                                                                  Required, but never shown







                                                                                  Popular posts from this blog

                                                                                  An IMO inspired problem

                                                                                  Management

                                                                                  Has there ever been an instance of an active nuclear power plant within or near a war zone?