text:
Naming ionic compounds
An ionic compound is named like so: (metal name) (non-metal suffixed with -ide). Here is a list of all the suffixes that need to be replaced with -ide:
-on -ogen -ygen -ine -orus -ur -ic -ium

The number of atoms of each element in the compound is not used in naming ionic compounds. Ignore the multivalent metal naming rules.
NaCl -> sodium + chlorine -> sodium chloride.
K2S -> potassium + sulphur -> potassium sulphide (or sulfide).
Yb2P3 -> ytterbium + phosphorus -> ytterbium phosphide.
PbTe2 -> lead + tellurium -> lead telluride.

A string containing an ionic compound (NaCl, K2S, Yb2P3) will be given as input. No polyatomic ions will be given. The program has to output the name of this compound.
Since nobody wants to compile the periodic table data themselves, here is a paste that has the names, symbols, and whether or not it is a metal of each element, in this order: (name) (symbol) (is metal?). You can save this to an external file (the length of the file will not be counted), or you can store the data within your program (just discount the length of that string from there.) You may not need all the information provided. Every element is seperated by a newline.
As always with code golf challenges, shortest code wins.

Does "Ignore the naming rules for multivalent metals" mean it is OK to omit the "(II)" in "copper(II) chloride"?

The specification and the examples contradict. Following the spec, the names would be sodium chloride, potassium sulide, ytterbium phosphoride and lead telluriide.

Also, you haven't specified the input format.

@PleaseStand: Yes

@PeterTaylor: :X I will fix that

These aren't even the correct rules for naming ionic compounds! My chemistry teacher would never approve.

@PhiNotPi: D: I was afraid I had it wrong/poorly explained! What is wrong about the rules (excluding multivalent metal names)?

Well, your question seems to be limited to ionic compounds that contain two atoms, but you didn't specify that.  Ionic compounds are made of two unique types of ion, in a ratio that makes the compound neutral. These ions can have one atom each, or they can be (and often are) polyatomic ions. If you mix the ammonium ion (NH4 +) with the sulfate ion (SO4 2-), you get ammonium sulfate ((NH4)2SO4).
I guess my main point is that you are forgetting about an entire class of ionic compounds, even when excluding multivalent metal names.

@PhiNotPi: Ah, that's what else I forgot to exclude :P Sorry about that.

Ruby, 114
f,s=$*[0].split /\d*(?=[A-Z]|\Z)/
puts (n=Hash[*<<X.split-%w[0 1]].invert)[f]+" "+n[s].sub(/(i..|.gen|..)\Z/,"ide")
Hydrogen H 0
Helium He 0
Lithium Li 1
Beryllium Be 1
Boron B 0
Carbon C 0
Nitrogen N 0
Oxygen O 0
Fluorine F 0
Neon Ne 0
Sodium Na 1
Magnesium Mg 1
Aluminium Al 1
Silicon Si 0
Phosphorus P 0
Sulfur S 0
Chlorine Cl 0
Argon Ar 0
Potassium K 1
Calcium Ca 1
Scandium Sc 1
Titanium Ti 1
Vanadium V 1
Chromium Cr 1
Manganese Mn 1
Iron Fe 1
Cobalt Co 1
Nickel Ni 1
Copper Cu 1
Zinc Zn 1
Gallium Ga 1
Germanium Ge 1
Arsenic As 0
Selenium Se 0
Bromine Br 0
Krypton Kr 0
Rubidium Rb 1
X

Uses a paste of the element text that I haven't counted in the score. I remove the metal tag (since I'm assuming the compounds are always given with the metal first, so I don't actually need it) and build a dictionary with it. I identify the part to replace with "ide" by checking the end of the string for three letters starting with i, four letters ending with gen, or otherwise just the last two characters.

What does it make of chlorine and phosphorus for example?

NaCl => Sodium Chloride (meets spec).
Yb2P3 => Ytterbium Phosphoride (doesn't meet current spec).  It also renders Nitrogen as Nitrogide rather than Nitride.  Now that the "syllable" part of the spec is gone, I'll probably have to steal your hardcoded list.

Okay, should meet the spec again.

Python, 134 Characters.
#T is a string containing the provided information on the elements
from re import*
print sub('(orus|[oy]ge|i?..)$','ide',' '.join(split(r'(\w+) %s '%e,T)[1]for e in findall('[A-Z][a-z]?',raw_input())))

T = """Hydrogen H 0
Helium He 0
Lithium Li 1
Beryllium Be 1
Boron B 0
Carbon C 0
Nitrogen N 0
Oxygen O 0
Fluorine F 0
Neon Ne 0
Sodium Na 1
Magnesium Mg 1
Aluminium Al 1
Silicon Si 0
Phosphorus P 0
Sulfur S 0
Chlorine Cl 0
Argon Ar 0
Potassium K 1
Calcium Ca 1
Scandium Sc 1
Titanium Ti 1
Vanadium V 1
Chromium Cr 1
Manganese Mn 1
Iron Fe 1
Cobalt Co 1
Nickel Ni 1
Copper Cu 1
Zinc Zn 1
Gallium Ga 1
Germanium Ge 1
Arsenic As 0
Selenium Se 0
Bromine Br 0
Krypton Kr 0
Rubidium Rb 1
Strontium Sr 1
Yttrium Y 1
Zirconium Zr 1
Niobium Nb  1
Molybdenum Mo 1
Technetium Tc 1
Ruthenium Ru 1
Rhodium Rh 1
Palladium Pd 1
Silver Ag 1
Cadmium Cd 1
Indium In 1
Tin Sn 1
Antimony Sb 1
Tellurium Te 0
Iodine I 0
Xenon Xe 0
Cesium Cs 1
Barium Ba 1
Lanthanum La 1
Cerium Ce 1
Praseodymium Pr 1
Neodymium Nd 1
Promethium Pm 1
Samarium Sm 1
Europium Eu 1
Gadolinium Gd 1
Terbium Tb 1
Dysprosium Dy 1
Holmium Ho 1
Erbium Er 1
Thulium Tm 1
Ytterbium Yb 1
Lutetium Lu 1
Hafnium Hf 1
Tantalum Ta 1
Tungsten W 1
Rhenium Re 1
Osmium Os 1
Iridium Ir 1
Platinum Pt 1
Gold Au 1
Mercury Hg 1
Thallium Tl 1
Lead Pb 1
Bismuth Bi 1
Polonium Po 1
Astatine At 0
Radon Rn 0
Francium Fr 1
Radium Ra 1
Actinium Ac 1
Thorium Th 1
Protactinium Pa 1
Uranium U 1
Neptunium Np 1
Plutonium Pu 1
Americium Am 1
Curium Cm 1
Berkelium Bk 1
Californium Cf 1
Einsteinium Es 1
Fermium Fm 1
Mendelevium Md 1
Nobelium No 1
Lawrencium Lr 1
Rutherfordium Rf 1
Dubnium Db 1
Seaborgium Sg 1
Bohrium Bh 1
Hassium Hs 1
Meitnerium Mt 1
Darmstadtium Ds 1
Roentgenium Rg 1
Copernicium Cp 1
Ununtrium Uut 0
Flerovium Fl 0
Ununpentium Uup 0
Livermorium Lv 0
Ununseptium Uus 0
Ununoctium Uuo 0"""

Mathematica 252 267 254
Code
ElementData[] contains information about the elements; it is native to Mathematica.
d=ElementData; a=Reverse@SortBy[d[#,"Abbreviation"]&/@d[],StringLength[#]&];
g[e_]:=Row[{e," \[RightArrow] ", p=Row[z=(d[#,"StandardName"] &/@StringCases[e,a]),
  " + " ] , " \[RightArrow] ",p[[1,1]]<> " "<>StringReplace[p[[1,2]],
  f__~~z:"on"|"ogen"|"ygen"|"ine"|"orus"|"ur"|"ic"|"ium":> f~~"ide"] }]

Examples
g["NaCl"]
g["K2S"]
g["Yb2P3"]
g["PbTe2"]

Explanation
The code removes digits from the compound, then separates the elements by their abbreviated names.  It then converts the abbreviations to the standard names of elements.  Finally, it replaces the non-metal by the term with the correct suffix.

You don't need the multivalent metals in the output for PbTe2, lead telluride will suffice.

APL 142 150
If I am allowed to store the element names and symbols in a pair of nested arrays within the APL workspace then the following code should do it:
(e[s⍳c[1]]),((∊¯1×((+/¨⍳¨i)=+/¨(¯1×i)↑¨t⍳¨⊂n)/i←⍴¨t←'ic' 'on' 'ur' 'ine' 'ium' 'ogen' 'ygen' 'orus')↓n←∊e[s⍳(c←(98>⎕av⍳c)⎕penclose c←⍞~⍕⍳9)[2]]),'ide'

It works roughly as follows:
c←(98>⎕av⍳c)⎕penclose c←⍞~⍕⍳9

Takes the input from the screen via ⍞ and splits the chemical name into symbols and discards any numbers
e[s⍳c[1]]
Looks up the first element name from its symbol. Similarly for c[2]
(∊¯1×((+/¨⍳¨i)=+/¨(¯1×i)↑¨t⍳¨⊂n)/i←⍴¨t←'ic' 'on' 'ur' 'ine' 'ium' 'ogen' 'ygen' 'orus')↓n

Identifies which of the eight possible endings the non-metal has and drops it and then replaces it with ide via:
,'ide'

There is no error trapping so only works for valid compounds dictated via the one or zero identifier in the list of elements provided.

does oxygen -> oxide or hydrogen -> hydride work?

@beary605. They didn't but they do now - thanks.


text:
Shortest 8-bit xor cipher
8-bit XOR encryption takes a single byte and XORs every byte in the file by that byte. Here is a reference program in C++:
/*xorcipher.cpp
 *Encrypts a file using 8-bit xor encrytpion
 */

#include <iostream>
#include <fstream>
#include <stdlib.h>
using namespace std;

int main(int argc, char** argv){
   ifstream* in = NULL;
   ofstream* out = NULL;

   if(argc < 3){
      cerr << "Usage: xor <key> <filename...>" << endl;
      exit(1);
   }

   int key = atoi(argv[1]);

   for(int x = 2; x < argc; x++){
      in = new ifstream(argv[x], ios::binary);
      if(!in->good()){
         cerr << "Error reading from " << argv[x] << endl;
         exit(1);
      }

      //Get file size
      in->seekg(0, ios::end);
      int size = in->tellg();
      in->seekg(0, ios::beg);

      //Allocate memory
      int* data = new int[size];

      int c = 0;
      for(int y = 0; (c = in->get()) != EOF; y++)
         data[y] = c ^ key;

      in->close();
      delete in;
      in = NULL;

      out = new ofstream(argv[x], ios::binary);
      if(!out->good()){
         cerr << "Error writing to " << argv[x] << endl;
         exit(1);
      }

      for(int y = 0; y < size; y++)
         out->put(data[y]);

      out->flush();
      out->close();
      delete out;
      out = NULL;

      delete[] data;
      data = NULL;
   }
   cout << "Operation complete" << endl;

   return 0;
}

The shortest answer (whitespace doesn't count) that produces the same end result will be selected. It does not have to store everything in memory at once or open and close every file multiple times. It can do anything as long as a file encrypted with the reference program can be decrypted with the answer, and vice versa.

Edit: The above program is not a specification. The only requirement is that answers should be able to decrypt a file encrypted with the above program, and the above program should be able to decrypt a file encrypted with the answer. I'm sorry if that was unclear.
The above program can be compiled with:
g++ xorcipher.cpp -o ~/bin/xor

It can be run like this:
xor <key> <filename...>

For example, if the key is 42 and the file is alpha.txt, you would use:
xor 42 alpha.txt

A 10-line specification which gives acceptance criteria is a lot more useful than a 60-line program in a language which not everyone knows.

You know that saying 'whitespace doesn't count' means there's going to be a 0-character solution in Whitespace, right?

Are alternate input formats, like streaming in the data, allowed?

Yeah, it would be real nice if this didn't have the requirement for file I/O...

PHP 40 38 bytes
<?for(;;)echo@~fgetc(STDIN)^~$argv[1];

And updated version. Now handles all inputs correctly, and 2 bytes shorter as well.
Sample usage:
$ more in.dat
This is a test.
This is only a test.

$ php xor-cipher.php A < in.dat > out.dat

$ more out.dat
§)(2a(2a a5$25oK§)(2a(2a./-8a a5$25o

$ php xor-cipher.php A < out.dat
This is a test.
This is only a test.

Perl 30 bytes
$k=pop;s/./print$&^$k/egsfor<>

I/O is the same as for the PHP solution above.

Does it work if the output contains a zero character? (e.g. encrypt This is a test with the key T)?

The Perl solution will work for all cases. The PHP will terminate prematurely if the generated character becomes a 0 (not character 0, literally a 0). I'll update my answer.

Brainfuck - 269
,>,[<[>>+>+<<<-]>>>[<<<+>>>-]>>>++++++++[-<<<<<[->>+<<[->>->+<]>>[->>>
>+<<]<<<<]>>>[-<<<+>>>]<<[->+<[->->+>>>>>]>[->>>>>+>>]<<<<<<<<]>>[-<<+
>>]>>>[->>+<<]>[>[-<->]<[->+<]]>[[-]<<<[->+>-<<]>[-<+>]+>+++++++[-<[->
>++<<]>>[-<<+>>]<]<[->>>>+<<<<]>>]<<<]>>>>>.[-]<<<<<<<<<<,]

C, 61 59 bytes
Quite simple, and very similar to primo's solution.
First parameter is the key, in decimal, reads stdin, writes stdout.
The only tricky part is using ~getchar, so EOF becomes 0 and terminates the loop, then printing c^~key, where the additional ~ undoes the previous one.
main(c,v)int*v;{
    while(c=~getchar())putchar(c^~atoi(v[1]));
}

I like the bit inversion trick. Would ~c=getchar() also work (thereby saving the second inversion)?

@primo, ~(c=getchar()) works, but the parentheses are needed. The second inversion saves them.

The Powder Toy, 598 bytes, 8 particles
Only 8 particles and O(n) speed. :) (This is unsurprisingly difficult in TPT for most tasks unless you know subframe really well; I do not.)
This creation takes input at a rate of 8 bits per frame, with a 8 bit word size. If you input the xor byte 3 times at once (24bit), then you can process 3 bytes of the stream per frame.
Reversible xxd dump:
00000000: 4f50 5331 5d04 9960 151d 0c00 425a 6839  OPS1]..`....BZh9
00000010: 3141 5926 5359 5cdf 0ea9 006c 37ff ffff  1AY&SY\....l7...
00000020: f553 0252 11d7 423f 27df b6bf f7df e340  .S.R..B?'......@
00000030: 0200 4000 0400 1050 0008 0000 2002 0840  ..@....P.... ..@
00000040: 01fc 69b5 3508 44d1 0068 0034 1ea0 6800  ..i.5.D..h.4..h.
00000050: 0d03 4034 6800 000d 0814 d4fd 2626 4c89  ..@4h.......&&L.
00000060: a68d 0190 0000 d343 4069 9003 4d03 8686  .......C@i..M...
00000070: 4d34 34c8 d0d3 2320 c8c8 d0c8 0c4d 1934  M44...# .....M.4
00000080: 0193 2310 c244 9232 86a6 327a 4191 a260  ..#..D.2..2zA..`
00000090: 0046 2604 6260 8600 d263 4dbb b2e2 d1e3  .F&.b`...cM.....
000000a0: 21f5 cd39 7920 2062 4360 0924 1e6c 4021  !..9y  bC`.$.l@!
000000b0: 2224 22bb f2b3 9fbd 77d2 c6ad dc4e 4b3c  "$".....w....NK<
000000c0: 9fac 12d3 9ad6 6cae 6940 2409 08b2 9961  ......l.i@$....a
000000d0: a30e 9a64 b599 68b6 e10a 87ac c869 64a6  ...d..h......id.
000000e0: 6977 e649 2102 4227 62ce 6214 0641 cc41  iw.I!.B'b.b..A.A
000000f0: b575 205e 255c 520c 4603 15cc a222 4325  .u ^%\R.F...."C%
00000100: 1df7 2106 df63 c319 3bfd d191 25a8 0020  ..!..c..;...%..
00000110: 0484 3ab5 62ab ef4d 0902 4236 d9d3 eb8d  ..:.b..M..B6....
00000120: 23f1 3ee4 8113 30c0 6435 d122 2572 033d  #.>...0.d5."%r.=
00000130: 9edb f17a ac03 636c 60c0 82b9 1226 125c  ...z..cl`....&.\
00000140: 20c0 8855 972a ac26 833a 8466 8143 208a   ..U.*.&.:.f.C .
00000150: 4c9d 811d 9ec1 d800 356e ad3f 9b51 e0a0  L.......5n.?.Q..
00000160: 8a96 54ff 891d c761 71c3 3618 5844 f4f2  ..T....aq.6.XD..
00000170: 5453 ac54 d94a b86d 8261 11c9 3b70 4222  TS.T.J.m.a..;pB"
00000180: 9bfb 2445 4443 f202 f004 5b14 e01d 1696  ..$EDC....[.....
00000190: e06d 7348 e262 981e 847f 9e4d ba42 9040  .msH.b.....M.B.@
000001a0: d740 45b1 8fd9 7a62 20b8 7850 a40b a2a1  .@E...zb .xP....
000001b0: 34a5 a790 c2ab 8af3 2bec d254 9b50 c39e  4.......+..T.P..
000001c0: 1b74 9ec7 3627 63b2 f9da f832 09a4 9406  .t..6'c....2....
000001d0: 135c 78e3 0a29 a9ac 991a 44da a6d9 e38c  .\x..)....D.....
000001e0: 4886 f6db 9a65 3ce9 bd32 b3a9 8522 a053  H....e<..2...".S
000001f0: 5ee2 a930 527b 8dd6 f7b5 b5a9 15d7 b771  ^..0R{.........q
00000200: 8d2f bace a196 d95b f48c a895 05a1 0402  ./.....[........
00000210: c2c3 48cc 8e90 3567 0b0c acab 0eb2 1ce2  ..H...5g........
00000220: 80e9 40e7 1432 82fe b141 4412 b86b e551  ..@..2...AD..k.Q
00000230: 33bf 6160 a733 e306 cca3 5479 bf93 9a21  3.a`.3....Ty...!
00000240: 8921 0024 2342 f402 4090 8f91 7724 5385  .!.$#B..@...w$S.
00000250: 0905 cdf0 ea90

I/O
This creation takes the byte to XOR data by in particle #0, and the data stream at particle #4. Output is given by any particle at X 501. Once the stream is over it decodes the last byte(s) forever.
The XOR byte must have the 30th bit set, and the data byte must NOT have the 30th bit set. This is due to the fact that a input of 0 will cause no output if this is not done in this manner (TPT filt logic restriction, cannot be worked around)
What does it look like?
[TODO]
How does it work?
[Also TODO. Sorry.]

Looking forward to seeing a visualization of this code in action.

@JonathanFrech Sorry to disappoint you, it's not the most intresting thing ever. FILT has a builtin XOR. Most of the particles are overhead for shooting rays.

Hm. Would still be cool to see it in action ...

Python, 78 chars
from sys import argv as v

print ''.join(chr(ord(v[1])^ord(i)) for i in open(v[2]).read())

Must be run like:
python solution.py <key> <input_file> > <output_file>

Where solution.py is the python file that contains the above code, key is the single byte to XOR, input_file is the file to be encrypted and output_file will contain the decrypted output.
I am not sure if it matches your solution (as per "...that produces the same end result will be selected") since your example doesn't seem to produce output. However, it does successfully decrypt an encrypted file with the same key byte.
Since whitespace doesn't count, I used the following code to count chars:
>>> with open('solution.py') as f:
...     text = f.read()
...
>>> len(text) - text.count('\n') - text.count(' ') # There are no tabs in this code
78

Python 75
import sys
for j in sys.stdin:print''.join(chr(int(sys.argv[1])^ord(i))for i in j),

The hardest requirement was not to keep the whole file in memory.
Usage:
python xor.py 123 <file.in >file.out

I only said it didn't have to keep the file in memory. This means it could.

GolfScript, 16 characters
"#{$*}"~{^}+%:n;

Usage is as given above - the key (numeric) passed as parameter while input/output is through console:
golfscript.rb xor.gs 42 <in.txt >out.txt

Edit: The issues with the trailing newline are now solved.

Postscript 101 67
(]){exch def}def
ARGUMENTS aload pop(w)file/O](r)file/I]cvi/K]{O I read not{exit}if K xor write}loop

The 67 byte version is equivalent to the above with all executable system names replaced by binary tokens. It is produced as output by this program (which shows a hex representation).
(xorb.ps)(w)file
<
    285D297B923E92337D9233
    415247554D454E54539202927528772992412F4F5D
    28722992412F495D922C2F4B5D
    7B4F2049927B92707B92407D92544B92C192BC7D9265
>
writestring

Invoke with ghostscript's argument-processing option --.
josh@Z1 ~
$ gs -dNODISPLAY -- xorw.ps
GPL Ghostscript 9.06 (2012-08-08)
Copyright (C) 2012 Artifex Software, Inc.  All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.

josh@Z1 ~
$ xxd xorb.ps
0000000: 285d 297b 923e 9233 7d92 3341 5247 554d  (]){.>.3}.3ARGUM
0000010: 454e 5453 9202 9275 2877 2992 412f 4f5d  ENTS...u(w).A/O]
0000020: 2872 2992 412f 495d 922c 2f4b 5d7b 4f20  (r).A/I].,/K]{O
0000030: 4992 7b92 707b 9240 7d92 544b 92c1 92bc  I.{.p{.@}.TK....
0000040: 7d92 65                                  }.e

josh@Z1 ~
$ gs -dNODISPLAY -- xorb.ps 42 xor.ps xor.ps.out
GPL Ghostscript 9.06 (2012-08-08)
Copyright (C) 2012 Artifex Software, Inc.  All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.

josh@Z1 ~
$ gs -dNODISPLAY -- xorb.ps 42 xor.ps.out xor.rev
GPL Ghostscript 9.06 (2012-08-08)
Copyright (C) 2012 Artifex Software, Inc.  All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.

josh@Z1 ~
$ diff xor.ps xor.rev

josh@Z1 ~
$

Subtracting whitespace only gives me -10. :(

There's only 1 byte of whitespace in the binary version, between the O and the I.

q/kdb+, 35 bytes (41 including whitespace)
Solution:
{x 1:0b sv'(0b vs 4h$y)<>/:0b vs'read1 x}

Example:
q)read0 `:test.txt
"Hello World!"
"Welcome to PPCG :)"
q){x 1:0b sv'(0b vs 4h$y)<>/:0b vs'read1 x}[`:test.txt;"A"]
`:test.txt
q)read0 `:test.txt
"\t$--.a\026.3-%`"
"\026$-\".,$a5.a\021\021\002\006a{h"
q){x 1:0b sv'(0b vs 4h$y)<>/:0b vs'read1 x}[`:test.txt;"A"]
`:test.txt
q)read0 `:test.txt
"Hello World!"
"Welcome to PPCG :)"

Explanation:
Read in the file as a bytestream, convert to bitstream, convert key to bitstream and xor <> with each byte. Convert back to bytestream and write back to file:
{x 1:0b sv'(0b vs 4h$y)<>/:0b vs'read1 x} / ungolfed solution
{                                       } / lambda function taking x and y as implicit parameters
                                 read1 x  / read file x as bytestream
                           0b vs'         / convert each byte to bits (boolean list)
                       <>/:               / xor (<>) left with each-right (/:)
           (          )                   / do this together
                  4h$y                    / convert key to a byte
            0b vs                         / convert byte to bits (boolean list)
     0b sv'                               / convert each list of bits to a byte
 x 1:                                     / write bytes to file x

Notes:
If we drop to the k prompt we have a 32 byte solution (33 inc whitespace), pretty much a straight port except we dont have <> for xor.
{x 1:0b/:'~(0b\:4h$y)=/:0b\:'1:x}

K4 Example:
  {x 1:0b/:'~(0b\:4h$y)=/:0b\:'1:x}[`:test.txt;"A"]
`:test.txt
  0:`:test.txt
,"\t$--.a\026.3-%`K\026$-\".,$a5.a\021\021\002\006K"
  {x 1:0b/:'~(0b\:4h$y)=/:0b\:'1:x}[`:test.txt;"A"]
`:test.txt
  0:`:test.txt
("Hello World!";"Welcome to PPCG")

Tcl, 120 bytes
set t [open t w]
lmap x [split [read [open $argv]] ""] {puts -nonewline $t [format %c [expr 255^[scan $x %c]]]}
close $t

Try it online!

Chip, 39 bytes (62 incl. whitespace)
 A0   C2   E4   G6
a{L}bc{L}de{L}fg{L}hS!9
  1B   3D   5F   7H

Try it online!
The first byte of stdin is the key, all other bytes are the message.
The elements H-A are the eight bits of each input byte, h-a are the eight bits of each output byte, and 7-0 are the eight bits of the stack head.
On the first cycle, S!9 causes the input bits to be written to the stack (along with the pairs like A0, 1B...), and prevents any output.
On subsequent cycles, the input bits are xor'd with their corresponding stack bits to produce the output bits. A single bit is computed like this:
 A0
a{'

or like this:
,}b
1B

(which are just rotations of each other). Those two patterns can be made to overlap slightly, and we use four of each to cover all eight bits.

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/

sort: votes


text:
Cambridge Transposition
I'm sure most, if not all, of you have come across this at some point or another:

Aoccdrnig to a rscheeachr at Cmabrigde Uinervtisy, it deosn't mttaer
in waht oredr the ltteers in a wrod are, the olny iprmoetnt tihng is
taht the frist and lsat ltteer be at the rghit pclae. The rset can be
a toatl mses and you can sitll raed it wouthit porbelm. Tihs is
bcuseae the huamn mnid deos not raed ervey lteter by istlef, but the
wrod as a wlohe.

Create a program that inputs any amount of text. For testing purposes, use the unscrambled version of the above text, found below.

The program must then randomly transpose the letters of each word with a length of 4 or more letters, except the first and last letter of each word.

All other formatting must remain the same (capitalization and punctuation, etc.).

Testing text:

According to a researcher at Cambridge University, it doesn't matter
in what order the letters in a word are, the only important thing is
that the first and last letter be at the right place. The rest can be
a total mess and you can still read it without problem. This is
because the human mind does not read every letter by itself but the
word as a whole.

As usual, this is a code-golf. Shortest code wins.

Similar to How to randomize letters in a word, though in that one only a single word needs to be scrambled whereas here it's every word in a sentence.

I agree. The questions are similar enough that solutions for one problem can be used almost directly for the other.

Last letter is not right in rscheearch in your sample text.

@Daniero it isn't my typo, but it is a known typo (see the link). I left the [sic] out of the quotes.

I'd be more impressed with a program that did the reverse (i.e. input is the scrambled text).

Must the position of the apostrophe in don't remain in the same position? The spec says All other formatting must remain the same (capitalization and punctuation, etc.). but I'm not sure how that works out here...

Ruby - 50 48 chars, plus -p command line parameter.
gsub(/(?<=\w)\w+(?=\w)/){[*$&.chars].shuffle*''}

Thanks @primo for -2 char.
Test
➜  codegolf git:(master) ruby -p 9261-cambridge-transposition.rb < 9261.in
Acdrcinog to a racreseher at Cagribmde Ursvetniiy, it dsoen't mttaer in waht odrer the leertts in a word are, the olny ionarpmtt tnhig is that the fsirt and last letetr be at the rghit pcale. The rset can be a taotl mses and you can slitl raed it wthiuot perlbom. Tihs is buaecse the hmuan mind does not raed ervey lteetr by ietlsf but the word as a wlhoe.

Ruby doesn't support \K for zero-width look-behind assertion? Also, the innermost grouping is unnecessary, using $& instead of $1.

@primo, I think not, it doesn't work, and neither have I found it in any reference page. Thanks for $& tip :)

You're right. I guess I assumed they had taken perl regex directly, as php does ;)

tell me more about this codegolf script

Many years later, but: There is no need to create a new array before the shuffle: [*$&.chars] => $&.chars, saving 3 bytes.

Also many years later: Ruby does support the \K operator. I’m too lazy too look up when it was added.

PHP 84 bytes
<?for(;$s=fgets(STDIN);)echo preg_filter('/\w\K\w+(?=\w)/e','str_shuffle("\0")',$s);

Using a regex to capture words that are at least 4 3 letters long†, and shuffling the inner characters. This code can handle input with multiple lines as well.
If only one line of input is required (as in the example), this can be reduced to 68 bytes
<?=preg_filter('/\w\K\w+(?=\w)/e','str_shuffle("\0")',fgets(STDIN));

† There's only one letter in the middle, so it doesn't matter if you shuffle it.

Python, 118
Python is terribly awkward for things like this!
from random import*
for w in raw_input().split():l=len(w)-2;print l>0and w[0]+''.join((sample(w[1:-1],l)))+w[-1]or w,

Bonus
I tried some other things that I thought would be clever, but you have to import all sorts of things, and a lot of methods don't have return values, but need to be called separately as its own statement. The worst is when you need to convert the string to a list and then joining it back to a string again.
Anyways, here are some of the things that I tried:

Regex!

import re,random
def f(x):a,b,c=x.group(1,2,3);return a+''.join(random.sample(b,len(b)))+c
print re.sub('(\w)(\w+)(\w)',f,raw_input())

Permutations!

import itertools as i,random as r
for w in raw_input().split():print''.join(r.choice([x for x in i.permutations(w)if w[0]+w[-1]==x[0]+x[-1]])),

You can't shuffle a partition of a list directly and shuffle returns None, yay!

from random import*
for w in raw_input().split():
 w=list(w)
 if len(w)>3:v=w[1:-1];shuffle(v);w[1:-1]=v
 print ''.join(w),

Actually, the Regex version is the only one that works. The others fail for words that are followed by punctuation, because the punctuation is treated as the last letter.

Looks like you're right, @movatica. I almost haven't touched Python in years (this post is 8 years old!), but I'll see if I'll get around to fixing it eventually.
edit: Oh, you fixed it (well, kinda; python 3). Have an upvote ;)

Retina, 10 bytes
?V`\B\w+\B

Try it online!
Hey, this old challenge was made for the new Retina!
Explanation
\B\w+\B matches groups of letters between non-boundaries, that is groups of letters that don't begin or end a word. Since regexes are greedy, this will match all the letters of a word except the first and the last one.
V is the "reverse" stage, that reverses the order of characters in each match of the regex. With the ? option it scrambles them instead.

I happened across this after finding another 10-byte solution.

J (48)
''[1!:2&4('\w(\w+)\w';,1)({~?~@#)rxapply 1!:1[3

Explanation:

1!:1[3: read all input from stdin
rxapply: apply the given function to the portions of the input that match the regex
({~?~@#): a verb train that shuffles its input: # counts the length, this gets applied to both sides of ? giving N distinct numbers from 0 to N, { then selects the elements at those indices from the input array.
('\w(\w+)\w';,1): use that regex but only use the value from the first group
[1!:2&4: send unformatted output to stdout
''[: suppress formatted output. This is necessary because otherwise it only outputs that part of the output that fits on a terminal line and then ends with ....

Nibbles, 15 bytes
This was a little awkward since nibbles doesn't have shuffle or even randomness (nor does it have regex).
+.%~@ \$a
  :@
    ::`($
      ++=~
        `)\`'$
        `# $ 0
      $

(Nibbles isn't on TIO yet). But use it like:
> nibbles cambridge.nbl < input.txt
Aoinrccdg to a raeeercshr at Caibrmgde Uvteiinrsy, it doesn't mttaer in waht oerdr the ltteers in a word are, the olny itoanrmpt tinhg is taht the first and last ltteer be at the rihgt palce. The rest can be a ttoal mess and you can stlil raed it wutoiht poelbrm. Tihs is buaecse the huamn mind does not raed every ltteer by itelsf but the word as a wolhe.

That's the literate form which is 30 nibbles.
That last $ could be left out but there is no point since this program is 30 nibbles (it would be 29 half bytes then rounded up)
How?
+.%~@ \$a          concat the map of the split by alpha numeric chars
  :@               append the value that preceded the split match
    ::`($          append the first value of the match to
      ++=~         concat the concat of the group by of
        `)\`'$     the tail of the reverse of the transpose of the tail of the match
        `# $ 0     hash of the char (0 says range is infinite)
      $            the head of the reversed thing from earlier

Essentially it selects groups of alphanums, then selects the inner part of that using uncons twice. Then for randomness does a group by (which also sorts by) the hash of a character.
The transpose part is so that doing uncons on an empty string returns an empty string instead of null character (which becomes a space). You could leave it out but you'd get an extra space on 1 letter words like "a".

APL 107
Unfortunately my APL interpreter does not support regexs so here's a home rolled version where the text to be scrambled is stored in the variable t:
⎕av[((~z)\(∊y)[∊(+\0,¯1↓n)+¨n?¨n←⍴¨y←(~z←×(~x)+(x>¯1↓0,x)+x>1↓(x←~53≤(∊(⊂⍳26)+¨65 97)⍳v←⎕av⍳,t),0)⊂v])+z×v]

Essentially the code partitions the text into words based on the letters of the alphabet only and then into the letters between the first and last letters of those words. These letters are then scrambled and the whole character string reassembled.

APL, 58 49
I believe this works in IBM APL2 (I don't have IBM APL)
({⍵[⌽∪t,⌽∪1,?⍨t←⍴⍵]}¨x⊂⍨~b),.,x⊂⍨b←' ,.'∊⍨x←⍞,' '

If not, then in Dyalog APL, add to the front:
 ⎕ML←3⋄

which adds 6 chars

This assumes the only non-word characters are space, comma, and period.

Still golfable, but I don't have APL symbols on iPhone...

VBA, 351 373/409
Sub v(g)
m=1:Z=Split(g," "):j=UBound(Z)
For u=0 To j
t=Z(u):w=Len(t):l=Right(t,1):If Not l Like"[A-Za-z]" Then w=w-1:t=Left(t,w):e=l Else e=""
If w>3 Then
n=Left(t,1):p=w-1:s=Right(t,p):f=Right(t,1)
For p=1 To p-1
q=w-p:r=Int((q-1)*Rnd())+1:n=n & Mid(s,r,1):s=Left(s,r-1) & Right(s,q-r)
Next
Else
n=t:f=""
End If
d=d & n & f & e & " "
Next
g=d
End Sub

Alternate (larger) Method:
Sub v(g)
m=1:Z=Split(g," "):j=UBound(Z)
For u=0 To j
t=Split(StrConv(Z(u),64),Chr(0)):w=UBound(t)-1:l=Asc(t(w)):If l<64 Or (l>90 And l<97) Or l>122 Then e=t(w):w=w-1 Else e=""
If w>3 Then
n=t(0):p=w-1:s=""
For i=-p To -1
s=t(-i) & s
Next
f=t(w)
For p=1 To p-1
r=Int((w-p)*Rnd())+1:n=n & Mid(s,r,1):s=Left(s,r-1) & Right(s,w-p-r)
Next
n=n & s
Else
n=Z(u):f="":e=""
End If
d=d & n & f & e & " "
Next
g=d
End Sub

Both of these methods change the value of the variable passed to the Sub. i.e.
Sub Test()
strTestString = "This is a test."
v strTestString
Debug.Print strTestString
End Sub

will output something like this:
"Tihs is a tset."

Also, this does randomize mid-word punctuation, so this may not fit the spec 100%.

APL NARS 172 chars
r←g x;i;s;d;k
s←⎕AV[98..123]∪⎕A
i←1⋄v←''⋄r←''⋄k←⍴x
A:d←''⋄→C×⍳i>k⋄d←x[i]⋄→C×⍳∼d∊s⋄v←v,d⋄i+←1⋄→A
C:v←{t←¯2+⍴r←⍵⋄t≤1:r⋄r[1+t?t]←⍵[1+⍳t]⋄r}v
r←∊r,v,d
v←''⋄i+←1⋄→A×⍳i≤k
g x←⍞

13+17+18+44+41+8+17+5+9=172;
This function g() has input as a string; has output as a string. I add the input command because i don't know how insert \' in a quoted string. Commented
∇r←g x;i;s;d;k
   ⍝ words are element of  a-zA-Z separed from all other
   s←⎕AV[98..123]∪⎕A ⍝a-zA-Z ascii ⎕IO = 1
   i←1⋄v←''⋄r←''⋄k←⍴x
A:   d←''⋄→C×⍳i>k⋄d←x[i]⋄→C×⍳∼d∊s⋄v←v,d⋄i+←1⋄→A
C:      v←{t←¯2+⍴r←⍵⋄t≤1:r⋄r[1+t?t]←⍵[1+⍳t]⋄r}v
        r←∊r,v,d
        v←''⋄i+←1⋄→A×⍳i≤k
∇

result
g x←⍞
According to a researcher at Cambridge University, it doesn't matter in what order the letters in a word are, the only important thing is that the first and last letter be at the right place. The rest can be a total mess and you can still read it without problem. This is because the human mind does not read every letter by itself but the word as a whole.
  Androiccg to a rhraeecser at Cgirbdmae Uirevtsiny, it deson't mtetar in waht oderr the ltrtees in a wrod are, the olny intro
  apmt tinhg is taht the frsit and lsat lteter be at the rghit pacle. The rset can be a ttaol mses and you can siltl rae
  d it wtuhoit poeblrm. Tihs is bcsauee the hmaun mnid deos not raed eervy lteter by isletf but the wrod as a wolhe.

PHP 7.1, not competing, 80 bytes
for(;$w=$argv[++$i];)echo$w[3]?$w[0].str_shuffle(substr($w,1,-1)).$w[-1]:$w," ";

takes input from command line arguments. Run with -nr. (will obviously fail at punctuation)

PHP, 94+1 bytes
+1 for -R flag
<?=preg_replace_callback("/(?<=\w)\w+(?=\w)/",function($m){return str_shuffle($m[0]);},$argn);

Pipe input through php -nR '<code>'.
Note:
preg_replace_callback came to PHP in 4.0.5;
closures were introduced in php 5.3;
so this requires PHP 5.3 or later.
Unfortunately, the match is always sent as an array, even if there are no sub patterns,
thus I cannot just use str_shuffle as the callback, which would save 29 bytes.

JavaScript, 76 67 bytes
thanks to Arnauld for -9 bytes.
t=>t.replace(/\B\w+\B/g,m=>[...m].sort(_=>Math.random()-.5).join``)

Try it online!

Ungolfed
t =>                  // function with a single argument
     t.replace(       // Replace ...
         /\B\w+\B/g,  // every match of the regex
         m => ...     // with the return value of the replacement function
     )

/       /g            // Match all occurences of
   \w+                // 1 or more word chars ...
 \B   \B              // ... that aren't on the beginning or end of the word

m =>                  // Replacement function
     [...m]           // convert matched string to a list of chars
       .sort(_ => Math.random()-.5) // sort with a random comparision function
       .join``        // join the list into a single string

Note that "shuffle by doing sort like that is not uniform"

You can use /\B\w+\B/g. (But for the bounty, note that code length isn't important.)

@Arnauld thanks a lot. As this is still codegolf, every byte counts.

@Arnauld Serious contender rule still applies.

The "Try it online" redirects me to "JavaScript (Node.js)". Will this work in pure, no-Node.js depended JavaScript run as i.e. script inside some HTML file, in a browser? Second thing, as I think the original rules for Cambridge Transposition were a bit different than showed here (in OP question). Is it possible to modify your code to scramble words 5+ letters long (instead of 4+ letters long, as in OP's question)?

@trejder I added an explanation that should help you to modify the code for your needs. In its current form the code should run well in most browsers. If you want to use in this in real code, you should probably change the way it shuffles the characters to a uniform algorithm.

For example Fisher-Yates algorithm? 26 bytes more for the replacement function but x=>(l=x.length,g=a=>l?a.splice(l--*Math.random(),1)+g(a):"")([...x]) should be a uniform algorithm. Of course no one would use golfed codes in production lol

Jelly, 22 20 bytes
e€ØẠ+ƝỊŻœṗµḢ,ṪjW)ẎẊ€

Try it online!
This was fun to make.
Each non-alphabet character is grouped into a single character string, and the first and last characters of each word are grouped the same way as well. That way, taking a random permutation of those characters will not change their order.
Made with a lot of help from caird coinheringaahing.
-2 bytes from caird coinheringaahing.
Explanation
e€ØẠ+2\ỊŻœṗ⁸µḢ,ṪjW)ẎẊ€
 €                     for each character:
e ØẠ                   check if it's in the alphabet
    +2\                add overlapping pairs
       Ị               check if they are ≤ 1
        œṗ⁸            and partition the input using that bitmask
           µ      )    execute the following on each part:
            Ḣ,ṪjW      get head, tail, and join with the modified list
                   Ẏ   join the list of triplets together
                    Ẋ€ get a random permutation of each of the elements

-2 bytes

Stax, 15 14 13 bytes
â#]ø\┘‼↕ip2╚_

Run and debug it
Regex is busted.
-2 bytes from recursive.

Python 3, 113 bytes
based on the original python answer by daniero
import re,random
print(re.sub('(\w)(\w+)(\w)',lambda m:m[1]+''.join(random.sample(m[2],len(m[2])))+m[3],input()))

Try it online!

R, 159 bytes
function(x){l=attr(w<-el(gregexpr("[a-zA-Z]+",x)),"m")
Map(function(i,j)substr(x,i,j)<<-Reduce(paste0,sample(substring(x,r<-i:j,r))),s<-w[l>3]+1,s+l[l>3]-3)
x}

Try it online!
Posted before realizing that there was already another R answer, but pleasingly the two approaches are quite different...
Ungolfed code:
cambridge_transpose=
function(x){                        # x is the input string,
  w=el(gregexpr("[a-zA-Z]+",x))     # w gets the words in x using a regex,
  l=attr(w,"match.length")          # l gets the lengths of each word,
  s=w[l>3]+1                        # s is the start letter to jumble in each word,
  e=s+l[l>3]-3                      # e is the end letter to jumble in each word.
  Map(function(i,j) ... ,s,e)       # Now, use this function on all elements i,j from s,e:
    substr(x,i,j)<<-                #   replace letters in x from i to j
      Reduce(paste0,                #   with these letters joined-together:
        sample(                     #     a random sample of
          substring(x,r<-i:j,r)))   #     the letters in x from i to j.
x}                                  # Finally, return (modified) x.

Python3, 110 bytes:
lambda x:re.sub('(?<=\w)\w{3,}(?=\w)',lambda x:''.join(r.sample(g:=x.group(),len(g))),x)
import re,random as r

Try it online!

102 bytes: lambda s:re.sub('(?<=\w)\w+(?=\w)',lambda m:''.join(r.sample(m[0],len(m[0]))),s)

R, 179
Using the function I wrote for the randomize letters in a word problem:
Input:
s <- "According to a researcher at Cambridge University, it doesn't matter in what order the letters in a word are, the only important thing is that the first and last letter be at the right place. The rest can be a total mess and you can still read it without problem. This is because the human mind does not read every letter by itself but the word as a whole."

Solution:
f=function(w){l=length;s=strsplit(w,"")[[1]];ifelse(l(s)<3,w,paste(c(s[1],sample(s[2:(l(s)-1)]),s[l(s)]),collapse=""))}
g=Vectorize(f)
paste(g(strsplit(s," ")[[1]]), collapse=" ")

Result:
[1] "Arioccdng to a reehaecrsr at Cabrgimde Uveirisnyt, it des'not mttear in waht odrer the lttrees in a wrod are, the olny inpotmart thnig is that the fsrit and lsat letetr be at the right palce. The rset can be a toatl mses and you can stlil raed it wutioht pmrlebo. This is bsuceae the hmuan mnid deos not read ervey lteetr by iesltf but the word as a wleho."

Pyth, 23 bytes
jdm?gld4++hd.<Ptd1eddcz

Non-competing because Pyth was made after this challenge was posted.
Try it online

Japt, 32 bytes
m@Xl ¨4?Xg0 +Xs1J ö(x) +XgJ:X}"

Try it online!

Can I run Japt directly in a browser? Without any external libraries, compilers etc.? If not then this unfortunately doesn't count as per bounty rules (need solution that works in pure web browser). Second thing, as I think the original rules for Cambridge Transposition were a bit different than showed here (in OP question). Is it possible to modify your code to scramble words 5+ letters long (instead of 4+ letters long, as in OP's question)?

@trejder All submissions must conform to the rules in the original question. Modifying it like this would make it invalid.

@trejder Japt can't run directly in a browser without a compiler. Secondly if you replace the 4 in the code with 5 then it should only scramble 5+ letter long words.

Java, 1557 834 bytes
Thanks to @JoKing for tips.
A bit late to the competition. Forgot that I had started on this problem.
Golfed
import java.util.*;public class s{ public static void main(String[] args){ Scanner s=new Scanner(System.in);String a=s.next();String[] q=a.split("\\s+");for (int i=0;i<q.length;i++) { q[i]=q[i].replaceAll("[^\\w]", ""); }String f="";for (String z:q) { f+=scramble(z);f+=" "; }System.out.print(f); }private static String scramble(String w){if(w.length()==1||w.length()==2){return w;}char[]l=w.toCharArray();char q=l[w.length()-1];String e=Character.toString(l[0]);char[]n=new char[l.length-2];for(int i=0;i<l.length-2;i++){n[i]=l[i+1];}HashMap<Integer,Character>s=new HashMap<>();int c=1;for(char p:n){s.put(c,p);c++;}HashMap<Integer,Integer>o=new HashMap<>();Random z=new Random();for(int i=0;i<w.length()-2;i++){int m=z.nextInt(n.length);while(o.getOrDefault(m,0) == 1){m=z.nextInt(n.length);}e+=s.get(m+1);o.put(m,1);}return e+=q;}}

Non-golfed
import java.util.HashMap;
import java.util.Random;

public class SentenceTransposition {
    public static void main(String[] args) {
        String input = "According to a researcher at Cambridge University, it doesn't matter in what order the letters in a word are, the only important thing is that the first and last letter be at the right place. The rest can be a total mess and you can still read it without problem. This is because the human mind does not read every letter by itself but the word as a whole.";
        String[] words = input.split("\\s+");
        for (int i = 0; i < words.length; i++) {
            words[i] = words[i].replaceAll("[^\\w]", "");
        }
        String finalsentence = "";
        for (String word : words) {
            finalsentence += scramble(word);
            finalsentence += " ";
        }
        System.out.println(finalsentence);
    }

    private static String scramble(String word) {
        if (word.length() == 1 || word.length() == 2) {
            return word;
        }
        char[] letters = word.toCharArray();
        char lletter = letters[word.length()-1];
        String endword = Character.toString(letters[0]);
        char[] nletters = new char[letters.length-2];
        for (int i = 0; i < letters.length-2; i++) {
            nletters[i] = letters[i+1];
        }
        HashMap<Integer, Character> set = new HashMap<>();
        int count = 1;
        for (char nletter : nletters) {
            set.put(count, nletter);
            count++;
        }
        HashMap<Integer, Integer> chosen = new HashMap<>();
        Random random = new Random();
        for (int i = 0; i < word.length()-2; i++) {
            int cur = random.nextInt(nletters.length);
            while (chosen.getOrDefault(cur,0) == 1) {
                cur = random.nextInt(nletters.length);
            }
            endword += set.get(cur+1);
            chosen.put(cur, 1);
        }
        return endword += lletter;
    }
}

It looks like there's a lot of whitespace you can remove. Have you had a look at Tips for golfing in Java? edit: also, you seem to have the input hard-coded. You should be taking input from the user instead

@JoKing ah ok. I will take input from the user.

I managed to golf this down to 650 bytes before realizing that it doesn't work.

@Quintec do you mean that my code doesn't work?

539 bytes

Sidef, 89 85 bytes
Block (anonymous callable):
{.words.map{[_[0],(_.len-1?([_[1..^(_.len-1)]].shuffle...,_[1]):'')].join}.join(' ')}

Output, when used like { ... }('..'):
 I hvae nveer not ocne in my life slleepd nhedatarnel crtreolcy
 I have never not once in my lfie sepelld naetadenrhl ccrtloery

Somewhat ungolfed
.words.map{
  [
    .first,
    (_.len-1
      ? (  [ _[1..^(_.len-1)] ].shuffle..., .last )
      : '')
  ].join
}.join(' ')

Perl 5 -p, 74 bytes
s|\pL\K\pL{2,}(?=\pL)|$,=$q=$&;$q=join'',shuffle$,=~/./g while$,eq$q;$q|ge

Try it online!

Raku, 49 bytes
Moved from the duplicate thread.
{S:g/(\w)(\w*)(\w)/{$0~$1.comb.pick(*).join~$2}/}

Try it online!

05AB1E, 19 bytes
.γa}εDaićsD¨.rsθJ]J

Try it online.
Explanation:
.γ              # Consecutive group by:
  a             #  Is alphabetic (so all upper- and lowercase letters)
 }ε             # After the group-by, map each string to:
   D            #  Duplicate the current string
    ai          #  If it's alphabetic:
      ć         #   Extract head; pop and push the remainder-string and first character
                #   separated to the stack
                #    i.e. "According" → STACK: "ccording","A"
       s        #   Swap so remainder-string is at the top again
                #    STACK: "A","ccording"
        D       #   Duplicate it
                #    STACK: "A","ccording","ccording"
         ¨      #   Remove the last character from the copy
                #    STACK: "A","ccording","ccordin"
          .r    #   Shuffle the remaining characters
                #    STACK: "A","ccording","occdrni"
            s   #   Swap so the remainder-string is at the top again
                #    STACK: "A","occdrni","ccording"
             θ  #   Only leave its last character
                #    STACK: "A","occdrni","g"
              J #   Join the three back together to a string again
                #    STACK: "Aoccdrnig"
  ]             # Close both the if-statement and map
   J            # And join all strings in the list back together
                # (after which the result is output implicitly)

Go, 248 226 bytes
import(."math/rand";."regexp")
func f(s string)string{return MustCompile(`(\w)(\w+)(\w)`).ReplaceAllStringFunc(s,func(S string)(e string){k:=S[1:len(S)-1]
for _,i:=range Perm(len(k)){e+=k[i:i+1]}
return S[:1]+e+S[len(S)-1:]})}

Attempt This Online!
Embeds my answer for "How to randomize letters in a word" within this answer.

-22 from rand.Perm, string slices, and named return.

Japt, 13 bytes
r"%B%w+%B"Èö¬

Try it

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/


text:
Emulate a 7-segment display
Task
The task is to display any of the 128 possible states of a
7-segment display.
Your program should accept a string of 7 characters ("bits") that are either 0 or 1.
First bit of input corresponds to segment A of the following illustration, the
second to B, etc (ignore dp):

How you represent the display is up to you -- a single Unicode or ASCII symbol,
ASCII art, grafically, or whatever you can come up with. However, each
input must have it's own distinct output. If you come up with something fancy I'm sure you can harvest upvotes by showing off some examples.
All 128 possible states of the display are:

Rules

Codegolf
As I said, any kind of output is allowed, but it would be nice if you specified it.
Input can be stdin or command line argument.

Examples
Input
1101101

Output

As ASCII/Unicode:

2

Different kinds of ASCII art (I'm not too good at this)

 _   ╺┓  ╒╗   ---
 _|  ┏┛  ╔╝     |
|_   ┗╸  ╚╛   ---
              |
              ---

Closely related to http://codegolf.stackexchange.com/questions/997/render-digital-clock-style-numbers   ?

@DavidCarraher: They're related, yes; I even linked to it myself. However, this is slightly harder I would say, as you have 118 more 'numbers' to generate. Most(?) of the answers to the other question would not work here, or would have to be heavily rewritten. Also, here you don't need to encode the different numbers, so other optimizations shuld be possible.

You are correct. Thanks for pointing that out.

it is a requirement that we use the encoding you provided? e.g. "1101101" should always represent "2" ?

@ardnew: yes. The position of the bits in input should map to the alphabetical order of the segments A to G in the first picture.

@Daniero In case the program uses an external resource, should the size of that resource be added to the total character (byte) count?

@w0lf I'll say that loading images and graphics externally is OK. Loading external scripts, or other resources that handle logic etc, is not.

Voting to close as "needs details or clarity" because the output format is very vague, approaching that of a popularity contest.

@RedwolfPrograms "Approaching that of a popularity contest".  Popularity contests need rules too.

J (51)
1 2 1#"1[5 3$' #'{~,|:>0;(88707#:~7#7){>".&.>1!:1[1

output:
1101101
 ##
   #
 ##
#
 ##

This can be shaved down to 38 char with a little effort: 1 2 1#"1' #'{~5 3$,0,.502 A.".&>1!:1]1.

C, 106
Size is 74 chars if allowed to rename program "W00WG5WW1GW66WG4WW2GW33WG"
main(int i,char**s){
    for(s[0]="W00WG5WW1GW66WG4WW2GW33WG";i=*s[0]++;putchar(s[1][i&7]-49?i==71?10:32:42));
}

running:
./a.out 1101101
 **
   *
 **
*
 **

notes:
'W' and 'G' (0x47 and 0x57) are chosen such that the value & 7 = 7, i.e they safely index the null character that terminates the input string.

Brainfuck - 224
++++++++++[>+>+++<<-]
>>++>,>,>,>,>,>,>,
<<<<<<<.
>[<+.->-]<<.
>>
>>>>>[<<<<<+<+>>>>>>-]<<<<<<.>[<->-]<.>>[<<+.->>-]<<<.>.
>>>>>>>[<<<<<<<+.->>>>>>>-]<<<<<<<<.
>>>>>>[<<<<+<+>>>>>-]<<<<<.>[<->-]<.
>>>[<<<+.->>>-]<<<<.>.
>>>>[<<<<+.>]

Prints using Exlamation points:
 !
! !
 !
! !
 !

Not the most readable, but not too horrible either.
Surprised at how close this is to not being last place.

Postscript 121 107
1 12 moveto{}5 0{0 -5 rmoveto}0 5 0 5 -5 0 0 -5 0 -5 5 0
n{49 eq{rlineto}{rmoveto}ifelse exec}forall stroke

requires n to be defined as the string to process so invoke like
gs -g7x14 -sn=1101101 lcd.ps

to get

the complete set is

Mathematica: 135 129 118, image display
Image[MorphologicalComponents@Import@"http://goo.gl/j3elE" /.
      Thread[Range@7 -> IntegerDigits[#, 2, 7][[{7, 2, 6, 1, 3, 5, 4}]]]] &

spaces added "for clarity"

Edit
For those picky fellow site users: Without using an external mask:
Image[MorphologicalComponents[ColorNegate@Rasterize@8, CornerNeighbors -> False] /.
    Thread[Range@7 ->IntegerDigits[#, 2, 7][[{7, 2, 6, 1, 3, 5, 4}]]]] &

The code appears to be incomplete. I don't think you wanted your program to terminate with &.

@DavidCarraher It's a function,so it ends with &.

Yes, but it is not applied to anything.  How does one obtain output?

@DavidCarraher i = Import@"http://goo.gl/j3elE"; r = Range@7; Image[MorphologicalComponents@i /.       Thread[r -> {7, 2, 6, 1, 3, 5, 4}] /.      Thread[r -> IntegerDigits[#, 2, 7]]] & /@ Range[0, 11]

Importing code from the internet is abuse of the rules -1

@FUZxxl I'm not importing any code. Click on the link and see what you get

@belisarius I still don't like the fact that you embed external ressources.

@FUZxxl At least, delete your previous comment, since it's misleading and add another one properly targeted towards  your preferences.

I think it does not make any sense to remove my previous comment as that would make it much harder for somebody else to follow this discussion. You import external data which is funny as a joke but not part of a serious code golf answer. -1

@DavidCarraher If you follow the comments thread you'll understand my POV about this site :)

@belisarius Yes, I see what you mean.

Does this work for you? Rasterize[Style[8, FontFamily -> "Synchro LET"], RasterSize -> 75, ImageSize -> 200]

@dude I don't have that font installed. But it looks nice in the images available on the Internet.

APL, 58 55
' _|'[1+3 3⍴0,x[1],0,(x←1 2 2 1 2 2 1×⍞='1')[6 7 2 5 4 3]]

Example input:
1101101

Output:
 _
 _|
|_

⍞='1' takes the input as a character array and converts it to a numeric array.
1 2 2 1 2 2 1×⍞='1' converts that array to: 0 for blank, 1 for _, 2 for |
(x←1 2 2 1 2 2 1×⍞='1')[6 7 2 5 4 3] assign that array to variable x and reorder to represent segments F, G, B, E, D, C
0,x[1],0,(x←1 2 2 1 2 2 1×⍞='1')[6 7 2 5 4 3] concatenates a blank, segment A and another blank to the front
3 3⍴0,x[1],0,(x←1 2 2 1 2 2 1×⍞='1')[6 7 2 5 4 3] reshape to a 3x3 matrix
1+3 3⍴0,x[1],0,(x←1 2 2 1 2 2 1×⍞='1')[6 7 2 5 4 3] converts to 1-based indexing
Finally uses the string ' _|' to convert indicies into characters

Edit
' _|'[1+3 3⍴(0,1 2 2 1 2 2 1×⍞='1')[1 2 1 7 8 3 6 5 4]]

Shaved off 3 chars by concatenating a 0 to front the array and using duplicate indicies, preventing a variable assignment

Iff your APL supports it, I think the from function { is 1-char shorter than bracket indexing [].

PHP 66 bytes
<?for(;11>$i;)echo++$i&3?$argv[1][md5(¡æyÚ.$i)%8]?$i&1?~ƒ:_:~ß:~õ;

A slight improvement using an md5 magic formula, but requires 3 additional binary bytes:
¡, æ, and Ú are characters 161, 230, and 218 respectively. It should work as is if copied directly, and saved as an ANSI format.

PHP 73 (70) bytes
<?for($s=327638584;3<$s;)echo++$i&3?$argv[1][7&$s/=8]?$i&1?'|':_:' ':'
';

If you'll allow me three binary characters, this can be reduced to 70 bytes:
<?for($s=327638584;3<$s;)echo++$i&3?$argv[1][7&$s/=8]?$i&1?~ƒ:_:~ß:~õ;

where ƒ, ß, and õ are characters 131, 223, and 245 respectively.
Receives input as a command line argument. Sample usage:
$ php seven-seg.php 1101101
 _
 _|
|_

$ php seven-seg.php 0111011

|_|
 _|

i tried to run your code, but am getting loads of error :( i dont understand your logic but seems interesting.

@D34dman The only messages it will produce are notices (undefined variables, etc). These can either be turned off in php.ini (by default they already are), or for testing, you can prepend the following code to the script: <? error_reporting(E_ALL & ~E_NOTICE); ?>

awesome! i got it working :D naice!

JavaScript + jQuery + HTML + CSS (210 201)
This solution uses CSS sprites and the image provided as an example:
HTML (3)
<a>

CSS (82 71)
Thanks to xem for the "background:url" trick:
a{background:url(//bit.ly/VesRKL);width:13px;height:23px;display:block}

JavaScript (125 after removing newlines added here for readability)
i=prompt();
x=-parseInt(i.substr(0,3),2)*23;
y=-parseInt(i.substr(3),2)*13.75;
$('a').css('background-position',y+'px '+x+'px');

Online test: http://jsfiddle.net/zhqJq/3/

Hey, but what about the 17.937 bytes of the image?? ;)

@ThomasW. I don't know whether that should be counted as well. Let's leave this to the OP to decide.

You could use <p> tag and avoid display:block on CSS to save space

background-image:url(http://bit.ly/VesRKL); => background:url(//bit.ly/VesRKL);

@xem thanks for the tip; I've edited my answer

Python 2 - 65
s=raw_input()+'0\n'
for i in`0x623C239E38D2EAA1`:print s[int(i)],

Example:
echo 1101101|python2 7seg.py
0 1 0
0 0 1
0 1 0
1 0 0
0 1 0

R (65 chars):
plot((3^(1i*1.5:-4.5)*(1:7!=7)),col=strsplit(readline(),'')[[1]])

Relies on some loose approximations for some transcendental nuumbers ...

PostScript: 53 binary, 87 ASCII 52 binary, 86 ASCII
Hexdump of the program using binary tokens:
$ hexdump -C lcd_binary.ps
00000000  28 34 34 30 34 30 38 30  34 30 34 30 30 30 30 34  |(440408040400004|
00000010  30 34 30 34 34 34 34 34  38 34 38 30 38 29 7b 7d  |0404444484808){}|
00000020  92 49 6e 7b 92 70 31 92  04 92 96 92 6b 92 63 92  |.In{.p1.....k.c.|
00000030  a7 7d 92 49                                       |.}.I|
00000034

Download this file to try it out.
Using ASCII tokens:
(4404080404000040404444484808){}forall
n{not 1 and setgray moveto lineto stroke}forall

First forall loop puts all required coordinates on the stack. The coordinates are stored in a string to minimize required space. The coordinates are in reverse order, i.e. the last 4 chars are for segment A. We draw a line from (0,8) to (4,8) for this segment (actually, we have to add 48 to all coordinates, because forall puts all ASCII codes on the stack).
The second forall loops through all the 0s and 1s in the input string and turns them into a gray value. 0s are drawn white (gray value 1) and 1s are drawn black (gray value 0). Then we use the coordinates that the first forall loop left on the stack to draw the lines.
Invoke the program using Ghostscript, just like Geoff Reedy's:
gs -sn=1101101 lcd.ps

This displays:

I think you can replace neg 49 add (which is awesome btw) with 1 and.

@luserdroog: Brilliant, bitwise operators, haven't thought of them. But it has to be not 1 and, right? Still saves one byte in both ASCII and binary.

I feel there's gotta be a neat way with a 1bit bitmap. but bitshift is such a long word.

But it's only a two byte binary token

Yeah. But it still feels like a cheat to me somehow. :) I feel I need to do as much as possible with readable source before resorting to binary.

You know, if the code isn't ascii, then the data doesn't need to be ascii, either....

APL 101 86 73 69
m←45⍴' '⋄m[¯40+⎕av⍳(⍎∊3/' ',¨⍕⍞)/')*+16;EJOQRSAFK-27=>?']←'⎕'⋄9 5⍴m

Input is from the screen via ⍞
1101101

Which produces a 9x5 character matrix composed of blanks and ⎕ as follows:
 ⎕⎕⎕
     ⎕
     ⎕
     ⎕
 ⎕⎕⎕
⎕
⎕
⎕
 ⎕⎕⎕

The seven digit number is converted into a partition vector to select the ⎕ co-ordinates.

My head hurts...

Mathematica 112 103 100 96 88, using Graphs
HighlightGraph[z=GridGraph@{3,2},Pick[EdgeList[z][[{3,4,1,2,6,7,5}]],Characters@#,"1"]]&

Using it to show a calculator display

l = {7-> 7, 1-> 6, 0-> 63, 8-> 127, 9-> 111,3 -> 79, 5-> 109,  2-> 91, 4-> 102, 6-> 125};
GraphicsRow[
  HighlightGraph[z = GridGraph[{3,2}, EdgeStyle-> {White}, GraphHighlightStyle-> {"Thick"}],
    EdgeList[z][[{3, 4, 1, 2, 6, 7, 5}]][[IntegerDigits[#, 2, 7] Range@7]]] & /@
            (IntegerDigits[8736302] /. l)]

What sort of input do you expect? Neither [123] nor ["123"], nor IntegerDigits[123] work for me.  I get only z, with no highlighting.

@dude Try `HighlightGraph[z = GridGraph@{3, 2},
Pick[EdgeList[z][[{3, 4, 1, 2, 6, 7, 5}]], Characters@#,
"1"]] &@"1111111"`` :)

Javascript 123
s=prompt(i=o='');for(m=' 0516423';i++<15;i%3==0?o+='\n':1)o+=' ─│'[~i%2&(A=+s[+m[~~(i/2)]])+(A&+'110'[i%3])];console.log(o)

I can bring the character count lower (101) if we use only one character for the "on" state, but it is less legible:
s=prompt(i=o='');for(m=' 0516423';i++<15;i%3==0?o+='\n':1)o+=' ■'[~i%2&s[+m[~~(i/2)]]];console.log(o)

+1 This is impressive. I'm still trying to reverse-engineer it. It's taught me a few things already!

Python (107)
Definitely more golfable.
a=map(int,raw_input())
for i in(0,6,3):print' .. '*a[i]+('\n'+' .'[a[5-i/6]]+'  '+' .'[a[1+i/6]])*(2*(i!=3))

Output:
1101101
 ..
   .
   .
 ..
.
.
 ..

Explanation:
a is a list of booleans extracted from the input.
When you multiply a string with a number, it will return the string repeated (number) times.
If that number happens to be zero, it returns an empty string.
i is iterated through 0 (pos A), 6 (pos G), and 3 (pos D).
' .. ' will print either section A, G, or D, depending on the value of i.
([string here])*(2*(i!=3)) will print [string here] twice only if i!=3.
Breaking down [string here]:
 - '\n' will print a newline for each repetition.
 - '  ' is the null space between horizontal sections.
 - ' .'[(bool)] will return either ' ' if (bool) is 0, and '.' if (bool) is 1.
 - 5-i/6 will return 5 if i=0 and 4 if i=6. a[5] is section F and a[4] is section E.
 - 1+i/6 will return 1 if i=0 and 2 if i=6. a[1] is section B and a[2] is section C.

Python 2.7 (93 chars):
print (' {0}\n{5} {1}\n {6}\n{4} {2}\n {3}').format(*map(lambda x:int(x)and'*'or' ',raw_input()))

Explanation:
With the stdin input, use a makeshift ternary operator to give * for true and a space for false.  Take those values and plug them into a format statement that's in the format of the 7 digit display.  It'd be at most 83 characters if the display worked like this:
 a
b c
 d
e f
 g

but the ordering makes it longer.  Anyone have a way around this?
Example:
$ ./7seg.py
111000

 *
  *

  *

$ ./7seg.py

1111111

 *
* *
 *
* *
 *

Nice, but that lambda seems unnecessary: print' {0}\n{5} {1}\n {6}\n{4} {2}\n {3}'.format(*[' *'[i=='1']for i in raw_input()]) ;) No need for brackets and space for the print statement either.

Wow!  I didn't know you could put booleans in indexers.  Thanks :-)

Np. Also, >'0' instead of =='1' and input() (with backticks around, but that won't show up because of the formatting here) instead of raw_input().

fyi, you can use tripple backticks if you need backticks in the code x = `input()`

Cool. Then I learned something today too :)

I thought we needed a lispy answer...
Clojure, 159 chars
(print(apply str(flatten(interpose\newline(partition 3(map(fn[x](if(= x\1)\o" "))(str" "(apply str(interpose" "(map(vec(read-line))[0 5 1 6 4 2 3])))" ")))))))

The above will run in the REPL and provide the correct answer. For example:
1111111
 o
o o
 o
o o
 o

Throwing numbers at it with small modifications:
(doseq [i ["1111110" "0110000" "1101101" "1111001" "0110011" "1011011" "1011111" "1110000" "1111111" "1111011"]]
(println (apply str(flatten(interpose\newline(partition 3(map(fn[x](if(= x\1)\o" "))(str" "(apply str(interpose" "(map(vec i)[0 5 1 6 4 2 3])))" ")))))))
(println))

yields:
 o
o o

o o
 o

  o

  o

 o
  o
 o
o
 o

 o
  o
 o
  o
 o

o o
 o
  o

 o
o
 o
  o
 o

 o
o
 o
o o
 o

 o
  o

  o

 o
o o
 o
o o
 o

 o
o o
 o
  o
 o

nil

Not easy to read, but they're there!

PHP - 155 characters
<?php
$y=array("   \n"," - \n","   \n","  |\n","|  \n","| |\n"); $x = $argv[1]; echo $y[$x[0]].$y[2*$x[6]+$x[2]+2].$y[$x[7]].$y[2*$x[5]+$x[3]+2].$y[$x[4]];

it would be 150 characters if we use php 5.4 type array declaration, but i dont have that installed on my laptop so couldn't test it.
Sample out puts.

Explanation:
First i divided the 7 segment display to Five rows and 3 columns. With 1st, 3rd and 5th row havimg '-' in the middle column, and space otherwise.
The 2nd and 4th row has a pipe '|' character in the first and last column. Now the presence of these character should be guided by the input values.
I created a lookup table, which is basically two lookup table. First one for the calculation of values for 1st, 3rd and 5th row. And another one at offset 2 ( 3rd item ) for calculation of rows 2nd and 4th.

Postscript 136
Not winner, but a different approach.
15 string exch{1 and 255 mul}forall
[7 3 9 13 11 5 1]{count 1 sub index 3 1 roll exch put}forall
3 5 8[.02 0 0 .05 0 0]{}image showpage

Expects the input string to be on the stack:
$ echo '(1101101)'|cat - 7seg.ps |gs -sDEVICE=png16 -sOutputFile=6c.png -

This one's even worse. 294 to make a "binary" bitmap. I took me a while to remember that each row is padded to an even byte. So a 3x5 bitmap is five bytes with the 3 msb bits significant.
2#1101101
(12345)exch
2 copy 64 and 0 exch put %A
2 copy 2 and 6 bitshift 2 index 32 and or 1 exch put %F B
2 copy 1 and 6 bitshift 2 exch put %G
2 copy 4 and 5 bitshift 2 index 16 and 1 bitshift or 3 exch put %E C
2 copy 8 and 3 bitshift 4 exch put
pop
3 5 1[.02 0 0 .02 0 0]{}image showpage

Output is just as ugly as the other one. :(
Alright here's one that looks good. 190
Edit: It was upside-down and backwards. Fixed now.
(1101101)
{neg 49 add 255 mul
1 string dup 0 4 3 roll put}forall
(\377){@/g/f/e/d/c/b/a}{exch def}forall
@ a a @
b @ @ f
b @ @ f
@ g g @
c @ @ e
c @ @ e
@ d d @
4 7 8[.01 0 0 .01 0 0]{}image showpage

This shows me some funny patterns. Is there still a bug somewhere?

hmm. yeah. (1111110) does not look like a zero. It's just an enlarged bytemap. I guess boxes is oversimplified. :(

it's kindof in the nature of this bitmap approach, I think. I'm not sure how to make it not ugly.

Some light commentary available here.

Mathematica 264
Getting the output to look right required many bytes, so no cigar this time.
But here's the verbose (264 chars) code anyway.
{a, b, c, d, e, g} = {{-1, 5}, {1, 5}, {1, 3}, {1, 1}, {-1, 1}, {-1, 3}};
f@n_ := Graphics[{Yellow, Thickness[.1], CapForm["Round"],
   Line /@ {{g, c}, {g, a}, {g, e}, {e, d}, {d, c}, {c, b}, {b, a}}[[Flatten@
   Position[IntegerDigits[n, 2, 7], 1]]]},
   Background -> Blue, PlotRange -> {{-1, 1}, {1, 5}}, PlotRangePadding -> 1]

The complete set of characters:
GraphicsGrid[Partition[Table[f[p], {p, 0, 128}], 16]]

The digits:
{f[63], f[6], f[91], f[79], f[102], f[109], f[125], f[7], f[127], f[111]}

Java - 204 characters
class A{public static void main(String[]a){char[]c=new char[7];for(int i=0;i<7;i++)c[i]=a[0].charAt(i)==49?i%3==0?95:'|'):32;System.out.printf(" %c %n%c%c%c%n%c%c%c",c[0],c[5],c[6],c[1],c[4],c[3],c[2]);}}

Sample output:
 _
 _|
|_

Formatted properly:
class A {
    public static void main(String[] a) {
        char[] c = new char[7];
        for (int i = 0; i < 7; i++)
            c[i] = a[0].charAt(i) == 49 ? (i % 3 == 0 ? 95 : '|') : 32;
        System.out.printf(" %c %n%c%c%c%n%c%c%c", c[0], c[5], c[6], c[1], c[4], c[3], c[2]);
    }
}

Really wish I could avoid that for loop, but I tried a few other things and they were all longer.  There's probably a better way to do this, but this is my first attempt at code golf.  (And Java's like the worst language for it, which is why I thought it would be interesting.)  Even Brainfuck has me beat, but at least my output looks nicer.
EDIT: can get rid of "public" on class, saves me 7 chars!
And thanks, daniero, for showing me printf! (18 chars saved)
Rewrote the output format, changed character literals to decimal, 12 chars saved.

Welcome to codegolf.se! Java introduced a printf method a few versions back, which is basically println and format in one (like the C function); This will save you some characters,

Here's another trick: You can combine the "body" of the for loop and the update part into one, saving one character: for(int i=7;i>0;c[--i]=a[0].charAt(i)==49?(i%3==0?95:'|'):32);

VBA - 263
It's ugly but it works, I think. I am having trouble viewing the proper bit order, so I'm inferring from others' answers. Even if that piece is wrong, the code length should remain the same.
Sub d(b)
Dim c(1 To 7)
For a=1 To 7
c(a)=Mid(b,a,1)
Next
x=" - "
y="|"
z=" "
w="   "
v=vbCr
MsgBox IIf(c(1)=1,x,w) & v & IIf(c(6)=1,y,z) & z & IIf(c(2)=1,y,z) & v & IIf(c(7)=1,x,w) & v & IIf(c(5)=1,y,z) & z & IIf(c(3)=1,y,z) & v & IIf(c(4)=1,x,w)End Sub

VBScript - 178 characters
m=Split("2 7 11 10 9 5 6")
s=" _ "&vbCr&"|_|"&vbCr&"|_|"
For x=1 To 7
If Mid(WScript.Arguments.Item(0),x,1)=0 Then r=m(x-1):s=Left(s,r-1)&" "&Right(s,Len(s)-r)
Next
MsgBox s

Thanks!  Couple bonehead mistakes cost me 6 characters. I can almost get this down to the size of the VBA one even with the absurdly long call to get the function line argument.

Unless your code is functional without the newline characters, you have to count them too. This has 178 characters according to my count.

VBA, 188 characters
Note that the one has to type 188 characters if only including mandatory whitespace -- the IDE expands it out when you copy it into the VBA editor.
Sub f(i)
Dim c() As Byte
m=Split("1 6 10 9 8 4 5")
c=StrConv(" _  |_| |_|",128)
c(3)=10
c(7)=10
For x=1 To 7
If Mid(i,x,1) = 0 Then c(m(x-1))=32
Next
MsgBox StrConv(c,64)
End Sub

Sadly, VBScript doesn't have a strongly typed Byte array, or that one could be much shorter using this method.

CJam - 29
l0N]s7078571876784728737Ab\f=

CJam is a new language I am developing, similar to GolfScript - http://sf.net/p/cjam. Here is the explanation:
l reads a line from the input
0 is the number 0
N is a variable preinitialized to the newline string
] gathers the elements on the stack into an array
s converts a value (the array) to string, thus appending a zero and a newline to the given input
7078571876784728737 is a number (the same number I used in python, but it was in hex there)
A is a variable preinitialized to 10
b does a base conversion, generating the array [7 0 7 8 ... 3 7]
\ swaps the last two values on the stack
f= applies the = operator (here, indexed array access) on the input string (plus zero and newline) and each number 7, 0, 7, ...
The index 7 corresponds to the appended zero, and 8 corresponds to the appended newline.
My python solution does exactly the same thing (except the digit separation is done via string conversion)

What am I looking at here? Care to offer a brief explanation of the code?

@daniero I added an explanation

Javascript (ECMAScript 2016) - 108 bytes
console.log(([a,b,c,d,e,f,g]=[...prompt()].map((x,i)=>+x?'_||'[i%3]:' '),` ${a}
${f}${g}${b}
${e}${d}${c}`))

This probably can be golfed further, but I can't think of anything.

Welcome to the site! That's a nice first entry :)

JavaScript, 148 bytes
e=>(e[0]==1?" #\n":"\n")+(e[5]==1?"#":" ")+(e[1]==1?" #\n":"\n")+(e[6]==1?" #\n":"\n")+(e[4]==1?"#":" ")+(e[2]==1?" #\n":"\n")+(e[3]==1?" #\n":"\n")

Try it online! (Footer is Node.js to read .input.tio)
Accepts input of ABCDEFG in binary flags and returns:
 #
# #
 #
# #
 #

SmileBASIC, 136 bytes
DIM A[7,2]COPY A,@L@L?DATA.,1,1,3,4,3,6,1,4,0,1,0,3,1INPUT X$FOR I=0TO 6M=I MOD 3GBOX A[I,1],A[I,0],A[I,1]+!M,A[I,0]+!!M,-VAL(X$[I])NEXT

Output is graphical.

PHP 5.6, 65 bytes plain ASCII
for(;$p++<9;)echo$argn[_707561432[$p]]?"||_"[$p%3]:" ","\n"[$p%3];

or, without a trailing linebreak, but with some bitwise fun:
for(;$p++<11;)echo$argn[_70785618432[$p]]?L|Sx[$p&1]:a^kAAA[$p&3];

Run as pipe with -nR or try them online.
breakdown 1
for(;$p++<9;)echo           # loop through positions
    $argn[_707561432[$p]]   # map position to input bit
        ?"||_"[$p%3]            # if set: underscore in 2nd column, pipe symbol else
        :" "                    # else space
    ,"\n"[$p%3]             # add newline every 3 columns
;

breakdown 2
for(;$p++<11;)echo          # loop through positions
    $argn[_70785618432[$p]] # map position to input bit (bit 8 for EOL, never set)
        ?L|Sx[$p&1]             # if set: underscore in the middle, pipe symbol else
        :a^kAAA[$p&3]           # else: newline in 4th column, space else

Whether the language is new or old doesn't matter anymore since the Summer of 2017. So you won't have to mention non-competing.

@KevinCruijssen Thanks I missed that. But it´s also a nice challenge to revive old PHP versions; it also sometimes gives a different view on more recent features: I found, on occasions, that the "old" way is more efficient (in size, in performance, in readability and sometimes all three) than using stuff that was added to PHP later No golfing advantage in this case, though: The first approach would require 8 extra bytes, the second one 5.

05AB1E, 4 bytes
C₄+ç

Try it online or verify all possible inputs.
See the verify all possible inputs link above to see the mapping used for each input.
Explanation:
This abuses the rules where it states:

How you represent the display is up to you -- a single Unicode or ASCII symbol, ASCII art, grafically, or whatever you can come up with. However, each input must have it's own distinct output.

C       # Convert the (implicit) input from binary to integer
 ₄+     # Increase it by 1000
   ç    # Convert it to a unicode character with this value (and output implicitly)

Alternative more in the spirit of the challenge using the output-format:
 -
| |
 -
| |
 -

38 bytes:
Σ•L7×•Nè}εi" -| | "14∍2ôNèëðº]J24S5∍£»

Can definitely be golfed..
Try it online or verify all possible inputs.
Explanation:
Σ       }          # Sort the (implicit) input-digits by:
 •L7×•Nè           #  The digit at the same index in the compressed integer 1367524
                   #   i.e. "1101101" → ["1","0","1","1","1","0","1"]
ε                  # Then map each digit to:
 i                 #  If it's a 1:
  " -| | "         #   Push string " -| | "
          14∍      #   Lengthen it to size 14: " -| |  -| |  -"
             2ô    #   Split it into parts of 2: [" -","| ","| "," -","| ","| "," -"]
               Nè  #   Index into it
 ë                 #  Else (it's a 0):
  ðº               #   Push "  " (two spaces) instead
    ]              # Close both the if-else and map
                   #  i.e. ["1","0","1","1","1","0","1"]
                   #   → [" -","  ","| "," -","| ","  "," -"]
J                  # Join everything together to a single string
                   #  i.e. [" -","  ","| "," -","| ","  "," -"] → " -  |  -|    -"
 24S               # Push [2,4]
    5∍             # Lengthened to size 5: [2,4,2,4,2]
      £            # Split the string into parts of that size
                   #  i.e. " -  |  -|    -" → [" -","  | "," -","|   "," -"]
       »           # Join by newlines (and output implicitly)
                   #  i.e. [" -","  | "," -","|   "," -"] → " -\n  | \n -\n|   \n -"

See this 05AB1E tip of mine (section How to compress large integers?) to understand why •L7×• is 1367524.