12
\$\begingroup\$

Your task is to make a program that will take an input of a word of any length, in the Calibri font. This word will be made out of letter characters that are found on a normal QWERTY keyboard. There will be no accents or any other characters (i.e punctuation, numbers etc).

So, the original characters are:

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

The program will then scramble it to change the characters so they look similar or exactly the same, which would probably confuse a spell checker by flagging it, but it would confuse me as it looks the same as the normal word, with the unchanged character.

An example of this is the Unicode character U+0430, Cyrillic small letter a ("а"), can look identical to Unicode character U+0061, Latin small letter a, ("a") which is the lowercase "a" used in English.

Another example is the Russian letters а, с, е, о, р, х and у have optical counterparts in the basic Latin alphabet and look close or identical to a, c, e, o, p, x and y.

Rules:

  1. The program has to work out similar characters. This means that they cannot be stored in any form. This means that Unicode value or the character itself.
  2. This is a code golf - the shortest answer wins!
  3. You have to post the ungolfed version too to avoid cheating that can't be detected when its golfed!
  4. You can use any function or program to do this, as long as words are not stored there either.
  5. You must use UTF-8. Other inputs and outputs are banned. This is so that I am actually able to read what you are outputting, and what I am inputting, so I do not have a random mass of squares, question marks and ❮ther rand❮m punctuati❮n!
  6. It has to work with any word that I input.

A working example (Copy and paste this into word and insert a space after, it should flag the second one and not the first one.)

Halim 
Hаlim  

Some helpful info is here

Good Luck! Begin

\$\endgroup\$
  • 1
    \$\begingroup\$ I think this is a great candidate for code-golf instead of popularity-contest. \$\endgroup\$ – ProgrammerDan Apr 1 '14 at 17:23
  • \$\begingroup\$ @ProgrammerDan the question with this as code-golf is, how many characters have to be replaced and how dissimilar are they allowed to look for an answer to be valid? \$\endgroup\$ – Martin Ender Apr 1 '14 at 17:58
  • 1
    \$\begingroup\$ In either case, a definition of "confuse the spell checker" would be nice. Which spell checker? Also, what is our input alphabet? Output alphabet? I recommend that you specify a popular online spell checking tool, and specify an encoding, such as UTF-8. \$\endgroup\$ – Rainbolt Apr 1 '14 at 18:03
  • \$\begingroup\$ I've taken your comments on board and changed a few things - thanks for the advice :) \$\endgroup\$ – George Apr 1 '14 at 18:11
  • \$\begingroup\$ This would have been a great April Fools' prank if I had asked this a few days ago! \$\endgroup\$ – George Apr 1 '14 at 18:52
12
\$\begingroup\$

JavaScript, 71 characters

function f(s){return "\u202E"+s.split("").reverse().join("")+"\u202C";}

Try it out on JSFiddle.

By the way, this would be a good bit shorter in CoffeeScript (53 characters)

f=(s)->"\u202E#{s.split('').reverse().join ''}\u202C"

EDIT: I just noticed that UTF-8 requirement. That's going to be tough in JavaScript. :-/

\$\endgroup\$
  • \$\begingroup\$ Don't downvote this answer - its a good one, but it was posted before the rules changed slightly. You also have to input a word and it cant just be hardcoded in. Sorry. \$\endgroup\$ – George Apr 1 '14 at 18:44
  • \$\begingroup\$ @GeorgeH well the function takes any arbitrary text (not just single words). It's just the JSFiddle that showcases the usage with one specific example. \$\endgroup\$ – Martin Ender Apr 1 '14 at 18:45
  • 1
    \$\begingroup\$ Oh, Sorry, I've never used JSFiddle before! Its really confused Word now - It thinks George is Egret and other stuff! \$\endgroup\$ – George Apr 1 '14 at 18:48
  • 5
    \$\begingroup\$ Hmm... I randomly picked some words to test your function but it doesn't work... The words I picked were level, rotor, racecar, refer and kayak. \$\endgroup\$ – ace Apr 1 '14 at 20:31
  • 1
    \$\begingroup\$ @ace Touché. :P \$\endgroup\$ – Martin Ender Apr 1 '14 at 20:35
9
\$\begingroup\$

Python3 - 51

print(''.join(chr(ord(c)+0xFEE0)for c in input()))

The lazy way!

Slightly ungolfed

r=''
for c in input():
    r += chr(ord(c) - 0x20 + 0xFF00) # convert to fullwidth ASCII range
print(r)
\$\endgroup\$
  • \$\begingroup\$ Please can you post an ungolfed version? Thanks! \$\endgroup\$ – George Apr 2 '14 at 21:28
  • \$\begingroup\$ Done, it should be self explaining :) \$\endgroup\$ – LemonBoy Apr 2 '14 at 21:38
  • \$\begingroup\$ If you use it in IDLE you can remove the print() - it'll print it out anyway \$\endgroup\$ – chill0r Jun 14 '14 at 16:35
  • \$\begingroup\$ You can save one byte by changing the hexadecimal number FEE0 to a decimal number (65248). \$\endgroup\$ – 0WJYxW9FMN Apr 3 '17 at 8:59
8
\$\begingroup\$

Common Lisp, 142

I have no font named Calibri, and most of my fonts lack these symbols, but DejaVu Sans has them. I replace letters with Mathematical Alphanumeric Symbols. The spell checker does not flag any errors. Instead, it fails to detect errors, even if words have obvious typos.

Golfed:

(ignore-errors(do(c)(())(setf c(char-code (read-char)))(write-char(code-char(cond((< 64 c 91)(+ c 120159))((< 96 c 123)(+ c 120153))(t c))))))

Ungolfed:

(ignore-errors      ; Ignore when (read-char) signals end of file.
  (do (c) (())      ; Loop forever with variable c.
    (setf c (char-code (read-char)))
    (write-char
     (code-char
      (cond
         ;; Replace A to Z with U+1D5A0 to U+1D5B9.
         ((< 64 c 91) (+ c 120159))
         ;; Replace a to z with U+1D5BA to U+1D5D3.
         ((< 96 c 123) (+ c 120153))
         ;; Keep other characters.
         (t c))))))

Usage

  • clisp asconfuse.lisp <in >out
  • ecl -shell asconfuse.lisp <in >out
  • sbcl --script asconfuse.lisp <in >out

I assume that your Lisp interpreter has Unicode support and your locale is UTF-8. Do not use abcl, because it has problems outside the Basic Multilingual Plane.

Unix clones: You can run locale in a terminal. If the line for LC_CTYPE does not mention UTF-8, try export LC_CTYPE=en_US.UTF-8.

Example

I pasted some output into LibreOffice. My text has obvious spelling errors, but LibreOffice fails to detect them. It draws no red squiggles under the words, and the spell-check button only reports, "The spellcheck is complete."

LibreOffice

The text is, "𝖭𝗈𝗐𝗐 𝗂𝗓 𝗍𝖾𝗁 𝗍𝗍𝗂𝗆𝖾 𝖿𝗈𝗈𝗋 𝖺𝗁𝗅 𝗀𝗎𝖽 𝗇𝖾𝗆 𝗍𝗍𝗈 𝖼𝗈𝖾𝗆 𝗍𝗍𝗈 𝗍𝖾𝗁 𝖺𝖾𝖽 𝗈𝗏 𝗍𝖾𝗋𝖾 𝖼𝗈𝗎𝗇𝗍𝗋𝖾𝖾." Firefox also finds no spelling errors in this text.

\$\endgroup\$
5
\$\begingroup\$

Dyalog APL, 7 chars

∊''∘,¨

There is a U+FEFF (Zero Width No-Break Space, a.k.a Unicode BOM) between the quotes. This character occurs in in the Calibri font. The character '' is prepended , to each ¨ character in the argument, and the whole thing is then flattened .

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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