text:
Parking lot supervisor
Introduction
You are a supervisor of a parking lot and your manager is preparing for shrinking the size to the extreme.
It is a simplified and adapted version of a problem in last year's PAT top-level.
Challenge
You are asked to calculate how many cars are in the lot at the same time, at most.
Standard rules apply. And this is a code-golf so shortest code wins.
First line is the quantity of entries (no more than 100,000, your input may not contain this line if you like, for it is only a makeshift to determine where input ends). The following text contains one entry per line. And each entry includes three numbers:
<Car plate number> <Time (seconds) since open> <0(In) | 1(Out)>

Modification 2: It is OK to use an array of triples as input.
Modification 3: You can change the order of numbers in one entry. And you can choose which to use. (see the Remarks section)
The input is guaranteed to be valid, assuming that:

Car plate number is a integer in the range of 10000 ~ 99999
Time is a integer in the range of 0 ~ 86400

And

Entries are not necessarily chronologically ordered.
There is no car before the first second.
There is not necessarily no car after the last second.
A car would not leave before it gets in.
Car plate number is unique. (but a same car may visit for more than one time)
So it is impossible for a car to enter the lot when it is already in it.
A same car wouldn't go in and out at the same time.
A car is considered to be in the lot at the time of in / out.

Example 1
Input
11
97845 36000 1
75487 16500 1
12345 16 0
75486 3300 0
12345 6500 1
97845 32800 0
12345 16400 0
97846 16501 1
97846 16500 0
75486 8800 1
75487 3300 0

Output
3

Explanation
At 16500, car 12345 and 75487 were in the parking lot.
Example 2
I made this because I found many code failed on it.
Input (with first line left out)
12345 16400 0
12345 16500 1
75487 16500 0
75487 16600 1

Output
2

Explanation
At 16500, car 12345 and 75487 were in the parking lot.
Remarks
Actually, not all three are required for the output. At least, you only need plate+time or in/out+time for the result. But the algorithm is slightly different under two circumstances, so the choice of being shorter stays unknown in a certain language. And of course you can use all of three numbers. So I leave them in the challenge.

Are car plate numbers always 5 digits long?

@Titus I believe numbers from 10000 to 99999 are always 5 digits long.

Gee I´m blind today.

I assume a car can't enter again before leaving leaving the first time? It doesn't seem to be stated explicitly.

@JanDvorak eh sorry. No it cannot. It is implied by car plate number is unique because in reality it is impossible for one same car to enter the lot when it is already in it.

Mathematica, 33 bytes
-Min@Accumulate[2#2-1&@@@Sort@#]&

I had to read the problem statement better to realize that there's a much simpler algorithm that doesn't require the license plate information.
Unnamed function returning an integer; the input format is a list of ordered triples in the form {time, 0|1, license plate}. We start by Sorting, which makes the list chronological and also breaks time-ties by sorting 0s before 1s; then 2#2-1&@@@ keeps the arrival/departure information and forgets the rest, and also converts 0s to -1s.
Accumulate calculates the running totals of that list; the result is a list of the negatives of the numbers of cars in the parking lot after every arrival/departure. Then Min picks the smallest (most negative) of these and the negative sign is stripped.
Mathematica, 56 bytes
Max[<|#|>~Count~0&/@FoldList[List,{},#3->#2&@@@Sort@#]]&

The original submission (the first several comments refer to this submission). Unnamed function returning an integer; the input format is a list of ordered triples in the form {time, 0|1, license plate}.
The reason we choose to put the time entry first and the in/out entry second is so that Sort@# sorts the list chronologically, and records arrivals before departures if they're simultaneous. After that, #3->#2&@@@ returns a list of "rules" of the form license plate -> 0|1, still sorted chronologically.
Then, FoldList[List,{},...] creates a list of all the initial segments of that list of rules. Actually, it really messes up those initial segments; the kth initial segment ends up being a list with one rule at depth 2, one rule at depth 3, ..., and one rule at depth k+1. (FoldList[Append,{},...] would yield the more natural result.) However, <|#|> turns each of these initial segments into an "association", which has two desirable effects: first, it completely flattens the nested-list structure we just created; and second, it forces later rules to override earlier rules, which is exactly what we need here—for any car that has left the parking lot, the record of its initial entry is now completely gone (and similarly for cars that re-enter).
So all that's left to do is to Count how many 0s there are in each of these associations, and take the Max.

Will this always do the right thing if cars come and go at the same time?

Your answer may be wrong. The maximum doesn't necessarily happen when a car entered once again so it is unsafe to erase entries using association. See this picture: http://i.imgur.com/D5xUl3z.png Obviously there are 3 cars at 16500.

@KeyuGan: I didn't claim that the maximum happens when a car re-enters. Note that my solution counts the number of cars in the parking lot at the time of every single entry/departure, and takes the maximum of those.

Maybe you could try the example 2.

Oh, okay, I understand the criticism now, and you (both) are correct. I've fixed it (at no byte cost even).

Well, however I believe it is not good to change 0/1 to -1/1 for it is beyond rearrangement of input.

Fine, I will change the solution to accommodate the change in the specification. But 0|1 isn't any more natural than -1|1, indeed 1 for in and 0 for out is more natural than the reverse, in my opinion.

Personally I agree with you. :) What I have done is to copy the definition from the original problem. The major difference is that the original one requires car plates being recognized from images and printed as the final result.

Haskell, 76 63 61 bytes
2 bytes saved by a variation of @nimi's suggestion.
f l=maximum$scanl1(+)[(-1)^c|i<-[0..8^6],(_,b,c)<-l,i==2*b+c]

Expects the argument as a list of triples in the order given by the problem statement.
For each possible time (and some more), we search first for coming and then for leaving car events and turn them to a list of plus or minus ones. We take the partial sums of this list and then the maximun of these partial sums.

Drop the import and use [(-1)^c|i<-[1..86400],(_,b,c)<-l,i==b].

I need the incoming cars before the outgoing ones, so it is a bit more complicated, but I could still save 2 bytes with your idea. Thanks!

JavaScript (ES6), 83 … 68 70 bytes
EDIT: fixed to support the 2nd example
Takes input as an array of [in_out, time, plate] arrays. But the plate column is actually ignored.
a=>a.sort(([a,b],[c,d])=>b-d||a-c).map(v=>a=(n+=1-v[0]*2)<a?a:n,n=0)|a

Test

let f =

a=>a.sort(([a,b],[c,d])=>b-d||a-c).map(v=>a=(n+=1-v[0]*2)<a?a:n,n=0)|a

console.log(f([
  [1, 36000, 97845],
  [1, 16500, 75487],
  [0, 16,    12345],
  [0, 3300,  75486],
  [1, 6500,  12345],
  [0, 32800, 97845],
  [0, 16400, 12345],
  [1, 16501, 97846],
  [0, 16500, 97846],
  [1, 8800,  75486],
  [0, 3300,  75487]
]));

console.log(f([
  [0, 16400, 12345],
  [1, 16500, 12345],
  [0, 16500, 75487],
  [1, 16600, 75487]
]));

Reading the in_out column instead of the plate column should save you six bytes: v=>n+=1-v[2]*2.

This is incorrect for the second example, so if you edit this again, you'll need to take that into account. (Since the last edit on this was before the second example was added, it's technically exempt from complying to it, and I'm not at all jealous!)

@PatrickRoberts Will try to fix that when I'm back in front of a computer ^^

@Neil Good catch! I had to rewrite it anyway to support the 2nd example, but I ended up following your advice.

PHP 7.1, 126 117 bytes
for(;$s=file(i)[++$i];)$d[+substr($s,6)][$s[-2]]++;ksort($d);foreach($d as$a){$r=max($r,$n+=$a[0]);$n-=$a[1];}echo$r;

takes input from file i, ignores first line. Run with -r.
Requires a trailing newline in input. Replace -2 with -3 for Windows.
breakdown
# generate 2-dim array; first index=time, second index=0/1 (in/out);
# values=number of cars arriving/leaging; ignore plate number
for(;$s=file(i)[++$i];) # read file line by line (includes trailing newline)
    $d[+substr($s,6)][$s[-2]]++;    # substring to int=>time, last but one character=>1/0
ksort($d);                      # sort array by 1st index (time)
foreach($d as$a)    # loop through array; ignore time
{
    $r=max($r,                      # 2. update maximum count
        $n+=$a[0]                   # 1. add arriving cars to `$n` (current no. of cars)
    );
    $n-=$a[1];                      # 3. remove leaving cars from `$n`
}
echo$r;                         # print result

Sorry you may use an array of triples as input if you are writing a function. My friends and I believe it is a good way to make non-golfing language more competitive if we are talking about a problem without complicated input.

@KeyuGan:Thanks for the hint; but with an array as input, I´d need a function, and that would costs two bytes, both with an array of triplets and with a triplet of arrays. functions, array mapping and custom sort are bulky in PHP. Only way I could save anything would be my prepared $d as input or sorted input (by time and in/out). And thast would take too much from the challenge. Aligned input ttttt i plate would save 17 bytes, 19 more with the count aligned with the plate number.

C, 147 bytes
A complete program, reads input from stdin.
int r[86402]={},u,i,n,t;g(s,o){for(;s<86401;n<r[s]?n=r[s]:0,++s)r[s+o]+=o?-1:1;}main(){for(n=0;scanf("%d%d%d",&u,&t,&i)==3;g(t,i));printf("%d",n);}

Try it on ideone.

I believe it is safe to remove spaces between %d

Oops, thanks. I don't use scanf enough, I guess.

I love cin. LOL

118 bytes

JavaScript (ES6), 63 73 71 bytes
d=>Math.max(...d.sort((a,[b,c])=>a[s=0]-b||a[1]-c).map(e=>s+=1-e[1]*2))

This accepts input as an array of entries ordered [time, inout, plate]. Unfortunately due to the fact that identical inout times means that both cars are considered in the lot at the moment in time, the sorting algorithm must order 0 prior to 1, which costed 11 bytes.
Credits

I saved 1 byte by moving the shift and multiplication inside the map function completely (thanks Neil).
I saved another two bytes by using a destructured argument in the sort function (thanks edc65).

Demo

// test the two examples
console.log([[[36000,1],[16500,1],[16,0],[3300,0],[6500,1],[32800,0],[16400,0],[16501,1],[16500,0],[8800,1],[3300,0]],[[16400,0],[16500,1],[16500,0],[16600,1]]].map(
// answer submission
d=>Math.max(...d.sort((a,[b,c])=>a[s=0]-b||a[1]-c).map(e=>s+=1-e[1]*2))
));

It seems your code doesn't work well on d=[[16400,75487,0],[16500,75487,1],[16500,99999,0],[16600,99999,1]]; I supposed it should print 2?

Well in the 4-entry test case, there are only 2 cars. I have formatted it to meet your input order.

@KeyuGan sorry for the misunderstanding, I didn't realize you were referring to the second example. It's fixed now.

I know your algorithm doesn't depend on plate number. However I suggest it should be included in the definition of input order, just leave it to the last ;)

Using sort(([a,b],[c,d])=>a-c||b-d) and setting s=0 inside the map call saves 4 bytes

@edc65 correct me if I'm wrong but wouldn't that be 3 bytes, not 4? I have to add back a comma if I move s=0 somewhere else

My first count was 2, then I tried it and found 4, but I could be wrong again...

@edc65 actually, only 2 bytes, not 4. This is also 71 bytes: d=>Math.max(...d.sort(([a,b],[c,d])=>a-b||c-d).map(e=>s+=1-e[1]*2,s=0))

Either way, destructuring the second argument was an awesome idea, so thank you

Octave , 50, 64 38 bytes
@(A)-min(cumsum(sortrows(A)(:,2)*2-1))

Same as @Greg Martin 's Mathematica answer
The function gets an array with 3 columns [time, i/o,plateN]
previous answer:
@(A){[t,O]=A{:};max(cumsum(sparse({++t(!O),t}{2},1,!O*2-1)))}{2}

The function only gets two inputs t: time and O: I/O from first two element of a cell array A that contains triple inputs!
A sparse matrix created to count for each recorded time number of existing cars . For it time of out + 1 is considered for car exit and corresponding 1 change to -1 and 0 changed to 1.
Use of sparse here is very important since multiple cars may arrive or leave at the same time.
Then cumulative sum computed representing number of current cars in the lot and max of it is found.

I remember Octave support cell array, which means you may only use one array of triples as input. The restriction is according to the edition before M5 and it states 'an array of triples'. I have clarified it in M5

@KeyuGan I think your new invented restriction is unnecessary increased 14 bytes of my code. so You are new to this site it is better to have questions with minimal number of restrictions to attract more contributors.


text:
Kids shuffling cards
Shuffling a deck of cards is hard for kids, so they must figure out ways to get a reasonable well shuffled deck as simply as possible.
One way to do this that gives reasonably good results is:

Take the top card out and insert it a random place in the deck
Take the bottom card out and insert it in a random place in the deck
Continue until you believe it's good enough.

Note that you shall never insert a card in the top or bottom spot, it should be placed somewhere in the deck.

Instead of shuffling cards, we'll shuffle alphanumerical characters: 0-9, A-J, a-j, q-z and Q-Z.
Start with the string shown below and shuffle the characters the way it's described above. You can choose if you want to continue shuffling infinitely or shuffle the cards 100 rounds (100 cards from the top and 100 cards from the bottom).
0123456789abcdefghijqrstuvwxyzABCDEFGHIJQRSTUVWXYZ

The challenge is to display the characters being shuffled. Each "shuffle" (take out and insert card) shall take between 0.25 and 0.35 seconds.
The gif below shows an example output:

This is code-golf so the shortest code in bytes wins.

"Why don't you have a-t instead of a-j, q-z?" Because this shall illustrate suits of cards, not just characters. And yes, there are 5 suits.

Note: I have decided to stop using the check mark on code-golf-challenges. Relevant meta posts here and here.

How are there 5 suits?

@TrojanByAccident The five sets are cards (ASCII characters) by suit are 0-9, A-J, a-j, q-z and Q-Z, according to the question.

and there are 50 cards, not 52. perhaps the kids lost some.

@mbomb007 I was asking how there were 5 suits of cards. Unless I'm missing something, there's only Spades, Clubs, Hearts, and Diamonds. That's 4.

@TrojanByAccident This doesn't use cards. It uses ASCII instead of cards. These are the five suits of ASCII. Instead of shuffling cards, we'll shuffle alphanumerical characters

@mbomb007 I know it doesn't use actual cards, but ". . .Because this shall illustrate suits of cards. . ."

@TrojanByAccident Because having more characters to shuffle makes it more interesting.

@mbomb007 just wondering about the wording, was all :P

JavaScript (ES6), 192 188 185 bytes

document.write('
')
s='ABCDEFGHIJQRSTUVWXYZ'
a=[0,...123456789+s.toLowerCase()+s]
setInterval('o.innerText=a.join``;a.splice(Math.random(s^=1)*48+1,0,s?a.pop():a.shift())',250)

Edit: Saved 4 bytes thanks to @L.Serné. Saved 3 bytes thanks to @Arnauld.

I think you can save a few bytes if you move e^=1 inside the empty parentheses of the Math.random call. You can also change textContent to innerHTML, since you're not passing any special chars. You can also set e to 0 inside the toLowerCase call.

You don't really need e. You could just use s. (Because ('some_string'^1) === 1)

MATL, 62 58 56 bytes
2 Bytes saved thanks to @Luis
4Y2'A':'J'tk'Q':'Z'tk&h`48YrQJh&)@o?l&)wb}wO&)]&htD3&XxT

This version will run indefinitely. Try the online demo at MATL Online, an experimental online interpreter that supports dynamic output. This will run for 30 seconds (a hard limit imposed by the online version) if it isn't killed first.
Explanation
4Y2     % Predefined literal for the characters '0'...'9'
'A':'J' % Create an array of the characters 'A'...'J'
tk      % Duplicate and make lowercase
'Q':'Z' % Create an array of the characters 'Q'...'Z'
tk      % Duplicate and make lowercase
&h      % Horizontally concatenate everything
`       % Do...while loop
  48YrQ % Determine a random integer between 2 and 49
  Jh&)  % Split the string at the selected location
  @o?   % If this is an odd time through the loop
    l&) % Grab the first character
    wb  % Move it to the middle of the stack of three strings
  }     % Else...
    wO&)% Grab the last character and move it to the middle of the stack
  ]     % End of if statment
  &h    % Horizontally concatenate all strings on the stack
  tD    % Duplicate and display the current string
  3&Xx  % Pause for 0.3 seconds and clear the display
  T     % Push a literal TRUE to the stack to make this an infinite loop
        % Implicit end of while loop

Python 3, 199 196 192 186 bytes
Saved 4 bytes thanks to TuukkaX, and 6 bytes thanks to FlipTack!
import time,random
s="abcdefghijqrstuvwxyz";s="0123456789"+s+s.upper()
f=0
while 1:print(end="\r"+s);time.sleep(.3);s,e=s[1^f:50-f],s[f and-1];i=random.randint(1,49);s=s[:i]+e+s[i:];f^=1

Uses Python 3's print function to suppress newline, shorter than Python 2's sys.stdout.write.
Uses a flip-flop variable to switch between moving the top and the bottom cards.
Ungolfed:
from random import randint
from time import sleep

string = "abcdefghijqrstuvwxyz"
string = "0123456789" + string + string.upper()
flip_flop = 0
while True:
    print("\r"+string,end="")
    sleep(0.3)
    string,char = string[not flip_flop:50-flip_flop], string[flip_flop and -1]
    position = randint(1,49)
    string = string[:position] + char + string[position:]
    f = not f

Would import random,time be shorter?

@FlipTack Yeah, 6 bytes shorter, thanks!

@mbomb007 Thanks, done :-)

Perl, 117 bytes
@F=(0..9,a..j,"q"..z,A..J,Q..Z);{print"\r",@F;splice@F,++$|+rand(@F-2),0,++$v%2?shift@F:pop@F;select$,,$,,$,,.3;redo}

To run it:
perl -e '@F=(0..9,a..j,"q"..z,A..J,Q..Z);{print"\r",@F;splice@F,++$|+rand(@F-2),0,++$v%2?shift@F:pop@F;select$,,$,,$,,.3;redo}'

Explanations:
-@F=(0..9,a..j,"q"..z,A..J,Q..Z) creates the initial deck, and stores it in @F.
-{...;redo} executes ... forever.
-splice@F,++$|+rand(@F-2),0,++$v%2?shift@F:pop@F alternatively remove the first/last element from the deck and insert in at a random position (while incrementing $|, so the prints aren't buffered),
- print"\r",@F prints the deck,
- select$,,$,,$,,.3 sleeps for 0.3 seconds (Perl's sleep can't sleep for less than 1 second),

the numeric range is 0..9, not 1..9, and your initial deck is out of order as well :)

@ardnew indeed, thanks. I must have been tired when I wrote this code. It's fixed anyway :)

C, 290 285 bytes
#include<stdio.h>
#include<time.h>
#define S(s,a,b){int p=rand()%48+1;clock_t c=clock()+300;while(c>clock());int x=d[s];for(int i=s;i a p;)d[i b]=d[i];d[p]=x;printf(d);}
main(){char d[]="0123456789abcdefghijqrstuvwxyzABCDEFGHIJQRSTUVWXYZ\r";srand(time(0));for(;;){S(0,<,++)S(49,>,--)}}

Ungolfed:
#include<stdio.h> // variadic(printf) functions without a valid prototype = UB
#include<time.h>  // required for the implementation-defined clock_t type
// note that <stdlib.h> isnt required for srand()/rand() because they are
//  validly declared implicitly
#define S(s,a,b) // macro function
{
    int p=rand()%48+1;     // get a random position within the array
    clock_t c=clock()+300; // get the time 300 milliseconds from now
    while(c>clock());      // wait for that time
    int x=d[s];            // save the s'th character in a tempvar
    for(int i=s;i a p;)    // shift everything in the array from p
        d[i b]=d[i];       // a determines the comparison: </>
                           // b determines the operation: ++/--
    d[p]=x;                // put the tempvar in its new position
    printf(d);             // print the modified string
} // note: the \r at the end makes it so the next printf overwrites it

main() // main entry point
{      // deck to shuffle below
    char d[]="0123456789abcdefghijqrstuvwxyzABCDEFGHIJQRSTUVWXYZ\r";
    srand(time(0)); // seed the random number generator
    for(;;)         // infinite loop
    {
        S(0,<,++)   // shuffle from the start of the deck
        S(49,>,--)  // shuffle from the end of the deck
    }
}

Ruby (138 119 Bytes)
f=0;a=[*0..9,*?a..?j,*?q..?z,*?A..?J,*?Q..?Z];loop{$><0? a.shift : a.pop);f^=1;sleep 0.3}

Not as short as @PaulPrestidge but at least I understand it..
Also great to learn that ruby is like a endless tunnel of awesome!

Swift, 288 bytes
import Darwin
var o=Array("0123456789abcdefghijqrstuvwxyzABCDEFGHIJQRSTUVWXYZ".characters)
while true{
print(String(o),terminator:"\r")
fflush(__stdoutp);{o.insert(o.removeLast(),at:$0())
o.insert(o.removeFirst(),at:$0()+1)}({Int(arc4random_uniform(UInt32(o.count-1)))})
usleep(300000)
}

Golfing in Swift is always a challenge, as one of its selling points is expressiveness.

Noodel, noncompeting 41 bytes
"Q…Z"A…J"q…z"a…j"0…9⁵⁺ḷçṛ47⁺1ɱɲOṃḃɲ49ḅṙḍq

Try it:)
How It Works
"Q…Z"A…J"q…z"a…j"0…9⁵⁺                    # Creates the string literal to be shuffled.
                      ḷçṛ47⁺1ɱɲO      ṙḍq # The main "infinite" loop that applies the animation.
                                ṃḃɲ49ḅ    # Sub-loop that acts like an if-statement that only runs every odd iteration of the loop.

"Q…Z                                      # Pushes the string literal "QRSTUVWXYZ".
    "A…J                                  # Pushes the string literal "ABCDEFGHIJ".
        "q…z                              # Pushes the string literal "qrstuvwxyz".
            "a…j                          # Pushes the string literal "abcdefghij".
                "0…9                      # Pushes the string literal "0123456789".
                    ⁵⁺                    # Add the five strings on the stack to make one string.
                      ḷ                   # Unconditionally loop the following code.
                       ç                  # Copy what is on the top of the stack, clear the screen, and then print the copy.
                        ṛ47               # Create a random integer from 0 to 47.
                           ⁺1             # Increment the number to get 1 - 48 such that will not be the top or bottom of the deck.
                             ɱ            # Push the number of times that the unconditional loop has ran.
                              ɲO          # Consume the counter and push on zero if is even and one if is odd.
                                ṃ         # Conditional loop that only passes if the top of the stack is truthy (if the counter is odd).
                                 ḃ        # Throws away the top of the stack.
                                  ɲ49     # Pushes the literal 49 in order to represent the top of the deck.
                                     ḅ    # Ends the conditional loop.
                                      ṙ   # Relocate an element in the string by using the two numbers on the stack (either 0 or 49 to the random number).
                                       ḍq # Delay for a quarter of second. (End of unconditional loop)

Why is this non competing?

@StewieGriffin I did not finalize the release of the js parser until after the challenge. All functionality existed before that, but I did not know if it was correct for me to allow Noodel to compete. So, I took the safe route:)

@mbomb007, thank you for fixing that. I did not realize it was placed on top.

Ruby, 111 101 characters
s=[*0..9,*?a..?j,*?q..?z,*?A..?J,*?Q..?Z,?\r]*''
loop{$><<s;s[1+rand(48),0]=s.slice!$.^=-2;sleep 0.3}

Loops infinitely.

bash, 170 bytes
r(){((r=RANDOM%48+1));echo -n $c^;sleep .3;}
c=0123456789abcdefghijqrstuvwxyzABCDEFGHIJQRSTUVWXYZ
while r
do
c=${c:1:r}${c:0:1}${c:r+1}
r
c=${c:0:r}${c:49}${c:r:-1}
done

here '^' (on the first line) represents ctrl-m:  entered on the command-line as ctrl-v enter or in an editor according to how your editor works (assuming your editor works)

source: Stack Exchange

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

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

sort: votes


text:
Pi == 3.2
Inspired by this video of Infinite Series.
Introduction
Pi is defined as the ratio of the circumference to the diameter of a circle. But how is a circle defined? Usually a circle is defined as the points with constant distance to the centerpoint (let us assume that the center is at (0,0)). The next question would be: How do we define the distance? In the following we are considering different notions of distances (induced by the Lp-norms):
Given a norm (=something that measures a length) we can easily construct a distance (=distance between two points) as follows:
dist(A,B) := norm (A-B)

The euclidean norm is given by:
norm((x,y)) = (x^2 + y^2)^(1/2)

This is also called the L2-norm. The other Lp-norms are constructed by replacing the 2 in the above formula by other values between 1 and infinity:
norm_p((x,y)) = (|x|^p + |y|^p)^(1/p)

The unit circles for those different norms have quite distinct shapes:

Challenge
Given a p >= 1, calculate the ratio of circumference to diameter of a Lp-circle with respect to the Lp-norm with an accuracy of four significant figures.
Testcases
We can use that for p,q with 1 = 1/p + 1/q we get the same ratio for the Lp as well as the Lq norm. Furthermore for p = q = 2 the ratio is minimal, and for p = 1, q = infinity we get a ratio of 4, so the ratios are always between pi and 4.
p   or  q            ratio
1       infinity     4
2       2            3.141592
1.623   2.60513      3.200
1.5     3            3.25976
4       1.33333      3.39693

The shapes are known as Lamé curves or superellipses and exist for 0 < p < 1 too, even though the norm itself doesn't (because it violates the triangle inequality). The Wikipedia article for the superellipse includes a closed form for the area.

@Neil We do however need to consider the circumference, not the area, which - as far as I know - can only be calculated via a arc length integral.

Sorry, by the time I'd finished reading up on them I'd forgotten what the question had asked for.

Lovely challenge!

It's interesting to note that the area formula (A = πr²) does not hold for p ≠ 2

https://en.wikipedia.org/wiki/Indiana_Pi_Bill

@DenisdeBernardy Haha congrats, this is exactly what the title is an allusion to :D

the L2 norms sound like things in non-euclidean geometry.

Python + scipy, 92 bytes
from scipy.integrate import*
lambda p:2/p*quad(lambda x:(x/x**p+(1-x)**(1-p))**(1/p),0,1)[0]

Formula is from this math.SE question.

When testing an implementation with this appraoch I had trouble with the convergence of that approach, due to the singularity at x=1, how does your submission do?

Scipy is not part of the Python standard library. Maybe switch to Sage?

@flawr It seems scipy handles it fine. All examples are within the required accuracy.

@busukxuan There is no requirement on PPCG that allows you to only use standard libraries. But I'll mention it in the title anyways.

+1 for finding the formula. I couldn't, and didn't like to try my own integration because I was afraid of feeling bad when later someone else comes with a closed formula.

@ChristianSievers I did my own integration to avoid feeling bad for using someone else's closed formula :-P

@ChristianSievers I actually also included another formla in the sandbox, in case you're interested=)

MATL, 31 bytes
0:1e-3:1lyG^-lG/^v!d|G^!slG/^sE

Try it online! Or verify all test cases.
Explanation
This generates the x,y coordinates of one quarter of the unit circle sampled at 1001 points with step 0.001 in x. The length of the quarter of circle is approximated by that of the polygonal line that passes through those points; that is, the sum of the lengths of the 1000 segments. Length is of course computed according to p-norm. Multiplying the result by 2 gives the approximate lenght of half a circle, that is, pi.
0:1e-3:1   % Push [0 0.001 0.002 ... 0.999 1]. These are the x coordinates of
           % the vertices of the polygonal line that will approximate a quarter
           % of the unit circle
l          % Push 1
y          % Duplicate [0 0.001 0.002 ... 0.999 1] onto the top of the stack.
G          % Push input, p
^          % Element-wise power: gives [0^p 0.001^p ... 1^p]
-          % Element-wise subtract from 1: gives [1-0^p 1-0.001^p ... 1-1^p]
lG/        % Push 1, push p, divide: gives 1/p
^          % Element-wise power: gives [(1-0^p)^(1/p) (1-0.001^p)^(1/p) ...
           % ... (1-1^p)^(1/p)]. These are the y coordinates of the vertices
           % of the polygonal line
v          % Concatenate vertically into a 2×1001 matrix. The first row contains
           % the x coordinates and the second row contains the y coordinates
!          % Transpose
d|         % Compute consecutive differences down each column. This gives a
           % 1000×2 matrix with the x and y increments of each segment. These
           % increments will be referred to as Δx, Δy
G          % Push p
^          % Element-wise power
!          % Transpose
s          % Sum of each column. This gives a 1×1000 vector containing
           % (Δx)^p+(Δy)^p for each segment
lG/        % Push 1/p
^          % Element-wise power. This gives a 1×1000 vector containing
           % ((Δx)^p+(Δy)^p)^(1/p) for each segment, that is, the length of
           % each segment according to p-norm
s          % Sum the lenghts of all segments. This approximates the length of
           % a quarter of the unit circle
E          % Multiply by 2. This gives the length of half unit circle, that is,
           % pi. Implicitly display

Wolfram Language (Mathematica), 49 46 45 bytes
3 bytes saved thanks to alephalpha.
1 byte saved thanks to att.
\!\(2N@∫\_0\%1\@+++(a^-#-1)^(1-#)\%#a\)&

Try it online! Pure function. Takes a number as input and returns a number as output. The Unicode characters are U+222B for \[Integral] and U+F74C for \[DifferentialD].

2NIntegrate[(1+(a^-#-1)^(1-#))^(1/#),{a,0,1}]&

45 bytes

@att Thanks! It's funny how none of us thought to use the MakeExpression syntax for years.

It's rare in golf that an expression is complicated enough for those forms to save enough bytes to make up for the \!\( \) overhead, to be fair.

(1-#) -> ++-# for another -1

PARI/GP, 48 43 bytes
It's easy after @orlp has found the formula, and @alephalpha's version saves 5 bytes:
p->2*intnum(u=0,1,(1+(u^-p-1)^(1-p))^(1/p))

To add something slightly useful, let's calculate the p for which we get 3.2:
? f=p->2*intnum(u=0,1,(1+(u^-p-1)^(1-p))^(1/p));
? solve(p=1,2,f(p)-3.2)
%2 = 1.623002382384469009676324702

Correct usage
While the code gives results that are much more exact than the challenge demands, it can easily be improved a lot: if we replace the upper integration limit 1 with [1,1/p-1] (giving what the manual calls the singularity exponent) then all shown digits of f(2) agree with Pi. This is still true if we increase the precision to 100  (type \p100).
However, after that change the solve computation no longer worked. I changed the inner term to explicitely handle the case u=0 and also changed to a different computer with a newer PARI version and 64 bit (which implies a higher default precision).
Here is the improved calculation of the p value for Pi=3.2, and let's also have a look at the real Pi:
? f=p->2*intnum(u=0,[1,1/p-1],if(u,(1+(u^-p-1)^(1-p))^(1/p),0));
? f(2)
%2 = 3.1415926535897932384626433832795028842
? Pi
%3 = 3.1415926535897932384626433832795028842
? solve(p=1,2,f(p)-3.2)
%4 = 1.6230023823844690096763253745604419761

p->2*intnum(u=0,1,(1+(u^-p-1)^(1-p))^(1/p))

Desmos, 42 bytes
f(p)=2∫_0^1(x/x^p+(1-x)^{1-p})^{1/p}dx/p

Port of orlp's integration formula. Yay for integration built-in!
Try it on Desmos!

JavaScript (ES7), 80 bytes
Based on orlp's answer. This JS implementation is quite slow. You may want to try i=1e-7 (or even higher) for a faster approximation.
Note: This is basically intended for Chrome and Edge only. An equivalent ES6 version using Math.pow() on Firefox 50.1 seems to be much slower.
Edit: According to Neil, this should also work fine on Firefox 52.

f=
p=>{for(i=5e-8,s=x=0;(x+=i)<1;)s+=i*(x**(1-p)+(1-x)**(1-p))**(1/p);return 2/p*s}

console.log(f(1).toFixed(3))
console.log(f(2).toFixed(3))
console.log(f(1.623).toFixed(3))

The ES7 version seemed pretty sprightly when I tried it using Firefox 52 (I didn't measure it scientifically, but it felt about the same speed as Chrome; Edge froze on me).

@Neil Thanks for your feedback. Updated accordingly.

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


text:
Detect ASCII-art windows made of M and S characters
A Window is an ASCII-art square with odd side length of at least 3, with a single character border around the edge as well as vertical and horizontal strokes in the middle:
#######
#  #  #
#  #  #
#######
#  #  #
#  #  #
#######

An MS Window is a window where the border is made only of the characters M and S. Your task is to write a program (or function) that takes a string and outputs a truthy value if the input is a valid MS Window, and a falsey value if it is not.
Specifications

You may take the input as a newline-separated string or an array of strings representing each line.
The border of an MS Window may contain a mix of M and S characters, but the inside will always be composed of spaces.
You can choose to detect only windows with trailing newlines, or only windows without trailing newlines, but not both.

Test Cases
Truthy:
MMM
MMM
MMM

SMSMS
M M S
SMSMM
S S M
SMSMS

MMMMMMM
M  S  M
M  S  M
MSSSSSM
M  S  M
M  S  M
MMMMMMM

Falsey:
Hello, World!

MMMM
MSSM
MS M
MMMM

MMSMM
M S.M
sSSSS
M S M
MMSMM

MMMMMMM
M  M  M
MMMMMMM
M  M  M
MMMMMMM

MMMMMMM
M M M M
MMMMMMM
M M M M
MMMMMMM
M M M M
MMMMMMM

MMSSMSSMM
M   M   M
S   S   S
S   S  S
MMSSMSSMM
S   S   S
S   S   S
M   M   M
MMSSMSSMM

This is a great twist on ASCII arts, a decision problem to detect a certain structure.

@xnor I feel like we might want a different tag for reverse ASCII art like this.

while not specific to ascii art, pattern matching might be a good choice for a new tag

Can you add a test case or two where the string doesn't form a rectangular array?

Would MMSSM\nM S M\nMSSSS\nS M S\nMSSMS be valid? (the Ms and Ss are not constant)

Related: Clean the muddy quartata-fish

Can we assume the strings of the array will always be the same length (i.e. right-padded with spaces if needed)?

Why are the last two Falsey examples not Truthy? I'm probably missing something quite obvious here.

@Mast, I think because there should be four square panes

@ChrisM That does not appear to be part of the requirement though.

@Mast, you are quite right! Maybe the challenge needs clarifying

I suppose M is a valid MS window too?

@Adám NO because A Window is an ASCII-art square with odd side length of at least 3, with a single character border around the edge as well as vertical and horizontal strokes in the middle (that's the first sentence of the challenge) yours has length 1

@Mast A Window is an ASCII-art square with odd side length of at least 3, with a single character border around the edge as well as vertical and horizontal strokes in the middle The last 2 falsey are not square (the first) and with more than 1 vertical and horizontal stroke in the middle (the last one)

If we take the input as a single string, can we assume there's a trailing newline?

@PatrickRoberts No, but you can decide whether a valid window has a trailing newline.

@Challenger5 hah, just now noticed your edit. Luckily my program still satisfies that requirement!

Do we have to take into account different Windows / Linux line endings?

@DestructibleWatermelon That tag used to exist but was removed some time ago, because it's usage was quite arbitrary.

@edc65 I missed the last Falsey having an odd S, so I understand that one. The other one looks square though, 7x7.

Pyke, 34 31 bytes
lei}t\Mcn+it*i\M*+s.XM"QJ\S\M:q

Try it here!
lei                              -         i = len(input)//2
   }t                            -        (^ * 2) - 1
     \Mc                         -       "M".center(^)
        n+                       -      ^ + "\n"
          it*                    -     ^ * (i-1)
                 +               -    ^ + V
             i\M*                -     "M"*i
                  s              -   palindromise(^)
                   .XM"          -  surround(^, "M")
                               q - ^ == V
                       QJ        -   "\n".join(input)
                         \S\M:   -  ^.replace("S", "M")

Retina, 68 67 bytes
Byte count assumes ISO 8859-1 encoding.
S
M
^(M((M)*M)\2)((?<-9>¶M((?<9-3> )*(?(3)!)M|\5)\5)*(?(9)!)¶\1)\4$

Try it online!

Grime, 39 38 bytes
Thanks to Zgarb for saving 1 byte.
e`BB/BB/W+ W/+
B=W|B/W\ * W/\ /*
W=[MS

Try it online!
I'm not sure whether there's a simpler way to enforce the square aspect ratio of the individual window components than using a recursive nonterminal, but this seems to be working quite well.
Explanation
It's best to read the program from the bottom up.
W=[MS

This simply defines a nonterminal (which you can think of as a subroutine that matches a rectangle) W which matches either an M or an S (there's an implicit ] at the end of the line).
B=W|B/W\ * W/\ /*

This defines a non-terminal B which matches about a quarter of the output, i.e. one window panel with the left and top border. Something like this:
MSM
S
M

To ensure that this window panel is square, we define B recursively. It's either a window character W, or it's B/W\ * W/\ /* which adds one layer to the right and to the bottom. To see how it does this, let's remove some syntactic sugar:
(B/W[ ]*)(W/[ ]/*)

This is the same, because horizontal concatenation can be written either AB or A B, but the latter has lower precedence than the vertical concatenation / while for the former has higher. So B/W[ ]* is a B with a window character and a row of spaces below. And then we horizontally append W/[ ]/* which is a window character with a column of spaces.
Finally, we assemble these nonterminals into the final window shape:
BB/BB/W+ W/+

That's four window panels B followed by a row of window characters and a column of window characters. Note that we make no explicit assertion that the four window panels are the same size, but if they aren't it's impossible to concatenate them into rectangle.
Finally the e` at the beginning is simply a configuration which tells Grime to check that the entire input can be matched by this pattern (and it prints 0 or 1 accordingly).

Perl, 124 123 119 95 93 84
The following Perl script reads one candidate MS Window from the standard input. It then exits with a zero exit status if the candidate is an MS Window and with a non-zero exit status if it isn't.
It works by generating two regular expressions, one for the top, middle and bottom line and one for every other line, and checking the input against them.
Thanks, @Dada. And again.
map{$s=$"x(($.-3)/2);$m="[MS]";($c++%($#a/2)?/^$m$s$m$s$m$/:/^${m}{$.}$/)||die}@a=<>

I'm not sure giving the result as exit status is allowed (I don't have time to look for the relevant meta post though). Regardless, you can save a few bytes: @a=<>;$s=$"x(($.-3)/2);$m="[MS]";map{$a[$_]!~($_%($./2)?"$m$s$m$s$m":"$m${m}{$.}")&&die}0..--$.

@Dada: Thanks! That's an impressive improvement: 24 characters. (There was a stray "$m" in your code, so it's even shorter than it looked at first.) I wasn't sure if reporting the result with an exit code was allowed in general but I took the "write a program (or function)" as allowing one to be flexible with how the result is returned in this particular case; exit codes are practically the function return values of the *nix environment. :-)

Make that 26 characters.

Actually, I'm decrementing $. at the end to avoid using twice $.-1 (especially since the first time it was ($.-1)/2 so it needed some extra parenthesis), so the $m in $m${m}{$.} isn't a mistake. Also, I just realized now, but the regexs should be surrounded with ^...$ (so extra character at the end or the beginning make them fail), or shorter: use ne instead of !~.

Nevermind, obviously you can't use ne instead of !~ (I shouldn't write messages when I've been awake for just 15 minutes!). So you'll have to use ^...$ in both regex I'm afraid.

I managed to golf it a little bit more (while adding the necessary ^...$: map{$s=$"x(($.-3)/2);$m="[MS]";($c++%($#a/2)?/^$m$s$m$s$m$/:/^${m}{$.}$/)||die}@a=<>.

Awesome! I really like this refactoring. I didn't realize Perl could do map{...}@a=<>. It's clever but makes you go "of course!" in retrospect. Thanks for correcting me on the $m/lack of ^...$. I forgot to account for removing the line length check early on that would have caught this.

JavaScript (ES6), 115 113 bytes
a=>(l=a.length)&a.every((b,i)=>b.length==l&b.every((c,j)=>(i&&l+~i-i&&l+~i&&j&&l+~j-j&&l+~j?/ /:/[MS]/).test(c)))

Takes input as a an array of arrays of characters (add 5 bytes for an array of strings) and returns 1 or 0. After verifying that the height is odd, every row is checked to ensure the array is square, and every character is verified to be one of the character(s) that we expect in that particular position. Edit: Saved 2 bytes thanks to @PatrickRoberts.

You can change (...).includes(c) to ~(...).search(c) to save 1 byte

Actually, even better you can change it to (...?/ /:/[MS]/).test(c) to save 2 bytes instead of just 1.

@PatrickRoberts Cute, thanks!

Mathematica, 166 bytes
Union[(l=Length)/@data]=={d=l@#}&&{"M","S"}~(s=SubsetQ)~(u=Union@*Flatten)@{#&@@(p={#,(t=#~TakeDrop~{1,-1,d/2-.5}&)/@#2}&@@t@#),p[[2,All,1]]}&&{" "}~s~u@p[[2,All,2]]&

Unnamed function taking a list of lists of characters as input and returning True or False. Here's a less golfy version:
(t = TakeDrop[#1, {1, -1, d/2 - 0.5}] &;
Union[Length /@ data] == {d = Length[#1]}
  &&
(p = ({#1, t /@ #2} &) @@ t[#1];
SubsetQ[{"M", "S"}, Union[Flatten[{p[[1]], p[[2, All, 1]]}]]]
  &&
SubsetQ[{" "}, Union[Flatten[p[[2, All, 2]]]]])) &

The first line defines the function t, which separates a list of length d into two parts, the first of which is the first, middle, and last entries of the list, and the second of which is all the rest. The second line checks whether the input is a square array in the first place. The fourth line uses t twice, once on the input itself and once on all* of the strings in the input, to separate the characters that are supposed to be "M" or "S" from the characters that are supposed to be spaces; then the fifth and seventh lines check whether they really are what they're supposed to be.

JavaScript (ES6), 108 106 bytes
Input: array of strings / Output: 0 or 1
s=>s.reduce((p,r,y)=>p&&r.length==w&(y==w>>1|++y%w<2?/^[MS]+$/:/^[MS]( *)[MS]\1[MS]$/).test(r),w=s.length)

Test cases

let f =

s=>s.reduce((p,r,y)=>p&&r.length==w&(y==w>>1|++y%w<2?/^[MS]+$/:/^[MS]( *)[MS]\1[MS]$/).test(r),w=s.length)

console.log('Testing truthy test cases...');

console.log(f([
  'MMM',
  'MMM',
  'MMM'
]));

console.log(f([
  'SMSMS',
  'M M M',
  'SMSMS',
  'M M M',
  'SMSMS'
]));

console.log(f([
  'MMMMMMM',
  'M  S  M',
  'M  S  M',
  'MSSSSSM',
  'M  S  M',
  'M  S  M',
  'MMMMMMM'
]));

console.log('Testing falsy test cases...');

console.log(f([
  'Hello, World!'
]));

console.log(f([
  'MMMM',
  'MSSM',
  'MS M',
  'MMMM'
]));

console.log(f([
  'MMSMM',
  'M S.M',
  'sSSSS',
  'M S M',
  'MMSMM'
]));

console.log(f([
  'MMMMMMM',
  'M  M  M',
  'MMMMMMM',
  'M  M  M',
  'MMMMMMM'
]));

console.log(f([
  'MMMMMMM',
  'M M M M',
  'MMMMMMM',
  'M M M M',
  'MMMMMMM',
  'M M M M',
  'MMMMMMM'
]));

JavaScript (ES6), 140 138 141 140 bytes
I know this isn't a winning byte count (although thanks to Patrick Roberts for -3, and I realised it threw false positives for 1 instead of M/S: +3), but I did it a slightly different way, I'm new to this, and it was fun...
Accepts an array of strings, one for each line and returns true or false. Newline added for clarity (not included in byte count).
f=t=>t.every((e,i)=>e.split`S`.join`M`==[...p=[b='M'.repeat(s=t.length),
...Array(z=-1+s/2|0).fill([...'MMM'].join(' '.repeat(z)))],...p,b][i])

Instead of checking input against a generalised pattern, I construct an 'M' window of the same size, replace S with M on input, and compare the two.
Ungolfed

f = t => t.every( // function returns true iff every entry in t
                  // returns true below
  (e, i) => e.split`S`.join`M` // replace all S with M
                                 // to compare to mask
  == [ // construct a window of the same size made of Ms and
       // spaces, compare each row
      ...p = [ // p = repeated vertical panel (bar above pane)
               // which will be repeated
              b = 'M'.repeat(s = t.length),
                  // b = bar of Ms as long as the input array
              ...Array(z = -1 + s/2|0).fill([...'MMM'].join(' '.repeat(z)))],
              // z = pane size; create enough pane rows with
              // Ms and enough spaces
      ...p, // repeat the panel once more
      b][i] // finish with a bar
)

console.log(f(["111","111","111"]))

console.log(f(["MMMMM","M S M","MSSSM","M S M","MSSSM"]))

Test cases

f=t=>t.every((e,i)=>e.split`S`.join`M`==[...p=[b='M'.repeat(s=t.length),
...Array(z=-1+s/2|0).fill([...'MMM'].join(' '.repeat(z)))],...p,b][i])

truthy=`MMM
MMM
MMM

SMSMS
M M M
SMSMS
M M M
SMSMS

MMMMMMM
M  S  M
M  S  M
MSSSSSM
M  S  M
M  S  M
MMMMMMM`.split('\n\n')

falsey=`Hello, World!

MMMM
MSSM
MS M
MMMM

MMSMM
M S.M
sSSSS
M S M
MMSMM

MMMMMMM
M  M  M
MMMMMMM
M  M  M
MMMMMMM

MMMMMMM
M M M M
MMMMMMM
M M M M
MMMMMMM
M M M M
MMMMMMM`.split('\n\n')

truthy.forEach(test=>{
  console.log(test,f(test.split('\n')))
})

falsey.forEach(test=>{
  console.log(test,f(test.split('\n')))
})

For future reference, unless the function is recursive, f= doesn't need to be included in the byte count, so this is actually a 138 byte submission.

You can replace z=-1+s/2|0 with z=(s-3)/2 to save 1 byte

You can also replace e.replace(/S/g,'M')==... with e.split`S`.join`M`==... to save another byte

Thanks! z=-1+s/2|0 is there to return a positive integer for s==1 and even s, i.e. the function returns false without Array() crashing it. Otherwise the necessary logic made it longer. Great tip on split/join, thanks

Good catch, I didn't consider the s=1 case, since my invalid regex just silently fails.

JavaScript (ES6), 109 107 106 105 99 bytes
s=>!s.split`S`.join`M`.search(`^((M{${r=s.search`
`}})(
(M( {${w=(r-3)/2}})M\\5M
){${w}}))\\1\\2$`)

Edit: Whoa, Arnauld saved me 6 bytes by changing s.split`\n`.length to s.search`\n`! Thanks!
This takes a single multiline string and constructs a RegExp-based validation using the length of the input string. Returns true or false. Assumes a valid window has does not have a trailing newline.
Demo

f=s=>!s.split`S`.join`M`.search(`^((M{${r=s.search`
`}})(
(M( {${w=(r-3)/2}})M\\5M
){${w}}))\\1\\2$`);
`MMM
MMM
MMM

SMSMS
M M M
SMSMS
M M M
SMSMS

MMMMMMM
M  S  M
M  S  M
MSSSSSM
M  S  M
M  S  M
MMMMMMM

Hello, World!

MMMM
MSSM
MS M
MMMM

MMSMM
M S.M
sSSSS
M S M
MMSMM

MMMMMMM
M  M  M
MMMMMMM
M  M  M
MMMMMMM

MMMMMMM
M M M M
MMMMMMM
M M M M
MMMMMMM
M M M M
MMMMMMM`.split`

`.forEach(test=>{console.log(test,f(test));});

Nice approach! Could you use r=s.search('\n') instead of split / length?

@Arnauld awesome suggestion, thanks!

The parenthesys on s=>!s.split`S`.join`M`.search([...]) can be removed, without causing syntax errors.

@IsmaelMiguel correct, but then the string gets passed as a template, which invalidates the implicit RegExp

That sucks... I really wasnt expecting that...

@IsmaelMiguel here's how that syntax works: tagged template literals


text:
Output a random OEIS sequence
Your challenge: Connect to the Online Encyclopedia of Integer Sequences OEIS.org, access any random valid sequence, output it's ID, and ouput all of the members of the sequence provided by the OEIS entry. The only website you're allowed to connect to is OEIS.org.
Hints: Sequences are found in URLs such as http://oeis.org/A280629, however a more easily parseable version is found at URLs such as http://oeis.org/search?q=id:A280629&fmt=text. Every present and future sequence matches the regex "[A-Z]\d{6}". (The regex is there to describe what an ID looks like. There are a lot of invalid sequences that match it, too). The webcam (http://oeis.org/webcam) feature of OEIS generates random sequences, but you'll have to find a way to change the dropdown menu from 'best sequences' to 'all sequences' to use it.
Example output:
A280629
1, 1, 7, 139, 6913, 508921, 57888967, 9313574419, 1984690709953, 547467006437041, 188946742298214727, 79783392959511537499, 40498043815904027702593, 24314800861291379306213161, 17047720745682515427867108487, 13802952030641885344209574247779, 12780883488499783875309105315925633, 13420910251496135926622603184056054881, 15863354775169518855398667975850797997447, 20966527201075972453953302254528386060431659

Every existing sequence has to have a chance of being outputed, it does not have to be an equal chance.
Your program should continue to function properly regardless of future sequences being added. Even though all IDs presently start with A, there will eventually be a sequence B000001 after all the A sequences run out. You can assume that there will be no more sequences after Z999999 is defined, but you do have to assume that it will eventually be defined.
An invalid sequence, which your program should never output, is one that doesn't exist. You may treat sequences with no given members (such as A280611 either as invalid or give just the sequence ID and nothing else or a falsy value, but you must be consistent.
This is code-golf, fewest bytes wins!

Your regex isn't quite right - sequences can't end with 000000. Additionally, is outputting a valid sequence that doesn't exist yet acceptable?

What about "sequences" like this one. How shall we handle those? Do we have to check if the entry contains a sequence, and if not find another entry that does? This makes it a lot harder/cumbersome.

When the sequences names have leading 0, can we omit those 0? (for instance, A15 instead of A000015)

Arg, this is impossible in JS

@StewieGriffin That one now has member, so one can't fall to it when fail. OP should say if this fine though

@TrojanByAccident, Oh, no it's not!

Perl, 93 bytes
$u=chr(65+rand 26).sprintf("%06d",rand 1e6),$_=`curl oeis.org/$u`while!/tt>(.*?)</;say"$u
$1"

Run it with -E flag (and I suggest redirecting STDERR, as curl prints its progression on it):
perl -E '$u=chr(65+rand 26).sprintf("%06d",rand 1e6),$_=`curl oeis.org/$u`while!/tt>(.*?)</;say"$u
$1"' 2> /dev/null

Explanations:
-$u=chr(65+rand 26).sprintf("%06d",rand 1e6) generates a random name,
-$_=curl oeis.org/$u tries to retrieve the sequence,
-/tt>(.*?)</ checks if a tag <tt> is present on the page (it's only present on valid pages). If so, it stores the sequence's elements in $1. And if not, the while keeps looping.
-say"$u\n$1" outputs the sequence's name and its elements.

Do you know of an online interpreter where this works?

The easiest is to run it in a unix terminal... It does potentially a lot of http request, so I don't think there is an online interpreter capable of running it..

This actually fails for http://oeis.org/A280611 ...

@TrojanByAccident I don't think it does: replace $u=chr(65+rand 26).sprintf("%06d",rand 1e6) by $u=A280611 and you'll have the right output...

@Dada well, I'm no expert on Perl, and I can't run it, as I'm on Windows, but that page contains <tt> tags, so...

@TrojanByAccident The challenge says You may treat sequences with no given members (such as A280611 either as invalid or give just the sequence ID and nothing else. My code will output only the sequence name in that case, which follows the rules...

@Dada ah, sorry, as I said, I don't know much about Perl, I was just going by your explanation

Python 3, 221,208 bytes
from requests import*
from random import*
import re
r=randint
g=lambda x:re.findall(r'(?<=tt>)[^<]*',get('https://oeis.org/'+x).text)
a=''
while not g(a):a=chr(r(65,90))+str(r(0,999999))
print(a+'\n'+g(a)[0])

I'm sure there's a few tricks I missed (and requests is an external lib), but this was a fun first go at python code golf

Welcome to Code Golf, and nice answer! Could b be inlined? It only seems to be used in one place

Good catch! Was a holdover from when I had structured it slightly differently

JavaScript, 104 bytes
Because someone commented that this isn't possible in JS!
Must be run from the root directory of OEIS (consensus). Returns a 2-element array, with the first element being the sequence number and the second the sequence itself.
f=async n=>(s=/tt>[^<]+/.exec(await(await fetch(n+=Math.random()*1e6|0)).text()))?[n,s[0].slice(3)]:f`A`

To test it, go to the OEIS homepage (or any sequence's page), open your browser's console and copy & paste the code below:
f=async n=>(s=/tt>[^<]+/.exec(await(await fetch(n+=Math.random()*1e6|0)).text()))?[n,s[0].slice(3)]:f`A`
await f()

97 bytes
This should work and could maybe be golfed a little further but I'm on my phone so can't test it properly.
f=async n=>(s=/(?<=tt>)[^<]+/.exec(await(await fetch(n+=Math.random()*1e6|0)).text()))?[n,s]:f`A`

Count the URL you need to go, to avoid encoding program in URL

@l4m2, see the consensus I very deliberately linked to in order to avoid comments like yours. See also the consensus linked from that one.

The link isn't answered