text:
It's a double+ header!
Related
Exposition
After winning the SO raffle, you could have been on top the world, and you were! The raffle had been going on for a year, now, and you were one of a hundred programmers who were selected to enter into the SO stronghold. And finally, the wait is over. Today is the day you go to--[obfuscated text proceeds].
Whoops. Sorry, not supposed to tell.
Anyhow, you finally have arrived to meet a stoic-faced man in a black suit with the tiny SO emblem on it. He frowns at you. "The others are already inside," he said, noting that you had been identified at the gate. "Quickly."
You rush inside, a tad scared. What on earth had gone on? What was wrong at SO? Inside, you observe the other 99 programmers are staring intently at their screens, typing. You take the remaining seat, and are greeted with the following message:

Hello, programmer! It seems that we have encountered a problem; SO has been penetrated, by whom we don't know. (Personally, I suspect it was a Pyth or CJam programmer, but hey.) However, all that has been harmed is the Markdown editor. Well, actually, that's quite a lot, but that's where you come in.I want you to create a program (or function, we're not picky) that will interpret a markdown file and convert it to our new "SO Beautifier-Arity-Decomposer" (a.k.a. "SOBAD") format. You must do this in the shortest amount of bytes--we are running on lowdown until we resolve this hacking issue. Thanks for your time, and best of luck!Sincerely,The Maker of Stack Overflow

Objective Given a valid markdown file as input to your submission, perform and output the following transformations on the input:
(When I use the + symbol, I mean the RegExp "one or more instances of previous character" operator, not a literal plus sign.)

Transform all Level 1 headers (# ... or ...\n=+) to { ... }, with ... becoming ALL CAPS.
Transform all Level 2 headers (## ... or ...\n-+) to {{ ... }}, with every word capitalized
Transform all Level 3 headers (### ...) to small caps; that is, all letters (case insensitive) are mapped to ᴀʙᴄᴅᴇғɢʜɪᴊᴋʟᴍɴᴏᴘǫʀsᴛᴜᴠᴡxʏᴢ in a respective fashion.
Transform all bold instances (**...**) to ..., with ... becoming ALL CAPS.
Transform all italic instances (_..._) to . . ., where a space has been inserted between each pair of characters.
Transform all code instances (`...`) to < ... >.
Transform all strikethrough instances (---...---) to -.-.-.-, where a - has been inserted between each pair of characters.
Transform all numbered list instances (N. {a}\nN. {b} ... where N matches the regex [0-9]+) to (1. {a}\n 2. {b}...)
Transform all unordered list instances (* ...\n* ......) to (o ...\n o ......)

More details

Headers and list instances will only be found at the beginning of lines, however, they may be surrounded by an amount of whitespace.
There will be no linked instances, e.g., *a_*a_ is not valid for our standards, nor will anything like __a__, *_a_*, or _*a*_ appear in an input.
A multiline header is valid if and only if the - or =s directly follows a line of text.
No headers will contain other markdown entities. E.g., # `code` snippet is not a valid input for our purposes
You do not have to account for Level 4+ headers
You do not have to preserve excess spaces (i.e. > 1 spaces) within the file, so it is O.K. to have **hello  there** to become **hello there** but not **hellothere**. Similarly, trailing and leading spaces found on a line does not have to be preserved
No tabulators will be found in the input.
THERE WILL BE NO NESTED INSTANCES. For example, ***...*** would never occur.
A space will always follow an unordered bullet point (E.g., * ... not *...)
List items in ordered and unordered lists will always consist of a single line.
Unmatched pairs of characters should be ignored. E.g., ** cool and `java::def should remain the same.

Input methods
The input must be one of the following:

An array/tuple/list/etc. of strings.
OR a string containing newlines to separate lines.

Use your language's closest equivalent to the aforementioned data types if your language does not support them. (E.g., TI-BASIC doesn't support (1.)… not that TI-BASIC can compete, anyhow :P).
Test cases
A } signifies input, and the next line signifies output. Multiple }s signify newline-separated lines of text.
} Hello!
Hello!

} That _2 + 2 = 5_ challenge sure was **intense!**
That  2  +  2  =  5  challenge sure was INTENSE!
    // note that there are spaces also padding it

} It's `s/a/e/g` **not** `sudo g/a/e/s`, stupid.
It's < s/a/e/g > NOT < sudo g/a/e/s >

} **WHAT!** He did _WHAT?!_
WHAT! He did W H A T ? !

} _WHAT_ is undefined, here!
 W H A T  is undefined, here!

} OI)(EJDSFIJK L:JP #@*REF&WDS F*(D+S +&(SDFWEF )DSF _DSF_F #R#
OI)(EJDSFIJK L:JP #@*REF&WDS F*(D+S +&(SDFWEF )DSF  D S F F #R#

} # So, you wanna be a programmer, eh?
} ## Step 1: learn recursion
} ### Learning recursion requires learning recursion
} **Programming** is a futile task. _Leave w h i l e you still can!_
{SO YOU WANNA BE A PROGRAMMER, EH?}
{{Step 1: Learn Recursion}}
ʟᴇᴀʀɴɪɴɢ ʀᴇᴄᴜʀsɪᴏɴ ʀᴇǫᴜɪʀᴇs ʟᴇᴀʀɴɪɴɢ ʀᴇᴄᴜʀsɪᴏɴ
PROGRAMMING is a futile task.  L e a v e   w   h   i   l   e   y o u   s t i l l   c a n !  // trailing space not required

} Haha, you're a _Java_ golfer? You'd be better of with brainf***.
Haha, you're a  J a v a  golfer? You'd be better of with brainf***. // less than four asterisks, do nothing

} # Reasons why NOT to use C--:
} 1. It doesn't exist.
} 2. I don't care.
{REASONS WHY NOT TO USE C--:}
 1. It doesn't exist.
 2. I don't care.

} 1. This is a test!
} 1. <-- And this actually works in Markdown.
 1. This is a test!
 2. <-- And this actually works in Markdown. // less than three -s, ignore

} * no.
} * NOOO.
} * fine.
 o no.
 o NOOO.
 o fine.

} Python, ---34--- 3 bytes.
Python, -3-4- 3 bytes.

} ---Long line of crossed text.---
-L-o-n-g- -l-i-n-e- -o-f- -c-r-o-s-s-e-d- -t-e-x-t-.-

} ** cool!
** cool! // is not a bullet point, because a space doesn't follow the *; Isn't bold, because there is no matching **

 -- end of test cases --

Bonus

-19 bytes if you support the escaping of characters (so that they are treated as "normal"); you may choose any escape character, but I'd suggest \ or ^. Note that the escaping system on SO sites is different from what I am suggesting (and more complicated), so don't do it! SO would treat `\` as \, but I would want you to treat the second ` as then a regular character, and instead match the next ` character.

The spec is too weak for a golf question.

"The markdown editor is broken! Quick, instead of using the vast number of programmers at our disposal to fix it, let's change formats and convert millions upon millions of posts!"

@FryAmTheEggman I said a_aa_ssume a valid markdown entry. That means that all uses of characters will be correct. I am editing spec now.

Thanks, downvoters, for telling me exactly what I am doing wrong. It really helps me make this question better.

I think there are cases where applying one transformation could change whether another transformation applies. For example, ***word*** becomes * * w o r d * * after you apply the italics transformation, and suddenly the bold transformation doesn't apply. It's unclear how to handle this.

@CᴏɴᴏʀO'Bʀɪᴇɴ There are a number of issues noted in the comments, which have upvotes. I don't think downvoters are purposefully neglecting to provide feedback; they're likely just upvoting existing feedback.

@AlexA. When both downvotes occurred, no upvotes existed on the comments, neither for a period afterwards.

It may be easier if you keep bold to **...** and italics to _..._

@ETHproductions Thank you for the suggestion -- it is greatly appreciated.

The question seems clear now, so I retracted my close vote.

@FryAmTheEggman Ah, I see. That example would be invalid; it's technically a nested expression. (When I say =+, I mean the RegExp command. Sorry, Lemme clarify.)

You should just post your challenges in the Sandbox first. That way you avoid all the complaints.

@mbomb007 Noted.

What do you mean by "Transform all italic instances (_..._) to ..., with ... being split by spaces"?

@PeterTaylor _Hello_ -> H e l l o

Python 3, 652 640 bytes
import re
def N(o):c,t,_=o.groups();x=' -'[c<'_'];return['< %s >'%t,t.upper()][c<'`']if c in'**`'else x+x.join(t)+x
def f(s):
 S=[];i=0
 while s:
  l=s.pop(0);n=set(*s[:1])
  if n<={*'=-'}and n:s=s[1:];l='#'*('-'in n)+'# '+l
  if'# '==l[:2]:l='{%s}'%l[2:].upper()
  if'## '==l[:3]:l='{{%s}}'%l[3:].title()
  if'### '==l[:4]:l=''.join('ᴀʙᴄᴅᴇғɢʜɪᴊᴋʟᴍɴᴏᴘǫʀsᴛᴜᴠᴡxʏᴢ'[ord(c)-65]if'@'<c<'['else c for c in l[4:].upper())
  l=re.sub(('(\*\*|_|---|`)(.*?)'*2)[:-5],N,re.sub(r'^\s*[*] (.*)',r' o \1',l))
  if re.match(r'\s*\d+\. ',l):i+=1;l=re.sub(r'\s*\d+\.(.*)',' %d.'%i+r'\1',l)
  else:i=0
  S+=[l]
 return S

Try it online!


text:
Electron Configuration Diagrams
Challenge
Given an element name, output its electron configuration.
Input
Your input will be the full name of each element (the range being from Hydrogen, 1, to Calcium, 20) with some exceptions - you should be able to account for the following inputs:
Natrium - This is sodium
Kalium - This is potassium

Note that inputs "sodium" and "potassium" must still be valid.
The first letter will always be capitalised.
Output
You can refer to this webpage for guidance on how to generate an electron configuration diagram.
The following list shows the maximum number of electrons in each shell:

1st shell - 2 electrons
2nd shell - 8 electrons
3rd shell - 8 electrons
4th shell - 14 electrons (although the maximum number of electrons in this shell required is 2)

An example output of the electron configuration is the following:

In the centre of the diagram must be the element's one to two letter symbol.
Either dots or crosses may be used and where they are placed does not matter.
The output does not have to be exactly like this but it does have to be an ASCII graphic. The one thing it cannot be is in the form 2.8.8.1 or any other form like this.
The circles are not necessary
Built in functions which access the periodic table of elements or produce diagrams or electron configurations are hereby disallowed.
Winning
The shortest program in bytes wins.

Do we need to show the electrons in pairs?

I recommend requiring one of ASCII art or graphical output, otherwise submissions aren't really comparable.

Is the first letter always capitalised (I hope so...)

Also in the link they draw them differently - you have both electrons on the first shell at the top, they have one at the top, one at the bottom.

I assume we can use any symbol to represent an electron (for example a large dot or even a square.) Do we need to include the element symbol in the centre?

Oh and having just looked at the existing answer, do we have to draw the circles?

Also, existing answers seem to have ignored the bit about charge. I suggest you remove it (you didn't specify a range for the charge anyway). Note that Ca-- is theoretically possible, though unlikely. Would the two additional electrons go into the expansion of the 3rd shell to from 8 to 18 (which is where they really belong) or elsewhere?

For more accurate info on what happens after 20, see here: https://en.wikipedia.org/wiki/Electron_shell

@TomCarpenter As long as you show x many electrons on each shell, it doesn't matter where you place the dots/crosses

MATLAB, 360 363 290 304 295 bytes
See at the bottom of the post for how to test the old code with Octave.
This code takes the name of the element (including Kalium, etc.) and displyas the output in ascii format now that the rules have changed.
f=input('');e=1;a=['CPACxxSAMSNxxxxxBLHxCKACSPSAMNNFONCBBLHH';'aorhxxilaoexxxxxeiexa rl  ilgae     eie '];for s=a;n=s(s~=32);if strncmpi(n,f,nnz(n));break;end;e=mod(e,20)+1;end;s=spiral(10);p=[8,18,33,28,23,39,60,53,46,95];p=[p;p+1];o=s*0;o(ismember(s,p(1:21-e)))='x';o(45:46)=a(:,e+20);char(o')

The rules changed since I wrote the code to require an ASCII output. I have updated my code to do this at the expense of 14 bytes. I have saved 9 bytes by getting rid of the reshape() and just making the a matrix the right shape to begin with.
Here is an explanation of how it works:
%Get the name - actually we only need at most the first two characters, but the whole thing will do
f=input('');
e=1;
%This bit makes a map which allows us to find the element (including with
%the names like Kalium. All of the elements appear twice, with the actual
%symbols being the second set. The first set gets all those whose names are
%either more than one character, or don't begin with the first two
%characters of the short for (e.g. Sodium). The string is reshaped into a
%2x40 array. 'Natrium' is a pain in the neck as it as it would get caught
%by 'N' for 'Nitrogen'. I have reversed the element order - so that all the
%ones beginning with N come before N. Some maths is done later on to
%correct for the number of electrons - basically 21-e so 1 becomes 20.
a=['CPACxxSAMSNxxxxxBLHxCKACSPSAMNNFONCBBLHH';'aorhxxilaoexxxxxeiexa rl  ilgae     eie '];

%For each group of 2 in the array of elements
for s=a

    %Remove any spaces from the name
    n=s(s~=32);

    %Do a comparison of the first one or two characters of the requested string
    if (strncmpi(n,f,nnz(n)))

        %break once the element is found
        break;
    end

    %If not this element add another electron. We wrap around after 20 as there are two copies of each
    e=mod(e,20)+1;
end
%e is now number of electrons

%Generate an array of points for each electron
s=spiral(10);
p=[8,18,33,28,23,39,60,53,46,95];p=[p;p+1];

%make an output array
o=s*0;

%Plot all the points in is up to and including the number of electrons (see the notes above for why 21-e)
o(ismember(s,p(1:21-e)))='x';

%And add the text in the centre - we extract the element name from the second group appearance in the 'a' array, hence adding 20.
o(45:46)=a(:,e+20);

%Display the result
char(o')

This is the output for Hydrogen (ignore the dots, they are to avoid the lines being removed when showing here):
          .
          .
          .
          .
   xH     .
          .
          .
          .
          .
          .

And here is the output for Calcium.
          .
    xx    .
    xx    .
          .
 xxxCa xxx.
 xxx   xxx.
          .
    xx    .
    xx    .
          .

And the output for Natrium, which now works properly (before Natrium it would result in Nitrogen!).
          .
     x    .
    xx    .
          .
  xxNa x  .
  xx   x  .
          .
    xx    .
          .
          .

The new version of the code doesn't work with Octave as it uses spiral() which is only present in MATLAB.
You can however test the old code using the Octave online interpreter:
f=input('');e=1;a=['CPACxxSAMSNxxxxxBLHxCKACSPSAMNNFONCBBLHH';'aorhxxilaoexxxxxeiexa rl  ilgae     eie '];for s=a;n=s(s~=32);if strncmpi(n,f,nnz(n));break;end;e=mod(e,20)+1;end;u=14:(34-e);r=floor(u/8);t=u*pi/4;polar(t,r,'o');text(0,0,a(:,e+20)','horizontalalignment','c')

Run that, then enter a string like: 'Hydrogen' (including the quote marks). Once it is done, you will have to click the expand plot button (looks like a little graph symbol in the top right corner of the interpreter) to get it to show the full thing. In Octave it unfortunately add lines joining the points, this does not happen in MATLAB. But at least it allows you to test the logic behind it. As I say, this is still a graphical output, but you get the idea of how the elements are looked up.

Now prints in ASCII.

Python 3, 529 bytes
thanks Thomas and Beta for pointing out some things that should've been obvious to me, saving me some bytes
massive improvement: using string slicing instead of dict lookup
s="""    {18}
    {10}{14}
    {2}{6}
    {0}{1}
 {17}{9} %s {3}{11}
 {13}{5}    {7}{15}

    {8}{4}
    {16}{12}
    {19}"""
e="H HeLiBe B C N O F NeNaMgAlSiP S ClArK Ca"
r="hydrogen   helium     lithium    beryllium  boron      carbon     nitrogen   oxygen     fluorine   neon       natrium    sodium     magnesium  aluminium  silicon    phosphoroussulfur     chlorine   argon      kalium     potassium  calcium    "
n=r.find(input().lower())//11
n-=(n>10)+(n>18)
print(s.format(*[' *'[i<=n]for i in range(20)])%e[n*2+1:n*2+3])

Not the prettiest of programs or outputs, but hey, we needed something to kick this challenge off. Try it online.

In the dictionary, couldn't you put the values in a single string like "H 1" and split them at the space later?

That's a long cup of coffee ;)

j=0
do
{
if(elnum=1)
{
draw_circle(100,100,50)
draw_sprite_ext(spr_electron,sprite num,100,100+50,direction,c_white,c_alpha)

}
else
{
if(elnum=2)
{
draw_circle(100,100,50)
draw_sprite_ext(spr_electron,sprite num,100,100+50,direction,c_white,c_alpha)
draw_sprite_ext(spr_electron,sprite num,100,100+50,direction,c_white,c_alpha)
}
if(j>1&&j<=8)
{
if(j>5)
angdeviation=5
else
angdeviation=-5
draw_circle(100,100,100)
draw_sprite_ext(spr_electron,sprite num,100+length_dirx(j*100+angdeviation),100+length_diry(j*100+angdeviation),direction,c_white,c_alpha)
}
}

}until(j<=enum)

Welcome to the site. What language is this in? I would recommend adding a heart like other submissions with all the relevant information.  Also since this is [tag:code-golf] you should aim to minimize the length of your program.  I can't be sure because I don't know what language you are using here but it looks like you have a good deal of excess whitespace.  Most languages have a tips page listing a bunch of helpful golfing tips you can use.  I would recommend checking out the page for the language you use here.

I am quite sure this is GML (the propietary Game Maker Language): https://en.wikipedia.org/wiki/GameMaker_Studio#GameMaker_Language  and https://docs.yoyogames.com/source/dadiospice/002_reference/001_gml%20language%20overview/

@WW other than the two blank lines I don't see any obvious excess whitespace.  The lines don't appear to end with semicolons or some other delimiter so I wouldn't be surprised that there can't be more than one thing on a line.  But the variable names could be shorter....

I am not sure how the "sprite num" part works - from the documentation it looks like it should be an integer and spaces in a variable name wouldn't be allowed: https://docs.yoyogames.com/source/dadiospice/002_reference/drawing/drawing%20sprites%20and%20backgrounds/draw_sprite_ext.html

source: Stack Exchange

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/

sort: votes


text:
Remove repeated words from a string
Remove all repeating words from an inputted sentence.
Input will be something like cat dog cat dog bird dog Snake snake Snake and the output should be cat dog bird Snake snake. There will always be a single space separating words.
Output order must be the same as input. (Refer to the example)
You don't need to handle punctuation but capital letter handling is required.

I recommend waiting to accept an answer for at least a few days. A shorter solution may still come.

I expect similar solutions to uniqchars, except that this doesn't ban built-ins that remove duplicates.

Seeing the example, there is not special capital letter handling: Snake and snake are treated simply as different

@AlexA.: In fact, there already is one. http://codegolf.stackexchange.com/questions/62044/remove-repeated-words-from-a-string/62108#62108

gs2, 3 bytes
,É-

Encoded in CP437.
STDIN is pushed at the start of the program. , splits it over spaces. É is uniq, which filters duplicates. - joins by spaces.

CJam, 7 chars
qS/_&S*

Can probably be much shorter... but whatever I've almost never used CJam. ^.^
q reads input, S/ splits on spaces, _& duplicates and applies a setwise AND (therefore getting rid of duplicates), and S* re-joins on space.
Online interpreter link

How can you even get much shorter than 7? lol

Some one just did.

Haskell, 34 bytes
import Data.List
unwords.nub.words

Usage example: (unwords.nub.words) "cat dog cat dog bird dog Snake snake Snake" -> "cat dog bird Snake snake".

APL, 22 20 bytes
{1↓∊∪(∊∘' '⊂⊢)' ',⍵}

This creates an unnamed monadic function that accepts a string on the right and returns a string.
Explanation:
               ' ',⍵}    ⍝ Prepend a space to the input string
     (∊∘' '⊂⊢)          ⍝ Split the string on spaces using a fork
    ∪                    ⍝ Select the unique elements
{1↓∊                     ⍝ Join into a string and drop the leading space

Try it online
Saved 2 bytes thanks to Dennis!

I love any answer that uses a non-esoteric, non-golf language.

Ruby, 21 chars
->s{s.split.uniq*' '}

JavaScript (ES6) 33
(see this answer)
Test running the snippet below in an EcmaScript 6 compliant browser (implementing Set, spread operator, template strings and arrow functions - I use Firefox).
Note: the conversion to Set drop all the duplicates and Set mantains the original ordering.

f=s=>[...Set(s.split` `)].join` `

function test() { O.innerHTML=f(I.value) }

test()
#I { width: 70% }
<input id=I value="cat dog cat dog bird dog Snake snake Snake"/><button onclick="test()">-></button>

Wow wow wow... I am continually amazed by your ability to cut any solution I think up by 25% or more. +1

Looked at the problem and immediately thought of Sets... only to realize that you'd already done it =P very nice!

how can set maintain the original ordering?

@njzk2 ask the developers of the language. It could be: a set is internally an Array, and at each insertion there is a check to reject duplicates. It's an implementation detail anyway

@njzk2 while I don't know how, I know that this fact is specified by the language: Set objects are collections of values, you can iterate its elements in insertion order. A value in the Set may only occur once; it is unique in the Set's collection. (https://developer.mozilla.org/it/docs/Web/JavaScript/Reference/Global_Objects/Set)

TeaScript, 12 bytes
TeaScript is JavaScript for golfing.
xs` `u()j` `

This is pretty short. It splits on each space, filters out duplicates, then rejoins.
Try it online

Is it tee-a script or tee script?

@MathiasFoster it would be "tee-script"

Does TeaScript have letters reserved for variable names? Most of them appear to be shorthands for built-in properties.

@intrepidcoder yes all of these: cdfghijklmnopstuvw are reserved for variables, they are all pre-initialized to 0. b is also reserved for a variable name, it is pre-initialized to an empty string

PowerShell, 15 Bytes
$args|select -u

Whoa, an actual entry where PowerShell is somewhat competitive? That's unpossible!
Takes the string as input arguments, pipes to Select-Object with the -Unique flag. Spits out an array of strings, preserving order and capitalization as requested.
Usage:
PS C:\Tools\Scripts\golfing> .\remove-repeated-words-from-string.ps1 cat dog cat dog bird dog Snake snake Snake
cat
dog
bird
Snake
snake

If this is too "cheaty" in assuming the input can be as command-line arguments, then go for the following, at 24 21 Bytes (saved some bytes thanks to blabb). Interestingly, using the unary operator in this direction happens to also work if the input string is demarcated with quotes or as individual arguments, since the default -split is by spaces. Bonus.
-split$args|select -u

Relying on the environment's behavior of spoon-feeding the code with readily split up input…?

@manatwork I've added a clarification if the first usage is considered too "cheaty" -- since it's not clear exactly how the input is specified, we'll leave it up to the OP.

And now is clear how efficients are PowerShell's own features. That 24 really deserves an upvote.

@timmyD you can chop off 3 bytes to the uncheaty ?? version by using the unary split and no need for "" '' in the commandline args too
:>ls -l split.ps1 & type split.ps1 & echo.&powershell -nologo -f split.ps1 cat
dog cat dog bird dog Snake snake Snake
-rw-rw-rw-  1 Admin 0 21 2015-11-02 19:06 split.ps1
-split$args|select -u
cat
dog
bird
Snake
snake

Julia, 29 bytes
s->join(unique(split(s))," ")

This creates an unnamed function that splits the string into a vector on spaces, keeps only the unique elements (preserving order), and joins the array back into a string with spaces.

R, 22 bytes
cat(unique(scan(,"")))

This reads a string from STDIN and splits it into a vector on spaces using scan(,""), selects only unique elements, then concatenates them into a string and prints it to STDOUT using cat.

Retina, 22 bytes
 (\w+)\b(?<=\b\1\b.+)

Save the file with a trailing linefeed and run it with the -s flag.
This is fairly straight forward in that it matches a single word, and the lookbehind checks whether that same word has appeared in the string before. The trailing linefeed causes Retina to work in Replace mode with an empty replacement string, removing all matches.

Mathematica, 43 39 bytes
StringRiffle@*Keys@*Counts@*StringSplit

Kudos for using StringRiffle[].

could use Keys@Counts instead of DeleteDuplicates

@branislav Does Keys@Counts preserve order?

@LegionMammal978 Counts[list] gives an association whose keys are in the same order as they first occur as elements of list.

Pyth - 9 bytes
Well this is why we're all waiting for Pyth5, could have been 5 bytes.
jdoxzN{cz

Try it online here.

Why isn't Pyth5 valid? It appears to be implemented.

@ThomasKwa I don't think it's finished. There hasn't been a versioned release yet.

C++11, 291 bytes
#include<iostream>
#include<string>
#include<list>
#include<sstream>
#include<algorithm>
using namespace std;main(){string s;getline(cin,s);list<string>m;stringstream b(s);while(getline(b,s,' '))if(find(m.begin(),m.end(),s)==m.end())m.push_back(s);for(auto a:m)cout<<a<<' ';cout<<endl;}

I don't see a whole lot of C++ answers compared to golfing languages, so why not. Note that this uses C++11 features, and so if your compiler is stuck in the dark ages sufficiently old enough, you may need to pass a special compilation switch to make it use the C++11 standard. For g++, it's -std=c++11 (only needed for versions < 5.2). Try it online

If you compare the number of bytes with other languages, you will see why no one is using C++.

@CroCo If you realize the point of this site is to find the shortest solution in each language, you will see why I posted this answer.

sorry I'm not aware of it.

Why not use a set? It allows no duplicates by design. Just push into it.

@black A set is not guaranteed to have the items in the same order they were added.

K5, 9 bytes
" "/?" "\

FYI, this is a function.
Explanation
     " "\    Split the input on spaces
    ?        Find all the unique elements
" "/         Join them back together

Matlab: 18 Bytes
unique(d,'stable')

where d is d = {'cat','dog','cat','dog','bird','dog','Snake','snake','Snake'}.
The result is 'cat'    'dog'    'bird'    'Snake'    'snake'

Welcome to Programming Puzzles and Code Golf! Submissions here need to either be full programs that read from STDIN and write to STDOUT, or functions which accept input and return output. As it stands, this is merely a snippet; it assumes the variable d is already assigned. You can rectify this by using a function handle: @(d)unique(d,'stable'), at the cost of 4 bytes.

Python 3, 55
l=[]
for x in input().split():l+=[x][x in l:]
print(*l)

Yeesh, this is long. Unfortunately, Python's set doesn't keep the order of the elements, so we have to do the work ourselves. We iterate through the input words, keeping a list l of elements that aren't yet in l. Then, we print the contents of l space-separated.
A string version of l would not work if some words are substrings of other words.

C#, 38 bytes
String.Join(" ",s.Split().Distinct());

I'm not sure you can assume input is already populated in s, I think you should get it as an argument.

Welcome to PPCG! Please have a look at our default answer formats. Answers should either be full programs or functions. Unnamed functions (like lambda literals) are fine, but snippets which expect the code to already exist in some variable/on the stack etc. or require a REPL environment are generally disallowed unless the OP explicitly permits them.

Perl 6, 14 bytes
As a whole program the only way you would write it is 21 bytes long
say $*IN.words.unique # 21 bytes

As a lambda expression the shortest is 14 bytes
*.words.unique # 14 bytes

say ( *.words.unique ).('cat dog cat dog bird dog Snake snake Snake')

my &foo = *.words.unique;
say foo $*IN;

While the output is a List, if you put it in a stringifying context it will put a space between the elements. If it was a requirement to return a string you could just add a ~ to the front ~*.words.unique.

If snippets were allowed, you could shorten it to 13 bytes by removing the *.
$_ = 'cat dog cat dog bird dog Snake snake Snake';

say .words.unique

Python 3, 87 80 bytes
turns out the full program version is shorter
s=input().split(' ')
print(' '.join(e for i,e in enumerate(s)if e not in s[:i]))

Did it without regex, I am happy
Try it online

Lua, 94 bytes
function c(a)l={}return a:gsub("%S+",function(b)if l[b]then return""else l[b]=true end end)end

An anonymous user suggested to replace ... return""else l[b]=true end end... with ...return""end l[b]=""end....

awk, 25
BEGIN{RS=ORS=" "}!c[$0]++

Output:
$ printf "cat dog cat dog bird dog Snake snake Snake" | awk 'BEGIN{RS=ORS=" "}!c[$0]++'
cat dog bird Snake snake $
$

Scala, 44 47 bytes
(s:String)=>s.split(" ").distinct.mkString(" ")

EDIT: using toSet might not preserve order, so I'm now using distinct // that just cost me 3 bytes :(

JavaScript, 106 102 100 bytes
function(s){o={};s.split(' ').map(function(w){o[w]=1});a=[];for(w in o)a.push(w);return a.join(' ')}

// way too long for JS :(

Try using JS (aka ECMAScript) 6 arrow functions, which should save 6 bytes. Also, I can already see porting this to CoffeeScript will save at least 30 bytes.

This answer is in native JavaScript (ECMA5), there is edc65's one for es6.

PHP 64 59 bytes
function r($i){echo join(" ",array_unique(split(" ",$i)));}

explode() → split(), implode() → join()?

Thanks! Good suggestions. Seems split is being depricated though, but guess that does not matter for codegolving.

Hassium, 91 bytes
func main(){d=[]foreach(w in input().split(' '))if(!(d.contains(w))){d.add(w)print(w+" ")}}

Run online and see expanded here

AppleScript, 162 bytes
Interestingly, this is almost identical to the non-repeating characters thing.
set x to(display dialog""default answer"")'s text returned's words
set o to""
repeat with i in x
considering case
if not i is in o then set o to o&i&" "
end
end
o
I didn't actually know the considering keyword before this. the more you know...

Burlesque, 6 bytes
blsq ) "cat dog cat dog bird dog Snake snake Snake"wdNBwD
cat dog bird Snake snake

Rather simple: split words, nub (nub = remove duplicates), convert back to words.

Gema, 21 characters
*\S=${$0;$0}@set{$0;}

(Very similar to the unique character solution, as there are no arrays in Gema, so allowing built-in unique functions not helps us much.)
Sample run:
bash-4.3$ gema '*\S=${$0;$0}@set{$0;}' <<< 'cat dog cat dog bird dog Snake snake Snake'
cat dog bird Snake snake

PHP, 37 Bytes
Assuming $s is the input string.
print_r(array_flip(explode(' ',$s)));

Ruby, 24 bytes
Similar to Doorknob's answer, just a full program.
puts gets.split.uniq*' '

puts                     print
     gets.split          split input by space
               .uniq     make each element unique
                    *' ' join with spaces

If it's a full program then I guess it should have some output too...?

Thanks, I forgot to add puts facepalm

C#, 909 bytes
class Dictionary
{
    public Dictionary<int, string> InsertWordsIntoDictionary(string userInput)
    {
        Dictionary<int, string> newWords = new Dictionary<int, string>();
        int a = 0;
        int b = 1;

        userInput = userInput.Insert(userInput.Length, " ");

        for (int i = 0; i < userInput.Length; i++)
        {
            char holder = userInput.ElementAt(i);
            if (holder.Equals(' '))
            {
                if (!newWords.ContainsValue(userInput.Substring(a, i - a)))
                {
                    string hello = userInput.Substring(a, i - a);
                    newWords.Add(b, hello);
                    a = i + 1;
                    b++;
                    hello = userInput;
                }
                a = i + 1;
            }
        }
        return newWords;
    }
}

Welcome to PP&CG. This post is a codegolf, which means that you're supposed to solve the problem in as few bytes as possible. Take a look at the other answers here and you'll probably get the idea. Also you haven't told us what language youranswer is in (is it C#? Then this might prove useful), and there is no byte-count.

Wow, am such a noob! I see, thanks for your help! Yes it is C#

I added a header to your answer (it is good practice to do that yourself). The best way to respond to comments is by editing your answer. You really should make some attempt to actually golf your answer.

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


text:
Find amount of heads and tails from percentages
Note: as this question has been marked as a duplicate, I have accepted an answer. However, I will still check this question if users can find a shorter way of doing it, and accept that answer.
Given two numbers (which are multiples of 0.5) representing heads-percentage and tails-percentage from a series of coin-flipping, output the minimum amounts of heads and tails to produce percentages such as those. Input and output can be in any form. However, output must be in a readable format (Good examples are x y, [x y], etc).
Examples:

Input: 25 75 (25% heads, 75% tails) Output: 1 3 (an output of 25 75 is invalid since that is not the minimum amounts of heads and tails to produce those percentages)
Input: 30 70 (30% heads, 70% tails) Output: 3 7
Input: 99.5 0.5 (99.5% heads, 0.5% tails) Output: 199 1

You may assume that there will always be a digit before and after a decimal point in an input (no .5s or 15.s). You may also assume the input adds up to 100%. This is code-golf, shortest code in bytes wins!

Can the numbers be taken as a list? As two number inputs?

@xnor either is fine

Would [199.0, 1.0] a valid output for the last example?

@Dennis yes it would.

This might effectively be the same as simplifying a fraction. My answer there is basically the same as here except for input processing.

I'm not sure whether this is a dupe of the question xnor linked or whether it's a continued fractions question similar to http://codegolf.stackexchange.com/q/17239/194 or http://codegolf.stackexchange.com/q/26278/194 which requires finding the simplest fraction which rounds to the given input.

Also similar to this one.

And the BigRational datatype in my Java library is set up to simplify the fraction automatically in the constructor.

@xnor it is defined similar, but I dont think it is close enough to close.

If the total adds up to 100%, why not accept a single number input 0 <= x <= 100?

@JArkinstall that is a good thought, but it is much too late now as 9 people would have to change their answers and it is not a good idea to change spec after this many people answered.

I'm not suggesting that it is changed - I was just wondering if there's a specific reason. Aaaand now this has been closed as a dupe, so that's my half-baked Haskell attempt lost in the sands of time.

@JArkinstall I just did not think of it at first, now thinking about it though, it would of prevented a 3 byte answer... oh well.

Dyalog APL, 3 bytes
,÷∨

This is a dyadic function train that accepts the percentages as left and right arguments:
┌─┼─┐
, ÷ ∨

It is equivalent to the following, train-less function:
{(⍺,⍵)÷⍺∨⍵}

Try it online on TryAPL.
How it works
  ∨  Compute the GCD of both arguments.
,    Concatenate both arguments.
 ÷   Divide the latter by the former.

There is literally no way this can be beaten. Excellent job! :D

I really should learn this language, it looks fascinating.

Python 2, 47 bytes
A,B=a,b=input()
while b:a,b=b,a%b
print A/a,B/a

Takes input like 15,20 and prints the output like 3 4.
Performs the Euclidian algorithm to find the gcd, then scales the numbers by it.
Fortunately, Python will happily compute % on fractions, so inputs like 0.5 99.5 behave just the same. More type-strict languages (cough, Haskell) aren't so lucky.

Also, floats are annoying in Haskell. 20/100*5 is not equal to 20/100 + 20/100 + 20/100 + 20/100 + 20/100, which is what is put in lists like [0,20/100..]

J, 4 bytes
,%+.

Explanation:
       (x +. y)     NB. GCD of the left and right inputs
      %             NB. divided by
(x, y)              NB. a vector consisting of the inputs

Try it online

CJam, 25 14 bytes
{_~{_@\%}h;f/}

This is an unnamed function that pops a list from the stack and leaves one in return. Like @xnor's answer, it uses the Euclidean algorithm to find the GCD, then divides the list elements by it.
Try it online in the CJam interpreter.
How it works
_             Push a copy of the input array.
 ~            Dump its elements on the stack.
  {    }h     Do:
   _            Push a copy of the topmost integer.
    @           Rotate the bottom-most integer on top of it.
     \          Swap them.
      %         Calculate the residue of their division.
              While the residue is positive, repeat the loop.
         ;    Discard the last residue (0).
              This leaves the GCD on the stack.
          f/  Divide the elements of the input array by their GCD.

Pyth, 12 bytes
J/R.5Q/RiFJJ

Like @xnor's answer, this divides each list item by their GCD. Pyth has the GCD as a built-in, but it doesn't work for floats out of the box.
Try it online.
How it works
              (implicit) Save the evaluated input in Q.
 /R.5Q        Divide each element of Q by 0.5.
              This transforms the array's floats into integers.
J             Save the result in J.
        iFJ   Compute the GCD of the elements of J.
      /R   J  Divide the elements of J by their GCD.

Since the numbers are multiples of 0.5, could you multiply the inputs by 2, and then use the integer GCD?

That's actually what I'm doing. /R.5 divides by 0.5, casting to integer in the process.

Oh, ok, that makes sense. From the description I got the impression that you might not be using the built-in GCD, and went for the Euclid algorithm instead.

APL, 20 bytes
{⍺⍵÷⍺{0<⍵:⍵∇⍵|⍺⋄⍺}⍵}

This creates an unnamed dyadic function that accepts the inputs on the left and right and returns an array. Unlike Dennis' super slick Dyalog solution, this works with other versions of APL because it doesn't use trains and it doesn't assume that GCD (∨) works for floats.
Explanation:
    ⍺{0<⍵:⍵∇⍵|⍺⋄⍺}⍵}   ⍝ Compute the GCD of the inputs using the Euclidean algorithm
{⍺⍵÷                   ⍝ Divide the inputs by their GCD

Try all test cases online

Mathematica, 21 bytes
#/GCD@@Rationalize@#&

Another program with the same byte count is
#/GCD@@(Floor[2#]/2)&

Mma has never supported FP well...

TI-BASIC, 31 22 24 bytes
Forgot to count new lines before...
Prompt A,B
gcd(2A,2B➡C
Disp 2A/C,2B/C

This was done in the middle of math class...

You can skip the closing parenthesis in the third line.

And you can use Disp instead of Output to save about 8 bytes.

Also, chainging the top two lines to 'Prompt A,B' might help.

You can use the implicit Disp at the end if you output as a list: 2/C{A,B.

If you also take input as a list from Ans there's an 11 byte solution: 2Ans/min(gcd(2Ans,min(2Ans

Common Lisp, 168 94
(let((x(floor(*(read)2)))(y(floor(*(read)2))))(format t "~A ~A"(/ x(gcd x y))(/ y(gcd y x))))

I missed the original bit about everything being a multiple of 0.5 (thanks xnor!), so this is a good bit shorter than my first go (Gotta' love that almost a third of those bytes are parentheses.)

You're guaranteed the inputs are multiples of 0.5, so doubling suffices to make them whole.

Oh wow, I didn't even notice that. I'll shorten this answer right quick, thanks.


text:
A single pixel moving in a circular path
This is a graphical output challenge where the task is to give the shortest code per language.
Task
Your code should plot a single purple pixel (hex value #800080 or
rgb(128, 0, 128)), moving clockwise round a circle. It should take exactly 60 seconds to make a full journey round the circle and should continue indefinitely. Nothing else should be shown on the screen or window except for the pixel.  The width of the circle should be 0.75 (rounding suitably) the width of the screen or window and the background should be white.  To prevent silly solutions, the screen or window should be at least 100 pixels wide.
Your code should be a full program.
Languages and libraries
You can use any language or library you like. However, I would like to be able to test your code if possible so if you can provide clear instructions for how to run it in Ubuntu that would be very much appreciated.
Missing top twenty languages. Help needed.
The following top twenty programming languages are currently missing any solution at all.

C, C++, C#, Python, PHP, Visual Basic .NET, Perl, Delphi/Object Pascal, Assembly, Objective-C, Swift, Pascal, Matlab/Octave, PL/SQL, OpenEdge ABL, R

Catalog
The Stack Snippet at the bottom of this post generates the catalog from the answers a) as a list of shortest solution per language and b) as an overall leaderboard.
To make sure that your answer shows up, please start your answer with a headline, using the following Markdown template:
## Language Name, N bytes

where N is the size of your submission. If you improve your score, you can keep old scores in the headline, by striking them through. For instance:
## Ruby, <s>104</s> <s>101</s> 96 bytes

If there you want to include multiple numbers in your header (e.g. because your score is the sum of two files or you want to list interpreter flag penalties separately), make sure that the actual score is the last number in the header:
## Perl, 43 + 2 (-p flag) = 45 bytes

You can also make the language name a link which will then show up in the snippet:
## [><>](http://esolangs.org/wiki/Fish), 121 bytes

 <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b">

Shortest Solution by Language

Language	User	Score

Leaderboard

	Author	Language	Size

{{PLACE}}	{{NAME}}	{{LANGUAGE}}	{{SIZE}}	Link

{{LANGUAGE}}	{{NAME}}	{{SIZE}}	Link

what radius should the circle be?

@TimothyGroote "The width of the circle should be 0.75 (rounding suitably) the width of the screen or window and the background should be white." (Although I'm not sure what window, since the animation should fill the entire screen.)

Why should the pixel be purple? I would assume some languages like TI-Basic don't have color capabilities, which means they can't be used for the challenge for a pretty abitrary reason

@Fatalize that doesn't mean you can't golf the color into the program in some clever creative way to save bytes.

@TimothyGroote TI-BASIC has mainly only one color: black. Everything else is an off pixel. There are C(SE) calculators that have colors, but not everyone has one.

@CᴏɴᴏʀO'Bʀɪᴇɴ The good news is that BBC BASIC can do color. http://www.bbcbasic.co.uk/bbcwin/manual/bbcwin3.html

@Lembik ....Lucky. Verry lucky

I'm sure putting a purple cellofane over your screen does not add to your code size in bytes. i mean it worked vor the vectrex ;)

No restriction on move granularity? So a pixel jumping each 30 seconds to the diagonally opposite point on the circle would be valid?

@manatwork Good question. No that would be no good.  It should be smooth animation. I don't want to define exactly what that means but it should certainly not skip pixels out on purpose.

QBasic also has a limited set of colors. Is #8B008B (dark magenta, COLOR 5) close enough?

@DLosc Yes that will be fine. If you could include instructions for how to run qbasic code too that would be great.

Another question. The QBasic screen mode I want to use is 320 wide by 200 tall.  The biggest circle that fits on that screen will be slightly less than 0.75 of the width of the screen.  Ok to use as long as it's more than 0.75 of the height of the screen?

@DLosc Please go ahead :)

Can the pixel blink as it moves?  Also curious whether purple is mandatory, I have an answer using TI-Basic and its monochrome screen.

@codebreaker I am not sure what you mean by blink.  purple is the rule but as there is no winning criterion I would just do your best and see if anyone upvotes you :)

I think you should've chosen black for the background so we could actually see the pixel more easily.

@mbomb007 Yes you are right.

Is it at least 0.75x screen width, or exactly?

There should be a turtle answer!

What is the minimum update rate? 1 frame per second?

@Lembik: Is it OK if the time required for a full circle is 60 seconds on a particular machine, or does the timing have to be machine-independent?

@FranzD. Ideally it would be machine-independent but I won't be too fussy.

@Lembik, you're a quick one :)

@ThomasKwa Given that it has to do a full circle in 60 seconds and it has to be smooth, the frame rate should be fast enough to allow that.

@Lembik If you mean by smooth that every pixel on the circle must be displayed, I need to change my answer again, since TI-BASIC doesn't have any means of getting fractional seconds. Is it acceptable for the program to terminate after a couple of years?

@ThomasKwa Yes it is!

as there is no winning criterion I would just do your best and see if anyone upvotes you That's not how catalogs work. If your challenge says the pixel must be purple, it must be purple. If you want exempt some languages from this rule, say so in the question.

@Dennis You are right. I just didn't want to be mean.

interesting coincidence, a quora answer about drawing a circle to a CRT on a PDP-8 in 1969 just came up in my digest feed this morning: http://qr.ae/RkWTqm

@zamnuts A clear case of time travel assisted plagiarism I think!

Processing, 101 97 96 bytes
4 bytes thanks to Flambino.
1 byte thanks to Kritixi Lithos.
float d;void draw(){background(-1);stroke(#800080);d+=PI/1800;point(50+cos(d)*38,50+sin(d)*38);}

This creates a default 100 by 100 pixel window with the required animation.

Disclaimer: that image is not a GIF. Don't stare at it for a minute.

clever. i had no idea you could just omit setup.

Does this implement the 60 seconds rule?

@Lembik Yes. The default framerate is 60 fps, and I'm incrementing the angle π/1800 radians at a time. (It was π/3600 10 seconds ago because of my brain fart.)

@Pietu1998 That brainfart was due to the fact that pi is wrong

@Cruncher gotta love vi hart!

You can save 4 bytes: Don't bother initializing d to zero, and define the stroke as stroke(#800080); - Processing understands CSS-style hex colors

Hey, your GIF isn't working, I stared at it for a minute but nothing happened

@BetaDecay If you look closely, it's actually a video file. Simply click on the play button and watch carefully.

background(-1); is 1 byte shorter

Also you can move the d+=PI/1800 into cos like this: point(50+cos(d+=PI/180)*38,50+sin(d)*38); to save few bytes

QB64, 79 bytes
QB64 is a QBasic emulator that adds some nice features. This program uses one (CLS,15) that isn't supported by vanilla QBasic.
SCREEN 7
DO
T=TIMER/9.55
PSET(COS(T)*75+99,SIN(T)*75+99),5
PLAY"c8"
CLS,15
LOOP

This is very loud. It uses the PLAY command to halt execution for a short while before clearing the screen; otherwise the pixel will flicker and become invisible.
Download QB64, load this file, click Run and then Start.
Here it is in action:

I took some tricks (SCREEN 7 instead of SCREEN 13, and PSET instead of POKE) from @DLosc's answer, so credit is due. As in his answer, my magenta is actually #8B008B, which was deemed acceptable by the OP.
(The constant 9.55 is an approximation of 30/π = 9.54929658551. Is it close enough?)

Ha! Never thought of using PLAY for a delay. Could've sworn there was a code for a rest, but I'm not seeing it now in the help file. I did consider using (a function of) TIMER as the parameter, but never tried it to see if it was shorter. Kudos!

Thank! I shamelessly lifted PSET from you, so kudos back :) It looks like a rest is n0 which is longer than c. Also, I like it as a bit of rule-bending: the OP said nothing else could be shown in the window, but never said my program couldn't loudly go BEEP BEEP BEEP BEEP.

I have nothing against the beeps but I can't actually see a pixel moving around a circle when I try in linux.

Here it is in action on my machine, which should be enough proof.

@Mauris That is convincing. Is that in QB64 on linux?

That's QB64 on Windows. I have no idea what would cause it to behave differently... Maybe @DLosc can test it in DOS?

I stared at the image for a while, because you said "here it is in action".

Works for me too now! (I had a typo.) Very impressive.

@Mauris The ,15 after CLS is not valid for QBasic 4.5 and not necessary - you can omit it.

Doesn't the background color have to be white? For me, that changes it to black.

Yes it does, (I didn't read that). Still, it is not valid QB Syntax (debugger expects the end of the statement after CLS). I tried it with QBasic 1.1 and 4.5. I don't have 7.1 currently installed, but it should make no difference. What's the version you are targeting?

Ah, it looks like that argument to CLS is a QB64 extension... I'll add that to the post.

@Mauris QB64 is really almost it's own language. I suggest changing the header to "QB64" :)

HTML, 235 290 295 354 347 bytes

Edits

Added 7 bytes. I thought nobody would notice, that there's a default easing on the animation. ;) I've set it to linear now.
Saved 59 bytes by throwing everything abort that the browser will handle automatically.
Saved 3 bytes by removing the trailing )}}. Thanks to toothbrush.
Saved 2 bytes by using 12% instead of 12px which is the same value corresponding to the size of the parent element.
Saved 55 bytes due to massive refactoring, also taken a lot of comments into account. Thanks a lot for all the contributions.

I just wanted to comment on the post, i would like to see a pure html/css solution (ty for submitting one)

Using fiddle the speed of the moving pixel is very uneven. It almost grinds to a halt when the pixel is on the far left. Any ideas why?

@Lembik Argh, I thought nobody would notice due to the long duration of 60 seconds. ;) There's a default easing which you have to overwrite by linear. The answer is already updated.

@insertusernamehere :) I think the ungolfed version needs updating too now.

You could use other units, like em, cm, mm, in and so on. 9cm should be enough.

I'm pretty sure you can use  to cut a few bytes.

@Ypnypn Wouldn't that result in invalid HTML5?

@insertusernamehere If I'm not mistaken, most browsers will still accept it

@Ypnypn True that, but then you could also skip the head and body elements and set styles within body. ;)

You should go for the smallest working code irrespective of validity. Things like polluting the global namespace are par for the course while golfing.

@JanDvorak Thanks for your tip. I've thrown everything abort now that is unnecessary. :)

@JanDvorak  Dirty advice! Maybe at least have one good quality answer and one that breaks all the rules :)

@lembik perhaps separate valid/invalid HTML in two separate languages?

@ismael 9% for the win. As long as it works in your environment, you're golden.

Do you need to specify the body size at all? I think not.

Can you remove the content:''?

You can drop )}} from the end (the CSS parser will automatically end the blocks)

@toothbrush Good catch. Updated.

You can skip the whole :after ruleset. Instead set a to left: 50%, width: 1px, and border-top: 1px solid #800080 - saves you 48 bytes by my count

If you merge position:absolute, which is defined for both a and a:after, you can save 8 more bytes:

authors: n̴̖̋h̷͉̃a̷̭̿h̸̡̅ẗ̵̨́d̷̰̀ĥ̷̳

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


text:
Combination lock counter
The scene is:
Peter is at the gym with his buddy Brian when Brian suddenly is in dire need of his inhaler. Brian manages to tell Peter the code to his combination lock before he collapses on the floor.
The moment Peter gets to Brian's locker and sees what the indicator is pointing at, Stewie ambushes him and sprays a full can of pepper spray in his face, thus blinding Peter.
Peter must now try to open the lock without looking at it. He starts turning the dial to the right, counting the numbers while he passes them. He then, at the correct number starts turning the dial to the left, still counting, and finally turns it to the right until the lock opens.

The challenge:
Write a function/program that takes two inputs, the combination from Brian, and the indicator position. Output the numbers Peter has to count.
Rules:

The combination and the indicator position must be separate arguments.
The input can be either from command prompt or as function arguments.
The output must be printed to the screen / otherwise displayed (not to file)
Assume that the starting position is not the same as the first number, and that all three numbers in the combination are unique
It's the lock shown in the picture below, with possible numbers: 0-39.

Instructions:
To open the lock below, you need to follow a set of instructions:

You must know your code. Assume it's (38, 16, 22) for now.
Turn the dial 3 times to the right (passing the starting number three times), then stop when the first number (38) aligns with the indicator
Turn the dial 1 full turn to the left, passing
the first number, and stop when the second number (16) lines
up with the indicator.
Turn the dial to the right and stop when the
third number (22) lines up with the indicator
Pull the lock down

Example:
Input
38 16 22
33

Output
33  32  31  30  29  28  27  26  25  24  23  22  21  20  19  18  17  16  15  14  13  12  11  10   9   8   7   6   5   4   3   2   1   0  39  38  37  36  35  34  33  32  31  30  29  28  27  26  25  24  23  22  21  20  19  18  17  16  15  14  13  12  11  10   9   8   7   6   5   4   3   2   1   0  39  38  37  36  35  34  33  32  31  30  29  28  27  26  25  24  23  22  21  20  19  18  17  16  15  14  13  12  11  10   9   8   7   6   5   4   3   2   1   0  39  38  37  36  35  34  33  32  31  30  29  28  27  26  25  24  23  22  21  20  19  18  17  16  15  14  13  12  11  10   9   8   7   6   5   4   3   2   1   0  39  38  39   0   1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  17  18  19  20  21  22  23  24  25  26  27  28  29  30  31  32  33  34  35  36  37  38  39   0   1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  15  14  13  12  11  10   9   8   7   6   5   4   3   2   1   0  39  38  37  36  35  34  33  32  31  30  29  28  27  26  25  24  23  22

Standard code golf rules apply.
Solutions that are posted later can still win if they're shorter than Dennis' answer.

Unless he can speed count, the inhaler would be pointless... Thus, my program is: function combination(code){alert("Help! Someone open this locker, the combination is "+code+"!")}

@CᴏɴᴏʀO'Bʀɪᴇɴ, valid point...:-)  But: 1. The Peter-person we're talking about isn't the sharpest tool in the shed. 2. You wouldn't want to tell the code to someone would you. 3. Who knows, maybe Stewie had a spare can of spray..?

Oh, right. Stewie has an infinite can of pepper spray, right? Haha :3

Can we use alternative algorithms that still open that lock?

On this particular lock, you only need to be within 1 of the target number for the first two numbers. In addition, it lets you try as many times as you want for the last number, so once you get the first two, you don't need to count anymore.

@bmarks, OK. First of all, that's a ridiculous design feature. Second: You have to use the algorithm in the post!

Peter needs to learn martial arts. (And why is there no coach at the gym when Brian collapses? Budget cuts? ;)

CJam, 52 39 bytes
q~[3X0].{@40,m<1$({(+W%}&:T*T@#)T<)}e_p

Try it online in the CJam interpreter.
How it works
q~      e# Read and evaluate all input. This pushes the initial position
        e# as an integer and the combination as an array.
[3X0]   e# Push [3 1 0]. This encodes the respective numbers of full turns
.{      e# For each number in the combination (N) and the corresponding
        e# number of full turns (F):
  @     e#   Rotate the initial position on top of the stack.
  40,m< e#   Push [0 ... 39] and rotate it that many units to the left.
        e#   For position P, this pushes [P P+1 ... 39 0 ... P-2 P-1].
  1$(   e#   Copy F and subtract 1.
  {     e#   If the result is non-zero:
    (+  e#     Rotate the array of length 40 one unit to the left.
    W%  e#     Reverse it.
  }&    e#   For position P, this pushes [P P-1 ... 0 39 ... P+2 P+1].
  :T*   e#   Save in T and repeat the array F.
  T@    e#   Push T. Rotate N on top of the stack.
  #)    e#   Find the index of N in T and add 1 to it.
  T<    e#   Keep that many elements from the beginning of T.
  )     e#   Pop the last element of the result (N).
}       e# N is the new initial position.
e_p     e# Flatten the resulting array and print it.

Groovy, 189 175 bytes
Assumes the indicator is passed as arg0 and the combo is passed as arg1, arg2, and arg3 on the command line...
i=(args[0]as int)+1
r={i--;i=i<0?39:i;print"$i "}
l={i=++i%40;print"$i "}
M={j,c->while(i!=j as int){c()}}
120.times{r()}
M(args[1],r)
40.times{l()}
M(args[2],l)
M(args[3],r)

Perl 5, 129 + 1 (-a) = 130 bytes
sub c{$f=pop;do{say$f;$f+=$_[0];$f=$f==-1?39:$f==40?0:$f}while$f-$_[1]}$p=3;c(2*!$p-1,@F[$_,$p]),$p=$_ for 3,3,3,0,0,1,2;say$F[2]

Try it online!
How?
sub c{                       # Takes 3 parameters: increment, ending position, starting position
  $f=pop;                    # first place to start counting
  do{
    say$f;                   # output current position
    $f+=$_[0];               # move position
    $f=$f==-1?39:$f==40?0:$f # roll over when passing zero
  }while$f-$_[1]             # stop when ending positition reached
}

# @F gets defined by the -a command line option
# @F holds the combination followed by the starting position

$p=3;                       # starting position is in array index 3, this variable will track the array index of
                            # the current position on the dial

c(2*!$p-1,@F[$_,$p]),$p=$_  # call the movement function (c), setting direction to the left (1) or right (-1) as needed
                            # based on the array index of the previous position (go left when moving from array index 0)
for 3,3,3,0,0,1,2;          # list of the array index of the next position

say$F[2]                    # output final position

Python 2, 262 bytes
It feels so long. But there is also a lot of turning going on.
def f(l,s):
 r=lambda a,b,c=1:range(a,b,c)
 a=r(39,l[0],-1);b=r(l[0],-1,-1)
 c=r(l[1],l[2]-1,-1)if l[2]<l[1]else r(l[1],-1,-1);c.extend(r(39,l[2]-1,-1))
 return'  '.join(`x`for x in sum([r(s,-1,-1),a,b,a,b,a,b,r(39,l[0],-1),r(l[0],40),r(0,40),r(0,l[1]+1),c],[]))

Try it online!
I think I can concatenate some parts better in my last line but I am still new to code golf and I don't know how to tackle that list combination in a short way.
Any Ideas on improving this?

Haskell, 135 112 bytes
s!t=[s..39]++[0..mod(t-1)40]
s#t=[s,s-1..0]++[39,38..mod(t+1)40]
(a%b)c s=[s#s,s#s,s#s,s#a,a!a,a!b,b#c,[c]]>>=id

Try it online!
Saved 23 bytes thanks to Laikoni

You can shorten declarations like l s t= by declaring an infix operator s#t= instead. It also works for more than two arguments: (a%b)c s=.

And I think you can drop the s+1.