text:
Interpret +p code
Inspired by the recent craze over another two character language, ;#
Intro
According to community consensus, acceptable answers on this site must use programming languages that, at minimum:

Can determine if a natural number is prime
Can add two natural numbers together
Can represent a list/tuple of numbers, as well as a single number

For purposes of this challenge, we will ignore #3. Therefore, the simplest language that could be used on this site (ignoring #3) would have exactly two commands, isPrime and add. For ease of interpretation and byte count, let's assign isPrime to p and add to +. Thus, we have our language, +p. Your challenge is to interpret some +p code.
Behavior

+ the add instruction takes two numbers, adds them, and outputs the result
p the isPrime instruction takes a single number, and outputs 1 if it is prime, and 0 if it is not

Rules

You must write a program/function which, given a string of characters, interprets that string as +p code. You may assume well-formed input (only + and p characters).
Input is flexible. You may take in the program as a string, character array, integer array of codepoints, etc. Input for the program being interpreted is also flexible. You may take in an integer array, and use up entries as the program executes, or each instruction (+ and p) may individually request input. You may assume there will be enough input for every instruction. Input is guaranteed to consist of numbers between 0 and 200 (but your algorithms should theoretically work for any positive integer input).
Output is also flexible. You may print the results, return them as a list, return a string that contains all the results, etc. If printed or returned as a string, output must be separated by some non-digit, consistent separator, such as a new line, tab, space, or , character. You may have a trailing separator or some trailing whitespace. Also, p's output may be any truthy or falsey value, as defined by the language you are working in, rather than 1 or 0.
The interpreter may or may not terminate (if it is a full program), but it must stop printing after all instructions are interpreted. (It cannot continue printing the separator forever, or a null character, etc.).
These standard loopholes are forbidden by default
This is code-golf, the answer with the least bytes wins

Test Cases
Program: +
Input: [56, 50]
Output: 106
----------------------------------
Program: p
Input: [12]
Output: 0
----------------------------------
Program: p
Input: [13]
Output: 1
----------------------------------
Program: ++
Input: [172, 120, 33, 58]
Output: 292 91
----------------------------------
Program: p
Input: [29]
Output: 1
----------------------------------
Program: pp
Input: [176, 12]
Output: 0 0
----------------------------------
Program: ++++p
Input: [32, 16, 69, 197, 73, 171, 21, 178, 72]
Output: 48 266 244 199 0
----------------------------------
Program: pp+++p+pp+
Input: [151, 27, 119, 189, 198, 107, 174, 15, 166, 106, 134, 108, 169, 55, 42]
Output: 1 0 308 305 189 0 240 0 0 97
----------------------------------
Program: p+p+++++++pp+p
Input: [143, 67, 30, 149, 178, 52, 112, 122, 55, 122, 142, 199, 20, 175, 138, 80, 116, 180, 50, 116, 15, 92, 74]
Output: 0 97 1 230 234 177 341 195 218 296 0 0 107 0
----------------------------------
Program: ++p++p+pp+++++p+p+pp++
Input: [120, 177, 23, 116, 163, 52, 65, 98, 177, 16, 96, 131, 160, 48, 153, 0, 139, 33, 62, 49, 129, 86, 99, 135, 187, 80, 137, 130, 113, 136, 0, 1, 186, 100, 38, 153]
Output: 297 139 1 117 275 0 227 0 0 153 172 111 215 234 0 217 0 249 0 0 286 191
----------------------------------
Program: ++p+++++p+p+++++++
Input: [181, 169, 6, 84, 68, 171, 129, 107, 106, 114, 197, 58, 11, 88, 156, 169, 43, 77, 49, 43, 102, 78, 93, 51, 91, 37, 64, 93, 82, 126, 181, 81, 44]
Output: 350 90 0 300 213 311 69 244 0 120 0 145 171 142 101 175 307 125
----------------------------------
Program: ++p+
Input: [131, 127, 115, 40, 113, 196, 83]
Output: 258 155 1 279
----------------------------------
Program: +ppp++p+ppp+p++++++++p+p+++pp+ppp++
Input: [6, 9, 187, 168, 96, 167, 178, 139, 86, 148, 99, 103, 166, 18, 119, 15, 132, 77, 16, 88, 139, 34, 58, 90, 43, 69, 68, 152, 59, 106, 134, 49, 155, 100, 52, 55, 27, 188, 41, 77, 23, 49, 171, 23, 193, 84, 111, 165, 80, 18, 63, 23, 116, 112, 119]
Output: 15 0 0 0 345 225 0 202 0 0 0 147 0 104 173 148 112 220 165 183 255 0 82 0 118 72 194 1 0 276 0 0 0 139 231
----------------------------------
Program: ++++++++p++++++++++++
Input: [156, 5, 34, 25, 117, 98, 139, 131, 88, 82, 191, 13, 1, 170, 51, 116, 144, 85, 92, 170, 25, 94, 149, 131, 19, 161, 115, 160, 8, 6, 195, 101, 11, 185, 87, 50, 33, 140, 188, 135, 164]
Output: 161 59 215 270 170 204 171 167 0 177 195 243 150 276 168 201 112 272 83 328 299
----------------------------------

Many, many, very long test cases
The java code used to generate test cases
Example
Below is an ungolfed java function which will interpret +p:
public static void interpret(String program, int[] input) {
    int index = 0;
    for (char inst : program.toCharArray()) {
        switch (inst) {
            case '+':
                System.out.print((input[index++] + input[index++]) + " ");
                break;
            case 'p':
                int n = input[index++];
                System.out.print((isPrime(n) ? 1 : 0) + " ");
                break;
        }
    }
}

public static boolean isPrime(long n) { //Taken from https://stackoverflow.com/a/2385999/4484294
    if (n < 2) return false;
    if (n == 2 || n == 3) return true;
    if (n % 2 == 0 || n % 3 == 0) return false;
    long sqrtN = (long) Math.sqrt(n) + 1;
    for (long i = 6L; i <= sqrtN; i += 6) {
        if (n % (i - 1) == 0 || n % (i + 1) == 0) return false;
    }
    return true;
}

Note: Using the search query prime AND add AND interpret is:question, there do not appear to be any duplicates to this question. If there is one, sorry.

In your outputs the ps' results are concatenated without separator, is this intended?

Can we use a heuristic prime test? i.e. isprime in julia.

Interestingly enough, I made an exact opposite to the challenge

@GáborFekete They are? They look fine to me...

@Riker If what you mean is prime tests that are unproven, then no. If not, please clarify.

pp, [11, 7] should output 1 1 or 11? Your example program's line System.out.print(isPrime(n) ? 1 : 0 + " "); only adds a space when the value is 0, when it's 1 it just concatenates.

@GáborFekete unintentional; I had parenthesis before, but now I edited it and I guess they got lost in the process, I'll fix that

@SocraticPhoenix apologies, not heuristic, probabilistic. i.e. there's a 99.99% chance it's a prime but it's possible it's not. see here.

@Riker I'm going to say no to that as well. You could still post your answer and mark it as noncompeting if you want.

@SocraticPhoenix You can't post non-competing answers because they break the rules of the challenge.

Could there be more input numbers than instructions to handle them?  eg. program 'p', input [1, 2, 3].

@Sean No. If you're taking in a list/array as input, you can expect that it will be exactly the correct length. (2 for every +, 1 for every p).

05AB1E, 5 bytes
vy.V,

Try it online!
Explanation
This challenge fit 05AB1E like a glove :)
vy      # for each instruction in the program
  .V    # execute as 05AB1E code
    ,   # print

Definitely the right tool for the job.

This looks cheaty... I mean really.

@Christopher: Luckily + and p means add and isPrime in 05AB1E :)

@Emigna I've never used 05AB1E, so I had no idea! Clever answer :)

@Emigna Wait were you Enigma?

S',ý.V was thinking you could do it non-iteratively, longer though.

@Christopher: Nope. Always Been Emigna.

Well, we have a winner.

Python 2, 135 133 bytes
l,p=input()
i=j=0
while len(l)-i:print(int(all(l[i]%k for k in range(2,l[i])))if p[j]=='p'else l[i]+l[i+1]);i+=1+'p+'.find(p[j]);j+=1

-2 bytes thanks to kundor

i,j=0,0 is redundant, right? Couldn't it be i,j=0 ?

@Phoenix: No, that won't work. You can do i=j=0 though.

Python 2, 91 bytes
p,i=input()
for c in p:n=i.pop(0);print all(n%k for k in range(2,n))if c>'+'else n+i.pop(0)

Try it online!

Haskell, 88 79 bytes
('+':r)!(a:b:c)=a+b:r!c
('p':r)!(a:c)=min(foldr((*).mod a)1[2..a-1])1:r!c
_!e=e

"commands" ! [args] for use.

Saved 9 bytes thanks to @Laikoni (#56433)

I'm still learning Haskell; golfing tips appreciated!

This tip to use infix notation for functions can save you some bytes. Also the base case i _[]=[] can be moved to be the last pattern matching rule and then be shortened to i _ e=e, or something like _!e=e after you switched to infix notation.

(min$product ... can be min(product ....

product$map(mod a) can be shortened to foldr((*).mod a)1.

Perl 6, 70 bytes
{@^b.rotor($^a.comb.map(1+(*ne'p'))).map({$_-2??.[0].is-prime!!.sum})}

First the rotor method is used to split the input list into chunks of size 1 or 2 depending on whether the next character of the program is p or not.  Then that chunked list is mapped over; chunks of size 2 are summed, and chunks of size 1 have their sole element tested for primality.

Ruby 2.4, 77+7 = 84 bytes
Uses the -rprime flag.
->g,i{g.chars.map{|c|c==?p?i.shift.prime?? 1:0: c==?+?i.shift(2).sum: p}-[p]}

Jelly, 18 bytes
ÆP,+/ị@L
OḂ‘Bṁ@Ç€K

Try it online!
Alternate solution, 18 bytes
⁴Ḣ
¢+¢µ¢ÆPµḂ?
OÇ€K

Try this one online!

C#, 130 129 bytes
p=>d=>{var i=0;p.Any(c=>{Console.Write((c==43?d[i++]+d[i]:Enumerable.Range(2,d[i]-2).Any(x=>d[i]%x==0)?0:1)+" ");return++i<0;});}

Try it online!

Saved 1 byte by currying the function (thanks to Cyoce)

not sure how C# works, but could you change (p,d)=> to p=>d=> to save a byte and make a curried function?

Right, thanks. (It is debatable how much of the required C# boilerplate should be included in the byte count, but yeah, you can write that. (See the linked TIO.))

PowerShell 3+, 151 121 Bytes
$r,$v=$args;$p={0-notin((2..(($n=0+"$args")-1)|%{$n%$_}))};$i=0;$r|%{if($_-eq"p"){&p $v[$i]}else{$v[$i]+$v[($i+=1)]}$i++}

PowerShell has no prime built-ins so I had to roll my own. My first version was terrible and I took from most of the other ones that test for 0 among modulus results which saves a lot.  Also sabed a few bytes by using -notin instead of -notcontains but it mean PowerShell v2 is out.
Comment based explanation
# $r is the program code. Assumed char array
# $v is the remaining variables in an assumed integer array.
$r,$v=$args
# Anonymous function to determine if a number is a prime or not.
# Test all potential factors. Check if any 0 modulus remainders are present
$p={0-notin((2..(($n=0+"$args")-1)|%{$n%$_}))}
# $i is an index for tracking location in $v
$i=0
# Cycle each of the instructions
$r|%{if($_-eq"p"){
        # Call the prime checking anonymous function on this number
        &p $v[$i]
    }else{
        # Add the next two numbers. Adjust the index accordingly.
        $v[$i]+$v[($i+=1)]

    }
    # Next number in list.
    $i++
}
    # Next number in list.
    $i++
}

F#, 130 bytes
let rec r=function|[],_->()|'+'::t,f::s::u->printf"%i "(f+s);r(t,u)|_::t,n::u->printf"%b "(List.exists((%)n>>(=)0)[2..n-1]);r(t,u)

Try it online!

QBasic, 122 bytes
INPUT p$
FOR i=1TO LEN(p$)
INPUT x
IF"+"=MID$(p$,i,1)THEN INPUT y:?x+y:ELSE f=0:FOR j=2TO x:f=f-(x MOD j=0):NEXT:?f=1
NEXT

Takes the code as a line of input, then takes each input number on its own line. The outputs are interspersed with the inputs because they're printed as soon as they're calculated. The truthy value is -1; falsey is 0.

Japt, 15 bytes
Takes the programme as a character array, outputs true or false for the prime test.
Ëø²?Vv j:Vv +Vv

Try it (Header splits the programme into an array)

Rockstar, 206 197 177 bytes
Outputs 0 for composites and -0.5 for primes
listen to S
cut S
while S
listen to N
if roll S's "+"
listen to I
say N-I/-1
else
let D be N
let P be N-1
while P and D-2
let D be-1
let M be N/D
turn M up
let P be N/D-M

say P

Try it here (Code will need to be pasted in, with the programme as the first line of input and each integer on its own line)


text:
XKCD Password Generator
Introduction
Apparently, this question has been asked here and it unfortunately closed. I thought it was a good idea to try again with it, but done right.
XKCD looks at the how we are  trained to use "hard to remember passwords", thinking it's secure, but instead, would take a computer 3 days to crack. On the flip side, remembering 4-5 words brings Kuan's Password Intropy up, and is easy to remember. Crazy how that works, huh?
Challenge
The job today is to create 5 passwords using words. 4 words per password and a minimum of 4 letters per word, but no maximum. Kuan's Password Intropy will need to be calculated for every password, but a forced minimum will not be set.
What is Kuan's Password Intropy?
Kuan's Password Intropy is a measurement of how unpredictable a password is, according to Kuan. There is a simple calculation: E = log2(R) * L. E being Kuan's Password Intropy, R being range of available characters and L for password length.
Range of available characters is self explanatory. It's the range of characters that a password can have, in this case is Upper and lower case. Since there is 26 characters in the alphabet, 26 x 2 = 52 characters in the whole range of the password.
Password Length is also self explanatory. It's the total length of the password after creation.
Constraints

No input.
A word cannot reappear in the same password.
No symbols or numbers allowed in a password.
4 words per password, but a forced minimum of 4 letters per word.
No spaces between words.
You cannot generate the same password over and over again.
Each word has to be capitalized in a password.
Output has to be human-readable, must be spaced out. Must also include Kuan's Password Intropy of the password with it using Kuan's Password Intropy equation above.
Dictionary. You must use this, download it as a text file and integrate accordingly. This will be the list from which you grab words from. Your code should assume its available.
This is code-golf, shortest bytes win.

Output
TriedScarProgressPopulation 153.9
TryingPastOnesPutting 119.7
YearnGasesDeerGiven 108.3
DoubtFeetSomebodyCreature 142.5
LiquidSureDreamCatch 114.0

Is our code required to load the dictionary or can we assume that it is already available somehow (e.g., via a JavaScript variable)?

Should assume its available, let me add that.

For the test cases, why is the password entropy varying? All 4 word passwords that are generated from the same dictionary should have the same entropy.

Password entropy is dependent on the symbol set. If your password is N symbols from the set S, the password entropy is log2(|S|)*N. Here the size of the symbol set is the size of the dictionary ( |S|=4284 ) and the number of symbols is the number of words ( N=4 ), so the entropy for each password is 48.3.

@NonlinearFruit Whether or not you're right or wrong (I'm assuming you are right, since I got most information from the InfoSec stack exchange), I'm factoring in password length in too, which probably isn't right, but it provides different numbers. Naturally, of course you probably are right, but just generating passwords is too easy, along with the entropy with them with these set standards. The equation is there for variable numbers, not for being correct. And to be fair, I got those entrophies from here.

Keeping the calculation this way is fine, I would clarify how to calculate R and L.

@KuanHulio these results are incorrect per the challenge even with the password dependent definition, since the charset here is only the alphabet (52 chars)

No. Forgot to add that.

@Uriel fixed. hopefully.

Read comments 3 and 4.

"Dictionary. You must use this, download it as a text file and integrate accordingly. This will be the list from which you grab words from. Your code should assume its available." @JonathanAllan

It's available in the fact that its parsed and loaded to use. We don't need input for this challenge, it's just a hassle.

So I may assume it is input if it is shorter in my language?

Let us continue this discussion in chat.

This definition of entropy is dangerously wrong! If each character is chosen uniformly at random from a set of size R, then indeed a length-L password has R^L possibilities, so the entropy is the log of that: log₂(R^L) = log₂(R)*L which is your formula. However, if passwords are chosen at random from a different set (e.g. you'll never have a password like 3t1ta#asd), then the entropy will be the logarithm of the number of possible passwords. If you always choose 4 words uniformly at random from a 4284-word dictionary, then there are 4284^4 passwords, each with entropy log₂(4284)*4 ≈ 48.26.

For the record, this kind of passwords predates the XKCD comic. They're called "diceware" passwords.

Aside from the issue of words having less entropy than random characters, your question requires that the words be capitalised, meaning the case is fixed and cannot be counted for entropy.

Yeah, this is a fake entropy calculation.

@ShreevatsaR how exactly does the attacker know that your are choosing only latin letters or that you are using words to compose your password? I could apply the same password algorithm on Italian words. Or Japanese words.

Please don't call this number “entropy”. Call it “meaningless number” or something. It doesn't change anything as a code golf task, but calling it “entropy” is confusing because that term implies things that are contradictory with the definition.

@Gilles You are right, fixed it

OhNoPastebinIsBroken

Python 2, 102 101 97 91 bytes
from random import*
exec"x=''.join(x.title()for x in sample(f,4));print(x,57*len(x)/10);"*5

Assumes the dictionary as a list named f.
Can be tested by saving the file as dict.txt and calling
f = open('dict.txt').readlines()

Python lists don't have shuffle method, and you can save two bytes in Python 2 by removing parenthesis around exec (exec is a keyword in Python 2).

@xfix Yeah it should be shuffle(f);.

Whoops, fixing that asap

You could use my trick of noting that the rounding at 5.7 is fine to 1 decimal place so long as floating point errors are not introduced and save five bytes with 57*len(x)/10.. Save another byte by removing the parentheses making the print take a tuple. Here is a cut-down version: TIO

Use sample(f,4) instead of shuffle. Also f can just be open('dict.txt').read().split('\n'), open('dict.txt').readlines(), or just open('dict.txt') (I know it's not golfed but still).

PowerShell (3.0+), 77 bytes
1..5|%{($p=-join($d|random -c 4|%{culture|% te*|% tot* $_}));57*$p.Length/10}

Try it online!
Using Jonathan Allan's 57*len/10 trick.
$d contains the dictionary as an array of words. If you're playing at home and want to fill $d:
$d=-split(irm pastebin.com/raw/eMRSQ4u2)

Using a golfed version of (Get-Culture).TextInfo.ToTitleCase() to capitalize the first letter; I don't think there's a shorter way to do that in PowerShell.
The rest is pretty straightforward I think.
The TIO link has the whole dictionary; disable the cache and go nuts!

Can someone point me to a reference for " Jonathan Allan's 57*len/10 trick" ?

@JamesCurran See the breakdown of his answer here, and also his comment on this answer.

This will not work in 2.0 correct. That should be noted in the title. I also think you need to read in $d as supposed to assuming it is present in the environment. (gc d)| random.. where the dictionary is a file called d in the same directory.

Would 5.7*$h.length not be better?.... was reading on the trick and it depends on the precision it seems

@Matt read the topic (and the comment discussion); unlike most challenges, in this one we are assuming the dictionary is loaded (in fact I think it was Jonathan Allan who had to ask permission to load it as input). You're right it likely won't work in 2.0, but I don't bother specifying that in golfing anymore usually; I'll add it anyway. As Jonathan Allan pointed out, there are a few instances where 5.7* will lose precision.

I misunderstood the wording of the dictionary rule. Seems everyone is doing it this way so my bad. The versioning thing seems important in languages like python. I usually use extra bytes to keep it 2.0 centric but for things like this those method shortcuts are a life saver. Also didnt know about the entropy calculations... Just saw something to fix at first.

@Matt on SO I might go out of my way to make an answer work with v2 (or do 2 versions), but this is code golf man! The more arcane the better ;-p

I am just trying to save bytes in my answer titles.

Jelly, 22 bytes
Ẋḣ4ŒtFµL×57÷⁵⁸,K
çÐ€5Y

A monadic link taking a list of list of characters, the parsed dictionary (as allowed in chat).
Try it online! (Click "Arguments" to hide the dictionary and reduce the need to scroll.)
How?
Since the dictionary only contains valid words (4characters or more, only [a-z]), there is no need to check this condition.
Since all the words in the dictionary have lengths in [4-8] the possible password lengths are in [16,32], and the possible entropies will never round differently to one decimal place than by replacing log(52,2) with 5.7. The only problem is that using a floating point value of 5.7 will give floating point rounding errors for lengths 18, 26, and 31. However multiplying by 57 and then dividing by 10 using ×57÷⁵ avoids this (while still being a byte shorter than printing the full floating point precision value using ×52l2¤).
çÐ€5Y - Main link: list of list of characters (the parsed dictionary)
   5  - literal 5
 Ð€   - map across the implicit range [1,2,3,4,5]:
ç     -   last link (1) as a dyad
    Y - join with newlines
      - implicit print

Ẋḣ4ŒtFµL×57÷⁵⁸,K - Link 1, get password and entropy: list of lists of characters, number
Ẋ                - shuffle the list of lists (shuffle all the words)
 ḣ4              - head to 4 (the first four words)
   Œt            - title case (make the first letter of each uppercase)
     F           - flatten into one list of characters
      µ          - monadic chain separation, call that p
       L         - length of p
         57      - 57
        ×        - multiply
            ⁵    - 10
           ÷     - divide -> entropy to 1 decimal place
             ⁸   - link's left argument, p
              ,  - pair -> [p, entropy]
               K - join with (a) space(s)

Ruby, 89 83 bytes
d.select!{|w|w[3]}
5.times{p w=d.sample(4).map(&:capitalize)*'',5.700439718*w.size}

Assumes that the passwords are stored in the variable d. You can add this line before the code:
d=$<.map(&:chomp)

and call the script for instance like this:
$ ruby generate_passwords.rb < dictionary_file.txt

Sample output:
"MarginStarvedOnusInsulted"
142.51099295
"KitchenMiseryLurkJoints"
131.110113514
"InducesNotablePitfallsPrecede"
165.312751822
"FarmersAbortFutileWrapper"
142.51099295
"RoutesBishopGlowFaithful"
136.81055323200002

KitchenMiseryLurkJoints... wow.

-6 bytes from Ajedi32

Might be able to save a few bytes by removing shuffle! and replacing pop with sample.

@Ajedi32 Oh, you're right! I actually thought about it, but I had misread this rule A word cannot reappear in the same password, thinking it meant no reuse of words across all passwords. Thanks :)

Mathematica, 178 bytes
t=1;l=Length;While[t<6,s=RandomChoice[Import["https://pastebin.com/raw/eMRSQ4u2"],4];c=Capitalize/@s;f=Flatten@Characters[c];Print[StringJoin[c]," ",Log[2,l@Union@f]*l@f//N];t++]

Try it online
copy and paste using ctrl-v and press shift+enter to run

Mathematica, 136 bytes
assuming that m is the dictionary the code is
m=ImportString[Import["C:\a.txt"]]

.
t=1;l=Length;While[t<6,s=RandomChoice[m,4];c=Capitalize/@s;f=Flatten@Characters[c];Print[StringJoin[c]," ",Log[2,l@Union@f]*l@f//N];t++]

"The job today is to create 5 passwords using words. " Need 5 instead of one.

ok...5 passwords.. fixed..

Why didn't you made the dictionary available local to shorten the code by avoiding the hyperlink text?

in order to be easy for you to test it...

It's best to provide simple, ungolfed helper code to ease testing than it is to golf your submission less so that it is self-contained. Also, the dictionary is supposed to be variable without hijacking the local DNS server (or modifying the hosts file).

All these are new to me. This is the first time I used "the internet" in mathematica.Thanks for your advice.

The OP has said you code can assume the dictionary is already loaded so you can shorten this a lot.

Ok everybody, fixed!

Bash, 66 65 bytes
for w in `shuf -n4 -`;{((l+=${#w}));printf ${w^};};bc<<<$l*5.7004

Try it online!
Dictionary is recived by STDIN.
Shuffles all words in dictionary and outputs first 4.
For each word, adds up its length in var l, and echoes the word capitalized. In the end calls bc to do the math.
Awk solution, 112 bytes,  four passwords:
shuf -n16 -|xargs -n4|awk '{for(i=1;i<5;i++)printf toupper(substr($i,1,1))substr($i,2);print(length($0)-3)*5.7}'

JavaScript (ES6), 164 bytes
d=>{for(i=5;i--;)console.log(p="....".replace(/./g,_=>(w=d.splice(Math.random()*d.length|0,1)[0])[0].toUpperCase()+w.slice(1)),(Math.log2(52)*p.length).toFixed(1))}

Assumes the dictionary is passed to the function as an array.
Test Snippet

Japt, 30 bytes
5Ç[V=Uö4 ®g u +Zt1Ã¬Mm52 *Vl]¸

Try it online!

Nice! But unfortunately it creates the same password 5 times, and it should be different every time..

This may be 30 characters, but at least in UTF-8, my system clocks it at 35 bytes.

@MichaelKjörling Japt uses ISO 8859-1, not UTF-8.

@Dennis Interesting. Thank you.

(This is an adaptation of Martmists' answer, but I don't have the rep to comment)
Python, 88 86 bytes
g={*f}
exec('x="".join(g.pop().title()for i in "a"*4);print(x,len(x)*5.700439718);'*5)

By exploiting how set is nondeterministic, you can avoid having to import any randomness libraries.

This consistently produces the same output for me. If it does work on some implementation then you could save a few bytes by doing set(f).pop().

I don't think this is really valid. It's not deterministic, so it isn't guaranteed to produce the same password, but in practice it will rarely create different results.

I suspected it might be implementation-dependent. I did it on a freshly-installed Windows release of Anaconda Python 3, and it worked. However set(f).pop() doesn't work, I tried it. It gives the same result each time.

"In practice it will rarely create different results" -- it seems to for me, here's a sample: https://pastebin.com/raw/ZHiHgzxV

@dain I am curious. Please provide information about your Python build.

Python 3.6.0 |Anaconda 4.3.1 (64-bit)| (default, Dec 23 2016, 11:57:41) [MSC v.1900 64 bit (AMD64)] on win32

tcl, 137
Not a winner for sure, but I think it can be a golfed a little more.
time {set p "";time {set p [string totitle [lindex $d [expr int(rand()*[llength $d])]]]$p} 4;puts $p\ [expr 5.7004*[string length $p]]} 5

demo — The line 1 purpose is only to put the dictionary contents into the variable d

You could probably golf it down since the password requires 4 words instead of 5.

And you asked for 5 passwords instead of 4. LOL! I mismatched the numbers!

Hahaha! @sergiol

Fixed! @KuanHulio

That's better. Nice job.

Mathematica, 71 Bytes
Assuming the dictionary is already loaded into an array called d.
Table[{#,Log[2,52]StringLength[#]}&[""<>Capitalize@d~RandomSample~4],5]

Explaination:
                                        Capitalize@d                    - Capitalize all the dictionary
                                                    ~RandomSample~4     - make an array with 4 values. By default values can not repeat.
                                    ""<>                                - Concatenate with empty string to turn array into single string.
      {#,Log[2,52]StringLength[#]}&[                               ]    - Put current string next to log(2,52) times length of current string
Table[                                                              ,5] - Repeat this 5 times.

What about the entropy number?!

Oops missed that bit. Updated.

PHP, 136 129 bytes

-7 bytes, thanks Jörg
for(shuffle($a);$i++<5;){for($s='',$c=0;$c<4;)strlen($w=$a[$k++])<4?:$s.=ucfirst($w).!++$c;echo$s.' '.log(52, 2)*strlen($s)."
";}

Try it online!

ColdFusion 216 bytes
p={};z=arrayLen(c);for(x=0;x<5;x++){pw="";r={};while(structCount(r)<4){n=RandRange(1,z);r.append({"#c[n]#":true});}for(w in structKeyList(r)){pw&=REReplace(w,"\b(\w)","\u\1","All");};p.append({"#pw#":57*len(pw)/10})}

This works in ColdFusion 11+ and Lucee 4.5+
To run it: https://trycf.com/gist/ff14e2b27d66f28ff69ab90365361b12/acf11?theme=monokai
The TryCF link has less-golf-ish but the same code.
I didn't really expect to have a competitive golfing answer; I just wanted to see what it would take to complete this challenge in ColdFusion. Especially since there isn't much CF in these answers. :-) After the setup, it was surprisingly shorter than I expected.
My first attempt was a little shorter until I remembered that the same word can't be used more than once. Even though it's highly unlikely that the randomizer would pick the same index more than once, I dump the indexes into the keys of a structure, which will prevent duplication. Then I use that list of keys to build my final password string. I also used the math trick to find entropy.

Python 3, 252 bytes
This is my first ever code golf challenge I've done! I know there are other Python answers on here (that are probably better than mine) but this looked fun, and so I wanted to try it anyways.
Here's the golfed version:
import random, math
with open("d") as f: d=f.read()
l=d.split()
for a in range(5):
 u=[]
 p=""
 for b in range(4):
  w=random.choice([w for w in l if not w in u and len(w)>=4])
  u.append(w)
  w=w.title()
  p+=w
 print("%s %s"%(p,math.log2(52)*len(p)))

I would post a Try it Online! link, but that doesn't support multiple files. So here's a repl.it link: https://repl.it/InIl/0
Also, here's the ungolfed version:
import random
import math
with open("d") as f:
    dictionary = f.read() #this is the dictionary text file, simply saved as "d" as to use as few bytes as possible
words = dictionary.split() #here we turn that dictionary string into a list
for a in range(5): #here we iterate through 5 passwords
    used_words = []
    password = ""
    for b in range(4): #here we iterate through the 4 words in each password
        word = ""
        word = random.choice([word for word in words if not word in used_words and len(word) >= 4]) #Thanks to blackadder1337 from #python on freenode IRC for helping me with this.
        used_words.append(word)
        word = word.title()
        password = password + word
    print("%s %s"%(password, math.log2(52) * len(password)))

Like I said, this is my first time code gofling, so I'm sure this could be improved a lot.

Welcome to PPCG!

q/kdb+, 76 74 65 56 bytes
Solution:
{(x;5.70044*(#)x)}(,/)@[;0;upper]each -4?" "vs(*)(0:)`:w

Example:
q){(x;5.70044*(#)x)}(,/)@[;0;upper]each -4?" "vs(*)(0:)`:w
"RulingOverheadSaddensPriest"
153.9119

Explanation:
Read in the word list, break apart on " ", pick 4 random words from this list, uppercase first letter of each word, then join together. Feed this into a lambda function which returns the password and the calculated 'entropy':
                                                     `:w / the wordlist is a file called 'w'
                                                 (0:)    / read in the file list (\n separated list)
                                              (*)        / take first (and only) item in the list
                                         " "vs           / split this on " "
                                      -4?                / take 4 random items from this list, neg means 'dont put back'
                      @[; ;     ]                        / apply a function to variable at indices (variable is implicit)
                           upper                         / uppercase (the function being applied)
                         0                               / index 0, the first character
                                 each                    / each of the 4 random items
                  (,/)                                   / 'raze' (flatten lists)
{                }                                       / anonymous lambda function
 (x;            )                                        / a 2-item list, x is first item
            (#)x                                         / count x, return the length of the list
    5.70044*                                             / multiply by 5.70044

Notes:
I caved in and used 5.70044 instead of 2 xlog 52 xexp...

Vim, 87 keystrokes
qq:r!echo "$RANDOM"l<CR>D:w o|e w<CR>@"ev4bd:w|bp<CR>p0~wX~wX~wX~Y:.!wc -c<CR>A*5.7003<Esc>:.!bc<CR>PJq4@q

Assumes that the dictionary is in a file named w. Will always use 4 consecutive words

Explanation:
qq                       Start recording a macro named 'q'
:r!echo "$RANDOM"l<CR>   Append the result of the shell command `echo "$RANDOM"l`
D                        Delete what you just appended
:w o|                    Save the buffer to the file 'o' and ..
e w<CR>                  Open the file 'w'
@"                       Execute the text we deleted as a normal-mode command
                         This will move the cursor a random number of characters
                         to the right
e                        Go to the end of the next word
v4bd                     Delete 4 words backwards
:w|                      Save the file and ..
bp<CR>                   Open the last buffer (the 'o' file)
p                        Paste the 4 words we deleted
0                        Move the cursor to the beginning of the line
~wX~wX~wX~               Remove the spaces between the words and capitalize
Y                        Copy current line
:.!wc -c<CR>             Pipe the current line through 'wc -c'
A*5.7003<Esc>            Append "*5.7003" to the end of the line
:.!bc<CR>                Pipe the current line through 'bc'
P                        Paste the password above the current line
J                        Join with line bellow
q                        Stop recording the 'q' macro
4@q                      Run the 'q' macro 4 times

source: Stack Exchange

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

sort: votes


text:
Validate 2Col syntax!
As a couple of people may have noticed lately, I've largely abandoned development of Braingolf because it's boring and uninspired, and moved on to 2Col which is a little more interesting, and not designed to be a golfing language.
The defining feature of 2Col is that every line of code must be exactly 2 characters long, excluding the newline. This means that the length of a 2Col program can always be calculated as 3n-1 where n is the number of lines in the program.
So here's my challenge: Given 2Col code as a string, output truthy if it is valid 2Col code (Every line is exactly 2 characters and it conforms with the 3n-1 formula), and falsey otherwise.
Input
Input should be taken as a single string, or an array of characters.
Output
A truthy value if the input string is valid layout, and a falsey value otherwise.
Your code should be consistent in which truthy/falsey values it uses
Testcases
======
F!
$^
----
truthy
======

======
*8
+1
Sq
----
truthy
======

======
nop
xt
----
falsey
======

======
+1
+1
#^

----
falsey
======

======
<empty string>
----
falsey
======

======
ye
----
truthy
======

======
no<space>
----
falsey
======

======
test
----
falsey
======

======
puzzle
----
falsey
======

Scoring
This is code-golf so fewest bytes wins!

@Shaggy no, not unless for some reason the language you use considers true falsey and false truthy

@StephenS Will do

@Mayube thanks, sorry, I forgot to add "could you" in front of that xD

I suggest you add a test case: puzzle. This will make solutions that do the whole length of the string modulo 3, then negated (which works for all the current test cases) invalid.

@ComradeSparklePony will do

Do you require the 2 output values to be consistent?

Just curious, is there a way to define new functions in 2Col?

@Qwerp-Derp not yet, I'm planning to add a feature that will allow you to jump to another line, and then another that will allow you to jump back, meaning you could define functions that way

Isn't from functools import reduce; unnecessary? And also... semicolons?

Brachylog (2), 4 bytes
ṇl₂ᵐ

Try it online!
Full program (because this is a decision-problem; Brachylog full programs output false. if there was an assertion failure, true. without one).
Explanation
ṇl₂ᵐ
ṇ     Split input into lines
   ᵐ  For each line:
 l₂     Assert that that line has length 2

Subscripts on l are one of Brachylog's newest features (although still older than the challenge), and this is a good challenge to use them on.

Although ṇlᵛ2 and ṇlᵛ² would also work.

JavaScript (ES6), 24 28 25 24 bytes
Fixed program and shaved of three bytes thanks to @PunPun1000
Shaved off one byte thanks to @Shaggy
s=>/^(..\n)*..$/.test(s)

Returns true if valid and false if not.

f=
s=>/^(..\n)*..$/.test(s)

t=
`22
22
22
22
22`

console.log(f(t));
console.log(f(t.slice(0, -1)));

Just looking at this I don't think it works for two of the test cases (the truthy one with only 2 characters and no new line, and the falsey one with a trailing newline).  However s=>s.match(/^(..\n)*..$/) should correctly match both of those while also being shorter at 25 bytes

@PunPun1000 thank you, you are correct.

Unfortunately this is invalid as the 2 output values aren't consistent. However, you should be able to fix that and save a byte by using test instead of match.

@Shaggy thanks - the reason I didn't see that when I answered because that was just edited in

I know, that's why I pointed it out ;) You might want to update the note on your return values.

Haskell, 23 52 32 bytes
all((==2).length).lines.(++"\n")

I got my inspiration from some other solutions, clever trick adding that "\n".

I've fixed it, but RIP my short solution.

Cubix, 20 bytes
Returns 1 for truthy and nothing for falsey
@1OuABq>;;?w-!$@;U_N

Cubified
    @ 1
    O u
A B q > ; ; ? w
- ! $ @ ; U _ N
    . .
    . .

ABq slurp in all the input, reverse it and push the EOI(-1) to the bottom of the stack
>;; Step into the loop and remove items from the stack
? Test for EOI(-1).

If found 1uO@ push 1 to the stack, u-turn onto integer output and halt
Otherwise _ reflect back onto the ? which redirects to the w lane shift

N-!$@;U push line feed (10) onto the stack, subtract, test result, skip the halt if false, remove the result and u-turn
;;> remove the line feeds from the stack and redirect into the loop.

Try it online!

Python, 51
lambda s:all(len(l)==2for l in(s+"\n").splitlines())

Test case runner:
tcs = {
    "F!\n$^": 1,
    "*8\n+1\nSq": 1,
    "nop\nxt": 0,
    "+1\n+1\n#^\n": 0,
    "": 0,
    "ye": 1,
    "no ": 0,
    "test": 0,
    "puzzle": 0
}
f = lambda s:all(len(l)==2for l in(s+"\n").splitlines())
for tc, expected in tcs.items():
    assert f(tc) == expected

JavaScript (ES6), 35 24 bytes
s=>!/^.?$|.../gm.test(s)

Try it

f=
s=>!/^.?$|.../gm.test(s)
oninput=_=>o.innerText=f(i.value)
o.innerText=f(i.value=`F!
$^`)
<textarea id=i></textarea><pre id=o>

There's gotta be a shorter way to do this with RegEx! Yup (and mine is probably not optimal)

Japt, 7 6 bytes
·eÈÊ¶2

Try it online

Explanation
     :Implicit input of string "U"
·    :Split to array on newline
eÈ   :Maps over the array, checking that every item's ...
Ê    :length ...
¶2   :Equals 2
     :Implicit output of result

Jelly, 6 bytes
ỴL€=2Ṃ

Try it online!
Explanation:
ỴL€=2Ṃ
Ỵ       Split at newlines
 L€     Length of each...
   =2   ...equals two.
     Ṃ  Minimum.

Retina, 10 bytes
^..(¶..)*$

Try it online! Outputs 1 or 0 as appropriate.

Java (OpenJDK 8), 25 bytes
s->s.matches("(..\n)*..")

Try it online!
Checks if the input string has any number of lines followed by a line feed and a final line without one (ensures at least one line)

05AB1E, 6 bytes
¶¡D2ùQ

Try it online!
¶¡D2ùQ   Argument s
¶¡       Split s on newlines
  D      Duplicate
   2ù    Keep only elements of length 2
     Q   Compare

J-uby, 19 18 bytes

:=~&/^(..\n*)..$/m

:=~& makes an anonymous function that takes x and returns 0 if it matches the regex /^(..\n*)..$/m, or nil otherwise.

Bash + GNU utilities, 13
grep -qv ^..$

This sets the shell return value (accessible in $?) to 0 for false and 1 for true.  This is actually the opposite sense compared to normal shell convention, so to make that right you'd need to do:
Bash + GNU utilities, 15
! grep -qv ^..$

Ruby, 22 bytes
->s{s=~/^(..\n*)..$/m}

Jelly, 5 bytes
ỴẈ=2Ȧ

Try it online!
A small improvement over the other jelly answer.
Explanation
ỴẈ=2Ȧ Main Link: takes string on the left
Ỵ     split on newlines
 Ẉ    length(vectorizes)
  =2  equals 2? (vectorizes)
    Ȧ are all elements truthy?

all_licenses: 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/


text:
AlTeRnAtE tHe CaSe
For today's challenge, you must write a program or function that alternates the case of a string. However, you must ignore non-alphabetic characters. This means that every alphabetic character must have a different case than the preceding and following alphabetic character. This is slightly more complex than uppercasing every other letter for example. If you take a string such as
hello world

and convert every other character to uppercase, you'll get:
hElLo wOrLd

As you can see, the lowercase o is followed by a lowercase w. This is invalid. Instead, you must ignore the space, giving us this result:
hElLo WoRlD

All non-alphabetic characters must be left the same. The output can start with upper or lowercase, as long as it consistently alternates. This means the following would also be an acceptable output:
HeLlO wOrLd

Your program should work regardless of the case of the input.
The input string will only ever contain printable ASCII, so you don't have to worry about unprintable characters, newlines or unicode. Your submission can be either a full program or a function, and you may take the input and output in any reasonable format. For example, function arguments/return value, STDIN/STDOUT, reading/writing a file, etc.
Examples:
ASCII                                   ->  AsCiI
42                                      ->  42
#include <iostream>                     ->  #InClUdE <iOsTrEaM>
LEAVE_my_symbols#!#&^%_ALONE!!!         ->  lEaVe_My_SyMbOlS#!#&^%_aLoNe!!!
PPCG Rocks!!! For realz.                ->  PpCg RoCkS!!! fOr ReAlZ.
This example will start with lowercase  ->  tHiS eXaMpLe WiLl StArT wItH lOwErCaSe
This example will start with uppercase  ->  ThIs ExAmPlE wIlL sTaRt WiTh UpPeRcAsE
A1B2                                    ->  A1b2

Since this is code-golf, standard loopholes apply and the shortest answer in bytes wins!

Ugh, I've only just realised this was that meme xD

@BetaDecay Hahaha, that was not my intention. More just unfortunate timing. I though of it as a chat-mini-challenge, and I like the idea behind it because it's subtly harder than it seems.

The next challenge is to print an ascii spongebob à la cowsay

Darn it! I just wrote a CJam script for this (as in yesterday) and deleted it.

There is some missed potential for the title or at least the examples using either penguin of doom or sporks.

Random test cases: https://tio.run/##RY9BSwMxEIXPya8Ie0qwZEERpNKTLnqQFWzBQykSs1M3kk3CJEvtr1@Tbqs5zTzy3vcmHFPv3c00rZt207QPzZqt2O09e2nap81znu9ofmYIHhND5To/XDaTAJP3NlL6/vr2WIw@gONVPUasY68Q6s7oVB88drESEkF1XMgYrEnWOIhc0L1H9sGMK9lfwGesWFKCEEebcmZVUeLG4RMwL39MqY/aAp9d10JQontvNMTiYJX89sbxua@Magj576nk4nxZcRS2zjUL/uzOYGL2J1WaqGzoFRdLltVLoasV28aE0voD4IKVcQwBcLd18JP43FTseInIDAI2wpL9m4tOSUDjEp9VQek0/QI

JavaScript (ES6), 66 63 bytes
Starts with uppercase.
s=>s.replace(/[a-z]/gi,c=>c[`to${(s=!s)?'Low':'Upp'}erCase`]())

Test cases

let f =

s=>s.replace(/[a-z]/gi,c=>c[`to${(s=!s)?'Low':'Upp'}erCase`]())

console.log(f("ASCII"))
console.log(f("42"))
console.log(f("#include <iostream>"))
console.log(f("LEAVE_my_symbols#!#&^%_ALONE!!!"))
console.log(f("PPCG Rocks!!! For realz."))
console.log(f("This example will start with lowercase"))
console.log(f("This example will start with uppercase"))
console.log(f("A1B2"))

Exactly how I was going to do it. I think I can see where you can save a couple of bytes but I'm on my phone so can't test properly.

Yup, using a ternary is what I was going to suggest.

How does the s=!s trick work?

That's a nice little trick :)

@KritixiLithos Because s is the input string, !s first evaluates to false (unless the input string is empty, in which case it would evaluate to true -- but an empty string will not generate any match anyway). After that, it just becomes a standard boolean operation, alternating between false and true. Also, we don't mind losing the content of s at this point because it was already used to feed .replace().

-1 byte if you use [A-z], and remove the i flag

@MayorMonty Unfortunately, that would match a few symbols. An input such as "A[I" would fail.

So basically, it replaces every alphabetical character by looping through and getting the variable at index of a string, where the string is determined by alternating a boolean to get the lowercase or uppercase function names, then once it has the function then it calls it.

05AB1E, 11 8 bytes
Code:
lvyJ¤aiš

Uses the 05AB1E encoding. Try it online!
Explanation:
l           # Lowercase the input
 vy         # For each element..
   J        #   Join the entire stack into a single string
    ¤a      #   Check if the last character is alphabetic
      iš    #   If true, swapcase the entire string

I love how I try going in blind, knowing I have to beat 11-bytes; then slowly go from 17 to 11 bytes and realize lvy¾Fš}Da½J is exactly what you already had ._.

@carusocomputing There is a much easier 8 byte solution :p

oh, yeah, super easy haha.

How do we pronounce this language? Sable, perhaps?

@Octopus There is some discussion about this, but I use both 'osable' and 'osabie'.

@Octopus the github page says that its Base, from the github page: 'If the name 05AB1E was interpreted as a hexadecimal number and converted to base64, it would result into "Base" '

@Marnix, that explains its origin, not it's pronunciation.

@octopus I literally say Oh-Five-Ay-Bee-One-Eee, I am not a creative man.

@MagicOctopusUrn I do the same, although it's Zero-Five, not Oh-Five. ;p

GNU Sed, 33

5 bytes saved thanks to @TobySpeight

Score includes +1 for -r flag to sed.
s/([a-z])([^a-z]*.?)/\U\1\L\2/gi

Try it online.

Jelly, 13 bytes
nŒsTm2
ŒlŒuÇ¦

Try it online!
How it works
ŒlŒsÇ¦  Main link. Argument: s (string)

Œl      Cast to lowercase.
    Ç¦  At indices returned by the helper link...
  Œu        apply uppercase.

nŒsTm2      Helper link. Argument: s (string)

 Œs         Apply swapcase to s.
n           Perform vectorizing not-equal comparison.
   T        Compute the truthy indices.
    m2      Select every other one, starting with the first.

Python 3, 86 76 68 66 63 bytes
-2 bytes thanks to DJMcMayhem
-3 bytes thanks to Cyoce

x=0
for i in input():print(end=(2*i).title()[x]);x^=i.isalpha()

Try it online! or Try all test cases

Two bytes shorter in python 3: Try it online!

any reason you can't do print(end=(2*i).title()[x])?

Japt, 16 14 bytes
r"%l"_m"uv"gT°

Try it online!
Explanation
r              // RegEx replace input
 "%l"          // [A-Za-z] as first arg to replace
     _         // created function Z=>Z as second arg to replace
       "uv"gT° // alternates "u" & "v"
      m        // map Z to either "u" upper or "v" lower

Very nice! You can remove the ,. Unless it's a number (i.e. [12]), Japt knows they're different items. I believe you can remove the &1 as well.

Thanks @obarakon. The Japt documentation is a little sparse.

Thanks for using Japt. Feel free to ask questions, suggestions, etc. in the Japt chat room. There's also a Tips for Japt thread. :)

_m"uv"gT° Nice. I was just about to suggest that.

@obarakon Yeah I saw where ETH responded to your question in the chat and it got me trying things out.

You can save 2 bytes using Japt v2

C (tcc), 60 57 56 bytes
Thanks to DigitalTrauma for noticing bit 5 is the only difference for ASCII upper/lower case.
Special thanks to zch for golfing off three more bytes.
Save one more byte from RJHunter's idea
l;f(char*s){for(;*s=isalpha(*s)?*s&95|++l%2<<5:*s;s++);}

Try it online!

I golfed it a bit more, and modified so it works on all of gcc, tcc, clang.  FWIW, gcc puts string literals in read-only memory, so I used strdup() to get pointers to read-write memory in the test-driver code.

@DigitalTrauma thanks for that.  I should have recognized bit 5 was the difference between upper and lower.  Nice !

I tried to make this version recursive too, but couldn't get it any shorter.

You can replace inner conditional with *s&~32|++l%2<<5 to save 3 bytes.

Since the input promises to be printable ASCII, you can replace &~33 with &95 to save a further byte.

Ruby, 57 55 47 41 bytes
Byte count includes two bytes for command line options.
Run it for example like this: $ ruby -p0 alternate_case.rb <<< "some input"
gsub(/\p{L}/){($&.ord&95|32*$.^=1).chr}

With the p0 option, the entire input is consumed in one go, and the magical global $. is incremented to 1. This is later toggled between 0 and 1 and used for keeping the state.
Works with multiline input;
Try it online!
Thanks to Ventero for amazing input -- check the comments for details.

Man, if it weren't for the fact that $. auto-increments with each gets call, a full program with the -p flag would've been shorter...

@ValueInk Hah didn't even think of using the -p switch, but yeah, that one's hard to get around if had to make it work for multiline inputs (which I think you should in this case). You could add the line $.+=1 on top to make it work, but then you're up to 56 bytes excluding the -p flag. And BEFORE{i=0} is way too long. Why isn't there another global integer? :D

Yeah, the problem is that you definitely need to work with multiple inputs with that solution in order to save space. Thankfully the -p flag usually counts as 1 byte by consensus, because ruby -pe 'your code' has an edit distance of 1 from ruby -e 'your code' so it is a tie with your solution at best.

1&$.+=1 allows you to drop the parentheses. And for completeness' sake, there is another global integer - it's unfortunately just read-only: $$.

Another thing about the command line flag: -p0 makes the interpreter read all available input in one go - so your code is only invoked once, allowing you to freely use $.. Combining that with the fact that gsub implicitly operates as $_.gsub! when specifying -p makes a full program significantly shorter: 48 characters for gsub(/[a-z]/i){[$&.upcase,$&.downcase][1&$.+=1]} and 2 for the p0 flag.

Final remark, I promise :) Once you're using -p0, you can actually save a few more characters in how you flip $. back and forth: Since it's now guaranteed to be 1 when your code is invoked, you can simply use $.^=1.

Turns out I lied, I have another comment :D As the input is guaranteed to only ever contain printable ASCII, we can use Ruby's support for Unicode categories in regular expressions: /\p{L}/ (Unicode category Letter) is one character shorter than /[a-z|/i.

@Ventero Hey, I got another Idea. Doesn't quite work yet -- Work in progress (really got to go to bed now): gsub(/\p{L}/){($&.ord&~(32*($.^=1))).chr} .. Too tired to see where the error is

instead of the BEFORE{i=0} thing you mentioned in a previous comment, you could do i||=0

@daniero I'm sure you'll spot it when you're fresher, but the AND-NOT technique only works to unset the lowercase bit (upcase); you'd need OR to set the lowercase bit on an uppercase letter (so it can cover downcase). Switching between Boolean operators could be done cleverly but probably no shorter than switching between string methods.

@daniero: You first need to clear out bit 5 before toggling it with 32*$. to alternate between upper and lower case. After fiddling a bit with operator precedence, I think the shortest you can get with that approach is 42: gsub(/\p{L}/){($&.ord&~32|32*$.^=1).chr}. Unfortunately, Integer only has a [] method without corresponding []=, otherwise you could just set the bit directly ...

@Ventero Since the challenge limits input to ASCII, &95 should be safely equivalent to &~32 to clear the lowercase bit.

Alice, 18 bytes
/olZlYuN
@iy.u..//

Try it online!
Explanation
This program follows a lesser-known template for odd-length programs that run entirely in ordinal mode.  The linearized version of this code is:
il.l.uN.YuZyo@

Explanation of code:
i - push input onto stack            ["Hello world!"]
l - convert to lowercase             ["hello world!"]
. - duplicate                        ["hello world!", "hello world!"]
l - convert to lowercase (should be no-op, but avoids what seems to be a bug in the TIO implementation)
. - duplicate again                  ["hello world!", "hello world!", "hello world!"]
u - convert to uppercase             ["hello world!", "hello world!", "HELLO WORLD!"]
N - difference between sets          ["hello world!", "helloworld"]
. - duplicate reduced string         ["hello world!", "helloworld", "helloworld"]
Y - unzip (extract even positions)   ["hello world!", "helloworld", "hlool", "elwrd"]
u - convert to uppercase             ["hello world!", "helloworld", "hlool", "ELWRD"]
Z - zip evens back into string       ["hello world!", "helloworld", "hElLoWoRlD"]
y - perform substitution             ["hElLo WoRlD!"]
o - output                           []
@ - terminate

Without using l on the duplicate, the stack after N would be ["helloworld", "helloworld"].  I strongly suspect this is a bug.

MATL, 16 15 bytes
Xktkyy-f2L))5M(

Try it online! Or verify all test cases.
Explanation
Consider input 'hello world'
Xk    % To upper case
      % STACK: 'HELLO WORLD'
t     % Duplicate top element
      % STACK: 'HELLO WORLD', 'HELLO WORLD'
k     % To lower case
      % STACK: 'HELLO WORLD', 'hello word'
yy    % Duplicate top two elements
      % STACK: 'HELLO WORLD', 'hello word', 'HELLO WORLD', 'hello word'
-     % Difference (of code points; element-wise)
      % STACK: 'HELLO WORLD', 'hello word', [-32 -32 -32 -32 -32 0 -32 -32 -32 -32 -32]
f     % Indices of nonzeros
      % STACK: 'HELLO WORLD', 'hello word', [1 2 3 4 5 7 8 9 10 11]
2L)   % Keep only even-indexed values (*)
      % STACK: 'HELLO WORLD', 'hello word', [2 4 7 9 11]
)     % Reference indexing (get values at indices)
      % STACK: 'HELLO WORLD', 'elwrd'
5M    % Push (*) again
      % STACK: 'HELLO WORLD', 'elwrd', [2 4 7 9 11]
(     % Assignment indexing (write values at indices). Implicit display
      % STACK: 'HeLlO wOrLd

'

Java 8, 99 bytes
a->{String r="";int i=0;for(int c:a)r+=(char)(c>64&c<91|c>96&c<123?i++%2<1?c|32:c&~32:c);return r;}

Explanation:
Try it here.
a->{                          // Lambda with char-array parameter and String return-type
  String r="";                //  Result-String
  int i=0;                    //  Flag for alteration
  for(int c:a)                //  Loop over the characters of the input
    r+=(char)                 //   And append the result-String with the following (converted to char):
      (c>64&c<91|c>96&c<123?  //    If it's a letter:
       i++%2<1?               //     And the flag states it should be lowercase:
        (c|32)                //      Convert it to lowercase
       :                      //     Else (should be uppercase):
        (c&~32)               //      Convert it to uppercase
      :                       //    Else:
       c);                    //     Simply append the non-letter character as is
                              //  End of loop (implicit / single-line body)
  return r;                   //  Return result-String
}                             // End of method

I couldn't get it shorter but you might be able to use (c+"").matches("[A-Za-z]") or Character.isLetter(c) to save bytes.

@TheLethalCoder Both are longer than c>64&c<91|c>96&c<123 though. And since the I use int anyway for the Character.toUpperCase(...) and Character.toLowerCase(...) golfed parts (these: (char)(c&~32) and (char)(c|32)), I doubt I could make it shorter with either of those.

I thought you wouldn't be able to but worth posting to see if you could make use of them anyway

@TheLethalCoder Ah ok. :) In some cases the first might help with a slightly different approach for other challenges, but for this challenge it's shorter as is. Thanks anyway.

a->{String r="";int i=0,f=32;for(int c:a)r+=(char)(c>64&c<91|c>96&c<123?(f=~f):c);return r;} ??

@RomanGräf Umm.. but where does it use c in the (f=~f) part? Currently it doesn't really work..

Brachylog, 25 bytes
{ḷ|ụ}ᵐ.{ḷ∈Ạ&}ˢ¬{s₂{∈Ạ}ᵐ}∧

Try it online!
This is both long and slow.
Explanation
{   }ᵐ.                       The Output is the result of mapping on each char of the Input:
 ḷ                              Lowecase the char
  |                             Or
   ụ                            Uppercase the char
       {    }ˢ                In the Ouput, select the chars that:
        ḷ∈Ạ&                    when lowercased are in "abc...xyz" (ie are letters)
              ¬{       }∧     In that new string, it is impossible to find:
                s₂              a substring of 2 consecutive chars
                  {∈Ạ}ᵐ         where both of them are in the lowercase alphabet

Pyth, 11 bytes
srR~xZ}dGrZ

Try it here
Explanation
              # Z = 0; Q = eval(input())
srR~xZ}dGrZQ  # Auto-fill variables
         rZQ  # lowercase the input
 rR           # Apply the r function to each letter of the input with
   ~xZ}dG     # ... this as the other argument
   ~          # use the old value of the variable Z, then update it with the value of ...
    xZ        # Z xor ...
      }dG     # the variable d is a lowercase letter
              # because of how mapping works in pyth, d will contain the current letter
              # This causes Z to flip between 0 and 1, alternately upper and lower casing
              # the current character if it is a letter

Perl 6,  32  30 bytes
{S:g/<:L><-:L>*<:L>?/$/.tclc()/}

Try it
{S:g{<:L><-:L>*<:L>?}=$/.tclc}

Try it
Expanded:
{  # bare block lambda with implicit parameter ｢$_｣

  S            # string replace (not in-place) implicitly against ｢$_｣

  :global

  {

    <+ :L >    # a letter
    <- :L >*   # any number of non-letters
    <+ :L >?   # an optional letter

  }

  =

  $/.tclc()    # uppercase the first letter, lowercase everything else
}

Pity you can't use .= in substitution regexes, otherwise you could do .=tclc

q/kdb+, 51 42 38 bytes
Solution:
{@[x;;upper]1#'2 cut(&)x in .Q.a}lower

Example:
q){@[x;;upper]1#'2 cut(&)x in .Q.a}lower"hello world"
"HeLlO wOrLd"

Notes:
.Q.a        // abcde...xyz lowercase alphabet
(&) x in    // where, returns indices for where x (hello world) is an alpha
2 cut       // splits list into 2-item lists
1#'         // takes first item of each 2-item list; ie the indices to uppercase
@[x;;upper] // apply (@) upper to x at these indices

Google Sheets, 264 bytes
=ArrayFormula(JOIN("",IF(REGEXMATCH(MID(A1,ROW(OFFSET(A1,0,0,LEN(A1))),1),"[A-Za-z]"),CHAR(CODE(UPPER(MID(A1,ROW(OFFSET(A1,0,0,LEN(A1))),1)))+MOD(LEN(REGEXREPLACE(LEFT(A1,ROW(OFFSET(A1,0,0,LEN(A1)))),"[^A-Za-z]","")),2)*32),MID(A1,ROW(OFFSET(A1,0,0,LEN(A1))),1))))

It's a big mess but it's a little easier if you expand it out:
=ArrayFormula(
  JOIN(
    "",
    IF(REGEXMATCH(MID(A1,ROW(OFFSET(A1,0,0,LEN(A1))),1),"[A-Za-z]"),
      CHAR(
        CODE(UPPER(MID(A1,ROW(OFFSET(A1,0,0,LEN(A1))),1)))
        +
        MOD(LEN(REGEXREPLACE(LEFT(A1,ROW(OFFSET(A1,0,0,LEN(A1)))),"[^A-Za-z]","")),2)*32
      ),
      MID(A1,ROW(OFFSET(A1,0,0,LEN(A1))),1)
    )
  )
)

The pseudo-logic would run like this:
For each character {                                    // ArrayFormula()
  If (character is a letter) {                          // REGEXMATCH(MID())
    Return CHAR(                                        // CHAR()
      CODE(UPPER(letter))                               // CODE(UPPER(MID()))
      +
      If (nth letter found and n is odd) {32} else {0}  // MOD(LEN(REGEXREPLACE(LEFT())))
    )
  } else {
    Return character                                    // MID()
  }
}

V, 17, 13 bytes
VUÍáƒ¨áü$©/ì&

Try it online!
Or Verify all test cases!
HeXdUmP:
00000000: 5655 cde1 83a8 e1fc 24a9 2fec 26         VU......$./.&

Explanation:
This uses a compressed regex™, so before explaining it, let's expand the regex out:
:%s/\v\a.{-}(\a|$)/\l&

The VU converts everything to uppercase. Then we run this:
:%                      " On every line:
  s/\v                  "   Substitute:
      \a                "     A letter
        .{-}            "     Followed by as few characters as possible
            (\a|$)      "     Followed by either another letter or an EOL
                  /     "   With:
                   \l   "     The next character is lowercased
                     &  "     The whole text we matched

Old/more interesting answer:
:se nows
Vuò~h2/á

CJam, 26 24 bytes
qeu{_'[,65>&,T^:T{el}&}%

Try it online!
Explanation
q         e# Read all input.
eu        e# Uppercase it.
{         e# For each character:
 _        e#  Duplicate it.
 '[,65>&  e#  Set intersection with the uppercase alphabet.
 ,        e#  Length (either 0 or 1 in this case).
 T^:T     e#  XOR with T (T is initially 0), then store the result back in T.
 {el}&    e#  If The result of the XOR is true, lowercase the character.
}%        e# (end for)

PHP, 71 Bytes
for(;a&$c=$argn[$i++];)echo ctype_alpha($c)?(ul[$k++&1].cfirst)($c):$c;

Try it online!

C 64 bytes
B;R(char *s){for(;*s=isalpha(*s)?(B=!B)?*s|=32:*s&=~32:*s;s++);}

Takes advantage of ascii encoding where upper and lower case letters are offset by 0x20.

You don't need the ' ' space between char and *s

This looks very similar to @cleblanc's answer.

I posted it when  @cleblanc's post used toUpper() and toLower().

My comment suggesting this approach was at 18:29:34Z.  cleblanc's edit to incorporate this was at 18:37:36Z.  Your answer was posted at 18:38:21Z.  So I guess cleblanc's answer was less than a minute before your post.  Your answer is remarkably similar to my suggestion, but I guess that's the nature of code-golf - often solutions in the same language will converge to the same thing - so I'll let it slide :)

Retina, 32 bytes
T`l`L
01T`L`l`[A-Z][^A-Z]*[A-Z]?

Try it online!
First converts the input to uppercase, and then groups the input into matches containing up to two capital letters. The only time it will contain only one letter is if the last letter doesn't have a pair. Then it lowercases the first letter of each of these matches.
The 01 in the second stage translates roughly to: do not change the behaviour of this stage based on the match number, but only apply the changes to the first character of each match.

PowerShell, 86 bytes
-join($args[0]|%{if($_-match"[a-z]"-and($i=!$i)){"$_".toupper()}else{"$_".tolower()}})

Input is a [char[]] array.
Comments in code for explanation
# Join the array of string and char back together.
-join
    # Take the first argument and pass each element ([char]) down the pipe.
    ($args[0]|%{
        # Check if this is a letter. Second condition is a boolean that changes at every pass
        # but only if the current element is a letter. If not the condition never fires
        if($_-match"[a-z]"-and($i=!$i)){
            # Change the character to uppercase
            "$_".toupper()
        }else{
            # Output the character to lowercase.
            # Special characters are not affected by this method
            "$_".tolower()
        }
    })

Haskell, 105 83 + 2 4 + 1 byte of separator = 108 86 88 Bytes
import Data.Char
f#(x:y)|isLetter x=([toUpper,toLower]!!f)x:(1-f)#y|1>0=x:f#y
_#l=l

Function is (1#), starts lowercase. Try it online!
The sad thing is that this is longer than the Java and C# answers Thanks to Ørjan Johansen for saving 22 bytes by merging three lines into one!

I saw it needed those long imported functions so I didn't even try... but that's a bit much, you can merge some lines: f#(x:y)|isLetter x=([toUpper,toLower]!!f)x:(1-f)#y|1>0=x:f#y

Sorry for nitpicking, but I think 1# does not count as an anonymous function. In my understanding, one should be able to bind an anonymous function to an identifier, but e.g. f=1# won't work. Instead you need the section (1#) for +2 bytes. This is also implicitly stated in our community guidelines for golfing in Haskell, though maybe those should be adapted to explicitly mention this case.

@Laikoni ok, answer updated

Perl 5, 24 bytes
23 bytes + 1 byte for -p.
Thanks to @Dada for -2 bytes.
s/\pl/--$|?uc$&:lc$&/eg

Try it online!

Neat. \pl instead of [a-z] to 2 bytes tho :)

@Dada, I genuinely didn't know that! How didn't I know that!! Thank you!

I think I learned it from Ton Hospel, and I use it now and then (actually I tend to forget about it too often and use [a-z] instead!). If you wonder, it comes from perlrecharclass ;)

Perl 5 -p, 17 bytes
s/\pL/<`>|uc$&/ge

Try it online!

What's the magic thing that's happening here to alternate it... I'm not seeing it obviously. I'm sure I've seen this elsewhere (possibly you too!) but I can't guess what's causing it...

@DomHastings <`> is a glob expression - in scalar context it yields a backtick then undef alternating

That makes sense to me, but it's how the substitution tracks that through each replacement that confuses me - since you're only replacing one letter at a time... I guess it's probably me not understanding how the substitution works on a deeper level perhaps?

@DomHastings It's a bit weird but each glob has global state. Maybe see this: Try it online!

That's really useful. Ok thanks for that! I had no idea and I don't know how that's tracked internally, A quick search doesn't yield any Perl monks discussion but super useful to know... Might warrant a tip? Thanks for explaining what you know here though!

Retina, 46 bytes
T`L`l
T`l`L`.(?=([^a-z]*|[a-z][^a-z]*[a-z])*$)

Try it online! Includes test cases.

PHP 5, 54 bytes
<?=preg_filter('/\pL/e','($0|" ")^a^aA[$i^=1]',$argn);

C#, 100 bytes
s=>{var r="";int m=0;foreach(var c in s)r+=char.IsLetter(c)?(char)(++m%2>0?c|32:c&~32):c;return r;};

Python 3, 192 bytes
x=list(input())
s=[]
for i in x[1::2]:
 s.append(i)
 x.remove(i)
s.reverse()
while len(x)<len(s):
 x.append("")
while len(x)>len(s):
 s.append("")
for i in range(len(x)):
 print(end=x[i]+s[i])

Try it online!

Groovy, 79 bytes
{x=0;it.toUpperCase().collect{(it==~/\w/)?x++%2?it:it.toLowerCase():it}.join()}

Japt v2.0a0, 11 10 bytes
r\lÈgYguiv

Try it

Acc!!, 110 bytes
N*8
Count i while _/256 {
_+_/520*(727/_)*2+_/776*(983/_)*4
Write _/8+32*(_%4/3-_%8%5/4)
(_+(_%8+2)/4)%2+N*8
}

Try it online!
Algorithm
Set toLower flag to 0
Read a character
While not EOL:
  Calculate isUpper and isLower flags
  If isUpper && toLower, output (character + 32)
  If isLower && !toLower, output (character - 32)
  Else, output character unchanged
  If isUpper or isLower, toggle toLower
  Reset isUpper and isLower, and read a new character

Accumulator partitioning
We reserve the lowest three bits of the accumulator for storing the flags: toLower in the 1's place, isUpper in the 2's place, and isLower in the 4's place. The rest of the accumulator, at the 8's place and above, stores the input character.
For example, with input of Hello World, after reading the H and calculating flags, the accumulator has a value of 578, or in binary:
1001000 0 1 0
   |    | | \-> toLower (false)
   |    | \---> isUpper (true)
   |    \-----> isLower (false)
   \----------> ASCII code for 'H'

After reading the space, the accumulator is 257:
0100000 0 0 1
   |    | | \-> toLower (true)
   |    | \---> isUpper (false)
   |    \-----> isLower (false)
   \----------> ASCII code for ' '

Code
Line 1
N*8

Stores the first input character and sets all the flags to 0.
Line 2
Count i while _/256 {

Loops while the accumulator value is >= 256 (i.e. the character's ASCII code is at least 32).
Line 3
_+_/520*(727/_)*2+_/776*(983/_)*4

Calculates the isUpper and isLower flags. The main trick here is using integer division for the inequalities. For example, if x is a printable-ASCII code, then 65 <= x is equivalent to x/65 with integer division: values smaller than 65 become 0, values between 65 and 126 become 1, and we don't have to worry about anything larger than 126. We can use this approach for all four inequalities (keeping in mind that the ASCII codes are all multiplied by 8 in the accumulator).
isUpper:
65 <= char <= 90
65*8 <= acc <= 90*8+7
acc/520 == 1 && 727/acc == 1

Expression: _/520*(727/_)

isLower:
97 <= char <= 122
97*8 <= acc <= 122*8+7
acc/776 == 1 && 983/acc == 1

Expression: _/776*(983/_)

This line, then, takes the accumulator and adds isUpper*2 + isLower*4 to it.
Line 4
Write _/8+32*(_%4/3-_%8%5/4)

Outputs the character, swapping case if necessary.
There are two instances in which we need to modify the ASCII value before output:

isUpper is 1, toLower is 1

We need to convert the uppercase letter to lowercase by adding 32
The three flag bits are 011, i.e. acc%4 == 3

isLower is 1, toLower is 0

We need to convert the lowercase letter to uppercase by subtracting 32
The three flag bits are 100, i.e. acc%8 == 4

We can simulate the equality test using mod and int-div. For example, acc%8 == 4 is equivalent to acc%8%5/4:
acc%8      0 1 2 3 4 5 6 7
     %5    0 1 2 3 4 0 1 2
       /4  0 0 0 0 1 0 0 0

This line, therefore, takes 1 if we need to convert upper-to-lower, subtracts 1 if we need to convert lower-to-upper, multiplies that by 32, adds it to the ASCII code, and outputs it.
Line 5
(_+(_%8+2)/4)%2+N*8

Toggle the toLower flag if necessary; inputs and stores a new character.
We need to toggle toLower if the character was a letter, i.e. either isUpper or isLower was set. The possible flag bit values are 010, 011, 100, and 101--i.e. 2 through 5 (note that 6 and 7 are not possible because a letter can't be both upper- and lowercase). This expression gives 1 for those values and 0 otherwise:
 _%8       0 1 2 3 4 5
    +2     2 3 4 5 6 7
(     )/4  0 0 1 1 1 1

Call this value isLetter. Then we want the new value of toLower to be toLower XOR isLetter (if isLetter is true, swap the value of toLower; otherwise, leave it unchanged). We can do XOR by adding the two values mod 2. Finally, we also read another character with N, multiply it by 8, and add it in.

Vyxal r, 8 bytes
ʀTy?⇩⁽⇧V

Try it Online!
The r flag shouldn't be needed, but bugs, bugs, bugs.

MUMPS, 98 bytes
 f i=1:1:$l(s) s c=$e(s,i) s:c?1A u=c?1U,f=$s(f="":u,1:'f),$e(s,i)=$c(2*f-1*-'(f=u)*32+$a(c))
 w s

Try it online!

f i=1:1:$l(s): Set i=1 and loop over this line of code until i reaches the length of the input string s (inclusive). i is incremented by 1 each loop.

s c=$e(s,i): Assign the ith character of s to c using the $extract function.

s:c?1A: Execute the following set statements if c is an alphabetical character (uppercase or lowercase). This line and the next use M's built-in string matching system.

u=c?1U: Make u a boolean storing whether c is an uppercase character. There is only one data type in M so u's value will be 1 for true or 0 for false.

f=$s(f="":u,1:'f): Make f a boolean storing whether c should be an uppercase character. f's value will also be 1 or 0. It's assigned u if this is the first alphabetic character because the first alphabetic character is in the right case by definition. Otherwise its value is flipped from its previous value using the not operator '.

$e(s,i)=$c(2*f-1*-'(f=u)*32+$a(c)): The left-hand side is the ith character of s again; we're setting it equal to the right-hand side which modifies s itself.  $a (for $ascii) and $c (for $char) are inverses: the former converts characters to the corresponding ASCII number and the latter converts numbers back into characters. The argument of $c is a compact way to add 32 to $a(c) if c is lowercase but should be uppercase, subtract 32 from $a(c) if c is uppercase but should be lowercase, and add 0 if c is already in the right case. Note that M's operator precedence is strictly left to right, so 2*f-1*x is unintuitively the same as (2*f-1)*x.

Finally, w s prints the now-alternating s.

Both lines have a leading space so that their first characters are interpreted as commands and not labels.

Convex, 16 bytes
¯{_U&,R^:R{¬}&}%

Try it online!
Convex port of @Business Cat's answer.

Python 3, 95 bytes
Not nearly as golfed as @Rod's, but I'm posting it nevertheless.
lambda s:"".join([s[i],[s[i].lower(),s[i].upper()][i%2]][s[i].isalpha()]for i in range(len(s)))

Try it online!

J, 40 bytes
(2|+/\@:e.&Alpha_j_)`(tolower,:toupper)}

Try it online!
This follows almost directly from the definition of Composite Item (}):
We stack the upper and lowercase version of the input for our two possibilities using (tolower,:toupper).
Next we create a boolean list to indicate whether each character is alphabetic: e.&Alpha_j_ and take the scan sum of that: +/\@: which creates a monotonically increasing list which increases only on alphabetic characters.  Finally we turn that into a boolean list where evens are 0 and odds are 1: 2|.
Putting those parts together means we alternate between the lower and uppercase versions of our input whenever we encounter a new alphabetic character, and only then.

C# (Visual C# Interactive Compiler), 84 bytes
int m,c;for(;(c=Read())>0;)Write((char)(c>64&c<91|c>96&c<123?m++%2>0?c|32:c&~32:c));

Try it online!
Modified version of The Lethal Coder's answer that takes advantage of some of the features of the interactive compiler.

Javascript, 104 bytes
I'm kind of new to this but wanted to submit anyway.
x=>x.split('').forEach((s,i)=>x+=i%2?s.toUpperCase():s.toLowerCase())||x.substring(x.length/2,x.length);
It takes in a string, splits it into an array so it can loop through with forEach and fit in as a one-liner, then goes through each character and index and adds the uppercase or lowercase version of the character depending on if the index is odd or not, then "or"s it with what I want to return (since otherwise it's undefined) and returns the second half of the string, so I don't have to clear the string to begin with or declare a new one.
However, this doesn't work with non-letter characters, so here's my pseudocode for something that would do that:
const sarcasticText = str=> {
    let newStr = '', numSkip = 0;
    for(let i=0; i<str.length; i++) {
        numSkip += str[i].match(/[a-z]/i) ? 0 : 1;
        newStr += (i + numSkip) % 2 ? str[i].toUpperCase() : str[i].toLowerCase();
    }
    return newStr;
};

Basically, I'd implement a counter to check how many characters to offset.

SM83, 29 bytes
Input pointer in hl, output in de, trashes bc, a, flags.
06 55 2A 4F CB AF D6 41
38 0C FE 1A 30 08 CB A9
CB 08 38 02 CB E9 79 12
13 B7 20 E6 C9

Disassembled:
fun:
    ld  b,$55       ;; 06 55    ; set b to alternating bits
loop:
    ld  a,(hl+)     ;; 2A       ; load char
    ld  c,a         ;; 4F       ; and into c
    res 5,a         ;; CB AF    ; turn a-z into A-Z
    sub 65          ;; D6 41    ; subtract 'A'
    jr  c,store     ;; 38 0C    ; if was less, not a letter
    cp  26          ;; FE 1A    ; compare to 26
    jr  nc,store    ;; 30 08    ; if not less, not a letter
    res 5,c         ;; CB A9    ; it is a letter; make uppercase
    rrc b           ;; CB 08    ; rotate b and check low bit
    jr  c,store     ;; 38 02    ; every other time skip next bit
    set 5,c         ;; CB E9    ; actually, make lowercase
store:
    ld  a,c         ;; 79       ; store faster this way
    ld  (de),a      ;; 12       ; store
    inc de          ;; 13       ; and increment
    or  a           ;; B7       ; quick test against 0
    jr nz,loop      ;; 20 E6    ; if not 0 continue
    ret             ;; C9       ; else return

brev, 103 bytes
(define h(make-parameter #f))(over(if(char-alphabetic? x)((if(h(not(h)))char-upcase char-downcase)x)x))

Are the examples wrong? How do you get to InClUdE from AsCiI?


text:
Word Poker, Who Wins?
The input will be two five letter words. They don't actually have to be dictionary words, just any five letters each, all lowercase or all uppercase, your choice. Only A-Z will appear in the input words and they will always be 5 characters in length.
Your program is to score them both as though they were poker hands and output the higher hand. Of course suits won't apply here, only rankings so there's no flushes.
The typical poker ranking system goes: '1 pair', '2 pairs', '3 of a kind', 'straight', 'full house', '4 of a kind', '5 of a kind', and of course there is the possibility the hand (or word in this case) could be worth nothing.
In the case of ties, letters closer to A are considered higher, so a pair of As beats a pair of Bs. In some cases both hands might be identical, but in a different order (or not), in that case output either hand or a resorted version of it.
This external page contains information about how to identify the winner and especially addresses ties within the specific rankings, in case you aren't familiar with how to score poker hands.
In the case of straights: the letters must be adjacent in the alphabet and are not allowed to wrap around. So 'defgh' in any order is a straight, 'xyzab' is not.
Examples of how to score a single hand:
word   | scored as
---------------------
ccccc  | 5 of a kind     <-- highest ranking
woooo  | 4 of a kind
opopo  | full house
vurst  | straight
vovvu  | 3 of a kind
ppoww  | 2 pairs
upper  | 1 pair
kjsdf  | high card only (in this case D) <-- lowest ranking

So the program will actually produce results like this:
input        |  output
-----------------------
voviu,kjsdf  |  voviu     because a pair beats nothing
opoqo,upper  |  opoqo     because 3 of a kind beats a pair
woooo,ggegg  |  ggegg     because 4 Gs beats 4 Os
queue,hopup  |  queue     because 2 pairs beats 1 pair
lodpl,ddkop  |  ddkop     because pair DD beats pair LL
huhyg,hijht  |  huhyg     both have pair HH, but G beats I
ddffh,ccyyz  |  ccyyz     both have 2 pairs, but CC(yyz) beats DD(ffh)
okaok,nkunk  |  nkunk     KK ties with KK, but NN beats OO
abcdf,bcdef  |  bcdef     because it is a straight
qtery,retyq  |  qtery     identical! so doesnt matter
abedc,vyxwz  |  abedc     because it is a "higher" straight
hhhij,hijkl  |  hijkl     because straight beats 3 of a kind
aaabb,zzzzz  |  zzzzz     because nothing beats 5 of a kind

The order of the letters in both the input and output are irrelevant, so the order in your output can be different than the input, but the same inventory of letters needs to be present.
The output must contain exactly five letters -- no more, no less.
The usual codegolf rules apply. Shortest code wins.

JavaScript (224 218 213 bytes)
s=>t=>(v=s=>(o={},l=n=0,z=3.5,[...s].sort().map(c=>(n+=o[c]=-~o[c],z*=!l|l+1==(l=c.charCodeAt()))),[n+z,Object.keys(o).sort((a,b)=>o[b]-o[a]||(o[b]>o[a]?1:-1))]),w=v(s),x=v(t),w[0]>x[0]||w[0]==x[0]&&w[1]<x[1]?s:t)

Ungolfed:
s=>t=>(
  v=s=>(
    o={},
    l=n=0,
    z=3.5,
    [...s].sort().map(c=>(
      n+=o[c]=-~o[c],
      z*=!l|l+1==(l=c.charCodeAt())
    )),
    [n+z,Object.keys(o).sort((a,b)=>o[b]-o[a]||(o[b]>o[a]?1:-1))]
  ),
  w=v(s),x=v(t),
  w[0]>x[0] || w[0]==x[0] && w[1]<x[1] ? s : t
)

After map() runs, n + z determines the ranking of a hand:

(You can understand why I initialized z to 3.5.)
In case of a tie, Object.keys(o).sort() is used to determine the higher ranking hand.
Snippet:

f=

s=>t=>(v=s=>(o={},l=n=0,z=3.5,[...s].sort().map(c=>(n+=o[c]=-~o[c],z*=!l|l+1==(l=c.charCodeAt()))),[n+z,Object.keys(o).sort((a,b)=>o[b]-o[a]||(o[b]>o[a]?1:-1))]),w=v(s),x=v(t),w[0]>x[0]||w[0]==x[0]&&w[1]<x[1]?s:t)

console.log(/voviu/.test(f('voviu')('kjsdf')))       //because a pair beats nothing
console.log(/opoqo/.test(f('opoqo')('upper')))       //because 3 of a kind beats a pair
console.log(/ggegg/.test(f('woooo')('ggegg')))       //because 4 Gs beats 4 Os
console.log(/queue/.test(f('queue')('hopup')))       //because 2 pairs beats 1 pair
console.log(/ddkop/.test(f('lodpl')('ddkop')))       //because pair DD beats pair LL
console.log(/huhyg/.test(f('huhyg')('hijht')))       //both have pair HH, but G beats I
console.log(/ccyyz/.test(f('ddffh')('ccyyz')))       //both have 2 pairs, but CC(yyz) beats DD(ffh)
console.log(/nkunk/.test(f('okaok')('nkunk')))       //KK ties with KK, but NN beats OO
console.log(/bcdef/.test(f('abcdf')('bcdef')))       //because it is a straight
console.log(/qtery|retyq/.test(f('qtery')('retyq'))) //identical! so doesnt matter
console.log(/abedc/.test(f('abedc')('vyxwz')))       //because it is a "higher" straight
console.log(/hijkl/.test(f('hhhij')('hijkl')))       //because straight beats 3 of a kind
console.log(/zzzzz/.test(f('aaabb')('zzzzz')))       //because nothing beats 5 of a kind

Jelly,  28 27 29  27 bytes
+2 & then -2 fix a bug, then re-golf.
FI=1ȦḤW
OµNĠLÞṚịµL€+Ç,N
ÇÞṪ

A monadic link taking a list of "hands" and returning (one of) the winners.
Works for all-uppercase OR all-lowercase input.
(...but not mixed, for that prepend the final line with Œl or Œu).
Try it online! or see the test suite.
How?
FI=1ȦḤW - Link 1, straight offset: grouped and reverse sorted hand ordinals
        -                     e.g. [[-101],[-100],[-99],[-98],[-97]]
F       - flatten                  [-101,-100,-99,-98,-97]
 I      - increments               [1,1,1,1]
  =1    - equal 1? (vectorises)    [1,1,1,1]
    Ȧ   - any and all?             1
     Ḥ  - double                   2
      W - wrap in a list           [2]
        -   The purpose of this is so that when "a" from Link 2 represents a straight we
        -   get [2], whereas for any other hand we get [0]. Adding the [2] to [1,1,1,1,1]
        -   (the lengths of a straight's groups) yields [3,1,1,1,1], placing it between
        -   three of a kind, [3,1,1], and a full house, [3,2], as required.

OµNĠLÞṚịµL€+Ç,N - Link 2, hand rank key function: list of characters       e.g. "huhyg"
O               - cast to ordinals                                [104,117,104,121,103]
 µ              - monadic chain separation, call that o
  N             - negate (to give them a reverse-sort order) [-104,-117,-104,-121,-103]
   Ġ            - group indices by value                            [[4],[2],[1,3],[5]]
     Þ          - sort by key function:
    L           -   length                                          [[4],[2],[5],[1,3]]
      Ṛ         - reverse                                           [[1,3],[5],[2],[4]]
       ị        - index into o                       [[-104,-104],[-103],[-117],[-121]]
        µ       - monadic chain separation (call that a)
         L€     - length of €ach                                              [2,1,1,1]
            Ç   - call last link (2) as a monad -> [isStraight? * 2]                [0]
           +    - addition (vectorises)                                       [2,1,1,1]
              N - negate o                                [[104,104],[103],[117],[121]]
             ,  - pair                        [[2,1,1,1],[[104,104],[103],[117],[121]]]
                -   now sorting by this will first be comparing the hand class, and if
                -   and only if they match comparing the card values in the required order.

ÇÞḢ - Main link: list of lists of characters (list of hands)
 Þ  - sort by key function:
Ç   -   last link (2) as a monad
  Ṫ - tail (best or an equal-best hand)

So freaking short compared to what I'm making in JS 0.o

@StephenS Welcome to PPCG, where you make something in some non-golfing language and then someone makes something in Jelly, 05AB1E, Pyth, CJam, etc that's shorter than your language name :I :P

@StephenS - JS should compete with JS. Do not let golfing languages deter you from submitting well thought out solutions in other languages!

@JonathanAllan it deters me from putting too much effort into overthinking and abstracting a problem that can be solved in ~25 characters, here's the fiddle I was working on - I wrote all the boilerplate and none of the actual code

This is awesome, but I recently added a test case that this doesn't compute, specifically ["hhhij","hijkl"]. I think it's because of the way you rank a straight as [3,1,1,1,1]?

@Octopus Ah, well it was comparing flat lists due to the concatenate and hence erroring when comparing a string with an int (oops) but you were still right about the sort order too. I might be able to change it to save bytes again... but it is fixed for now.

@Octopus - indeed I could, back to 27 bytes again.

JavaScript (250 247 232 bytes)
S=d=>(x={},l=99,h=s=0,[...d].map(v=>x[v]=-~x[v]),Object.keys(x).map(v=>(c=91-v.charCodeAt(),t=x[v],s+=1e4**t,c<x[t]?0:x[t]=c,g=(h=c>h?c:h)-(l=c<l?c:l))),[5,4,3,2,1].map(v=>s+=0|x[v]**v),s+(s<5e7&&g<5?1e13:0)),C=a=>b=>(S(a)>S(b)?a:b)

Ungolfed code & test cases in JSFiddle: https://jsfiddle.net/CookieJon/8yq8ow1b/
Saved some bytes with thanks to @RickHitchcock. @StephenS & @Arnauld

This is what I was trying to make but had no clue how to make.

Nor did I until after I started! :-)

s=0,h=0 => s=h=0 I believe

Fixed now after much hair-pulling.  Determining the tie-breaker in cases where the hand is the same AND the lowest characters in the 1st & 2nd largest groups were the same was the killer (33 bytes or so JUST for that!?) :-(

x[v]=x[v]?++x[v]:1 can become x[v]=(x[v]|0)+1, saving 3 bytes.

@RickHitchcock Handy, thanks!

Since you're not calling C except when you run it, you don't need the C=. You can also save some bytes with currying - =(a,b)=> => =>a=>b, switch all of your calls from C(a,b) to C(a)(b) fiddle (not completely fixed)

We took very different approaches, and dealing with ties was definitely the difficult part of this challenge.  I think I just now understand how you do that.  Clever!

I think x[v]=-~x[v] should work as well.

@RickHitchcock ...not as clever as sorting - which never once occurred to me. :P  Well done.

There's a new test case that doesn't seem to work with your code: =C('OKAOK')('NKUNK') returns OKAOK. I've been struggling to come up with a scoring function that works without doing a string comparison after sorting the keys, so I don't think this will be an easy fix.

@RickHitchcock Ha, of course it doesn't! :-(  I'll have a think and update it later, thanks.

@RickHitchcock or mods, I don't have time to fix for that test case.. what's the etiquette... delete this answer indefinitely, or just leave it as an example bar that test case?

Your code worked for the initial test cases, and it's possible that it could be modified to work for all cases.  I think you earned your points, so I'd say leave it.

Python 2.7, 242 223 bytes
from collections import*
s=sorted
f=lambda x,y:s(map(lambda h:(lambda (r,n):((3,1.5)if len(r)==5 and ord(r[0])+4==ord(r[4])else n,[-ord(d) for d in r],h))(zip(*s(Counter(h).items(),key=lambda z:(-z[1],z[0])))),(x,y)))[1][2]

Similar in basic concept to the javascript examples (sort by hand strength with an exception for straights; then by rank); but taking advantage of collections.Counter Unfortunately, .most_common doesn't have quite the desired behavior; so had to add a custom sort key.
Edit: a bit more code golfing to trim down 19 bytes.
Un-golfed code
from collections import Counter

def convertHand(h):
    # first get item counts, appropriately ordered; e.g. cbabc -> (('b',2), ('c',2),('a',1))
    sortedPairs = sorted(Counter(h).items(),key=lambda x:(-x[1],x[0]))

    # 'unzip' the tuples to get (('b','c','a'), (2,2,1))
    ranks, numberFound = zip(*sortedPairs)

    if len(ranks)==5:
        # no pairs; is it a straight? well, since they are in increasing order...
        if ord(ranks[0])+4 == ord(ranks[4]):
            # replace numberFound with something that will sort above 3 of a kind but below full house
            numberFound = (3,1.5)

    # invert the values of the ranks, so they are in decreasing, rather then increasing order
    ranks = [-ord(r) for r in ranks]

    # arrange tuples so we can sort by numberFound, and then ranks; and keep a reference to the hand
    return (numberFound, ranks, h)

# put it all together...
def f(x,y):
    hands = [convertHand(h) for h in (x,y)]
    rankedHands = sorted(hands)
    return rankedHands[1][2]

Mathematica, 635 bytes
H[x_]:=Block[{t},T=Sort@ToCharacterCode[x];L=Last/@Tally@T;t=0;S=Count;If[S[L,2]==1,t=1];If[S[L,2]==2,t=2];If[S[L,3]==1,t=3];If[S[Differences@T,1]==4,t=4];If[S[L,2]==1&&S[L,3]==1,t=5];If[S[L,4]==1,t=6];If[S[L,5]==1,t=7];t];F[K_,v_]:=First@Flatten@Cases[Tally@K,{_,v}];B=ToCharacterCode;(Z=Sort@B@#1;Y=Sort@B@#2;a=H[#1];b=H[#2];If[a>b,P@#1,If[a<b,P@#2]]If[a==b&&a==0,If[Z[[1]]<Y[[1]],P@#1,P@#2]];If[a==b&&(a==1||a==2),If[F[Z,2]<F[Y,2],P@#1,If[F[Z,2]==F[Y,2],If[F[Z,1]<F[Y,1],P@#1,P@#2],P@#2]]];If[a==b&&(a==3||a==5),If[F[Z,3]<F[Y,3],P@#1,P@#2]];If[a==b&&a==6,If[F[Z,4]<F[Y,4],P@#1,P@#2]];If[a==b&&(a==7||a==4),If[Tr@Z<Tr@Y,P@#1,P@#2]])&

.
.
Input form

["abcde", "kkekk"]

Is there a way to test this online?

https://sandbox.open.wolframcloud.com/app/objects/     paste with ctrl+v add the input at the end of the code and run with shift+enter


text:
Rotate-Replace a String
Task
Write a program or function that, given a string and a list of strings, replaces each occurrence of an element of the string list contained in the string with the next element of the string list.
Example
The string is The cat wore a hat on my doormat so I gave it a pat and the list is ["at","or","oo"], we observe that the following bracketed substrings are in the list of strings:
The c[at] w[or]e a h[at] on my d[oo]rm[at] so I gave it a p[at]

We replace each element simultaneously with the element after it. The element after "at" in the list is "or", the element after "or" is "oo", and the element after "oo" is "at". We get
The c[or] w[oo]e a h[or] on my d[at]rm[or] so I gave it a p[or]

so the output is
The cor wooe a hor a on my datrmor so I gave it a por

Note that when we were finding substrings, we selected d[oo]rm[at] instead of do[or]m[at]. This is because the substrings cannot overlap, so when deciding between overlapping substrings we choose the one(s) which come first in the string. When that has ambiguity, we choose the one(s) which come first in the input list.
Input
Input can be taken in any reasonable format. The list can be newline-delimited, space-delimited, or delimited by any reasonable character.
Output
Output the string generated after the replacements
Rules

You may assume that the input string and list consist only of printable ASCII (0x20 to 0x7E).
You may assume that the strings in the input list do not contain your delimiter.
You may assume that the input list has no repeated elements.
None of the Standard Loopholes are allowed.
Since this is code-golf, lowest score in bytes wins.

Testcases
String
List of Strings
Output
-----
"My friend John went to the park."
["j","J"," "]
"Myjfriendj ohnjwentjtojthejpark."
-----
"Monkey Tacos!"
["Monkey","Programming Puzzles"," "," & ","Tacos!","Code Golf", "Puzzles", "Dragons"]
"Programming Puzzles & Code Golf"
-----
"No matches this time :("
["Match","Duel","(No"]
"No matches this time :("
-----
"aaaaa"
["aa","b","a","c"]
"bbc"
-----
"aaaaa"
["b","a","c","aa"]
"ccccc"
-----
"pencil"
["enc","pen","nci","cil"]
"ncienc"
-----
"Seriously, a lowercase rot one?"
["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
"Sfsjpvtmz, b mpxfsdbtf spu pof?"

JavaScript (ES6), 99 bytes
f=(s,a,i=a.findIndex(w=>s.startsWith(w)))=>s?(~i?a[i+1]||a[0]:s[0])+f(s.replace(a[i]||s[0],''),a):s

Is this not actually 97 bytes? try it online

@Octopus The f= is counted in the bytecount because it is being referenced in the function f(s.replace...

Japt, 14 13 bytes
It's early so probably room for improvement.
rVq| @VgVbX Ä

Try it online

Explanation
                  :Implicit input of string U
r                 :Replace in U
 Vq|              :  V joined to a string with "|" (which is RegEx "or")
     @            :  Pass each match X through a function
        VbX       :    Index of X in V
            Ä     :    Add 1
     Vg           :    Get the element at that index in V

Java 8, 227 215 bytes
q->a->{String s=q,t;for(int i=0,j,l=a.length-1;i<s.length();i++)for(j=0;j<=l;j++)if(i==i+s.substring(i).indexOf(a[j])){s=s.substring(0,i)+(t=a[j<l?j+1:0])+s.substring(i+a[j].length());i+=t.length()-1;j=l;}return s;}

Ok, I got to admit: this challenge looks easy on paper, but there are many edge-cases for a verbose programming language like Java.. The first test case was easy, and was responsible for the general approach. The second test case caused a problem where it skipped two characters that both had to be replaced in a row <space>J -> j<space>. And then I had to fix another problem where test case "aaaaa"; ["aa","b","a","c"] resulted in bcb instead of the intended bbc. Oh, and the third test case replaced the Puzzles part twice at one point as well.. But, everything is fixed now, and all test-cases work.
Explanation:
Try it here.
q->a->{String s=q,                        // Method with String & String-array parameters and String return-type
  ,t                                      //  Temp String
  for(                                    //  Loop (1) over the characters of the input String
      int i=0,j,l=a.length-1,t;           //  Some temp integers
                               i<s.length();i++)
    for(j=0;j<=l;j++)                     //   Loop (2) over the String-array
      if(i==i+s.substring(i).indexOf(a[j])){
                                          //    If we've found a match:
        s=                                //     Replace the input-String with:
          s.substring(0,i)                //      The first part of this input-String
          +(t=a[j<l?j+1:0])               //      + the next item in the String-array (and set `t` to it)
          +s.substring(i+a[j].length());  //      + the last part of this input-String
        i+=t.length()-1;                  //     Raise `i` by the length of this replacement item (`t`) - 1
        j=l;//break;                      //     Break loop (2)
      }                                   //    End of if
                                          //   End of loop (2) (implicit / single-line body)
                                          //  End of loop (1) (implicit / single-line body)
  return s;                               //  Return resulting String
}                                         // End of method

As always, convert to Java 8 and use an anonymous function with currying to save bytes. Other than than I'm not sure there's much more you can golf, well done.

@TheLethalCoder Ok, ok. I'll try to use Java 8 some more from now on.. ;) (And thanks.)

Haha! I'll put my bloody 8 away and stop beating you with it then.

@TheLethalCoder Hehe. I actually answered something else this morning in just Java 8. Was thinking about switching to Java 8 from now on, but I still prefer to make these challenges in Java 7 locally.. I just have to remember to convert them to Java 8 before I post them here.

Python 2, 89 bytes
import re
s,a=input()
print re.sub('(%s)'%')|('.join(a),lambda m:a[m.lastindex%len(a)],s)

re.sub can use a replacer function, it just gets a shifted value from the original list.

Try it online!

APL (Dyalog), 12 bytes
Main answer
Needs escapeing of things that will clash with PCRE, which is acceptable.
{⍺⎕R(1⌽⍺)⊢⍵}
For each non-overlapping, sequential occurrence of each element of the left argument (⍺), Replace (⎕R) the occurrence with the corresponding element of the left argument rotated one step left (1⌽⍺), applied to (⊢) the right argument (⍵).

For general interest
A version which needs less escaping
Some arguments will clash with PCRE, so to avoid requiring the input to be pre-escaped, we can enclose each search pattern in \Q and \E:
{('\Q'∘,¨,∘'\E'¨⍺)⎕R(1⌽⍺)⊢⍵}
New here are '\Q' prepended (∘,) to each (¨) and append (,∘) '\E' to each (¨).
A version which needs no escaping
Still, this requires escaping any premature \E and also certain characters in the transformation patterns, so we can preprocess the search and transformation patterns to escape all problematic characters:
{R←⎕R'\\&'⋄('\P{Xan}'R⍺)⎕R(1⌽'\\|%|&'R⍺)⊢⍵}
R←⎕R'\\&' define the monadic operator R by currying the transformation pattern \\& (prefix a backslash to the matched text) as right operand.
⋄ then
'\\|%|&'R⍺ call R, looking for any backslash or percent or ampersand, (i.e. prefix them with a backslash) on the left argument
1⌽ rotate that one step to the left
'\P{Xan}'R⍺ call R, looking for any non-alphanumeric character, (i.e. prefix them with a backslash) on the left argument
(…)⎕R(…)⊢⍵  Replace text in the right argument – this time with safe search and transformation patterns

I think requiring certain escaped strings in the input is fine because that is a quirk of how the language deals with input. I don't know APL, so I'm not sure this is exactly how it works.

@fireflame241 Thank you, that's what I thought.

PHP>=7.1, 79 Bytes
<?[$s,$o]=$_GET;$k=$o;$k[]=array_shift($k);echo strtr($s,array_combine($o,$k));

Online Version

Ruby, 50 bytes
->a,b{a.gsub(%r[#{b*?|}]){|z|(b*2)[b.index(z)+1]}}

Straight forward as always :)

C#, 199 bytes
s=>a=>{for(int i=0,j,l=a.Count-1,t;i<s.Length;i++)for(j=0;j<=l;j++)if(i==i+s.Substring(i).IndexOf(a[j])){s=s.Substring(0,i)+a[t=j<l?j+1:0]+s.Substring(i+a[j].Length);i+=a[t].Length-1;j=l;}return s;};

A straight port of @KevinCruijssen's answer so go give him an upvote!
It's unfortunate that string.Split in C# removes the split strings otherwise I'm sure that would have been shorter.

PHP, 66 bytes
while($t=$argv[++$i+2])$p[$argv[$i+1]]=$t;echo strtr($argv[1],$p);

takes input from command line arguments; assumes that none of the arguments is 0.
Run with php -nr '<code>'.