-1
\$\begingroup\$

This question already has an answer here:

Your task is to create a program will transform each letter of a text typed on a AZERTY keyboard to the equivalent on a QWERTY keyboard, using the same keystrokes.

Example: Hello; Zorld1 => Hello, World!

List of character to convert:

  • A <=> Q
  • Z <=> W
  • , => m
  • ? => M
  • M => :
  • 1 => !
  • 9 => (
  • ; => ,
  • § => ?
  • 0 => )
  • ) => -
  • ù => '

QWERTY keyboard: QWERTY keyboard

AZERTY keyboard: enter image description here

Test cases:

Input: This is q text zritten zith q QWERTY keyboqrd:
Output: This is a text written with a AZERTY keyboard.

Input: Hello zorld in PythonM print9ùHello; Zorld1ù0
Output: Hello world in Python: print('Hello, World!')

Input: Zikipediq is q free online enciclopediq
Output: Wikipedia is a free online enciclopedia

Input: Progrq,,ing puwwles qnd code)golf
Output: Programming puzzles and code-golf

Input: Zhy ,y lqyout hqve szitched to QWERTY §
Output: Why my layout have switched to AZERTY ?

This is code golf, so the answer with the shortest byte count win.

\$\endgroup\$

marked as duplicate by Peter Taylor code-golf Jun 28 '16 at 20:55

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 3
    \$\begingroup\$ Could you please explicitly list which character should be replaced by which? \$\endgroup\$ – flawr Jun 28 '16 at 19:06
  • \$\begingroup\$ @flawr Every character, i'll add this \$\endgroup\$ – TuxCrafting Jun 28 '16 at 19:07
  • 3
    \$\begingroup\$ He means an explicit list. Like, A => Q, W => Z, etc. \$\endgroup\$ – Conor O'Brien Jun 28 '16 at 19:09
  • 2
    \$\begingroup\$ @TùxCräftîñg Can you please add that list? \$\endgroup\$ – flawr Jun 28 '16 at 19:34
  • 2
    \$\begingroup\$ @EʀɪᴋᴛʜᴇGᴏʟғᴇʀ it would seem that valid answers to that challenge would work for this one with minor changes then. So I would agree that it is a dupe. HOWEVER, the other challenge has a lot of restrictions that this one does not. One might argue that this challenge is open to entries from more languages which would be in favor of reopening. \$\endgroup\$ – Liam Jul 1 '16 at 15:41
7
\$\begingroup\$

Python 3, 70 132 bytes

My first try in code-golfing, so please be kind :) :

print(input().translate(str.maketrans('azqwAZQW&é"\'(-è_çà)^$Mù,?;:!§1234567890','qwazQWAZ1234567890-[]:\'mM,./?!@#$%^&*()')))

Try it online!

\$\endgroup\$
  • 1
    \$\begingroup\$ ; is converted to m, and numbers should also be handled. Oh and put your code in a code element (`code`), not a blockquote ;) \$\endgroup\$ – TuxCrafting Jun 28 '16 at 19:24
  • \$\begingroup\$ Should be better now :). \$\endgroup\$ – DimP Jun 28 '16 at 19:53
  • \$\begingroup\$ you can prolly save with a lambda instead of print/input. \$\endgroup\$ – Maltysen Jun 28 '16 at 19:54
  • \$\begingroup\$ ValueError: the first two maketrans arguments must have equal length \$\endgroup\$ – TuxCrafting Jun 28 '16 at 19:55
  • \$\begingroup\$ No such error on my local installation. I have just added a 'try it online' link. \$\endgroup\$ – DimP Jun 28 '16 at 20:06

Not the answer you're looking for? Browse other questions tagged or ask your own question.