text:
Find an Eulerian Circuit
Challenge
You have been assigned a task to write a program which takes a multigraph as its input and if it contains an Eularian circuit to return one. Otherwise, the program's behavior is undefined, according to the specifications you're handed by your boss.
However, you recently caught your new coworker Steven several times treating undefined behavior in C carelessly and urged him be more careful because undefined behavior can also mean that all files on the system get deleted. He now dared you to write your program in a way such that it deletes itself when the aforementioned case of (previously) undefined behavior occurs. You don't want to lose your honor and accept.
Description
An Eulerian circuit is a circuit in an undirected multigraph which visits every edge exactly once.
You may choose the formats of your program's input and output yourself. They don't need to be the same formats. For example, you may take a description of the edges like
({1,2},{1,4},{2,4},{2,3},{2,3})

as your input for this graph

, but return a sequence of vertices as your output:
(1,2,3,2,4,1)

Details
You don't need to be able to accept multigraphs which contain vertices without edges.
Holding your program only in RAM and terminating it afterwards doesn't count as deleting it. It needs to be in a file. The file must only be deleted if no Eulerian circuit exists in the input multigraph.
The vertices have to be identifiable (it needs to be possible to tell the Euler circuit in the input provided the output of your program), the edges don't. However, you may restrict the means of identification (e.g. only positive integers or only strings consisting of a # followed by a positive integer) as long as large graphs are representable (only 1 letter of the English alphabet isn't sufficient). Identifiers don't have to be explicit. For example, you may let the order of the input determine the number a vertex is identified with in the output.
The means of output (saved to a file, printed at stdout, return value of a function) don't matter.
You can't rely on the name of your program on the disk not changing. If you only write a function, you still have to delete the file on the disk.
Victory Condition
This is code golf, shortest code wins.

Spoiler warning for this link: Simple algorithms to solve this problem can be found on the internet.

Are functions allowed for this or only full programs with input and output?

@ngenisis They are: "The means of output (saved to a file, printed at stdout, return value of a function) don't matter."

If anyone wants to solve this in Python, just use Vigil instead and put a swear not cycle() in your main.

This really needs test cases for non-graph instances.

I downvoted this because it's basically two unrelated problems (finding a cycle, and deleting the program's file on disk) combined into one. That doesn't seem to add much over submitting the problems separately, other than making it harder to find the appropriate language.

Mathematica, 48 bytes
FindEulerianCycle@#/.{}->DeleteFile@FileNames[]&

Yep, there's a builtin for that. It returns {} if there's no Eulerian cycle, so we manually redirect that to a command deleting all files in the current working directory.

Actually, this just deletes all files in the current working directory. Wouldn't you need something like NotebookFileName[]? Do byte counts for notebooks include all of the cell data?

Also, if this is just a function it's not clear what "the file" means

I believe one can run Mathematica from the prompt and type << [filename] to run this program, which can be a simple text file. Not gonna test this particular one though :) Also the OP writes "The means of output (... return value of a function)".


text:
Hack the elections
You're a professional hacker and your boss has just ordered you to help a candidate win an upcoming election. Your task is to alter the voting machines data to boost the candidate's results.
Voting machines store voting results as two integers : the number of votes for your candidate (v1) and the number of votes for their opponent (v2).
After weeks of research, you have found a security hole in the system and you can increase the value of v1 by an integer x, and decrease the value of v2 by the same x.
But there is a constraint, you have to keep the security hash code constant:

security hash code : (v1 + v2*2) modulo 7

Also, the value for x must be minimal so your changes can go unnoticed.
Your program should accept as input v1 and v2 ; it should output the optimal value for x so v1>v2.
There are some cases for which you cannot hack the results; you don't have to handle them (this might lead to problems with your boss, but that's another story).
Test cases
100,123 --> 14
47,23 --> 0
40,80 --> 21
62,62 --> 7
1134,2145 --> 511

Comments are not for extended discussion; this conversation has been moved to chat.

Also, to the close voters: This is perfectly on-topic. If you don't like it, you can downvote it.

What a secure hash function!

Can you assume the inputs are followed by .0 (Like 100.0 123.0)?

Python 2, 30 bytes
lambda u,t:max(0,(t-u)/14*7+7)

u is our votes, t is their votes.

Couldn't (t-u)/14*7 be just (t-u)/2?

Oh, wait, nevermind, Py2 does integer division

@ConorO'Brien Nope. Consider t-u == 16. Then 16/14*7 = 7, but 16/2 = 8. Also, you aren't running as Python 2.

@orlp I don't know which one to ask, so I'll ask both of you, can you please explain to me how you thought of this? y<x?0:(y-x)/2-(y-x)/2%7+7;, I thought that I should take the difference split it in half, and then find the nearest multiple of 7. How did you arrive to this?

the same solution is above

Python 2, 30 bytes
lambda a,b:max((b-a)/14*7+7,0)

After fixing the bug we basically have the same answer =/

@orlp Yeah, I think this is just the way to write the expression. Unless a recursive solution is shorter, which I doubt.

@xnor I don't know which one to ask, so I'll ask both of you, can you please explain to me how you thought of this? y<x?0:(y-x)/2-(y-x)/2%7+7;, I thought that I should take the difference split it in half, and then find the nearest multiple of 7. How did you arrive to this?

@WadeTyler We're looking the the smallest multiple of 7 that is strictly greater than half the difference. To find that from (b-a)/2, we do /7*7 to round downs to the nearest multiple of 7, and then +7 to go up to the next up. That is, unless the we would get a negative number, in which case we're winning anyway can just do 0. Taking the max with 0 achieves this. Some of it was also just tweaking the expression and running it on the test cases to see what works.

@xnor What I don't understand is why /7*7?

@xnor I pretty much thought of the same thing except I don't know how to transform my formula to look like yours.

@WadeTyler The /7*7 is a kind of expression that shows up often enough in golfing that I think of it as an idiom. The idea is the n/7 takes the floor of n/7, i.e. finds how many whole multiples of 7 fit within n. Then, multiplying by 7 brings it to that number multiple of 7.

@xnor I got it. Thanks a lot. I don't like using formulas without knowing what they mean, so I usually spend as much time as needed to fully understand them.

In ruby: instead of (b-a)/147+7 I am using (a-b)/14-7, which should work in python too and save a byte.

@GB That doesn't work if the vote is tied (like 62,62).

Oops, you are right, I didn't check that test case...

just out of curiosity, how does this handle inputs where a is greater than b but by less than 7 (ie a=100 b=98)? if  i understood the tests correctly, the returned value should be 0

@JackAmmo That example gives -2/7*7, and since Python floor-division rounds towards negative infinity, 2/7 is -1, so 7*-7+1 is 0. So, both sides give 0, which works out fine.

Mathematica, 22 bytes
0//.x_/;2x<=#2-#:>x+7&

Pure function with arguments # and #2. Hits maximum recursion depth if the discrepancy is more than 7*2^16 = 458752.
Explanation
0                       Starting with 0,
 //.                    repeatedly apply the following rule until there is no change:
    x_                    if you see an expression x
      /;                    such that
        2x<=#2-#            2x <= #2-# (equivalently, #+x <= #2-x)
                :>        then replace it with
                  x+7       x+7 (hash is preserved only by multiples of 7)
                     &  End the function definition

Can you add an explanation for all this?

@Pavel Maybe your comment has continued getting upvotes because my explanation was unclear?

I thought it was fine, but then again I also know Mathematica.

@Pavel Well it's better now :)

Jelly, 9 bytes
IH:7‘×7»0

Try it online!
How it works
IH:7‘×7»0  Main link. Argument: [v1, v2]

I          Increments; compute [v2 - v1].
 H         Halve the result.
  :7       Perform integer division by 7.
    ‘      Increment the quotient.
     ×7    Multiply the result by 7.
       »0  Take the maximum of the product and 0.

Actually, 13 bytes
7;;τ((-\*+0kM

Try it online!
Uses the same max((b-a)/14*7+7,0) formula that xnor and orlp use.
Explanation:
7;;τ((-\*+0kM
7;;            3 copies of 7
   τ           double one of them
    ((-        bring the inputs back to the top, take their difference
       \*+     integer divide by 14, multiply by 7, add 7
          0kM  maximum of that and 0

Actually, this is a great answer

I feel like the name of this language was intentional to make the submission titles sound like punchlines: "Guys, Actually, this is 13 bytes! Come on!"

@PatrickRoberts Actually, that's correct.

Groovy, 41 37 bytes
{x,y->[Math.floor((y-x)/14)*7+7,0].max()}

This is an unnamed closure. Thanks to xnor and orlp for the formula and James holderness for pointing out a bug.
The previous solution used intdiv() for integer division but it behaves differently from // used in python.
Try it here!

Haskell, 30 24 bytes
a#b=max 0$div(b-a)14*7+7

An infix operator taking the number of votes of your preferred candidate first. Uses the same logic as the other answers of rounding with /14*7+7.

Finding the first value that meets a condition is a good use for until: a#b=until(\c->a+c>b-c)(+7)0, or better a%b=until(>(b-a)/2)(+7)0. Though an arithmetic formula is still likely shorter.

Note that apart from xnor's shorter alternatives head[...] can almost always be shortened to [...]!!0

@xnor: your until solution returns a Fractional a, I'm not sure if that is accepted. With div it is though shorter, so thanks! Eventually used the mathematical approach - and indeed, it was another two bytes shorter than until. @Laikoni: nice golfing, didn't know about that one, will remember it.

Excel VBA, 24 17 Bytes
Immediates window function that takes input from cells A1 and B1 and outputs to the VBE immediates window.
?([A1-B1]\14)*7+7

Subroutine Version, 43 Bytes
takes input b, c as variant\integer and prints to the VBE immediates window
Sub a(b,c):Debug.?Int((c-b)/14)*7+7:End Sub

J, 15 bytes
0>.7+7*14<.@%~-

Kinda interesting, I was working on a problem and I thought I had a solution but as it turns out I was wrong. Oh well. Try it online! Here's the result:
   f =: 0>.7+7*14<.@%~-
   tests =: 123 100 ; 23 47 ; 80 40 ; 62 62 ; 2145 1134
   (,. f/ each) tests
┌─────────┬───┐
│123 100  │14 │
├─────────┼───┤
│23 47    │0  │
├─────────┼───┤
│80 40    │21 │
├─────────┼───┤
│62 62    │7  │
├─────────┼───┤
│2145 1134│511│
└─────────┴───┘

In the future, please use TIO.run/nexus

@Pavel No, tio.run is v2, nexus is there only for v1 compatibility

@ASCII-only https://tio.run has a disclaimer at the bottom that all generated permalinks might break in the future. I think I should make that more prominent. Except for testing purposes, nobody should be using v2 at his moment.

@Dennis Oh, I didn't know! Will edit asap.

CJam, 13 12 15 bytes

Saved a byte thanks to Martin Ender.
Added 3 bytes thanks to Martin Ender.
Changed ] to [ thanks to ETHproductions.

q~\-Ed/m[)7*0e>

Blatantly stole orlp and xnor's methods.
Input is the two numbers separated by a space: 100 123
Explanation:
q~\-Ed/m])7*0e>
q~\-            e# Input two numbers, swap and subtract them.
    E           e# Push 0xE (15)
     d/m]       e# Float divide and take the floor.
         )7*    e# Increment and multiply by 7.
            0e> e# Max of this and 0.

D is only 13. And you can save a byte by incrementing the value before multiplication instead of adding 7 afterwards.

@JamesHolderness The issue is that Python's integer division works rounds towards -inf whereas CJam's rounds towards zero.

I may be misunderstanding, but I thought m] is ceil; m[ is floor.

@ETHproductions You're right, edited.

Japt, 14 bytes
V-U /2+7 f7 w0

Run it here!
Thank you ETHproductions for shaving off 3 bytes!

Very nice. f accepts an argument and floors to a multiple of that number, so I think you can so V-U /2+7 f7 w0 to save three bytes.

PHP, 41 39 bytes
    <?=7*max(0,1+($argv[2]-$argv[1])/14|0);

takes input from command line arguments; run with -r.
7 5 extra bytes just to handle $a>$b :-/

05AB1E, 9 bytes
-14÷>7*0M

Try it online!
Explanation
-          # push difference of inputs
 14÷       # integer divide by 14
    >      # increment
     7*    # times 7
       0   # push 0
        M  # take max

Or a corresponding function with same byte-count operating on a number-pair
Î¥14÷>7*M

Try it online!

Julia 0.5, 26 bytes
v\w=max(fld(w-v,14)*7+7,0)

Try it online!

Befunge, 19 bytes
777+:&&\-+\/*:0`*.@

Try it online!
This relies on a slightly different formula to that used by orlp and xnor, since the Befunge reference interpreter has different rounding rules to Python. Befunge also doesn't have the luxury of a max operation.
The basic calculation looks like this:
x = (v2 - v1 + 14)/14*7
x = x * (x > 0)

Examining the code in more detail:
7                     Push 7                                      [7]
 77+:                 Push 14 twice.                              [7,14,14]
     &&               Read v1 and v2 from stdin.                  [7,14,14,v1,v2]
       \-             Swap the values and subtract.               [7,14,14,v2-v1]
         +            Add the 14 that was pushed earlier.         [7,14,14+v2-v1]
          \/          Swap the second 14 to the top and divide.   [7,(14+v2-v1)/14]
            *         Multiply by the 7 that was pushed earlier.  [7*(14+v2-v1)/14 => x]
             :        Make a copy of the result                   [x,x]
              0`      Test if it's greater than 0.                [x,x>0]
                *     Multiply this with the original result.     [x*(x>0)]
                 .@   Output and exit.

Go, 36 bytes
func(a,b int)int{return(b-a)/14*7+7}
Try it online!

JavaScript (ES6), 31 bytes
(a,b,c=(b-a)/14|0)=>c>0?c*7+7:0

f=(a,b,c=(b-a)/14|0)=>c>0?c*7+7:0
document.write(f(1134,2145))

Java 8, 31 bytes
(a,b)->b<a?0:(a=(b-a)/2)+7-a%7;
This is a lambda expression assignable to IntBinaryOperator.
a is your candidate's votes, b is your opponent's.
java rounds down for division with positive integers, so +7-a%7 is used to bump up the value to the next multiple of 7.

a->b->(b=(b-a)/14*7+7)>0?b:0 is 3 bytes shorter, but I kinda like your approach more, so +1 from me. Almost every answer given already uses max((b-a)/14*7+7,0)..

i prefer using lambdas that return the result directly. and yeahb everyone did the formula a bit shorter but this was how i reasoned about the answer before checking everyone elses

a->b->(b=(b-a)/14*7+7)>0?b:0 does return the result directly as well: Try it here. Or do you mean you prefer single-method lambdas above currying lambdas; (a,b)-> preference over a->b->, even though it's longer?

single method over currying, but thats just a personal preference

Dyalog APL, 14 bytes
Takes v1 as right argument and v2 as left argument.
0⌈7×1+(⌊14÷⍨-)

0 ⌈ the maximum of zero and
7 × seven times
1 + (...) one plus...
 ⌊ the floor of
 14 ÷⍨ a fourteenth of
 - the difference (between the arguments)
TryAPL online!

Ruby, 26 27 bytes
->a,b{[(b-a)/14*7+7,0].max}

Basically the same as xnor's and orlp's Python solution, with a twist (no need to add 7, because of negative modulo, saves 1 byte in ruby, don't know about python)
No twist, the twist was just a bad case of cognitive dissonance. Forget it. Really. :-)

Scala, 31 bytes
(a,b)=>Math.max((b-a)/14*7+7,0)

The ternary version is 2 bytes longer

Pyth, 16 bytes
MtS+0[+7*7/-HG14

Try it here!

Noodel, 16 bytes
⁻÷14ɲL×7⁺7ḋɲl⁺÷2

Pulled equation from xor and orlp answers, but since Noodel does not have a max capability had to work around that.
Try it:)
How it works
⁻÷14ɲL×7⁺7       # The equation...
⁻                # v2 - v1
 ÷14             # Pops off the difference, then pushes on the (v2 - v1)/14
    ɲL           # Applies lowercase which for numbers is the floor function.
      ×7         # Multiplies that by seven.
        ⁺7       # Then increments it by seven.

          ḋɲl⁺÷2 # To relate with the other answers, this takes the max between the value and zero.
          ḋ      # Duplicates what is on the top of the stack (which is the value just calculated).
           ɲl    # Pops off the number and pushes on the magnitude (abs value).
             ⁺   # Add the abs to itself producing zero if the number came out negative (which means we are already winning).
              ÷2 # Divides the result by two, which will either be zero or the correct offset.

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:
Convert between balanced bases!
Balanced bases:
Balanced bases are essentially the same as normal bases, except that digits can be positive or negative, while in normal bases digits can only be positive.
From here on, balanced bases of base b may be represented as balb - so balanced base 4 = bal4.
In this challenge's definition, the range of digits in a balanced base of base b is from -(k - 1) to b - k, where
k = ceil(b/2)

Examples of the range of digits in various balanced bases:
bal10:
  k = ceil(10/2) = 5
  range = -(5 - 1) to 10 - 5 = -4 to 5
        = -4, -3, -2, -1, 0, 1, 2, 3, 4, 5
bal5:
  k = ceil(5/2) = 3
  range = -(3 - 1) to 5 - 3 = -2 to 2
        = -2, -1, 0, 1, 2

Representations of numbers in balanced bases is basically the same as normal bases. For example, the representation of the number 27 (base 10) to bal4 (balanced base 4) is 2 -1 -1, because
  2 -1 -1 (bal4)
= 2 * 4^2 + -1 * 4 + -1 * 1
= 32 + (-4) + (-1)
= 27 (base 10)

Task:
Your task is, given three inputs:

the number to be converted (n)

this input can be flexible, see "I/O Flexibility"

the base which n is currently in (b)
the base which n is to be converted to (c)

Where 2 < b, c < 1,000.
Return the number in balanced base c representation of n. The output can also be flexible.
The program/function must determine the length of n from the input itself.
I/O Flexibility:
Your input n and output can be represented in these ways:

your language's definition of an array
a string, with any character as a separator (e.g. spaces, commas)

Examples:
Note that these use a Python array as n and the output. You may use whatever fits your language, as long as it fits within "I/O Flexibility"'s definition.
[2, -1, -1] 4 7 = [1, -3, -1]
[1, 2, 3, 4] 9 5 = [1, 2, 2, -1, 2]
[10, -9, 10] 20 5 = [1, 1, 1, -2, 1, 0]

This is code-golf, so shortest code in bytes wins!

In your first answer, 4 is not a legal bal7 digit; I believe the answer should be [1, -3, -1]. And I get different answers for the second test case ([1,2,2,-1,2]) and third test case ([1,1,0,-2,1,0]) as well...?

@GregMartin Ah, whoops - I calculated those by hand, so there was bound to be some problems. Thanks for noticing! Can you double-check your solutions, just in case?

@GregMartin @Qwerp-Derp Third test case is [1,1,1,-2,1,0]

Mathematica, 85 bytes
#~FromDigits~#2~IntegerDigits~#3//.{p___,a_:0,b_,q___}/;b>⌊#3/2⌋:>{p,a+1,b-#3,q}&

Explanation
#~FromDigits~#2

Convert #1 (1 is implied--input 1, a list of digits) into an integer base #2 (input 2).
... ~IntegerDigits~#3

Convert the resulting integer into base #3 (input 3), creating a list of digits.
... //.{p___,a_:0,b_,q___}/;b>⌊#3/2⌋:>{p,a+1,b-#3,q}

Repeatedly replace the list of digits; if a digit is greater than floor(#3/2), then subtract #3 from it and add 1 to the digit to the left. If there is nothing on the left, insert a 0 and add 1.

It's usually recommend to talk about your solution a little, and explain it for people who may not know Mathematica.

@ATaco Added explanation!

I'm a little mystified by this. I've never seen optional patterns used anywhere but function definitions. You don't need the outer {...} since there's only one replacement rule.

@ngenisis Got rid of the extra {}. Thanks!

@ngenisis Well, function definition is actually a replacement rule too. For instance: f[x_] := 3 x; DownValues@f gives {HoldPattern[f[x_]] :> 3 x}

@JungHwanMin True, I guess what's confusing me is how this affects the match for p___. Does this find the shortest p___ followed by either a_,b_ or b_, or does it check the whole pattern requiring each of the optional patterns and then progressively drop the optional patterns until it finds a match (or some third option)?

@ngenisis I believe I was wrong in the previous comment (deleted), observing the result of FixedPointList[k=#3;#/.{p___,a_:0,b_,q___}/;b>⌊k/2⌋:>{p,a+1,b-k,q}&, #~FromDigits~#2~IntegerDigits~#3]&. {p___,a_,b_,q___} is matched first (for all possible p), and then {p___,b_,q___} is matched. The second replacement only applies when b is at the beginning because if there is a b in the middle that satisfies the condition, {p___,a_,b_,q___} would match it instead.

APL (Dyalog Unicode), 47 bytes
{z↓⍨⊥⍨0=⌽z←m+u⊤v-⍺⊥m←⌈.5×1-u←⍺⍴⍨1+⌈⍺⍟1⌈|v←⍺⍺⊥⍵}

Try it online!
A dop that takes n, b, c as three separate values. Call it like c (b f) n where f is the submission.
Dyalog APL has a dfns library function bt that does various arithmetic in balanced ternary. Part of it is encode/decode, i.e. conversion between balanced ternary and plain integer:
encode←{                            ⍝ balanced ternary from integer.
    digs←1+⌈3⍟1⌈|⍵                  ⍝ number of ternary digits.
    tlz ¯1+(digs⍴3)⊤⍵+3⊥digs⍴1      ⍝ vector of bt digits.
}                                   ⍝ :: ∇ num → bt
decode←{3⊥⍵}                        ⍝ integer from balanced ternary.

(the hidden function tlz trims leading zeros.)
This submission is just a generalization of the above code.
Ungolfed with comments
{                    ⍝ Input: ⍵←n, ⍺⍺←b, ⍺←c
    v←⍺⍺⊥⍵           ⍝ v← plain integer from base b

    u←⍺⍴⍨1+⌈⍺⍟1⌈|v   ⍝ u← copies of c with the size enough to fit the answer
              1⌈|v   ⍝ max(1,abs(v)) so that it works well with log(⍟)
           ⌈⍺⍟       ⍝ number of digits enough to fit v in plain base c
         1+          ⍝ ...enough to fit v in balanced base c
      ⍺⍴⍨            ⍝ that many copies of c

    m←⌈.5×1-u    ⍝ m← the minimum value in balanced base c with that many digits

    z←m+u⊤v-⍺⊥m  ⍝ z← n in balanced base c, possibly with leading zeros
            ⍺⊥m  ⍝ m as plain integer
          v-     ⍝ subtract from v (or, since m<0, add abs(m) to v)
        u⊤       ⍝ encode that value to plain base c, with that many digits
      m+         ⍝ revert the offset

    z↓⍨⊥⍨0=⌽z    ⍝ remove leading zeros from z and return it
       ⊥⍨0=⌽z    ⍝ count trailing zeros (⊥⍨) on reversed z
    z↓⍨          ⍝ drop that many items from z
}

I'm not sure if this will help you any, but If you calculate digs by first multiplying v by $\frac{c-1}{\lfloor\frac{c}{2}\rfloor}$, I don't think you need to trim leading zeroes

Okay, it turns out it's longer that way. You might be able to reduce it, though.

Perl 6, 121 bytes
->\n,\b,\c{sub f{sum [R,](@^n)Z*($^b X**0..*)}
first {f(b,n)==f c,$_},map {[$_-($_>floor c/2)*c for .base(c).comb]},0..*}

Slow brute-force solution.
How it works:

map {[  .base(c).comb]}, 0..* -- Generate the lazy infinite sequence of natural numbers in base c, with each number represented as an array of digits.
$_ - ($_ > floor c/2) * c -- Transform it by subtracting c from each digit that is greater than floor(c / 2).
first { f(b, n) == f(c, $_) }, ... -- Get the first array of that sequence which when interpreted as a base c number, equals the input array n interpreted as a base b number.
sub f { sum [R,](@^n) Z* ($^b X** 0..*) } -- Helper function that turns an array @^n into a number in base $^b, by taking the sum of the products yielded by zipping the reversed array with the sequence of powers of the base.

SageMath, 53 bytes
f=lambda a,b,c:ZZ(a[::-1],b).balanced_digits(c)[::-1]

I’d be (pleasantly) surprised if there is a more concise way to write this in Sage than the obvious one. The only complication here is that Sage represents numbers as lists of digits with the least-significant digit first, whereas this challenge assumes most-significant first. So the digit lists need to be reversed.

Mathematica, 118 114 bytes
IntegerDigits[#3~FromDigits~#2,k=⌊#/2⌋;#]//.{{a_,x___}/;a>k:>{1,a-#,x},{x___,a_,b_,y___}/;b>k:>{x,a+1,b-#,y}}&

⌊ and ⌋ are the 3-byte characters U+230A and U+230B, respectively. Converts #3 to base 10 from base #2, then converts to base # (so the argument order is reversed from the examples). If any digit is greater than the maximum allowed digit k=⌊#/2⌋, decrement that digit by # and increment the next digit up (may need to prepend 1). Keep doing this until all the digits are less than k.

JavaScript (ES6), 89 bytes
(n,b,c,g=(n,d=n%c,e=d+d<c)=>[...(n=n/c+!e|0)?g(n):[],e?d:d-c])=>g(n.reduce((r,d)=>r*b+d))

100 bytes works for negative values of n.
(n,b,c,g=(n,d=(n%c+c)%c)=>[...(n-=d,n/=c,d+d<c||(d-=c,++n),n?g(n):[]),d])=>g(n.reduce((r,d)=>r*b+d))

APL (Dyalog Unicode), 55 51 49 bytes
Saved 4 bytes thanks to ovs
{2↓((⊃(⊢,⍨⍵÷⍨-)x-⍨(⍵|(x←⌊⍵÷2)+⊃)),1∘↓)⍣(=⍥⊃)⍺⊥⍺⍺}

Try it online! (The ⍥ has been replaced by a C in the link because TIO has an older version of APL).
Without a train, 55 54 52 bytes (SBCS)
Saved a byte here too thanks to ovs
{c←⍵⋄2↓{m←x-⍨c|⊃⍵+x←⌊c÷2⋄(c÷⍨⊃⍵-m),m,1↓⍵}⍣(=⍥⊃)⍺⊥⍺⍺}

Try it online!
There's already a better APL answer here, but here's mine anyway.
Can be invoked with b (n f) c.
⍺⊥⍺⍺ converts n from base b to base 10.
(...)⍣(=⍥⊃) repeatedly takes a vector whose first element is the rest of the number to be converted and whose other elements are the digits of the result. It repeats until the first digit of the created vector is 0 (given by (=⍥⊃)).
The 2↓ at the beginning is because the function is applied one extra time, so there's 2 zeroes at the start of the vector.
In the top snippet, m represents the new leading digit. It's just \$(r + x (\mod c)) - x\$ where \$x\$ is \$\lfloor \frac{c}{2} \rfloor\$ and \$r\$ is the head of the vector, the leftover part from last time.
To get the new leftover part, it's \$\frac{(r - m)}{c}\$ (this is guaranteed to be an integer since \$r-m\$ is divisible by \$c\$). Then we join this leftover part with m and 1↓⍵ (to drop last time's leftovers).

One of the b's is still there.

@Bubbler Right, let me fix that

In both versions 0=(⊃⊣) can be shortened to 0=∘⊃⊣. And by removing two pairs of brackets, the train version can be 51 bytes.

R, 105 102 101 96 bytes
Edit: -5 bytes thanks to Giuseppe
function(a,b,c){x=a%*%b^(sum(a|1):1-1)
e={}
while(x){e=c(r<-x%%c-c*(x%%c>c/2),e);x=(x-r)%/%c}
e}

Try it online!
toFromBalBase=
function(a,b,c){
x=sum(a*b^(sum(a|1):1-1))   # get value x after conversion from balanced base b
e=NULL                      # initialze empty output vector of values
while(x){                   # repeat while x is not yet zero:
  e=c(...,e)                # prepend output vector with
    r<-(r=x%%c)             # define r as x mod c (base to convert to)
    -(r>c/2)*c              # adjusted to be balanced
  x=(x-r)%/%c}              # and update x to result of division,
                            # after accounting for possibly-negative remainder.
e}                          # finally, output e = output vector with all positive and negative
                            # remainders prepended

96 bytes

@Giuseppe - Thanks! Perhaps after another 10 hints I'll learn to finally remember about %*%...

I've spent so much time doing SUMPRODUCTs in Excel lately (for work) that it's a relief to have something that's a lot shorter to type when I'm golfing in R...

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


text:
Score rock-paper-scissors
Given two string inputs of "Rock", "Paper", or "Scissors", determine the outcome of the RPS round. Output 1 if the first player wins, -1 if the second player wins, or 0 for a tie.
Rock Rock -> 0
Rock Paper -> -1
Rock Scissors -> 1
Paper Rock -> 1
Paper Paper -> 0
Paper Scissors -> -1
Scissors Rock -> -1
Scissors Paper -> 1
Scissors Scissors -> 0

You must use the exact strings "Rock", "Paper", and "Scissors" as inputs. You may choose whether the first players' choice is (consistently) given first or second. You may alternatively take them as a single input with a single-character or empty separator. The input is guaranteed one of the 9 possible pairings of the three choices in your input format.
The output should be a number 1, 0, or -1, or its string representation. Floats are fine. So are +1, +0, and -0.
Related: Coding an RPS game

Leaderboard:

var QUESTION_ID=106496,OVERRIDE_USER=20260;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/106496/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="
"+e.body.replace(OVERRIDE_REG,"")+"
")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),size:+a[2],language:a[1],link:s.share_link})}),e.sort(function(e,s){var r=e.size,a=s.size;return r-a});var s={},r=1,a=null,n=1;e.forEach(function(e){e.size!=a&&(n=r),a=e.size,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/s.lang?1:e.lang<s.lang?-1:0});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.lang).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i;
body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px}
 <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b">

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

Does a single input with empty separator mean for example "rockpaper"?

@Emigna Yes, but capitalized as RockPaper.

That was WAY more fun than I had anticipated, my lord there are some cool ways to do this.

Can the input be an array of the two strings?

@LuisMendo Yes.

Wow, I completely agree with @carusocomputing There is currently more than one page of answers, and almost none of these use the same method twice. Usually you see a lot of: Port of Person's answer, or similar approaches done individually by different persons a lot more, but not with this challenge (so far).

Bonus for including Lizard Spock ;)

So the input must be a single argument of a string containing both plays? It can't be 2 input strings?

@Carcigenicate No, that's an optional alternative.

@xnor OK, good. Should like halve the length of my solution lol.

The 'Winners by Language' thing doesn't work for me.

How did I get more points than the question itself? For shame to you question non-voters!

Groovy, 67 56 50 Bytes
{a,b->Math.sin(1.3*((int)b[0]-(int)a[0])).round()}

Try it online!
Turns out that the rock, paper, scissors game has a pretty cool property.
Given strings a and b, take the first letter of each, this results in two of the following: R,P,S
The exhaustive list of possible values are (When 2 choices are combined):
XX=ASCII=Y=Wanted output
RR=82-82=0=0
PP=80-80=0=0
SS=83-83=0=0
RS=82-83=-1=1
RP=82-80=2=-1
PS=80-83=-3=-1
PR=80-82=-2=1
SR=83-82=1=-1
SP=83-80=3=1

Reorganizing the list to:
-3->-1
-2->1
-1->1
0->0
1->-1
2->-1
3->1

Gives us a sequence that looks inversely sinusoidal, and you can actually represent this formula as approximately (and by approximately I mean just barely enough to work, you could get an equation that is dead on but costs more bytes):
-sin((4*a[0]-b[0])/PI).roundNearest() = sin(1.3*(b[0]-a[0])).roundNearest()

The simplification of 4/pi to 1.3 was suggested first by @flawr and then tested by @titus for a total savings of 6 bytes.

Using groovy's double rounding properties, this results in the correct output for rock-paper-scissors.

05AB1E, 10 bytes (non-compete)
Ç¥13T/*.½ò

Try it online!
Same answer ported to 05AB1E using the new commands added 10/26/2017.

Couldn't you make it shorter by using that -sin(x) = sin(-x),that means just reversing the order of a and b and dropping the leading -? Other than that, hardcoding an approximation of 4/Pi like 1.273 could be sufficient, or 1.3 or 9/7 or 5/4.

PS: I also suggest making a link to try it online so people like me can play around with your submission=)

@flawr groovy on TIO? Since when!

You can save 1 byte with sin(b-a) instead of -sin(a-b). Great find!

Save another 7 bytes by multiplying by 1.3 instead of 4/Math.PI; that´s sufficiently exact.

@carusocomputing On your ascii conversion chart, towards the top, it looks like you have the values for P and S swapped.  btw, very cool answer!

@CraigR8806 P=80, R=82, S=83 is what I have up there, unless I'm blind (which is entirely possible).

@carusocomputing
`XX=ASCII=Y=Wanted output
RR=82-82=0=0
PP=83-83=0=0
SS=80-80=0=0`

@CraigR8806 I AM blind!

you could multiply by 2 and truncate instead of using round(), this might be shorter. /.8 instead of *1.3 seems to work, too.

@12Me21 .trunc() is similar in length to .round()

I meant truncate by doing |0 or something similar.

C, 50 35 bytes
#define f(i)*(short*)(i+7)%51%4%3-1

Call f with a string containing both players, without separator, and it will return whether the first one wins.
Explanation:
By looking at the nine possible strings, it turns out that the letter pairs on columns 7 and 8 are unique:
       vv
RockPaper
PaperScissors
ScissorsRock
RockRock         // Sneakily taking advantage of the terminating zero
PaperPaper
ScissorsScissors
RockScissors
PaperRock
ScissorsPaper
       ^^

The offset and savage cast to short* retrieve these letter pairs, and interpret them as numbers:
29285
29545
21107
107
25968
21363
29555
27491
20595

Then it was a matter of brute-force to find the 51 and 4 remainders, which applied successively reduce these numbers to:
3 0 0 1 1 1 2 2 2

Which is just perfect to tack yet another remainder at the end, and offsetting the result.
See it live on Coliru

Just don't do anything like calculating -f(i) to calculate the other player's score - unexpected output will result!

@nneonneo -(f(i)) should work fine. Macros are fun!

MATLAB/Octave, 63 54 52 bytes
It is very convenient that the ASCII-codes of the first letters of Rock,Paper,Scissors are R=82,P=80,S=83. If we subtract 79 we get conveniently 3,1,4, which we will use now as matrix indices: Here a 4x4-matrix is hardcoded, where the i,j-th entry corresponds to the outcome if you plug in the values from just before:
     1   2   3   4
  +---------------
1 |  0   0   1  -1
2 |  0   0   0   0
3 | -1   0   0   1
4 |  1   0  -1   0

A(5,5)=0;A(4:7:18)=1;A=A-A';@(x,y)A(x(1)-79,y(1)-79)

Try it online!

Python, 40 30 bytes
lambda x,y:(len(2*x+y)^67)%3-1

Try it online!
Background
I've started with the function template
lambda x,y:(len(a*x+b*y)^c)%d-e

and ran a brute-force search for suitable parameters using the following program, then picked one with a minimal-length implementation.
RPS = 'Rock Paper Scissors'.split()
g = lambda x,y:2-(94>>len(6*x+y)%7)%4
r = range(1,10)
R = range(100)

def f(a, b, c, d, e):
    h = lambda x,y:(len(a*x+b*y)^c)%d-e
    return all(g(x, y) == h(x, y) for x in RPS for y in RPS)

[
    print('%2d ' * 5 % (a, b, c, d, e))
    for e in r
    for d in r
    for c in R
    for b in r
    for a in r
    if f(a, b, c, d, e)
]

Try it online!

Pure Bash, 31
Borrowing @Dennis's formula:
a=$1$1$2
echo $[(${#a}^67)%3-1]

Try it online.

Previous answer:
Pure Bash, 43 35
echo $[(7+(${#2}^3)-(${#1}^3))%3-1]

Get the string length of each arg (4, 5, 8 respectively for Rock, Paper, Scissors)

XOR each with 3 to give 7, 6, 11 (which when taken mod 3 give 1, 0, 2)

Then subtract and fiddle with mod 3 to get the desired result.

Try it online.

Mathematica, 32 bytes
Mod[{1,-1}.(Length/@#-3)!,3,-1]&

Unnamed function taking an ordered pair of lists of characters, such as {{"R","o","c","k"},{"P","a","p","e","r"}}, and returning -1|0|1.
I wanted the code to avoid not only the three input words, but also the way-too-long function name ToCharacterCode; so I worked with the length 4,5,8 of the input words instead, and looked for a short function of those lengths that gave distinct answers modulo 3. (Integer division by 2 is mathematically promising, but those functions have too-long names in Mathematica.)
It turns out that taking the factorial of (the length – 3) gives the answers 1,2,120, which are 1,-1,0 modulo 3. Then we just compute, modulo 3, the difference of the two values (via the dot product {1,-1}.{x,y} = x-y, which is a good way when the two values are in a list).

"It turns out..." You have an eye for these things

Ruby, 36 35 30 bytes
a=->a,b{(a+b)[12]?a<=>b:b<=>a}

Try it on ideone.com
Test output:
a=->a,b{(a+b)[12]?a<=>b:b<=>a}

puts a.call("Rock", "Rock")
puts a.call("Rock", "Paper")
puts a.call("Rock", "Scissors")
puts a.call("Paper", "Rock")
puts a.call("Paper", "Paper")
puts a.call("Paper", "Scissors")
puts a.call("Scissors", "Rock")
puts a.call("Scissors", "Paper")
puts a.call("Scissors", "Scissors")

0
-1
1
1
0
-1
-1
1
0

Takes advantage of the fact that 7 of the 9 correct results are generated just by doing a lexicographic comparison using the spaceship operator <=>. The (a+b)[12] just reverses the inputs to the comparison if the inputs are Paper and Scissors (and also Scissors Scissors - but that's 0 either way round).
With thanks to Horváth Dávid for saving me a character, and thanks to G B for saving me another 5.

You can use an anonymous lambda and save 2 characters.

@GB If I don't give the function a name how am I supposed to call it? That smacks of cheating to me. But thanks for the other tip - I had looked at that but rejected it because ScissorsScissors is 16, but I see that doesn't actually matter. :-)

That's not cheating. Anonymous functions are allowed by default.

@Dennis You can't call it without assigning it. It feels like cheating to me, and unfair on languages without anonymous functions that have to define a name.

Sure you can. https://tio.run/nexus/ruby#@19QWlKsoGuXqJNUrZGonaQZbWgUa59oY2uXZJUEJBNr9ZITc3I0lILyk7OVdBSUAhILUouUNP//BwA

@Dennis Hmmm. I'm tempted to remove the 2 characters for the a= and add 5 for the .call since that's always required...

The task is to create a function, not to call it. Stop thinking about ways to increase your byte count. :P

Python, 39 36 34 33 bytes
lambda x,y:2-(94>>len(6*x+y)%7)%4

Try it online!
How it works
Let's take a look at a few values of the length of six copies of x and one copy of y modulo 7.
                                l(x,y) =:
x        y        len(x) len(y) len(6*x+y)%7
--------------------------------------------
Rock     Rock          4      4            0
Rock     Paper         4      5            1
Rock     Scissors      4      8            4
Paper    Rock          5      4            6
Paper    Paper         5      5            0
Paper    Scissors      5      8            3
Scissors Rock          8      4            3
Scissors Paper         8      5            4
Scissors Scissors      8      8            0

We can encode the outcomes ({-1, 0, 1}) by mapping them into the set {0, 1, 2, 3}. For example, the mapping t ↦ 2 - t achieves this and is its own inverse.
Let's denote the outcome of x and y by o(x, y). Then:
x        y        l(x,y) o(x,y) 2-o(x,y) (2-o(x,y))<<l(x,y)
-----------------------------------------------------------
Rock     Rock          0      0        2                10₂
Rock     Paper         1     -1        3               110₂
Rock     Scissors      4      1        1            010000₂
Paper    Rock          6      1        1          01000000₂
Paper    Paper         0      0        2                10₂
Paper    Scissors      3     -1        3             11000₂
Scissors Rock          3     -1        3             11000₂
Scissors Paper         4      1        1            010000₂
Scissors Scissors      0      0        2                10₂

Luckily, the bits in the last columns all agree with each other, so we can OR them to form a single integer n and retrieve o(x, y) as 2 - ((n ≫ o(x,y)) % 4). The value of n is 94.

Retina, 35 31 bytes
G`k P|r S|s R
*\)`.+
-
D`\w+
 .

Try it online!
Explanation
This works in two steps. First, we print the minus signs for the relevant inputs. Then we print a 0 for ties and a 1 otherwise.
G`k P|r S|s R
*\)`.+
-

This is two stages. The ) in the second stage groups them together, the * makes them a dry run (which means the input string will be restored after they were processed, but the result will be printed) and \ suppresses printing of a trailing linefeed. The two stages together will print a - if applicable.
The first stage is a Grep stage which only keeps the line if it contains either k P, r S, or s R. These correspond to the cases where we need to output -1. If it's not one of those cases, the input will be replaced with an empty string.
The second stage replaces .+ (the entire string, but only if it contains at least one character) with -. So this prints a - for those three cases and nothing otherwise.
D`\w+
 .

This is two more stages. The first stage is a Deduplication. It matches words and removes duplicates. So if and only if the input is a tie, this drops the second word.
The second stage counts the number of matches of  ., which is a space followed by any character. If the input was a tie, and the second word was removed, this results in 0. Otherwise, the second word is still in place, and there's one match, so it prints 1 instead.

Here's a different approach based off the input string lengths.  Its longer than yours, but I wonder if it could be golfed down any more?

@DigitalTrauma that's a really neat idea, but I'm not seeing anything to shorten it. I think you should post it anyway (and if you move the first line into the header then TIO won't include it in the byte count).

05AB1E, 18 17 15 10 9 bytes
6 bytes saved with Digital Trauma's input length trick
€g3^Æ>3%<

Takes input as [SecondPlayersChoice,FirstPlayersChoice]
Try it online!
or Validate all test-cases
Alternative 9 byte solution: íø¬ÇÆ>3%<
Explanation
€g          # length of each in input
  3^        # xor 3
    Æ       # reduce by subtraction
     >      # increment
      3%    # modulus 3
        <   # decrement

Previous 15 byte solution
A-D{„PSÊiR}Ç`.S

Try it online! or Validate all test-cases
Explanation
 A-               # remove the lowercase alphabet from the input (leaves a 2 char string)
   D{             # sort a copy of the leftover
     „PSÊ         # check if the copy isn't "PS" (our special case)
         iR}      # if true, reverse the string to get the correct sign
            Ç`    # convert the two letters to their character codes
              .S  # compare their values

You beat my fun one :( Ç¥13T/*.½ò WHY IT WORKS? NOBODY KNOWS.

@MagicOctopusUrn: Uuuh, that sure is a weird one. What would the input format be for it to return an int as output?

['R','P'] :P It's a port of this.

@MagicOctopusUrn: Oh yeah, I forgot about that one. My favorite answer to this challenge :)

Jelly, 8 bytes
L€Iµ-*×Ṡ

Try it online! (test suite, casts to integer for clarity)
How it works
L€Iµ-*×Ṡ  Main link. Argument: A (string array)

L€        Take the length of each string.
  I       Increments; compute the forward difference of the length.
   µ      Begin a new chain with the difference d as argument.
    -*    Compute (-1)**d.
      ×Ṡ  Multiply the result with the sign of d.

CJam, 15 14 12 bytes
rW=rW=-J+3%(

Take the ascii code of the last character of each string, then returns:
(a1 - a2 + 19) % 3 - 1
Test it here!

Python 2, 46 40 bytes
lambda x,y:+(x!=y,-1)[x[0]+y[0]in'RPSR']

Try it online!
With many thanks to @Dennis for letting me borrow his Try it online test code and for saving me 6 bytes.
Edit
@hashcode55 - Pretty much as you describe. (x!=y,-1) is a two element sequence and [x[0]+y[0]in'RPSR'] is computing which element to take. If the first letter of x + the first letter of y is in the character list then it will evaluate to True or 1 so (x!=y,-1)[1] will be returned. If it is not then (x!=y,-1)[0]. This is where it gets a bit tricky. The first element is in itself effectively another if. If x!=y then the first element will be True otherwise it will be False so if x[0]+y[0]in'RPSR' is false then either True or False will be returned depending on whether x==y. The + is a bit sneaky and thanks again to @Dennis for this one. The x!=y will return a literal True or False. We need a 1 or a 0. I still don't quite know how but the + does this conversion. I can only assume that by using a mathematical operator on True/False it is forcing it to be seen as the integer equivalent. Obviously the + in front of the -1 will still return -1.
Hope this helps!

Hi! Can you please tell me how this syntax is working? Logically guessing, (x!=y,-1) this is working like if, if the list generates a true then -1 else x!=y. Whats the use of that + sign? A source documenting this kind of syntax  would be really helpful!

@hashcode55 - I have added an explanation to my answer.

To answer your uncertainty about the + - in this case, that's a unary plus, like +10, and is essentially a short way to convert to an integer.

Thanks @FlipTack. Kinda guessed that was what it is doing but thanks for the proper explanation.

@ElPedro Thanks a lot! That indeed helped me.

JavaScript (ES6), 46 38 bytes
(a,b)=>(4+!b[4]+!b[5]-!a[4]-!a[5])%3-1

Makes use of the fact that Rock-Paper-Scissors is cyclic. JavaScript has neither spaceship nor balanced ternary operators, otherwise the answer would be (a,b)=>((b<=>'Rock')-(a<=>'Rock'))%%3.
Edit: Saved 8 bytes thanks to @WashingtonGuedes.

@WashingtonGuedes I can do even better than that!

You could curry to save 1 byte

i tried running it and always return 0

 Python 3, 54 bytes
lambda o,t:(o!=t)*[-1,1]['RPS'['PS'.find(t[0])]!=o[0]]

Try it online!

MATL, 14 13 bytes
TTt_0vic1Z)d)

Try it online! Or verify all test cases.
Explanation
If the ASCII code of the initial letter of the first string is subtracted from that of the second string we get the value in the D column below. Taking modulo 5 gives the value M. The final value in parentheses is the desired result, R.
                        D        M     R
                       ---      ---   ---
Rock Rock          ->   0   ->   0   ( 0)
Rock Paper         ->  −2   ->   3   (−1)
Rock Scissors      ->   1   ->   1   ( 1)
Paper Rock         ->   2   ->   2   ( 1)
Paper Paper        ->   0   ->   0   ( 0)
Paper Scissors     ->   3   ->   3   (−1)
Scissors Rock      ->  −1   ->   4   (−1)
Scissors Paper     ->  −3   ->   2   ( 1)
Scissors Scissors  ->   0   ->   0   ( 0)

Thus if we compute D and then M, to obtain R we only need to map 0 to 0; 1 and 2 to 1; 3 and 4 to −1. This can be done by indexing into an array of five entries equal to 0, 1 or −1. Since indexing in MATL is 1-based and modular, the array should be [1, 1, −1, −1, 0] (the first entry has index 1, the last has index 5 or equivalently 0). Finally, the modulo 5 operation can luckily be avoided, because it is implicitly carried out by the modular indexing.
TT     % Push [1 1]
t_     % Duplicate, negate: pushes [−1 −1]
0      % Push 0
v      % Concatenate vertically into the 5×1 array [1; 1; −1; −1; 0]
i      % Input cell array of strings
c      % Convert to 2D char array, right-padding with zeros if necessary
1Z)    % Take the first column. Gives a 2×1 array of the initial letters
d      % Difference
)      % Index into array. Implicit display

CJam, 12 bytes
0XXWW]rcrc-=

The two inputs are space-separated. Their order is reversed with respect to that in the challenge text.
Try it online! Or verify all test cases.
Explanation
Translation of my MATL answer. This exploits the fact that in CJam c (convert to char) applied on a string takes its first character. Also, the array for the mapping is different because indexing in CJam is 0-based.
0XXWW    e# Push 0, 1, 1, -1, -1
]        e# Pack into an array
rc       e# Read whitespace-separated token as a string, and take its first char
rc       e# Again
-        e# Subtract code points of characters
=        e# Index into array. Implicitly display

dc, 18
1?Z9+2/rZ1+2/-3%-p

Try it online.
Note that the two args are passed (space-separated) on one line to STDIN.  The args are contained in square brackets [ ] as this is how dc likes its strings.
dc has very limited string handling, but it turns out one of the things you can do is use the Z command to get a string length, which luckily is distinct for "Rock", "Paper" and "Scissors", and can be fairly simply arithmetically manipulated to give the desired result.

Java 7, 82 bytes
int c(String...a){int x=(a[0].charAt(1)-a[1].charAt(1))%5/2;return x%2==x?x:x/-2;}

Ungolfed:
int c(String... a){
   int x = (a[0].charAt(1) - a[1].charAt(1)) % 5 / 2;
   return x%2 == x
           ? x
           : x / -2;
}

Explanation:

The second letters are o, a and c, with the ASCII decimals 111, 97 and 99.
If we subtract these from each other for the test cases we have the following results:

0 (Rock, Rock)
14 (Rock, Paper)
12 (Paper, Scissors)
-14 (Paper, Rock)
0 (Paper, Paper)
-2 (Paper, Scissors)
-2 (Scissors, Rock)
2 (Scissors, Paper)
0 (Scissors, Scissors)

If we take modulo 5 for each, we get 4, 2, -4, -2, -2, 2.
Divided by 2 x is now the following for the test cases:

x=0 (Rock, Rock)
x=2 (Rock, Paper)
x=1 (Paper, Scissors)
x=-2 (Paper, Rock)
x=0 (Paper, Paper)
x=-1 (Paper, Scissors)
x=-1 (Scissors, Rock)
x=1 (Scissors, Paper)
x=0 (Scissors, Scissors)

Only the 2 and -2are incorrect, and should have been -1 and 1instead. So if x%2 != x (everything above 1 or below -1) we divide by -2 to fix these two 'edge-cases'.

Test code:
Try it here.
class M{
  static int c(String...a){int x=(a[0].charAt(1)-a[1].charAt(1))%5/2;return x%2==x?x:x/-2;}

  public static void main(String[] a){
    String R = "Rock",
           P = "Paper",
           S = "Scissors";
    System.out.println(c(R, R)); // 0
    System.out.println(c(R, P)); // -1
    System.out.println(c(R, S)); // 1
    System.out.println(c(P, R)); // 1
    System.out.println(c(P, P)); // 0
    System.out.println(c(P, S)); // -1
    System.out.println(c(S, R)); // -1
    System.out.println(c(S, P)); // 1
    System.out.println(c(S, S)); // 0
  }
}

Output:
0
-1
1
1
0
-1
-1
1
0

Why the second letter out of curiosity? I had the same approach (kinda) but used the first letter.

@carusocomputing Well, I noticed most of the other people were using either the first letter or length, and wanted to try something else. I first used the third letters (c, p, i) with the ASCII values 99, 112 and 105, as they seemed most useful, and noticed it would become 4, 2, 0 if I did modulo 5. Only then I figured I had to subtract both, so the 4, 2 and 0 weren't of much use. After some fuddling around/trial-and-error I tried the second letter and was getting more useful results with the same modulo 5 still present. Then I quickly came to the solution I presented above. :)

@carusocomputing Wanted to try an unique approach, and considering I'm pretty bad at these kind of solutions, it isn't as short as some other solutions, but still unique (which was my initial goal). :)

JavaScript, 37, 32, 31 bytes
a=>b=>a==b?0:!(a+b)[12]^a>b||-1

If a equals b, output zero.
Otherwise, xor the result of checking if length not greater than 12 (comparison of Scissors and Paper) with the comparison of a greater than b.
If this returns 1, return it.
If it returns 0, use the OR operator to replace with -1.

Could you write this as a curried function a=>b=> to save a byte?

Yes.  Thank you @FlipTack

PHP, 34 bytes
<?=md5("BMn$argv[1]$argv[2]")%3-1;

Perl 5 -p, 24 bytes
$_=/kS|rR|sP/-/kP|rS|sR/

The input should be on stdin without separators, e.g.:
echo PaperRock | perl -pe'$_=/kS|rR|sP/-/kP|rS|sR/'

The first regexp searches for first player win, the second for his loss. The difference is printed.
Try it online!

C#, 85 84 bytes
Saved 1 byte, thanks to TheLethalCoder
a=>b=>a==b?0:(a[0]=='R'&b[0]=='S')|(a[0]=='P'&b[0]=='R')|(a[0]=='S'&b[0]=='P')?1:-1;

It accepts two strings as an input, and outputs an integer. There is a tie, if the two strings are equal, otherwise it checks for the first charachter of the strings, in order to determine, which player wins.

Save one byte by using currying i.e. a=>b=>...

Pyth, 16
t%+7h.+mx3ldQ3

Probably could be shorter.
        x3ld      # lambda to get string length then XOR with 3
       m    Q     # map over the input (array of 2 strings)
     .+           # difference of the two results
    h             # flatten one-element array
  +7              # add 7
 %           3    # mod 3
t                 # subtract 1 and implicit print

Online.

Perl, 33 bytes
32 bytes of code + -p flag.
$_=/(.+) \1/?0:-/k P|r S|s R/||1

To run it:
perl -pe '$_=/(.+) \1/?0:-/k P|r S|s R/||1' <<< "Rock Paper"

Saved 3 bytes by using the regex of Martin Ender's Retina answer. (my previous regex was /R.*P|P.*S|S.*R/)
Explanation:
First, /(.+) \1/ checks if the input contains twice the same word, if so, the result is 0. Otherwise, /k P|r S|s R/ deals with the case where the answer is -1. If this last regex is false, then -/k P|r S|s R/is false, so we return 1.

Batch, 116 bytes
@if %1==%2 echo 0&exit/b
@for %%a in (RockScissors PaperRock ScissorsPaper)do @if %%a==%1%2 echo 1&exit/b
@echo -1

Japt, 19 bytes
-Ms(4*(Uc -Vc)/MP¹r

Try it here!
Inspired by carusocomputing's solution
Old 53-byte Solution
W=Ug c X=Vg c W¥X?0:W¥82©X¥83?1:W¥80©X¥82?1:W¥83©X¥80?1:J

Try it online!
Thanks again, ETHproductions!

You could start by using © instead of &&, changing the Ug0 c to Ug c (same with V) and replacing -1 with J. It's still quite a bit longer than the JS answer though, perhaps you can take some ideas from that

@ETHproductions Thanks! I don't know how I forget about ©

Actually you can just do W=Uc. I don't know why I keep forgetting that c works on any string :P

Jelly, 9 bytes
L€^3Iæ%1.

This uses the algorithm from @DigitalTrauma's Bash answer.
Try it online!
How it works
L€^3Iæ%1.  Main link. Argument: A (string array)

L€         Take the length of each string.
  ^3       XOR the lengths bitwise with 3.
    I      Increments; compute the forward difference of both results.
     æ%1.  Balanced modulo 1.5; map the results into the interval (-1.5, 1.5].

Dammit, I was about to start reading up on Jelly.  Oh well, here it is in pyth.  +1.

PHP, 55 53 bytes
<?=(3-(ord($argv[2])%6%4-ord($argv[1])%6%4+3)%3*2)%3;

takes the ascii values of the first letters (from command line arguments): 82,80,83
%6: 4,2,5
%4: 0,2,1
difference (b-a):

PS:1-2,SR:2-0,RP:2-0 -> -1 or 2; +3,%3 -> 2
SP:2-1,RS:0-2,PR:0-2 -> -2 or 1; +3,%3 -> 1
RR,PP,SS:0; +3,%3: 0

(3-2*x): -1,1,3
%3: -1,1,0

sine version, 49 46 bytes
<?=2*sin(1.3*(ord($argv[2])-ord($argv[1])))|0;

a golfed port of carusocomputing´s answer:
3 bytes saved by @user59178

For the sine version for can save 3 bytes by replacing round(x) with 2*x^0

Python 2, 32 bytes
lambda*l:cmp(*l)*(1|-('R'in`l`))

Try it online
A fairly short "natural" solution, though not as short as Dennis's brute-forced solution.
The cmp(*l) compares the inputs lexicographically, giving -1, 0, or +1 for smaller, equal, and greater. This gives the right negated answer on each pair of "Paper", "Rock", "Scissors" except on Paper vs Scissors in either order. To fix that, we multiply by -1 on any input without an 'R' in the string rep. This also flips Scissors vs Scissors and Paper vs Paper, but those gave 0 anyway.
Thanks to xsot for saving a byte with the (1|-(_)) construct to turn a Bool into ±1. This is shorter than the alternatives.
lambda*l:cmp(*l)*cmp(.5,'R'in`l`)
lambda*l:cmp(*l)*(-1)**('R'in`l`)
lambda*l:cmp(*l)*(1-2*('R'in`l`))

There's a shorter alternative: (1|-('R'in\l`))`

@xsot Thanks! That's a nice trick for a common situation, you could add a tip for it.

Perhaps you could mention it in this tip. Also, for what it's worth, I first encountered this trick here.

APL (Dyalog Unicode), 12 bytes
1-3|1+1-.⊃⍒¨

Try it online!
ngn's solution.
APL (Dyalog Extended), 28 26 19 18 bytes
(××¯1*3>|)-⍥⎕UCS⍥⊃

Try it online!
Jo King's similar train based solution.(-3 bytes)
(⍥ function is new in Dyalog 18.0, a polyfill is used instead in TIO.)
-2 more bytes from Jo King.
-7 bytes golfed by Bubbler.
-1 byte from Adám (change to Dyalog Extended)
APL (Dyalog Unicode), 31 bytes
{¯1 1 1 0 ¯1 ¯1 1[3+-/⎕UCS⊃¨⍵]}

Subtracts the unicode values of the first character of each string.
Then adds three to the difference, and returns the correct value as per this mapping:
 0  1  2  3  4  5  6
---------------------
-1  1  1  0 -1 -1  1

Code Explanation:
{¯1 1 1 0 ¯1 ¯1 1[3+-/⎕UCS⊃¨⍵]}
                           ¨⍵   For each value of ⍵
                          ⊃     Get the first letters
                      ⎕UCS      Transform them to their Unicode codepoints
                    -/          Reduce them by subtraction
                  3+            Add three to the difference
{¯1 1 1 0 ¯1 ¯1 1[           ]} Return the value, using the difference +3 as index

Try it online!

Oh, forgot to change the byte count to SBCS. I'll add that in.

didn't know trains could have left and right args. Nice.

The Ö is called a polyfill. The actual submission should use the proper symbol ⍥, even if the TIO link uses Ö.

Turns out you can golf it a lot.

No idea how that works at all, but if it follows the same array indexing, I'll add it.

-1: (××¯1*3>|)-⍥⎕UCS⍥⊃ Try it online!

@Adám -6: 1-3|1+1-.⊃⍒¨

what?!?!?!?!!??!?!?

@ngn : Try it online! did i give the wrong input?

@Razetime ⎕io←0

@Razetime I didn't switch to Extended; just using it as polyfill for 18.0.

Scala, 148 bytes
object R extends App{val t=Seq('R','P','S')
val(a,b)=(args(0)(0),args(1)(0))
print(if(a==b)0 else if(t.indexOf(a)%3==(t.indexOf(b)-1)%3)-1 else 1)}

Thankfully, since semicolons are required to separate multiple commands on the same line, Scala benefits from having formattable golf code!
In this golfing attempt I learned that you can replace
"somestring".charAt(index)

with
"somestring"(index)

because Scala lets you treat strings as arrays for the purpose of getting characters.

This can be golfed immensely. For starters, you're allowed to do a function instead of a complete program in most challenges here, so instead of the whole object extends app thing and pulling from args, try something like:
def g(a:Seq,b:Seq)=...

Additionally, you need not print the value. Returning it is sufficient, which is great when golfing Scala, since the return is free. And you can improve it even further by using the trick posted in the Groovy answer, which works almost identically in Scala.

C++, 98 bytes#
int main(int c,char*v[]){int a=v[2][0]-v[1][0];if(a%3==0)a=-a;if(a>1)a/=a;if(a<-1)a/=-a;return a;}

Could definitely be shortened, but I don't have that skill or knowledge.
Enlightenment?

Brought it down to 72, and there's probably more room to improve :)

GNU Sed, 39, 38 bytes
36 bytes code + 2 bytes for the "nr" flags
Golfed
/^(.+)\1/{a0
b}
/kP|rS|sR/{a-1
b}
a1

Test
>RPS() { echo "$1 => "`sed -rnf rps.sed<<<$1`; }

>RPS RockRock
RockRock => 0

>RPS RockPaper
RockPaper => -1

>RPS RockScissors
RockScissors => 1

>RPS PaperRock
PaperRock => 1

>RPS PaperPaper
PaperPaper => 0

>RPS PaperScissors
PaperScissors => -1

>RPS ScissorsRock
ScissorsRock => -1

>RPS ScissorsPaper
ScissorsPaper => 1

>RPS ScissorsScissors
ScissorsScissors => 0

///, 87 bytes
/_/1\/\///Paper/p//Rock/r//Scissors/s// ///pr/_rs/_sp/_rp/-_sr/-_ps/-_pp/0//rr/0//ss/0/

Try it online!
Ungolfed
/Paper/p//Rock/r//Scissors/s// //
/pr/1//rs/1//sp/1/
/rp/-1//sr/-1//ps/-1/
/pp/0//rr/0//ss/0/

Clojure, 43 bytes
#(get[0 1 1](mod(-(count %)(count %2))6)-1)

Uses (length(arg_1) - length(arg_2)) % 6 as a lookup to [0 1 1] and returns -1 if it goes out of bounds.

Clojure, 114 75 bytes
-39 bytes by accepting 2 parameters instead of parsing 1, and changing the "else" placeholder from :e to 0.
 (fn[[p][q]](let[d(-(int p)(int q))](cond(#{-1 -2 3}d)1(#{1 2 -3}d)-1 0 0)))

Ungolfed:
(defn rps-scorer [[p1] [p2]] ; Deconstruct out the first letters of each word
  (let [d (- (int p1) (int p2))] ; And find the difference of their numeric values
    (cond (#{-1 -2 3} d) 1 ; If it's a winning difference, return 1, else
          (#{1 2 -3} d) -1 ; If it's a losing difference, return -1, else
          :else 0))) ; return 0, because they're the same.

Totally naïve approach here. I found out if you subtract the ascii values of the first letter of each play, winning values will be -1, -2 and 3, and losing values will be 1, 2 and -3. I just check which set the plays fall into, then return based on membership.

C#, 43 bytes
a=>b=>(a[0]-b[0])/3*2+Math.Sign(b[0]-a[0]);

C# treats characters like integers that you can add and subtract.

SmileBASIC, 39 bytes
INPUT A$,B$?(67XOR LEN(A$*2+B$))MOD 3-1

A port of Dennis's algorithm. XOR and MOD are really long, I'm sure this could be made shorter.

Ruby -n, 20 bytes
p$_.to_i(30)/522%3-1

Try it online!
Take input in the form of "RockPaper", interpret it as a base 30 integer 18248834542947, divide by 522 rounding down to 34959453147, modulo 3 is 0, minus 1 is -1.

Zsh, 29 bytes
<<<${${:-{,,-,-}1}[#2-#1]:-0}

Try it online!
<<<${${:-{,,-,-}1}[#2-#1]:-0}
         {,,-,-}1                # expands to the list (1 1 -1 -1)
     ${:-        }               # empty-fallback (anon parameter)
   ${             [     ]   }    # index into list
                   #2-#1         # difference between each parameter's first character's codes
   ${                    :-0}    # if empty, substitute 0

This is similar to one of the CJam answers. However, since Zsh indexes from 0, we need the ${    :-0} empty fallback to handle the 'P' - 'P' => 0 case.

R, 39 bytes
with thanks to Giuseppe for bug-spotting
d=diff(nchar(scan(,'')));sign(d)*(-1)^d

Try it online!
I came to this challenge 3 years late, but there doesn't seem to be an answer in R yet.
So here's a first shot at it, before browsing the other (currently 51!) answers...
Edit after some browsing: this approach was already used in Dennis's Jelly answer 3 years ago...
Uses number of characters in the strings "Rock" (4), "Paper" (5) and "Scissors" (8).
Difference in characters (player 1 - player 2) gives the following table:
diff  answer
0  => 0
1  => 1
-1 => -1
3  => 1
-3 => -1
4  => -1
-4 => 1

So for all differences with an absolute value below 4, the answer is just the sign.
We need to reverse it for absolute values of 4, but not of 1 or 3.
Luckily 1 and 3 are odd, and 4 is even, so we can use powers of -1 (which is -1 for all odd, and 1 for all even numbers).

LaTeX, 81 bytes
Function
\def~#1#2{\ifcase\numexpr"#1"-"#2"+3{}-1'1'1'0'-1'-1'1\fi}\def"#1#2"{`#1}\let'\or

This works by taking the first character of the two strings and using its ASCII-value. Then the difference is used in a switch cases to leave the correct result in the input stream.
Complete Document
\documentclass[preview,border=3.14]{standalone}

\catcode`\"13
\catcode`\'13

\def~#1#2{\ifcase\numexpr"#1"-"#2"+3{}-1'1'1'0'-1'-1'1\fi}\def"#1#2"{`#1}\let'\or

\begin{document}

~{Rock}{Rock} should be 0

~{Rock}{Paper} should be -1

~{Rock}{Scissors} should be 1

~{Paper}{Rock} should be 1

~{Paper}{Paper} should be 0

~{Paper}{Scissors} should be -1

~{Scissors}{Rock} should be -1

~{Scissors}{Paper} should be 1

~{Scissors}{Scissors} should be 0

\end{document}

Results (in PDF)

Brain-Flak, 210 bytes
{({}(<()>))({}[((((()()()()()){}){}){}){}]){({}[()()]){({}[()]){(<{}({}[()()()])>)}(<{}({}())>)}(<{}({}())>)}{}({}()){({}<>)(<>)}{}}<>({}[{}()()]){({}()()()()){(<([()()()])>)}(<(()())>)}(([]){[{}]{}([])}{}[()])

Try it online!
{                           while input not empty
  ({}(<()>))                push identifier 0 under the first character
  ({}[((((()()()()()){}){}){}){}]) decrement input by 80 "P"
  {                         if not input = "P"
    ({}[()()]){             if not input = "R"
      ({}[()]){             if not input = "S"
        (<{}({}[()()()])>)  character = 0; identifier = -3
      }
      (<{}({}())>)          identifier += 1
    }
    (<{}({}())>)            identifier += 1
  }
  {}                        delete character
  ({}())                    identifier += 1
  {                         if identifier != 0
    ({}<>)                  push it onto the right stack
    (<>)                    return to left stack and push 0 for exit if
  }
  {}                        delete identifier or exit-if-0
}
<>                          go to right stack
({}[{}()()])                result = first item - second item - 2
                            # first - second would return the correct
                            # results for most cases. Only "Paper Scissors"
                            # or "Scissors Paper" results in -2 or 2.
{                           if result != 2
  ({}()()()()){             if result != -2
    (<([()()()])>)          push -3 0
  }
  (<(()())>)                push 2 0
}
(([]){[{}]{}([])}{}[()])    push sum of values - 1

Well, no Batch submission so far, So:
Batch 140 bytes
@Set/A RR=PP=SS=0,RP=PS=SR=-1,RS=PR=SP=1&Title press:RSP&@Set "#=@For /F Delims^= %%# in ('Choice /N /C:RSP')Do @"
%#:#=1%%#:#=2%Set %%1%%2

Input is taken via the Choice command In Macro form
Input Macro uses substring modification to substitute the For metavariable
Output is done using the set command on the values gained from the input macro to refer to the variables assigned for Win/Draw/Loss.
16 bytes could be shaved off by eliminating the Title command + Instructions ("&Title press:RSP")

Vyxal, 10 bytes
vtCƒ-19+ǒ‹

Try it Online!
Explained
vtCƒ-19+ǒ‹
v          # vectorise
 t         # tail
  C        # char
   ƒ-      # reduce by substraction
     19+   # +19
        ǒ  # modulus 3
         ‹ # decrement

Perl 6,  63 54 40  39 bytes
{2>($_=[-] %(<Rock -1 Paper 0 Scissors 1>){@_})>-2??$_!!-.sign}

Try it
{3>($_=[R-] @_>>.substr(0,1)>>.ord)>-3??.sign!!-.sign}

Try it
{3>($_=[R-] @_>>.ord)>-3??.sign!!-.sign}

Try it
{($_=[-](82 X<=>@_».ord)%3)>1??-1!!$_}

Try it

C#, 28 bytes
(a,b)=>""[*a-*b+3]-2;

Contains unprintable characters, so here's a hex dump:
Turns out my solution is pretty similar to Dennis's Python 3 answer, but calculates the index differently. not anymore
This uses unsafe so the string inputs need to be put in char* first.
How it works:
// Delegate signature
unsafe delegate int Signature(char* c, char* z);

/*unsafe Signature Lambda = */ (a, b) =>
    "\x1\x3\x3\x2\x1\x1\x3"               // The outcomes
    [*a - *b + 3]                         // Index by subtracting value of first char of p2
                                          // from p1, adding 3 so the result is >= 0
    -2                                    // Subtract 2 to put in range [-1, 1]

I think you ought to be including the unsafe term in your code, and so in the byte count. There is also a narrow consensus that 'untyped' lambdas are invalid, and you should include the types in the parameters, which C#ers should be aware of.

Based on that meta post, I don't think the types or unsafe are needed since both can be deduced. The problem clearly indicates the inputs are string types. The only string type in C# with the * prefix operator is char* which also implies unsafe.

The types can't be deduced by the compiler (or at least are not), and the compiler will just complain about a lack of unsafe context (which also requires a compiler argument, which is usually counted as well).

C 355 bytes
#define S strcmp f(char *a,char *b){*c[]={"Rock","Paper","Scissors"}; if((!S(a,c[0])&&!S(b,c[1]))||(!S(a,c[1])&&!S(b,c[2]))||(!S(a,c[2])&&!S(b,c[0]))==1 )puts("-1");if( (!S(a,c[0])&&!S(b,c[0]))||(!S(a,c[1])&&!S(b,c[1]))||(!S(a,c[2])&&!S(b,c[2]))==1 )puts("0");if( (!S(a,c[0])&&!S(b,c[2]))||(!S(a,c[1])&&!S(b,c[0]))||(!S(a,c[2])&&!S(b,c[1]))==1 )puts("1");}

Accept user inputs(argv[1],argv[2]) and pass it onto f(char *a, char *b);
Here is the Ungolfed version:
 #define S strcmp
 void f(char *a,char *b)
 {
   char *c[]={"Rock","Paper","Scissors"};
   if( (!S(a,c[0])&&!S(b,c[1]))||(!S(a,c[1])&&!S(b,c[2]))||(!S(a,c[2])&&!S(b,c[0]))==1 )
     puts("-1");
   if( (!S(a,c[0])&&!S(b,c[0]))||(!S(a,c[1])&&!S(b,c[1]))||(!S(a,c[2])&&!S(b,c[2]))==1 )
     puts("0");
   if( (!S(a,c[0])&&!S(b,c[2]))||(!S(a,c[1])&&!S(b,c[0]))||(!S(a,c[2])&&!S(b,c[1]))==1 )
     puts("1");
 }

There must definitely be a way to shorten this! I don't know though.
@Timtech Hope i understood you right. This code works, but prints 0 even if the strings are not exact, not sure if that satisfies the specification.
`#define S strcmp f(){printf("%d",(!S(a,c[0])&&!S(b,c[1])||!S(a,c[1])&&!S(b,c[2])||!S(a,c[2])&&!S(b,c[0]))?-1:(!S(a,c[0])&&!S(b,c[2])||!S(a,c[1])&&!S(b,c[0])||(!S(a,c[2])&&!S(b,c[1]) )?1:0));}

Looks like there's lots of ways to golf this. Here's a tip, instead of having the if statements output -1, 0, or 1, have them store to var. Then initialize the var as 0 and drop the middle if statement, returning or outputting the value at the end.

TI-Basic, 64 bytes
There is probably a shorter way but I'm not seeing it right now...
DelVar R1->P:2->S
Prompt Str1,Str2:1
If sum(not({~2,1}-sum(eval(sub(Str1,1,1)+"-"+sub(Str2,1,1
~1:Str1!=Str2

TI-84 BASIC, 55 bytes
Prompt Str1,Str2
sub(Str1,1,1→Str3
sub(Str2,1,1
(Str3≠Ans)*(1-2not(inString("SPPRRS",Str3+Ans

I saved a byte by using Prompt instead of Input thanks to Timtech.
Execution:
Input is given as two strings as prompted. The TI-84 does not have native lowercase letters.
prgmRPS
Str1=?"ROCK"
Str2=?"SCISSORS"

               1

C#, 48 bytes
(a,b)=>a==b?0:(a[0]>b[0])^(a[0]+b[0]==163)?-1:1;

Noodel, 21 bytes
1220200Ḷ2ėạȥḃ1€Ė⁻ạɲ⁻1

Try it:)
How It Works
The first input is the first player:) It works by using the first character of both the string inputs then subtract them. Then using that result to index into an string to get the correct value.
The result from each game after subtracting the values of the first characters:
"Rock"     -> "Rock"     =  0
"Rock"     -> "Paper"    = -2
"Rock"     -> "Scissors" =  1
"Paper"    -> "Rock"     =  2
"Paper"    -> "Paper"    =  0
"Paper"    -> "Scissors" =  3
"Scissors" -> "Rock"     = -1
"Scissors" -> "Paper"    = -3
"Scissors" -> "Scissors" =  0

How each position in the string is used to correspond to which game:
[0] or [-7] = 1 => "Rock" -> "Rock", "Paper" -> "Paper", "Scissors" -> "Scissors"
[1] or [-6] = 2 => "Rock" -> "Scissors"
[2] or [-5] = 2 => "Paper" -> "Rock"
[3] or [-4] = 0 => "Paper" -> "Scissors"
[4] or [-3] = 2 => "Scissors" -> "Paper"
[5] or [-2] = 0 => "Rock" -> "Paper"
[6] or [-1] = 0 => "Scissors" -> "Rock"

Break down of the actual script:
1220200               # Pushes the string "1220200" onto the stack.

       Ḷ2ėạȥḃ1€       # A loop that grabs the first character, turns it into a number, and then throws away the string.
       Ḷ2             # Loop the following block two times.
         ė            # Places what is on the top to the bottom (first loop is the string created before, second loop places the result of player two)
          ạ           # Grabs the first element of the string.
           ȥ          # Convert the string to a number as if it was a base 98 number.
            ḃ1        # Remove the second item off of the stack.
              €       # End of the loop.

               Ė⁻     # Grabs what is at the bottom of the stack then subtracts what was on the top from that.
               Ė      # Grabs what is at the bottom of the stack (which is the first number calculated (player two).
                ⁻     # Subtracts player one from player two producing the index into the string.

                 ạɲ⁻1 # Grabs an element from the string and decrements it by one to get the final result.
                 ạ    # Access the string based off of the number produced from the subtraction.
                  ɲ   # Turns that string into a number.
                   ⁻1 # Subtracts one from that number.

Common Lisp, 83 bytes
(setq c(- #1=(char-code(elt(read)0))#1#))(cond((= c 0)0)((member c'(1 2 -3))-1)(1))

Try it online!
The algorithm is ported from Carcigenicate’s answer.

C#, 151 bytes
public class P{public static void Main(string[]a){int v=(a[0][0]-a[1][0]);v=v==2?-1:v==-1?1:v==-2?1:v==0?0:v==1?-1:v==3?1:-1;System.Console.Write(v);}}

Try Online

Rust, 110 107 bytes
fn r(a:&str,b:&str)->i8{let p=if a.as_bytes()[0]+b.as_bytes()[0]==163{(b,a)}else{(a,b)};p.1.cmp(&p.0)as i8}

Try it online!

Thunno 2, 9 bytes
C€tẸ-⁺3%⁻

Attempt This Online!
Somehow passes all the test cases (I checked all 9).
Explanation
C€tẸ-⁺3%⁻  # Implicit input
C          # Convert to codepoints
 €t        # Last item of each
   Ẹ-      # Reduce by subtraction
     ⁺     # Increment
      3%   # Mod 3
        ⁻  # Decrement
           # Implicit output


text:
Python workarounds for assignment in lambda
This is a tips question for golfing in Python.
In Python golfing, it's common for a submission to be a function defined as a lambda. For example,
f=lambda x:0**x or x*f(x-1)

computes the factorial of x.
The lambda format has two big advantages:

The boilerplate of f=lambda x:... or lambda x:... is shorter than the def f(x):...return... or x=input()...print...
A recursive call can be used to loop with little byte overhead.

However, lambdas have the big drawback of allowing only a single expression, no statements. In particular, this means no assignments like c=chr(x+65). This is problematic when one has a long expression whose value needs to be referenced twice (or more).
Assignments like E=enumerate are possible outside the function or as an optional argument, but only if they don't depend on the function inputs. Optional arguments like f=lambda n,k=min(n,0):... fail because input n hasn't been defined when k is evaluated at definition time.
The result is that sometimes you suck up repeating a long expression in a lambda because the alternative is a lengthy non-lambda.
lambda s:s.strip()+s.strip()[::-1]
def f(s):t=s.strip();print t+t[::-1]

The break even point is about 11 characters (details), past which you switch to a def or program. Compare this to the usual break-even point of length 5 for a repeated expression:
range(a)+range(b)
r=range;r(a)+r(b)

print s[1:],s[1:]*2
r=s[1:];print r,r*2

Other languages have workarounds, Octave for example. There are known tricks for Python, but they are long, clunky, and/or limited-use.  A short, general-purpose method to simulate assignment in a lambda would revolutionize Python golfing.

What are ways for a Python golfer to overcome or work around this limitation? What potential ideas should they have in mind when they see a long expression repeated twice in a lambda?
My goal with this tips question is to dive deep into this problem and:

Catalog and analyze golfing workarounds to fake assignment inside a lambda
Explore new leads for better methods

Each answer should explain a workaround or potential lead.

I'm guessing this is one of those things that can't be done well in Python. JavaScript has a leg up on this one.

Just as with orlp's answer, Neil's (deleted) suggestion for using nested lambdas isn't necessarily longer than def in cases where you need a nested lambda anyway. I think it deserves more thorough analysis.

For the exact example given with the reversed lowercase string concatenation one could just go for lambda s:(s+s[::-1]).lower(). Of course this does not answer the actual question.

@JonathanAllan Good point, changed it to strip.

Assignment expressions in Python 3.8
Python 3.8 (TIO) introduces assignment expressions, which use := to assign a variable inline as part of expression.
>>> (n:=2, n+1)
(2, 3)

This can be used inside a lambda, where assignments are not ordinarily allowed. Compare:
lambda s:(t:=s.strip())+t[::-1]
lambda s:s.strip()+s.strip()[::-1]
def f(s):t=s.strip();return t+t[::-1]

See this tip for more.

eval
This is not that great in of itself, but if your solution already uses eval in some way or form you can usually use this technique.
eval("%f*%f+%f"%((5**.5,)*3))

Wow, that's smart! Why do I never see this kind of code?

@z0rberg's Probably because eval is evil.

I don't subscribe to this codeism. #EvalLivesMatter ... but seriously, how is that worse than simple dll-injection?

Inner lambdas
These allow you to define multiple variables at once.
lambda s:s.strip()+s.strip()[::-1]

vs.
lambda s:(lambda t:t+t[::-1])(s.strip())

is much longer, but if you have multiple variables, or variables that are longer, which are repeated many times:
lambda a,b,c:a.upper()*int(c)+b.lower()*int(c)+a.upper()[::-1]+b.lower()[::-1]+a.upper()*int(c)+a.lower()*int(c)

vs.
lambda a,B,c:(lambda A,b,n:A*n+b*n+A[::-1]+b[::-1]+A*n+b*c)(a.upper(),B.lower(),int(c))

Character count
Initial: (lambda:)() (11 bytes)
First variable: [space]a (2 bytes)
Subsequent variables: ,b, (3 bytes)
Use: a (1 byte).
(lambda* a*_,b_:)(*<value a>*_,<value b>_)
(Also saves on brackets)
So, this takes 3n + 10 bytes, where n is the number of variables. This is a high initial cost, but can pay off in the end. It even returns it's inner value,so you can nest multiple (Though this will quickly become not worth it.)
This is really only useful for long intermediate calculations in nested list comprehensions, as a def f():a=...;b=...;return will usually be shorter.
For 1 value, this saves: uses * length - length - uses - 13, so is only useful when that expression is positive.
For a n different expressions used u times in total, where their combined length is l, this saves:
l - (3 * n) - u - 10 ( + brackets removed )

Use a List
Declare a list as parameter and use .append() or to store the value:
lambda s:s.lower()+s.lower()[::-1]
turns into
lambda s,l=[]:l.append(s.lower())or l[-1]+l[-1][::-1]
Character count:
,l=[] 5 characters
l.append()or  13 characters
l[-1] 5 characters for each use
Break Even
The amount of added character is :
uses*(5-length) + 18 + length
In the previous example the statement is s.lower() is 9 characters long and is used 2 times, applying this technique added 19 characters.
If it was used 7 times, there would be a 1 character reduction.
The amount of minimal uses to this technique be worth is
min_uses = (18+length)/(length-5)
Upsides

Allow a new assignment at a slightly reduced cost (the list already is declared)
Is a list object so [0], .pop(), [x:y] and other list functions can be used for tricks. highly situational

Downsides

High initial cost
High use cost
Only works for uses with the length higher than 5

Use a Dictionary
thanks @Zgarb
Same idea as above
Declare a dictionary as parameter and use .setdefault() to store (and return) the value:
lambda s:s.lower()+s.lower()[::-1]
turns into
lambda s,d={}:d.setdefault(0,s.lower())+d[0][::-1]
Note that, unlike the list counterpart, setdefault returns the value assigned.
Character count:
,d={} 5 characters
d.setdefault(k,) 16 characters
d[k] 4 characters for each use
Break Even
The amount of added character is :
(uses-1)*(4-length) + 21
In the previous example the statement is s.lower() is 9 characters long and is used 2 times, applying this technique added 16 characters.
If it was used 7 times, there would be a 1 character reduction.
The amount of minimal uses to this technique be worth is
min_uses = 1-21/(4-length)
Upsides/Downsides

Basically the same as the list
Only works for uses with the length higher than 4

Other considerations

If this technique worth the character reduction, then the lambda can probably be dropped and the function be rewritten with def/input for a shorter program.
As @FlipTack pointed, the list and the dict ARE KEEPT between function calls, while this will mostly disturb, it can be used on recursive calls.again highly situational
The dictionary will always be shorter than the list.

Function submissions have to be usable more than once. Currently this uses the same list each time the lambda is run, which could mess up things on later runs.

@FlipTack out of interest, would you mind linking a source like meta? I think that rule might have some impact on a few tricks I know.

http://meta.codegolf.stackexchange.com/a/4940/60919

I think you can do better with a dictionary: lambda s,d={}:d.setdefault(0,s.lower())+d[0][::-1] It's also reusable.

You can use list.extend to add multiple elements at once, which will be shorter than using list.append multiple times.

I think I'm missing something. Any reason to use l[-1] rather than l[0] for the list case? Is this just to allow the function to be called multiple times and work uniformly?

@JulianWolf basically, yes

Use to set variables and return the data after operation like such:
add = lambda x, y: exec("x+=y")

alternatively:{add = lambda x, y: [x.append(x[0]+y), x.reverse(), x.pop()]}

List comprehensions
This is more of a last resort since it's so ungolfy, but you can do
[<expression> for <variable> in <value>]
to pseudo-set a variable in a lambda. Basically the only good point about this method is that the inner expression can stay readable, which is obviously the least of your concern when golfing.


text:
Make a string a e s t h e t i c
Basically, between every character of a uni-line string, add a space, but there can't be two spaces in between one character.

aesthetic becomes a e s t h e t i c.
The quick brown fox jumps over the lazy dog becomes T h e q u i c k b r o w n f o x j u m p s o v e r t h e l a z y d o g.
I'm Nobody! Who are you? becomes I ' m n o b o d y ! W h o a r e y o u ?

This is code golf, so the shortest answer in bytes wins.

PS this is my first challenge. Any feedback would be very helpful!

Would it be acceptable to output one extra trailing space? Will there ever be newlines in the input?

No newlines, yes to extra space

We can assume input will always be printable ascii? Can input be a char array?

@Pavel yes, as always

Will the input contain Tabs? Should we filter them out?

@ATaco No, the input will not contain tabs

I think this question is close enough to this to be a dupe

Welcome to PPCG.  Since you're asking for feedback - 1) This is a very simple challenge that (as you can see from all the quick, short answers) is trivial to answer in many languages.  2) Consider posting challenges to the sandbox first to get more constructive feedback before the challenge officially opens.

Jelly, 3 bytes
ḟ⁶K

ḟilter out spaces (⁶) then join by space (K).
Try it online!

Or ḲFK for the same byte count.

Python, 36 bytes
lambda s:" ".join(s.replace(" ",""))

Ninja'd me by a byte, I used lambda s:" ".join(''.join(s.split())) :P

31: print(*input().replace(' ',''))

Retina, 8

.
$0

Whitespace is significant - there are single spaces at the end of the first and last lines.
Try it online.

Pyth, 4 bytes
jdsc

Splitting on whitespace and then joining seems shorter than removing the spaces.
In pseudocode:
'     ' d,Q = " ",input()  # preinitialized variables
'jd   ' d.join(
'  s  '     sum(
'   cQ'         Q.split() ))

Try it online!

Haskell, 22 bytes
(((:" ")=<<)=<<).words

Laikoni saved 2 bytes with a nice use of words. Previous answer:
(=<<)(:" ").filter(>' ')

Try it online

(((:" ")=<<)=<<).words is two bytes shorter.

V, 7 bytes
Íó*/
X

Try it online!
Just a straightforward regex, and an "X" to delete one leading space.

tcl, 28
puts [split [join $s ""] ""]

testable on http://rextester.com/VFP77495