What numbers are these?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
4
down vote

favorite












While I was writing numbers I noticed after a while that my keyboard had the Shift key pressed and blocked and all I wrote was $%&-like characters. And even worse, I had been switching between the English and Spanish keyboard layouts so I don't know which one I used for each number.



Challenge



Given a string containing symbol characters, try to guess which number I wrote. My keyboard produces the following characters for the numbers when the Shift is pressed:



1234567890
----------
!"·$%&/()= Spanish layout
!@#$%^&*() English layout


  • The input will be a non-null, non-empty string composed of the symbols above.

  • The output will be a single number if the keyboard layout can be inferred from the string (i.e. if the string contains a @ an English layout was used, and if the string contains a " a Spanish layout was used) or if the number is the same for both layouts (i.e. the input is !$ which translates as 14 for both layouts); otherwise the output will be the two possible numbers for both layouts if it cannot be inferred and the resulting numbers are different.

  • The input string will always be written in a single layout. So you don't need to expect "@ as input.

Examples



Input --> Output
------------------
/() 789 (Spanish layout detected by the use of /)
$%& 456,457 (Layout cannot be inferred)
!@# 123 (English layout detected by the use of @ and #)
()&! 8961,9071 (Layout cannot be inferred)
((·)) 88399 (Spanish layout detected by the use of ·)
!$ 14 (Layout cannot be inferred but the result is the same for both)
!!$$%% 114455 (Layout cannot be inferred but the result is the same for both)
==$" 0042/42 (Spanish layout, if a number starts with 0 you can choose to
omit them in the result or not)

Single character translations:
------------------------------
! 1
" 2
· 3
$ 4
% 5
& 6,7
/ 7
( 8,9
) 9,0
= 0
@ 2
# 3
^ 6
* 8


This is code-golf, so may the shortest code for each language win!










share|improve this question





















  • Dang it, that · is challenging...
    – Erik the Outgolfer
    1 hour ago










  • @EriktheOutgolfer in fact the · is useless for Spanish, it is only used in the Catalan language.
    – Charlie
    1 hour ago










  • Is output like (8, 9, 6, 1), (9, 0, 7, 1) (for the 4th test case) acceptable?
    – Lynn
    46 mins ago










  • @Lynn yes, it is.
    – Charlie
    44 mins ago














up vote
4
down vote

favorite












While I was writing numbers I noticed after a while that my keyboard had the Shift key pressed and blocked and all I wrote was $%&-like characters. And even worse, I had been switching between the English and Spanish keyboard layouts so I don't know which one I used for each number.



Challenge



Given a string containing symbol characters, try to guess which number I wrote. My keyboard produces the following characters for the numbers when the Shift is pressed:



1234567890
----------
!"·$%&/()= Spanish layout
!@#$%^&*() English layout


  • The input will be a non-null, non-empty string composed of the symbols above.

  • The output will be a single number if the keyboard layout can be inferred from the string (i.e. if the string contains a @ an English layout was used, and if the string contains a " a Spanish layout was used) or if the number is the same for both layouts (i.e. the input is !$ which translates as 14 for both layouts); otherwise the output will be the two possible numbers for both layouts if it cannot be inferred and the resulting numbers are different.

  • The input string will always be written in a single layout. So you don't need to expect "@ as input.

Examples



Input --> Output
------------------
/() 789 (Spanish layout detected by the use of /)
$%& 456,457 (Layout cannot be inferred)
!@# 123 (English layout detected by the use of @ and #)
()&! 8961,9071 (Layout cannot be inferred)
((·)) 88399 (Spanish layout detected by the use of ·)
!$ 14 (Layout cannot be inferred but the result is the same for both)
!!$$%% 114455 (Layout cannot be inferred but the result is the same for both)
==$" 0042/42 (Spanish layout, if a number starts with 0 you can choose to
omit them in the result or not)

Single character translations:
------------------------------
! 1
" 2
· 3
$ 4
% 5
& 6,7
/ 7
( 8,9
) 9,0
= 0
@ 2
# 3
^ 6
* 8


This is code-golf, so may the shortest code for each language win!










share|improve this question





















  • Dang it, that · is challenging...
    – Erik the Outgolfer
    1 hour ago










  • @EriktheOutgolfer in fact the · is useless for Spanish, it is only used in the Catalan language.
    – Charlie
    1 hour ago










  • Is output like (8, 9, 6, 1), (9, 0, 7, 1) (for the 4th test case) acceptable?
    – Lynn
    46 mins ago










  • @Lynn yes, it is.
    – Charlie
    44 mins ago












up vote
4
down vote

favorite









up vote
4
down vote

favorite











While I was writing numbers I noticed after a while that my keyboard had the Shift key pressed and blocked and all I wrote was $%&-like characters. And even worse, I had been switching between the English and Spanish keyboard layouts so I don't know which one I used for each number.



Challenge



Given a string containing symbol characters, try to guess which number I wrote. My keyboard produces the following characters for the numbers when the Shift is pressed:



1234567890
----------
!"·$%&/()= Spanish layout
!@#$%^&*() English layout


  • The input will be a non-null, non-empty string composed of the symbols above.

  • The output will be a single number if the keyboard layout can be inferred from the string (i.e. if the string contains a @ an English layout was used, and if the string contains a " a Spanish layout was used) or if the number is the same for both layouts (i.e. the input is !$ which translates as 14 for both layouts); otherwise the output will be the two possible numbers for both layouts if it cannot be inferred and the resulting numbers are different.

  • The input string will always be written in a single layout. So you don't need to expect "@ as input.

Examples



Input --> Output
------------------
/() 789 (Spanish layout detected by the use of /)
$%& 456,457 (Layout cannot be inferred)
!@# 123 (English layout detected by the use of @ and #)
()&! 8961,9071 (Layout cannot be inferred)
((·)) 88399 (Spanish layout detected by the use of ·)
!$ 14 (Layout cannot be inferred but the result is the same for both)
!!$$%% 114455 (Layout cannot be inferred but the result is the same for both)
==$" 0042/42 (Spanish layout, if a number starts with 0 you can choose to
omit them in the result or not)

Single character translations:
------------------------------
! 1
" 2
· 3
$ 4
% 5
& 6,7
/ 7
( 8,9
) 9,0
= 0
@ 2
# 3
^ 6
* 8


This is code-golf, so may the shortest code for each language win!










share|improve this question













While I was writing numbers I noticed after a while that my keyboard had the Shift key pressed and blocked and all I wrote was $%&-like characters. And even worse, I had been switching between the English and Spanish keyboard layouts so I don't know which one I used for each number.



Challenge



Given a string containing symbol characters, try to guess which number I wrote. My keyboard produces the following characters for the numbers when the Shift is pressed:



1234567890
----------
!"·$%&/()= Spanish layout
!@#$%^&*() English layout


  • The input will be a non-null, non-empty string composed of the symbols above.

  • The output will be a single number if the keyboard layout can be inferred from the string (i.e. if the string contains a @ an English layout was used, and if the string contains a " a Spanish layout was used) or if the number is the same for both layouts (i.e. the input is !$ which translates as 14 for both layouts); otherwise the output will be the two possible numbers for both layouts if it cannot be inferred and the resulting numbers are different.

  • The input string will always be written in a single layout. So you don't need to expect "@ as input.

Examples



Input --> Output
------------------
/() 789 (Spanish layout detected by the use of /)
$%& 456,457 (Layout cannot be inferred)
!@# 123 (English layout detected by the use of @ and #)
()&! 8961,9071 (Layout cannot be inferred)
((·)) 88399 (Spanish layout detected by the use of ·)
!$ 14 (Layout cannot be inferred but the result is the same for both)
!!$$%% 114455 (Layout cannot be inferred but the result is the same for both)
==$" 0042/42 (Spanish layout, if a number starts with 0 you can choose to
omit them in the result or not)

Single character translations:
------------------------------
! 1
" 2
· 3
$ 4
% 5
& 6,7
/ 7
( 8,9
) 9,0
= 0
@ 2
# 3
^ 6
* 8


This is code-golf, so may the shortest code for each language win!







code-golf keyboard






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 1 hour ago









Charlie

6,9352081




6,9352081











  • Dang it, that · is challenging...
    – Erik the Outgolfer
    1 hour ago










  • @EriktheOutgolfer in fact the · is useless for Spanish, it is only used in the Catalan language.
    – Charlie
    1 hour ago










  • Is output like (8, 9, 6, 1), (9, 0, 7, 1) (for the 4th test case) acceptable?
    – Lynn
    46 mins ago










  • @Lynn yes, it is.
    – Charlie
    44 mins ago
















  • Dang it, that · is challenging...
    – Erik the Outgolfer
    1 hour ago










  • @EriktheOutgolfer in fact the · is useless for Spanish, it is only used in the Catalan language.
    – Charlie
    1 hour ago










  • Is output like (8, 9, 6, 1), (9, 0, 7, 1) (for the 4th test case) acceptable?
    – Lynn
    46 mins ago










  • @Lynn yes, it is.
    – Charlie
    44 mins ago















Dang it, that · is challenging...
– Erik the Outgolfer
1 hour ago




Dang it, that · is challenging...
– Erik the Outgolfer
1 hour ago












@EriktheOutgolfer in fact the · is useless for Spanish, it is only used in the Catalan language.
– Charlie
1 hour ago




@EriktheOutgolfer in fact the · is useless for Spanish, it is only used in the Catalan language.
– Charlie
1 hour ago












Is output like (8, 9, 6, 1), (9, 0, 7, 1) (for the 4th test case) acceptable?
– Lynn
46 mins ago




Is output like (8, 9, 6, 1), (9, 0, 7, 1) (for the 4th test case) acceptable?
– Lynn
46 mins ago












@Lynn yes, it is.
– Charlie
44 mins ago




@Lynn yes, it is.
– Charlie
44 mins ago










3 Answers
3






active

oldest

votes

















up vote
1
down vote














Python 3, 76 bytes





lambda s:(*map(k.find,s),)for k in['=!"·$%&/()',')!@#$%^&*(']if*s<=*k


Try it online!






share|improve this answer



























    up vote
    1
    down vote














    Java (JDK), 173 bytes



    Golfed





    c->s.contains("#")?e:e.contains("#")?s:s+","+e;


    Try it online!





    Ungolfed

    c->s.contains("#")?e: // If equal or Spanish is invalid return english
    e.contains("#")?s: // If English is invalid return Spanish
    s+","+e; // If both are valid but not equal, return both





    The Magic Hashing Lookup Array

    After some experimenting with values I realised that each of the ASCII values of the characters !"·$%&/()=@#^* modulo 16 returns a unique number. The 'magic hashing lookup array' stores the English numbers associated with each character at this unique index, and each of the Spanish numbers at this index offset by 16, making fetching the required number from the array trivial for each language. A hash is stored for values that are invalid for either language.






    share|improve this answer



























      up vote
      1
      down vote














      Jelly, 38 bytes



      183Ọ“=!"“$%&/()”j,“)!@#$%^&*(”iⱮ€⁸ẠƇ’Q


      Try it online!






      share|improve this answer






















      • Note that if the number is the same for both layouts you must return a single number, and not a list, as if you had identified the layout.
        – Charlie
        25 mins ago










      • @Charlie Whoops, fixed. :P
        – Erik the Outgolfer
        23 mins ago










      • Nice! Just one question, I have tried your code with () or (()) as input, but your code then return nothing. I suppose that's a limitation with what Jelly receives as input?
        – Charlie
        20 mins ago






      • 1




        @Charlie Try with '()' and '(())' respectively. Yes, if you don't quote the argument, it's only inputted as a string if it can't be evaluated to a Python 3 value.
        – Erik the Outgolfer
        20 mins ago











      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',
      convertImagesToLinks: false,
      noModals: false,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      bindNavPrevention: true,
      postfix: "",
      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%2f173942%2fwhat-numbers-are-these%23new-answer', 'question_page');

      );

      Post as a guest






























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes








      up vote
      1
      down vote














      Python 3, 76 bytes





      lambda s:(*map(k.find,s),)for k in['=!"·$%&/()',')!@#$%^&*(']if*s<=*k


      Try it online!






      share|improve this answer
























        up vote
        1
        down vote














        Python 3, 76 bytes





        lambda s:(*map(k.find,s),)for k in['=!"·$%&/()',')!@#$%^&*(']if*s<=*k


        Try it online!






        share|improve this answer






















          up vote
          1
          down vote










          up vote
          1
          down vote










          Python 3, 76 bytes





          lambda s:(*map(k.find,s),)for k in['=!"·$%&/()',')!@#$%^&*(']if*s<=*k


          Try it online!






          share|improve this answer













          Python 3, 76 bytes





          lambda s:(*map(k.find,s),)for k in['=!"·$%&/()',')!@#$%^&*(']if*s<=*k


          Try it online!







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 41 mins ago









          Lynn

          48.3k694223




          48.3k694223




















              up vote
              1
              down vote














              Java (JDK), 173 bytes



              Golfed





              c->s.contains("#")?e:e.contains("#")?s:s+","+e;


              Try it online!





              Ungolfed

              c->s.contains("#")?e: // If equal or Spanish is invalid return english
              e.contains("#")?s: // If English is invalid return Spanish
              s+","+e; // If both are valid but not equal, return both





              The Magic Hashing Lookup Array

              After some experimenting with values I realised that each of the ASCII values of the characters !"·$%&/()=@#^* modulo 16 returns a unique number. The 'magic hashing lookup array' stores the English numbers associated with each character at this unique index, and each of the Spanish numbers at this index offset by 16, making fetching the required number from the array trivial for each language. A hash is stored for values that are invalid for either language.






              share|improve this answer
























                up vote
                1
                down vote














                Java (JDK), 173 bytes



                Golfed





                c->s.contains("#")?e:e.contains("#")?s:s+","+e;


                Try it online!





                Ungolfed

                c->s.contains("#")?e: // If equal or Spanish is invalid return english
                e.contains("#")?s: // If English is invalid return Spanish
                s+","+e; // If both are valid but not equal, return both





                The Magic Hashing Lookup Array

                After some experimenting with values I realised that each of the ASCII values of the characters !"·$%&/()=@#^* modulo 16 returns a unique number. The 'magic hashing lookup array' stores the English numbers associated with each character at this unique index, and each of the Spanish numbers at this index offset by 16, making fetching the required number from the array trivial for each language. A hash is stored for values that are invalid for either language.






                share|improve this answer






















                  up vote
                  1
                  down vote










                  up vote
                  1
                  down vote










                  Java (JDK), 173 bytes



                  Golfed





                  c->s.contains("#")?e:e.contains("#")?s:s+","+e;


                  Try it online!





                  Ungolfed

                  c->s.contains("#")?e: // If equal or Spanish is invalid return english
                  e.contains("#")?s: // If English is invalid return Spanish
                  s+","+e; // If both are valid but not equal, return both





                  The Magic Hashing Lookup Array

                  After some experimenting with values I realised that each of the ASCII values of the characters !"·$%&/()=@#^* modulo 16 returns a unique number. The 'magic hashing lookup array' stores the English numbers associated with each character at this unique index, and each of the Spanish numbers at this index offset by 16, making fetching the required number from the array trivial for each language. A hash is stored for values that are invalid for either language.






                  share|improve this answer













                  Java (JDK), 173 bytes



                  Golfed





                  c->s.contains("#")?e:e.contains("#")?s:s+","+e;


                  Try it online!





                  Ungolfed

                  c->s.contains("#")?e: // If equal or Spanish is invalid return english
                  e.contains("#")?s: // If English is invalid return Spanish
                  s+","+e; // If both are valid but not equal, return both





                  The Magic Hashing Lookup Array

                  After some experimenting with values I realised that each of the ASCII values of the characters !"·$%&/()=@#^* modulo 16 returns a unique number. The 'magic hashing lookup array' stores the English numbers associated with each character at this unique index, and each of the Spanish numbers at this index offset by 16, making fetching the required number from the array trivial for each language. A hash is stored for values that are invalid for either language.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered 36 mins ago









                  Luke Stevens

                  639214




                  639214




















                      up vote
                      1
                      down vote














                      Jelly, 38 bytes



                      183Ọ“=!"“$%&/()”j,“)!@#$%^&*(”iⱮ€⁸ẠƇ’Q


                      Try it online!






                      share|improve this answer






















                      • Note that if the number is the same for both layouts you must return a single number, and not a list, as if you had identified the layout.
                        – Charlie
                        25 mins ago










                      • @Charlie Whoops, fixed. :P
                        – Erik the Outgolfer
                        23 mins ago










                      • Nice! Just one question, I have tried your code with () or (()) as input, but your code then return nothing. I suppose that's a limitation with what Jelly receives as input?
                        – Charlie
                        20 mins ago






                      • 1




                        @Charlie Try with '()' and '(())' respectively. Yes, if you don't quote the argument, it's only inputted as a string if it can't be evaluated to a Python 3 value.
                        – Erik the Outgolfer
                        20 mins ago















                      up vote
                      1
                      down vote














                      Jelly, 38 bytes



                      183Ọ“=!"“$%&/()”j,“)!@#$%^&*(”iⱮ€⁸ẠƇ’Q


                      Try it online!






                      share|improve this answer






















                      • Note that if the number is the same for both layouts you must return a single number, and not a list, as if you had identified the layout.
                        – Charlie
                        25 mins ago










                      • @Charlie Whoops, fixed. :P
                        – Erik the Outgolfer
                        23 mins ago










                      • Nice! Just one question, I have tried your code with () or (()) as input, but your code then return nothing. I suppose that's a limitation with what Jelly receives as input?
                        – Charlie
                        20 mins ago






                      • 1




                        @Charlie Try with '()' and '(())' respectively. Yes, if you don't quote the argument, it's only inputted as a string if it can't be evaluated to a Python 3 value.
                        – Erik the Outgolfer
                        20 mins ago













                      up vote
                      1
                      down vote










                      up vote
                      1
                      down vote










                      Jelly, 38 bytes



                      183Ọ“=!"“$%&/()”j,“)!@#$%^&*(”iⱮ€⁸ẠƇ’Q


                      Try it online!






                      share|improve this answer















                      Jelly, 38 bytes



                      183Ọ“=!"“$%&/()”j,“)!@#$%^&*(”iⱮ€⁸ẠƇ’Q


                      Try it online!







                      share|improve this answer














                      share|improve this answer



                      share|improve this answer








                      edited 23 mins ago

























                      answered 45 mins ago









                      Erik the Outgolfer

                      29.8k42899




                      29.8k42899











                      • Note that if the number is the same for both layouts you must return a single number, and not a list, as if you had identified the layout.
                        – Charlie
                        25 mins ago










                      • @Charlie Whoops, fixed. :P
                        – Erik the Outgolfer
                        23 mins ago










                      • Nice! Just one question, I have tried your code with () or (()) as input, but your code then return nothing. I suppose that's a limitation with what Jelly receives as input?
                        – Charlie
                        20 mins ago






                      • 1




                        @Charlie Try with '()' and '(())' respectively. Yes, if you don't quote the argument, it's only inputted as a string if it can't be evaluated to a Python 3 value.
                        – Erik the Outgolfer
                        20 mins ago

















                      • Note that if the number is the same for both layouts you must return a single number, and not a list, as if you had identified the layout.
                        – Charlie
                        25 mins ago










                      • @Charlie Whoops, fixed. :P
                        – Erik the Outgolfer
                        23 mins ago










                      • Nice! Just one question, I have tried your code with () or (()) as input, but your code then return nothing. I suppose that's a limitation with what Jelly receives as input?
                        – Charlie
                        20 mins ago






                      • 1




                        @Charlie Try with '()' and '(())' respectively. Yes, if you don't quote the argument, it's only inputted as a string if it can't be evaluated to a Python 3 value.
                        – Erik the Outgolfer
                        20 mins ago
















                      Note that if the number is the same for both layouts you must return a single number, and not a list, as if you had identified the layout.
                      – Charlie
                      25 mins ago




                      Note that if the number is the same for both layouts you must return a single number, and not a list, as if you had identified the layout.
                      – Charlie
                      25 mins ago












                      @Charlie Whoops, fixed. :P
                      – Erik the Outgolfer
                      23 mins ago




                      @Charlie Whoops, fixed. :P
                      – Erik the Outgolfer
                      23 mins ago












                      Nice! Just one question, I have tried your code with () or (()) as input, but your code then return nothing. I suppose that's a limitation with what Jelly receives as input?
                      – Charlie
                      20 mins ago




                      Nice! Just one question, I have tried your code with () or (()) as input, but your code then return nothing. I suppose that's a limitation with what Jelly receives as input?
                      – Charlie
                      20 mins ago




                      1




                      1




                      @Charlie Try with '()' and '(())' respectively. Yes, if you don't quote the argument, it's only inputted as a string if it can't be evaluated to a Python 3 value.
                      – Erik the Outgolfer
                      20 mins ago





                      @Charlie Try with '()' and '(())' respectively. Yes, if you don't quote the argument, it's only inputted as a string if it can't be evaluated to a Python 3 value.
                      – Erik the Outgolfer
                      20 mins ago


















                       

                      draft saved


                      draft discarded















































                       


                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f173942%2fwhat-numbers-are-these%23new-answer', 'question_page');

                      );

                      Post as a guest













































































                      Comments

                      Popular posts from this blog

                      What does second last employer means? [closed]

                      Installing NextGIS Connect into QGIS 3?

                      One-line joke