text:
Mountain range numbers
Mountain range number
A number is a mountain range number if the inequalities satisfied by their consecutive digits alternate. In a way, looking at the number's digits should exhibit a /\/\/\... or a \/\/\/... pattern.
More formally, if our number n has \$k\$ digits
$$n = d_1d_2d_3\cdots d_k$$
then n is a mountain range number if
$$\begin{cases}d_1 > d_2 \\ d_2 < d_3 \\ d_3 > d_4 \\ \cdots \end{cases} \vee \begin{cases}d_1 < d_2 \\ d_2 > d_3 \\ d_3 < d_4 \\ \cdots \end{cases}$$
Your task
Given an integer with 3 or more digits, output a Truthy value if the number is a mountain range number or Falsy otherwise.
Input
A positive integer n with 3 or more digits, in any reasonable format, e.g.

Integer
String
List of digits

Test cases
Truthy
1324 -> Truthy
9191 -> Truthy
12121 -> Truthy
121212 -> Truthy
1212121 -> Truthy
19898 -> Truthy

Falsy
(Added another Falsy test case as per the comments, some answers might not cover the 4422 test case)
123 -> Falsy
321 -> Falsy
4103 -> Falsy
2232 -> Falsy
1919199 -> Falsy
4422 -> Falsy

This is code-golf so shortest answer in bytes wins! Standard loopholes are forbidden.

May we take input as a list of digits rather than an integer?

@RobinRyder yes you may

Dupe?

@AdmBorkBork this one has an input relaxation (k>=3); also the other challenge is so old that many of the answers there wouldn't be close to competitive on this one; I'd actually rather remove the old one as a dupe of this.

@Giuseppe That's what I was leaning towards as well, hence why I didn't hammer it. I have now just hammered the old one. Thanks!

Related with a source restriction

Suggested test case: [4,4,2,2] (or 4422 if you prefer).

@ChasBrown thanks for the suggestion. why would you say 4422 is a nice test case here?

R, 44 40 bytes
 crossed out 44 is still regular 44
-1 byte thanks to Giuseppe.
function(x,d=diff)all(d(sign(d(x)))^2>3)

Try it online!
Computes the differences of the signs of the differences of the input. These must all be equal to 2 or -2, i.e. the square must equal 4; checking that the square is >3 is sufficient.
If two consecutive digits are equal, there will be a 0 in the signs of differences, leading to a difference of signs of differences equal to 1 or -1. If three consecutive digits are in ascending or descending order, then the corresponding differences will be of the same sign, leading to a difference of signs of differences equal to 0. If neither of these occurs, the number is a mountain range number.

Old version (included as it might be golfable):
R, 44 43 bytes
-1 byte thanks to Giuseppe.
function(x)all(s<-sign(diff(x)),rle(s)$l<2)

Try it online!
Computes the signs of the differences of consecutive digits. Then verifies that

none of the signs are 0s (would correspond to 2 equal consecutive digits);
the runs of the signs are all equal to 1, i.e. no 2 consecutive signs are equal.

Good job, I like the usage of the run length function! +1

all(.^2>3) is a bit shorter, since we know that the absolute value of the diff of the signs is bounded between -2 and 2.

similarly, for your old version, you can do rle(s)$l<2 since we know there aren't zero-length runs.

+1 for the clever squaring approach.  You could have saved another 6 by using scan for input, but (as I acknowledged in my own answer) this doesn't seem particularly clever, and seems more like a sneaky trick...

05AB1E, 6 bytes
¥ü*0‹P

Try it online!
With truthy and falsy reversed, this would be 5 bytes:
¥ü*dZ

TIO

Good job! +1 Why would the truthy <> falsy reversal make it shorter?

@RGS 05AB1E has a single-byte built-in for x >= 0, but not for its negation x < 0.

I see, thanks for the tip.

I've used your answer to golf my answer in the same challenge with source restriction. If you want to post it as your own answer there I will of course revert back to my 7-byter and allow you to.

JavaScript (ES6),  35  33 bytes
a=>!a.some(p=v=>a*(a=p-(p=v))>=0)

Try it online!
Commented
a =>                // a[] = input list of digits,
                    //       re-used to store the last difference
  !a.some(          //
    p =             // initialize p to a non-numeric value
    v =>            // for each v in a[]:
      a * (         //   multiply a by
        a =         //     the new value of a defined as
          p -       //       the difference between p and
          (p = v)   //       the new value of p, which is v
      )             //
      >= 0          //   the test fails if this is non-negative
  )                 // end of some()

+1 for your weird expression used. I haven't been around for a long time but I keep noticing you like to post JS answers! JS does incredibly well at golfing, does it not?

Also, could you explain a bit what is going on in x=p=v=>x*(x=p-(p=v))>=0 ?

@RGS We assign the arrow function v=>... to both x and p. Because this is non-numeric, the arithmetic operations in which these values are involved will result in NaN which is neither >=0 or <0. So the first 2 iterations will always be falsy, which is the expected behavior.

@RGS Initializing variables this way in the callback of a loop is a rather common trick in JS (err... I mean golfed JS, obviously). This also works if we want them to be zero'ish in some bitwise operations.

ah I get it! Thanks for the explanation!

Japt -!, 7 bytes
Takes input as a digit array.
äÎä* dÄ

Try it

Don't flags usually add up to the byte count?

Your code currently gives a truthy value for 122, which is not a mountain range number.

@RGS Flags used to be part of the byte count indeed, but now there's consensus that they can be used for free (Personally I don't like that, but...)

@LuisMendo They can be used but they count as a different language.

@RGS, fixed. And if you'd followed the link I very deliberately include with the flags in all my solutions ...

@Shaggy you are absolutely right! But I didn't even notice the link on the flags was different from the link on the language name :/ +1 now that the answer is right :)

Jelly, 7 6 bytes
A benchmarking solution.
A monadic link taking as input the list of digits
I×Ɲ<0Ạ

You can try it online or verify all test cases.
I         Take the forward differences
  Ɲ       and for each pair,
 ×        multiply them together.
   <0     Check if those are below 0.
      Ạ   Check if this array of booleans only contains Truthy values.

-1 byte thanks to @79037662

I don't know Jelly, but could it be shorter to simply check for negativity, instead of taking the sign and then checking it's equal to -1?

@79037662 yes it would! Thanks for the alert!

Nice answer. However, in general I’d consider holding back from answering your own question for a few days; as far as I understand that’s the general etiquette here.

@NickKennedy oh sorry, will do so for the next challenges. Thanks for letting me know.

@RGS no worries! And nice challenge.

Haskell, 57 55 47 44 42 bytes
all(<0).z(*).z(-)
z f(x:s)=zipWith(f)s$x:s

Try it online!
Takes input as a list of digits.

-2 by swapping the order of s and x:s
-8 by using a different helper function
-3 by using partial application and pointfree code
-2 by excluding f= from the submission (which I didn't realize was allowed :P)

xnor improved my answer using >>=.

Good job on this one! I like Haskell :D +1

APL+WIN, 17 15 12 11 bytes
5 bytes saved thanks to Jo King & 1 byte thanks to Bubbler. Turning into a real team effort!
Prompts for list of digits:
×/0>2×/2-/⎕

Try it online! (Dyalog Classic)

Good job on this one! +1

Is there a point to assigning the input to n?

Jo. No! There is no point. It was left over from an earlier version. Old age :(  Thanks for spotting it.

I believe there's no point to the 1= either, unless APL+WIN has a different result for 0>. Oh, and the second × too!

@JoKing Thanks again. Same excuse I am afraid!

The minus right after the second ×/ can be removed, since the sign of pairwise product is the same with and without it.

Python, 47 bytes
f=lambda a,b,*l:l==()or(a-b)*(b-l[0])*f(b,*l)<0

Try it online!
Takes input splatted like f(1,2,3,4). Same idea as my second Haskell answer.

Ah wow, you guys keep surprising me every time! +1

Husk, 7 bytes
Λ<0Ẋ*Ẋ-

Try it online!
Algorithm taken from the APL answer.
Explanation
Λ<0Ẋ*Ẋ-
     Ẋ- subtract pairs of consecutive elements
   Ẋ*   multiply pairs of consecutive elements
Λ       return truthy value if all elements are:
 <0     lesser than 0

Jelly, (5?) 6 bytes
5 if we may invert the truthy/falsey output (strip the trailing ¬).
IṠIỊẸ¬

Try it online!

Really clever solution! +1 it took me a bit to understand why you wanted to use the Ị after the second I but then I realized you were building the opposite result

Fun fact, the codepoints of this answer themselves (in Jelly encoding) are also a mountain/dale (same as this answer on the source-restriction challenge).

Bash, 147 144 bytes
M(){
a=${1:0:1}
d=x
i=1
while [ $i -lt ${#1} ]
do
b=${1:$i:1}
case $d$((a-b)) in
[ux]-*)d=d;;*0|u*|d-*)return 1;;*)d=u;;esac
a=$b
let i++
done
}

Try it online!
I seem to like trying shell submissions, and learned some bash-isms in golfing this one.
$((a-b)) is equivalent to $(( $a - $b )) -- apparently you don't need the $ inside a $(( )) construct.
There is a ++ operator, works in $(( )) and in let
Subtracting letters is accepted, strangely.  One of my samples in the TIO reads "xy", and apparently $((a-b)) evaluates a to x, and then variable x to an empty string and the empty string as numeric zero, and comparable for b and y.  If I set x and y in the environment, those values are used.
Edit: -3 bytes by not putting whitespace after ;;, thanks to S.S.Anne

+1 nice submission!

@RGS I think it is a very nice touch that you are commenting on (and upvoting) each answer.  Thank You.  +1

Thanks David! I just want to acknowledge every submission ;)

Do you need the newlines in case and while?

@S.S.Anne  You need separation of the in and do tokens from the surrounding tokens.  It can be space or newline or semicolon (though before "do" doesn't allow space).  For the case statement, it can be the optional ( as well.  Where you do not need separation is after the ;;.  Saved three bytes.  Thank You.

No, sorry, those are syntax errors.

@S.S.Anne  My output looks like my input because the trailer code deliberately matches the format from the original sample data.

exit instead of return and omitting the newlines before and after brackets won't work. I thought I was reading the output but I was reading the input, sorry.

@S.S.Anne I tested it too, and must have done the same thing.  Reverted back to 144.  Ah well.

Haskell, 37 bytes
all(<0).g(*).g(-)
g=(=<<tail).zipWith

Try it online!
Takes the zipWith-based answer of 79037662 and generalizes out the pattern of
g(?) = \s->zipWith(?)(tail s)s

that applies the operator (?) to pairs of adjacent elements. This is shortened to the pointfree g=(=<<tail).zipWith.
We first apply g(-) to the input to take differences of consecutive elements, then g(*) to take products of those consecutive differences. Then, we check that these products are all negative, which means that consecutive differences must be opposite in sign.

Haskell, 40 bytes
f(a:b:t)=t==[]||(a-b)*(b-t!!0)<0&&f(b:t)

Try it online!
The idea is a bit clearer to see in the slightly less-golfed form:
42 bytes
f(a:b:c:t)=(a-b)*(b-c)<0&&f(b:c:t)
f _=1>0

Try it online!
We check that the first three digits (a,b,c) have the a->b steps and b->c steps going opposite directions by checking that the differences a-b and b-c have opposite signs, that is, their product is negative. Then we recurse to the list without its first element until the list has fewer than 3 elements, where it's vacuously true.
An alternative to check suffixes directly turned out longer:
43 bytes
f l=and[(a-b)*(b-c)<0|a:b:c:t<-scanr(:)[]l]

Try it online!

Good job, as per usual. +1 because I see functions I know used in weird ways

Nice answer, I didn't know about =<<.

@79037662 And nice method from you! It looks like you converged to basically that same answer. I didn't think of doing this problem mostly pointfree -- I thought it would be long compared to the explicit recursion.

Python 2, 65 58 bytes
lambda A:all((x-y)*(y-z)<0for x,y,z in zip(A,A[1:],A[2:]))

Try it online!

Nice solution with the zip function +1 and this one handles gracefully the 1 and 2 digit cases (probably not the only answer here doing that, but this one I can easily spot ;) )

Ruby -nl, 57 41 bytes
Replaces each character in the input string with the cmp comparison (<=> in Ruby) between it and the next character $'[0] (if there is no next character, remove the character instead). Then, check if the resulting string consists entirely of alternating 1 and -1.
gsub(/./){$&<=>$'[0]}
p~/^1?(-11)*(-1)?$/

Try it online!
Old Solution, 57 bytes
Check for duplicate consecutive numbers first by checking if the input string matches /(.)\1/ and inverting it. If no such pairs are found, replace each character with true or false based on whether its cmp style comparisons (<=>) to the character before it $`[-1] and after it $'[0] are not equal. (If there is no character before or after it, the <=> returns nil, which is definitely not equal to whatever the other character comparison returns.) Finally, it checks if the result does not contain an f (meaning no falses were returned).
p ! ~/(.)\1/&&gsub(/./){($`[-1]<=>$&)!=($&<=>$'[0])}!~/f/

Try it online!

Really cool answer +1 !

Doesn't work for 212

@GB found the regex error. Fixed for no byte count change.

Brachylog, 9 bytes
¬{s₃.o↙Ḋ}

Try it online!
Takes a list of digits as input.
Explanation
¬{      }       It is impossible…
  s₃            …to find a subsequence of 3 elements…
    .o↙Ḋ        …which is already ordered

Slight subtility: o↙Ḋ is used to check whether the digits are increasing or decreasing. By default, o (which is the same as o₀) is for increasing order, and o₁ is for decreasing order. By using o↙Ḋ (Ḋ being an integer between 0 and 9), we check that the whole predicate is impossible for o₀, or o₁, or o₂, …, o₉. o₂ to o₉ are not implemented and thus will fail, which doesn’t impact the program as a whole.
If true. is an acceptable falsy value, and false. an acceptable truthy value (which I don’t think it should be), then you should be able to remove these 3 bytes: ¬{…}.

Thanks for your submission! And I agree with you, using "false" as a Truthy value and vice versa is questionable :p it looks like a lot of answers would've benefited from that, though. +1

Excel (Insider build ver. 1912), 122 Bytes
A1 'Input
B1 =SEQUENCE(LEN(A1))
C1 =MID(A1,B1#,1)
D1 =SIGN(IF(NOT(B1#-1),C1-C2,C1#-INDEX(C1#,B1#-1)))
E1 =(SUM(D1#)=D1*ISODD(LEN(A1)))*PRODUCT(D1#) 'Output

Returns ±1 (truthy) or 0 (falsy)
Explanation (can add more detail if people are interested)
B1 =SEQUENCE(LEN(A1)) ' Generates a spill array from 1 to the length of the input
C1 =MID(A1,B1#,1) ' Splits characters into rows. Using each value in the spill array B1#
                  ' as a charcter index
D1 =SIGN(IF(NOT(B1#-1), ' Choose different value on the first cell
           C1-C2, ' Use the opposite of the first difference between digits
           C1#-INDEX(C1#,B1#-1))) ' get the difference between each digit and the previous
E1 =(SUM(D1#)=D1*ISODD(LEN(A1))) ' Sum the digit differences, if the
                                 ' input length is even check if 0, else check if equal to
                                 ' thefirst row of the differences
       *PRODUCT(D1#))            ' ensure there aren't any repeated digits

Tests

Hey there, thanks for your Excel submission! Very unusual :D +1

J, 15 bytes
[:*/0>2*/\2-/\]

Try it online!
-7 bytes thanks to RGS's technique

Nice submission :) what does RGS's technique mean? +1

Meaning the logic is essentially the same as yours, translated into J, and was shorter than the initial approach i tried

Charcoal, 29 27 bytes
ＵＭθ⁻ι§θ⊕κＵＭθ×ι§θ⊕κ›⁰⌈…θ⁻Ｌθ²

Try it online! Link is to verbose version of code. Takes input as a list of digits and outputs as a Charcoal boolean (- for a mountain range number, otherwise no output). Explanation:
ＵＭθ⁻ι§θ⊕κ

Take consecutive differences (cyclic, so includes difference between last and first digit).
ＵＭθ×ι§θ⊕κ

Take consecutive products (again, cyclic).
›⁰⌈…θ⁻Ｌθ²

All results bar the last two must be negative.

Interesting submission! +1

Python 3, 101 \$\cdots\$ 103 94 bytes
Added 13 bytes to fix error kindly pointed out by @ChasBrown.
Saved 9 bytes thanks to @ChasBrown!!!
def f(l):x=[a<b for a,b in zip(l[1:],l)];return all(a!=b for a,b in zip(x[1:]+l[1:],x[:-1]+l))

Try it online!

Interesting submission! +1

94 bytes

@ChasBrown Nice one zip auto truncates the larger - thanks! :-)

Burlesque, 22 bytes
XX2COqcm^m2COPD{0.<}al

Try it online!
XX      # Explode into digits
2CO     # 2-grams ("abc"->{"ab" "bc"})
qcm^m   # Compare each via UFO operator
2CO     # 2-grams
PD      # Product
{0.<}al # All less than 0

Nice answer. It looks kind of funny +1 can't you save some bytes by taking a list of digits as input?

It makes very little difference, as I'd need to parse them with ps or pe anyway. This sneakily operates on strings and relies on ASCII comparison.

K (ngn/k), 14 bytes
&/0>2_*':-':$:

Try it online!
$: as string
-': subtract (as ascii codes) each prior; implicit 0 before first
*': multiply by each prior; implicit 1 before first
2_ drop first 2 elements
&/0> all negative?

The TIO link has 16 bytes? Is it 'cuz you assign your function to f? +1 for the good work :D

@RGS thanks. yes, by convention function naming is not counted unless it's used for (non-anonymous) recursion. here i use the name f only for testing.

Java (JDK), 95 83 bytes
p->{int i=0,j=1;for(;p.length>-~++i;)j=(p[i-1]-p[i])*(p[i]-p[i+1])<0?j:0;return j;}

Try it online!
Thanks to all in the comments for improvements - especially bit-shifting which I never would have thought of!!

Thanks for your submission! +1 for you. You can save 7 bytes by using 0/1 as Falsy/Truthy values!

Thanks! I hadn't thought to do that

you may be able to shave 2 more bytes by returning nothing for Falsy. I think that is still reasonable.

An index shift could possibly save three further bytes.

C (gcc), 59 bytes
d;m(int*s){for(d=*s/s[1];s[1]&&s[1]/ *s-d;d^=1)s++;s=s[1];}

Takes as input a wide string of digits and returns zero if that number is a mountain range number.
-12 bytes thanks to ceilingcat!
Try it online!

@ceilingcat Thanks!

+1 for the cool submission, but can you help me understand how the return here works?

@RGS Closest I can find is https://codegolf.stackexchange.com/a/106067/89298. It exploits GCC's behavior when compiling without optimization in which temporary results are stored in the return register.

R, 34 bytes
all((d=diff(scan()))[1]*d*.5:-1>0)

Try it online!
Alternately reverses signs of all differences, and then multiplies them all by first difference: mountain range sequences will all be positive
Would be 40 bytes if defined as a function instead, so apologies to Robin with whom this would tie without the scan for input.

Scala, 63 bytes
_.sliding(3).forall(t=>t(0)<t(1)&t(1)>t(2)|t(0)>t(1)&t(1)<t(2))

Checks whether for all sliding triplets the center is strictly larger (or strictly smaller) than the previous element and the next element.
Try it online!


text:
Give me Triangles
Given an integer n>0, write a program that will output an "isosceles" Triangle out of #'s of height n.
Examples:
n=3
  #
 ###
#####

n=1
#

n=5
    #
   ###
  #####
 #######
#########

This would be invalid:
#
###
#####
#######
#########

Are leading and trailing newlines allowed?

@S.S.Anne yes, that would be fine.

How is this not a duplicate? XD

May we use another character besides #?

can we have an extra leading space on each line?

Which isosceles triangle permitted?  For the input 3 is the triangle shown the only allowed triangle? Could you be a little more specific with you challenge?

To modify @PostRockGarfHunter’s query, is it a requirement that each row have exactly two characters more than the previous?  If it were N+4, it would be just as much an isosceles.

Related: Diamond creator +

Very Closely Related: Code Golf Christmas Edition: How to print out a Christmas tree of height N

Charcoal, 5 bytes
Ｇ↗↘Ｎ#

Try it online! Link is to verbose version of code. Explanation: The Ｇ draws a filled polygon, where the ↗↘ specifies the sides to follow (the polygon is automatically closed) and the Ｎ inputs the size and the # specifies the fill character. Using Ｇ↖↙Ｎ# also works of course.
Alternate solution, also 5 bytes:
Ｇ^Ｎ#⟲

Try it online! Link is to verbose version of code. Explanation: The ^ is a shortcut for two diagonal directions ↘↙ (sadly there is no shortcut for the above diagonals in the required order as < is ↘↗ and > is ↙↖) so the triangle has to be rotated into position using ⟲.

These are quite satisfying.

PowerShell, 36 bytes
"$args"..1|%{" "*--$_+"#"*++$i;$i++}

Try it online!
Loops from input $args down to 1, each iteration constructing a string consisting of the appropriate number of spaces plus a number of # marks that starts at 1 and increments by 2 every iteration. Those strings are left on the pipeline, and implicit output gives us newlines for free.

C (gcc), 104 \$\cdots\$ 72 71 bytes
Saved 5 11 bytes thanks to S.S.Anne!!!
Saved 6 bytes thanks to gastropner!!!
Saved a byte thanks to Stephen!!!
i;j;f(n){for(i=0;i++<n;)for(j=0;j<i*2;)printf(j++?"#":"\n%*s",n-i,"");}

Try it online!

84 bytes

@S.S.Anne Nice one - thanks! :-)

It's 84, not 85. Saves 5 bytes.

Anyway, 78 bytes with this comment.

@S.S.Anne Sorry must have mixed up the 4 and 5 while editing on my phone. :-(

@S.S.Anne Good play, was wondering about that myself - thanks again! :-)

72 bytes

@gastropner Clever contraction - thanks! :-)

++i<=n -> i++<n to save a byte

@Stephen Nice one - thanks! :-)

Python 2, 46 bytes
def f(n,i=1):1/n;print" "*~-n+"#"*i;f(n-1,i+2)

Try it online!
Basically the same solution as Jonathan Allan, but a function that prints and terminates with error, if that's allowed here. The 1/n is used to halt execution where n=0. Maybe there's a way to do that shorter by stuffing in a /n or %n somewhere.

05AB1E, 8 bytes
Multiple 8 bytes programs are possible:

·ÅÉ'#×.c: Try it online or verify all test cases.
L'#×€û.c: Try it online or verify all test cases.
L·<'#×.c: Try it online or verify all test cases.
'#×ηj€û»: Try it online or verify all test cases.

Explanations:
·         # Double the (implicit) input-integer
          #  i.e. 3 → 6
 ÅÉ       # Pop and push a list of all positive odd values below this doubled value
          #  → [1,3,5]
   '#×   '# Repeat "#" that many times as string
          #  → ["#","###","#####"]
      .c  # Centralize this list (which implicitly joins by newlines)
          #  → "  #\n ###\n#####"

L         # Push a list in the range [1, (implicit) input-integer]
          #  i.e. 3 → [1,2,3]
 '#×     '# Repeat "#" that many times as list
          #  → ["#","##","###"]
    €û    # Palindromize each
          #  → ["#","###","#####"]
      .c  # Centralize this list (which implicitly joins by newlines)
          #  → "  #\n ###\n#####"

L         # Push a list in the range [1, (implicit) input-integer]
          #  i.e. 3 → [1,2,3]
 ·        # Double each value
          #  → [2,4,6]
  <       # Decrease each by 1
          #  → [1,3,5]
   '#×.c '# Same as the first answer above

'#×      '# Repeat "#" the (implicit) input-integer amount of times as string
          #  i.e. 3 → "###"
   η      # Take the prefixes of that string
          #  → ["#","##","###"]
    j     # Pad spaces to each to make the total length equal to the (implicit) input
          #  i.e. 3 → ["  #"," ##","###"]
     €û   # Palindromize each
          #  → ["  #  "," ### ","#####"]
       »  # Join by newlines
          #  → "  #  \n ### \n#####"

For each of these programs the resulting string is then output implicitly (with trailing newline).

There’s also Lx<'#×.c, for an almost ASCII-only 8-byter.

@Grimmy True. I saw that approach as well here in this related challenge. I'm sure there are more equal-byte alternatives tbh.

@Grimmy Here another 8-bytes alternative (this time without centralize builtin): '#×ηj€û». :)

Ruby, 46 43 bytes
f=->g{g.times{|n|puts" "*(g-n)+?#*(2*n+1)}}

Try it online!

-3 thanks to IMP1

You could use g.times{} instead of (1..g).map{} to save 3 bytes (you'll need to change 2*n-1 to 2*n+1 as well).

@IMP1 Nice tip, thanks.

use p instead of puts

@canhascodez That makes it print the quotation marks, which isn't valid as far as I know.

@79037662 D: you're right

J, 19 18 bytes
' #'(#~|.,.1++:)i.

Try it online!
-1 byte thanks to FrownyFrog
Let's do 3:

i. Produces:
0 1 2

|.,.1++: - Reverse |. produces 2 1 0 and 1 + the double +: produces 1 3 5.  Then we zip ,. those together:
2 1
1 3
0 5

' #'#~ copies each character in the 2-character string # (space and pound) according to the mask specified above, and pads the end of the first two rows with spaces, so every row is 5 characters:
  #
 ###
#####

save one: ' #'(#~|.,.1++:)i.

Nice catch.  Thanks as always!

cQuents, 18 bytes
|
&@ (n-$)~@#(2$-1

Try it online!
Explanation
|
                   terms in sequence are separated by newline
&                  output first n terms in sequence
                   each term is:
 @                 " " *
   (n-$)                 n - index
        ~                          concat
         @#                               "#" *
           (2$-1                                2 * index - 1

APL+WIN, 23 bytes
Prompts for integer:
(-⌽⍳n)⌽⊃(1+2×⍳n←⎕)⍴¨'#'

Try it online! Courtesy of Dyalog Classic

MATL, 11 bytes
:&<~P2&ZvZc

Try it online!
How it works
Consider input 3 as an example.
:      % Implicit input. Range
       % STACK: [1 2 3]
&<     % Pairwise less-than comparison
       % STACK: [0 0 0;
                 1 0 0
                 1 1 0]
~      % Negate, elementwise
       % STACK: [1 1 1;
                 0 1 1;
                 0 0 1]
P      % Flip vertically
       % STACK: [0 0 1;
                 0 1 1;
                 1 1 1]
2&Zv   % Reflect horizontally, without repeating last column
       % STACK: [0 0 1 0 0;
                 0 1 1 1 0;
                 1 1 1 1 1]
Zc     % Replace nonzeros by '#' and zeros by ' '
       % STACK: ['  #  '
                 ' ### ';
                 '#####']
       % Implicit display

Python 2, 48 bytes
n=input();v=1
while n:n-=1;print' '*n+'#'*v;v+=2

Try it online!

A fun 49 with an extra space of padding is:
s=' '*input()+'#'
while'#'>s:print s;s=s[1:]+'##'

Try that

In case the extra leading spaces aren't allowed, you can move the n-=1 to the start of the loop to get rid of them. I haven't found anything shorter than your solution; I suspect it's optimal.

Red, 78 76 bytes
func[n][s: copy"#"repeat i n[print pad/left s n + i - 1 append s"##"take s]]

Try it online!
Alternative using Red's parse:
Red, 77 bytes
func[n][s: to""pad/left"#"n loop n[parse s[(print s take s)to"#"insert"##"]]]

Try it online!

k4 23 bytes
-6 thanks to streetster!
{(-x+!x)$(1+2*!x)#'"#"}

29 bytes previous solution+explanation:
{(-x+!x)$|:'x#x("##",)\"# "}

{                          } /lambda with implicit arg `x`
              x("##",)\"# "  /function composition - cumulatively join (,) "##" to "# " x times and return intermediate results ("# ";"### ";"##### ") etc
            x#               /take x items
         |:'                 /reverse each
 (-x+!x)                     /enumerate x and subtract x from each (x=3 -> -3+0 1 2)
        $                    /pad, left-pads when left arg is negative

23 bytes - {(-x+!x)$(1+2*!x)#'"#"}

@streetster, thanks. updated!

Rule 222, 1 byte (noncompeting)
#

Wolfram codes describe a family of celular automata. While most behave in very simple ways, some of them show very complex behaviour. Rule 110 is even Turing complete.
Rule 222 is one of the "simple" ones. After n generations, it produces a triangle of n levels, as specified in the challenge. A synonymous cellular automata in this case is Rule 254.

Jelly, 11 bytes
>þ`UŒBị⁾ #Y

Try it online!
A full program that takes an integer argument and prints a triangle. If a monadic link returning a list of Jelly strings is acceptable, the final byte can be saved for 10 bytes.
Explanation
>þ`         | Outer table using greater than and 1..n as both left and right argument
   U        | Reverse order of inner lists
    ŒB      | Bounce inner lists (i.e. repeat each one in reversed order without duplicating the final character)
      ị⁾ #  | Index into [" ", "#"]
          Y | Join with newlines

Python 3, 58 bytes
def f(n,i=1):print((n-i)*' '+(2*i-1)*'#');n>i and f(n,i+1)

Try it online!

@Stephen You should write an answer -- it's considered a different language.

C (gcc), 75 70 bytes
i,m;f(n){m=n*2;for(i=m*n;i--;)putchar(i%m?abs(i%m-n)<n-i/m?35:32:10);}

Try it online!

Burlesque, 30 bytes
2|*J' j|*iSj'#j|*iT2enq\[Z[unQ

Try it online!
Not left aligned, but functionally an isosceles triangle. Takes input as N.
2|*    # N*2
J      # Duplicate this number
' j|*  # 2N spaces
iS     # [2N..1] spaces as list
j      # Swap back
'#j|*  # 2N hashes
iT     # [1..2N] hashes as list
2en    # Take each odd
q\[Z[  # Zip together, and concatenate
un     # Add new lines between each element
Q      # Pretty print

Haskell, 91 72 62 bytes
(1!)
_!0=""
i!n=r n ' '++r i '#'++'\n':(i+2)!(n-1)
r=replicate

-10 bytes thanks to @Laikoni.
You can try it online!

"\n"++ can be '\n':. Defining f with two arguments instead of one tuple as argument would save some more bytes, and defining f as infix operator would be even shorter. Finally, the g= is usually not counted by convention. All together 62 bytes: Try it online!

@Laikoni all clever tricks! Thanks for the tips :)

@Laikoni what is the -cpp flag for?

@RGS Apparently it lets you put the g= outside the byte counted part.

Python 2, 54 bytes
n,i=input(),1
exec"print(n-i)*' '+(2*i-1)*'#';i+=1;"*n

Try it online!
Based on Jitse's Python 3 solution.

Japt -R, 9 bytes
õî'# mê û

Try it
Or 7 bytes if we can choose which character to use.
õ_î¬êÃû

Try it

Haskell, 57 bytes
r=replicate
f x=unlines[r(x-n)' '++r(2*n-1)'#'|n<-[1..x]]

Try it online!
The unlines function is often helpful for ASCII art problems.

Japt -R, 9 bytes
ÇÑÄ ç'#
û

Try it

MathGolf, 18 17 bytes
╒_'#*mñ\x *^my ═n

Try it online.
Explanation:
╒                  # Push a list in the range [1, (implicit) input-integer]
                   #  3 → [1,2,3]
 _                 # Duplicate this list on the stack
  '#*             '# Repeat "#" the values amount of time as string
                   #  → ["#","##","###"]
     mñ            # Palindromize each
                   #  → ["#","###","#####"]
       \           # Swap to get the duplicated [1, input] list at the top again
        x          # Reverse this to [input, 1]
                   #  → [3,2,1]
          *        # Repeat a space the values amount of time as string
                   #  → ["   ","  "," "]
           ^       # Zip the two lists together
                   #  → [["#","   "],["###","  "],["#####"," "]]
            my     # Join each inner pair together
                   #  → ["#   ","###  ","##### "]
               ═   # Pad leading spaces to each string to make them all of equal length
                   #  → ["  #   "," ###  ","##### "]
                n  # And join this list by newlines
                   #  → "  #   \n ###  \n##### "
                   # (after which the entire stack is output implicitly as result)

PHP, 65 64 62 bytes
for($j=$argn+$i=1;--$j;$i+=2)printf("%{$j}s%'#{$i}s\n",'','');

Try it online!
Muuuuch better version with string formatting. I knew there was something, PHP is a templating language after all.. It couldn't be that bad for this kind of job!!
EDIT: saved 1 byte and removed the extra leading space by moving $i++ to the printf
EDIT2: saved 2 bytes with new strategy by @GuillermoPhillips (thanks!)
ORIGINAL NAIVE ANSWER:
PHP, 104 bytes
for($t='#';$i++<$argn;$s.=' ',$t="#$t#"){$r[$i*2]="$t\n";$r[($argn-$i)*2+1]=$s;}ksort($r);echo join($r);

Try it online!

$i is always multiplied by 2, maybe something there?

@GuillermoPhillips Thanks but I was already on a much better way with printf.. If you have something for this one I'd be glad

One with 62 bytes: Try it online

@GuillermoPhillips Nice one! the strategy is different enough to post it as another answer if you want.. Or else I'll credit you ;)

Nah I don't want to steal the glory, it's based on yours anyway, never would have come up with it from scratch.

Canvas, 6 bytes
｛#×］±│

Try it online.
Explanation:
｛        # Map over the range [1, input]:
  #×      #  Repeat "#" the value amount of times
    ］±   # After the map: interpret the array as a 2D string, and reverse it
       │  # And palindromize it horizontally with 1 overlap
          # (after which it is output implicitly as result)

Java 8, 151 128 bytes
p->{for(int c=1;p>0;c+=2)System.out.println(new String(new char[p--]).replace('\0',' ')+new String(new char[c]).replace('\0','#'));}
TIO
See also JDK 13 answer

Hi, welcome (back) to CGCC! Here is the TIO of your current answer. In addition, you can use a leading # to make your first line a title (so #Java 8, 151 bytes in this case). As for golfs: 1) since you're using Java 8, you can use a lambda, so void t(int p) can become p->. 2) int c=1;while(p>0){...;p--;c+=2;} can become for(int c=1;p>0;c+=2)...; and change the p-1 to --p. 3) In addition, using Java 11+, you can use "#".repeat(int) instead of new String(new char[int]).replace('\0','#'). In total: 76 bytes.

In case you haven't seen them yet, tips for golfing in Java and tips for golfing in  might both be interesting to read through. PS: Your current answer is 150 bytes, not 151?

Icon, 73 bytes
procedure f(n,i)
/i&i:=1
write(right(repl("#",i),n+i))
n>1&f(n-1,i+2)
end

Try it online!

Stax, 9 bytes
é─C:UÅ≤┘.

My first Stax answer. :)
Try it online or try it online unpacked (10 bytes).
Explanation (of the unpacked version):
'#*        '# Repeat "#" the (implicit) input-integer amount of times as string
            #  i.e. 3 → "###"
   |[       # Get the prefixes of this string
            #  → ["#","##","###]
     |>     # Padding leading spaces up to a length equal to the longest string
            #  → ["  #"," ##","###"]
       m    # Map over each line:
        |p  #  Palindromize the line
            #   → ["  #  "," ### ","#####"]
       m    # And the map also prints each line with trailing newline afterwards
            #  → "  #  \n"
            #    " ### \n"
            #    "#####\n"

Haskell, 52 bytes
f x=do n<-[1..x];'\n':([n..x]>>" ")++([2..2*n]>>"#")

Try it online!

JDK 13, 94 76 bytes
p->{for(int c=1;p>0;c+=2)System.out.println(" ".repeat(p--)+"#".repeat(c));}
TIO
With thanks to Kevin for some suggestions in the comments!

Ah, hadn't seen you posted a second answer. This can be 76 bytes as mentioned in my comment on your Java 8 answer.

Retina 0.8.2, 21 bytes
.+
$*#
#
¶$.'$* $`#$`

Try it online! Link includes test cases. Output includes both leading and trailing newlines (but that helpfully separates the test cases!) Explanation:
.+
$*#

Convert the input to that many #s.
#
¶$.'$* $`#$`

For each #, output a new line, then as many spaces as there are #s remaining, then the #s so far, mirrored.

JavaScript V8, 48 bytes
f=(i,s=`#
`)=>i?(' '.repeat(--i)+s)+f(i,'##'+s):''

Test cases:

f=(i,s=`#
`)=>i?' '.repeat(--i)+s+f(i,'##'+s):''

console.log(f(1))
console.log(f(2))
console.log(f(3))
console.log(f(4))
console.log(f(5))
console.log(f(6))

Ruby, 42 bytes
Copying the Python answer from xnor.

f=->n,i=1{1/n;puts" "*~-n+?#*i;f[n-1,i+2]}

Try it online!

source: Stack Exchange

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

sort: votes


text:
Compress 8 bits to 6 when certain bit patterns will never occur
Consider an eight bit number in which an even position bit will never be 1 if one of its neighbors is 0 (considering MSB and LSB as neighbors). There are fewer than 64 such numbers, so there is at least some reversible mapping of them to 6 bit numbers.
Your task is to write a pair of functions (or code blocks or your language equivalent), one of which takes an 8-bit number and returns a 6-bit number, the other which reverses the process. "Numbers" here can be literal numbers or a list of booleans or even a string of Xs and Os.
Put another way, the following bit patterns will never occur:
......01
.....10.
....01..
...10...
..01....
.10.....
01......
0......1

PS: I'd really love to see an answer in Lua :)
PPS: Bonus imaginary internet points if you can pack the 47 valid values into a 6-bit number with a maximum of value of 47

what's the relationship with lua? the challenge looks lang-netural

@ngn I actually need a solution in lua for a real project. I can port one of the other answers, but I figured I'd at least give a small nudge in that direction in case it inspired anyone

just make a lookup table... codegolf solution will be terrible

@Sopel the codegolf solution is to make a lookup table :P

@JohnDvorak Although true, it's probably both easier and less confusing to have a hard-coded look-up table (with some comments explaining it) in the real-life Lua project than anything a code-golf answer would come up with. Code-golf is all about saving bytes, so things like readability, comments, coding standards, getting rid of warnings/errors, performance, and more are all irrelevant as long as we can save a single byte and it still gives the same results. If a byte can be saved but in the process the execution time goes from 0.1 sec. to 10 min., we don't care, because: yay, 1 less byte! ;)

Is the upper bound of $48$ for the bonus another constraint of your project? Otherwise, why not $46$ (0-indexed) or $47$ (1-indexed)?

@Sopel While I do agree in this particular case, it may occasionally be more efficient both size-wise and speed-wise to do some bitwise magic instead of using a lookup table if the code is executed on a platform where accessing memory is much slower than using the CPU registers. (It was especially true back in the day when there was no CPU cache.)

@Arnauld I would be REALLY surprised if this has a reasonable solution using only bitwise arithmetic

@Sopel the environment I will be applying this algorithm to has limits on code size (and code tokens) that are far more restrictive than its limits on memory or runtime, so constructing a lookup table (as many of the answers do) is a great solution for me.

@Arnauld 48 as a maximum was a mistake, it should have been 48 values and thus a max of 47 (zero indexed) all along. The motivation being to save another "half bit" that I could use to store additional information. Squeezing out a single additional value (to get to 47 total values instead of 48) would be almost useless to me.

@Sopel: Keep in mind that some modern x86 CPUs include things like the pext parallel bit-extract instruction.  I think a LUT is still probably best for this complicated a pattern, especially if you use it often enough to be likely to be in L2 cache at least, or for OoO exec to hide most of the cache miss latency, but It's harder to rule out bit-hack being possible.  (Unfortunately only Intel CPUs have efficient implementations; AMD's pext is pretty slow.  And also even modern Pentium/Celeron chips lack BMI2, making baseline BMI1/2 no closer :(

This is basically xor 170 and list unique values in base phi... but I don't know an esolang that has the right builtin.

@S.S.Anne point rewards for stretch goals are discouraged. Either they end up being irrelevant for good score, or mandatory.

Python, 60 bytes
l=[n^170for n in range(256)if n&n*2<1]
l.index,l.__getitem__

Try it online!
l.index compresses and l.__getitem__ decompresses. We just make a list l of all valid patterns as 8-bit numbers, except we ignore wrapping around, which still leaves 55 options which fits in 6 bits.
A useful idea is that if we flip the bits at even positions, which ^170 does, then the condition just becomes "no two 1's are (cyclically) adjacent". This is easy to check without wrapping around using the bit condition n&(n*2)==0, or shorter, n&n*2<1.
Fibonacci numbers
Binary strings with no adjacent ones have interesting connections to Fibonacci numbers. The number of such 8-bit numbers is 55, a Fibonacci number, following the general result. Moreover, Zeckendorf's Theorem tell us that each number can be uniquely expressed in the Fibonacci base without using a pair of adjacent ones, that is as a sum of distinct Fibonacci numbers without two consecutive ones, as these can be merged into the next Fibonacci number.
Perhaps a base conversion to the Zeckendorf Representation can be used for a less brute-force answer than the one here. We've had challenges to convert from and to the Zeckendorf representation, which could be used as the basis of a decoder-encoder pair.
Bonus: 64 bytes
For imaginary internet points, we can tweak the algorithm to accounts for cyclically adjacent ones, so as to limit the compression to 48 valid bit patterns from 55. We do this by modifying the bit check to n&n*2%255<1, at the cost of 4 extra bytes.
64 bytes
l=[n^170for n in range(256)if n&n*2%255<1]
l.index,l.__getitem__

Try it online!
The modulo 255 changes the bit-shift n*2 to a cyclic shift
abcdefgh -> bcdefgha

by moving the post-doubling place value of 256*a to just a. This is, except for n=255, which where n*2%255 is zero, giving a false positive at 255^170=85. But, since the bonus for imaginary internet points gives use one spare slot, with 48 slots for 47 values, we can just live with this hole.

shouldn't len(l) be 47?

I'm using the longer list which doesn't count wraparound, which is a superset. But I guess for checking let me use the correct l.

no bonus points though :)

K (ngn/k), 25 bytes (or 23 without imaginary internet points)
a:&&/1_|':9#2!(!8)+!8#2
a?

Try it online!
8#2 is the list 2 2 2 2 2 2 2 2
!8#2 generates an 8x256 matrix whose columns represent the bits of 0,1,..,255
!8 is 0 1 2 3 4 5 6 7
(!8)+ we add these to the corresponding rows in the matrix
2! mod 2
9# reshape to 9 rows, i.e. copy the first row after the last to ensure wrap-around (for internet points!)
|': boolean or each row with the row above it; with implicit 0 before the first
1_ drop the first
&/ boolean and-reduce over the rows - the result is a boolean mask of the encodable numbers
& where are the 1s in this mask - return list of ints
a: assign to a. the k language makes no distinction between function calls and list indexing, so a can act as the decompress function like this: a 26 -> 171
a? is a function that looks up the position of its argument in a. this is our compress function: a?171 -> 26

Ruby, 131 68 bytes
The most trivial answer, which generates all valid numbers (and a few extra values that aren't used) and finding the correct index.
Huge bytesaves thanks to GB, and also realizing I'm allowed to store the numbers list as a separate variable (?)
a=(0..255).select{|i|i.to_s(4)!~/1|30/}
d=->n{a[n]}
c=->n{a.index n}

Try it online!
Imaginary bonus points, 72 bytes
a=(0..255).select{|i|"%08b"%(i^85)*2!~/00/}
d=->n{a[n]}
c=->n{a.index n}

Try it online!

If you toggle every second bit, you only have to check for a double zero (or a zero at each end): "%08b"%(i^85)!~/00|^0.*0$/

Even shorter: "%08b"%(x^85)*2!~/00/

Or even x.to_s(4)!=/1|30/ (without bonus)

@GB I should have looked at this sooner lol

Jelly, 25 17 bytes
⁹Ḷ&Ḥ$Ðḟ^170
ị¢
Ñi

Try it online!
A set of links. The first link is shared and builds the list of possible valid 8-bit integers. The second link is the decompression link and the third handles compression. The footer compresses all the valid integers and then decompresses all the possible compressed values.
Saved 8 bytes by porting xnor’s Python answer with thanks!

Ruby, 89 85 74 bytes
a,b='14-7',"8abef"
f=->n{("%o"%n).tr(a,b).hex}
g=->n{("%x"%n).tr(b,a).oct}

Try it online!
Not going for the bonus points.
How:
Encode and decode using an octal-hexadecimal conversion: since some patterns cannot occur, the only allowed hex digits are [0,2,3,8,a,b,e,f]. So, if we take the hex digits and translate them to their index in the array, we get a 1- or 2-digits octal number, that is in the range 0-63. We can invert the process to decode the number.

05AB1E (legacy), 16 bytes
05AB1E, 17 bytes
Port of xnor's Python answer. -1 byte on legacy thanks to Kevin Cruijssen.
Compression:
ÝƵζ^x&ć¢

Decompression:
µNƵζ^x&_

Modern 05AB1E uses the same compression code, but needs an additional D in the decompression:
µNDƵζ^x&_

TIO links:

legacy compression
modern compression
legacy decompression
modern decompression

-1 byte by switching to the legacy version and removing the D in the decompression-program, since the N is output implicitly after the µ. Every builtin used was already available in the legacy version in both the compression and decompression programs by the looks of it.

Haskell (85 bytes)
The silly version that maps to at most 54:
import Foreign
p y=2*y.&.y<1
d=filter(p.xor 170)[0..255]
f x=sum[1|y<-d,y<x]
g=(d!!)

f encodes a byte and g decodes.
The next version should be much faster, consists of a bit of bit manipulation, but covers the range from 0 to 63 and requires 92 bytes:
(#)=div
(&)=mod
(k%j)e x=k*e(x#j)&k+e(x&j)&k
f=8%16$(#128).(453*)
g=16%8$(737715168#).(16^)

Here is the expanded, hopefully more comprehensible version:
module Compress8to6Bit where

import Data.Bits (xor, shiftL, shiftR, (.|.), (.&.))
import Data.Word (Word8)

import qualified Test.QuickCheck as QC

{-
> map compressNibble [0,2,3,8,10,11,14,15]
[0,7,2,4,3,6,1,5]
-}
compressNibble :: Int -> Int
compressNibble x = shiftR (453*x) 7 .&. 7

compress :: Int -> Int
compress x =
   shiftL (compressNibble (shiftR x 4)) 3  .|.  compressNibble (x .&. 15)

decompressNibble :: Int -> Int
decompressNibble x = shiftR 0x2BF8A3E0 (x*4) .&. 15

decompress :: Int -> Int
decompress x =
   shiftL (decompressNibble (shiftR x 3)) 4  .|.  decompressNibble (x .&. 7)

inverseProp :: Word8 -> QC.Property
inverseProp byte =
   let k = fromIntegral byte
       kx = xor 0xAA k
   in kx .&. shiftL kx 1 == 0
      QC.==>
      k == decompress (compress k)

How?
I found the multiplication trick of Arnauld interesting and found that you can do without modulo but simple shift and masking when using the factor 453.
But after all you could also encode dictionaries for compression and decompression (on a 32-bit machine you need to use Int64 instead of Int):
compressNibble :: Int -> Int
compressNibble x = shiftR 0o7600540300002100 (x*3) .&. 7

decompressNibble :: Int -> Int
decompressNibble x = shiftR 0xFEBA8320 (x*4) .&. 15

This one only needs 16 bit for the dictionary but requires popCount:
compressNibble :: Int -> Int
compressNibble x = popCount (0x6686 .&. (shiftL 1 x - 1) :: Int)

Welcome to the site.  It is nice to see people using Haskell, but this is a code-golf competition.  Just as it is rude to show up to a soccer game and decide you are going pursue the maximum number passes rather than goals, we ask that you make an attempt at the scoring provided.  You can still write fast answers, but you need to put in a show of good faith towards the scoring criterion.

I agree with @PostRockGarfHunter on this one. May I suggest trying to write a golfed answer in Haskel, putting it first in your answer, and then putting the fast answer, as it in fact may be of interest to OP, but shouldn't be the main point of your answer.

Where did the original poster requested a solution with a minimal number of characters of the program?

It seems there is a pretty narrow understanding of Code Golf. What is the discipline to find speedy or ressource saving or otherwise elegant solutions to a problem?

The OP should have indicated this in their question directly, but instead left the [tag:code-golf] tag to indicate.  I am of the opinion that this sort of behavior is unnecessarily hostile to newcomers, as it obscures what the challenge is actually about.  But some users do it so you do have to check the tags.  To answer your other question speediness is generally [tag:fastest-code] but this is much harder to measure than code length so there are objectivity issues.

Ruby, 88 bytes
(with imaginary bonus points)
a=[170]+(6..51).map{|i|"UJEBA@D"[i/8].ord*257>>i%8&255^170}
f=->n{a[n]}
g=->n{a.index n}

76 bytes if it is OK to check the array a directly instead of using f to do it.
Try it online!
I can't beat GB's excellent answer, but this is the shortest Ruby answer claiming the imaginary bonus points so far.
The question asks for all bytes where the even bits are less or equal to than the adjacent odd bits. An equivalent definition is all bytes where the odd bits are greater than or equal to the adjacent even bits, so overall the set is symmetrical.
There is only one possible byte where all even bits are strictly less than the adjacent odd bits, this is 10101010, decimal 170. The other 46 bytes where the even bits are less than or equal to the adjacent odd bits can be found by XORing this number with all possible bytes with no adjacent 1's. These comprise 7 distinct patterns and their bitwise rotations as listed below.
We build an array of the 47 bytes by XORing 10101010 with the patterns below, then use lookup and index functions to carry out the conversion.
Pattern  ASCII number of rotations
01010101  U    2
01001010  J    8
01000101  E    8
01000010  B    8
01000001  A    8
01000000  @    8
01000100  D    4

Total 46 (plus 00000000)

a=(6..51).map{...}<<170 saves 1 byte. I really like the way you encoded everything in a different order than normal! Also, I'm sorry to inform you that after implementing GB's suggestions on my Ruby answer you are unfortunately no longer the shortest with imaginary points ;)

C++ (gcc), 187 \$\cdots\$ 138 128 bytes
Saved 22 bytes thanks to S.S.Anne!!!
Saved 5 bytes thanks to ceilingcat!!!
struct F{int i,j,v[55];F(){for(i=j=0;j<55;++i)i&i*2?:v[j++]=i^170;}int c(int n){for(i=55;v[--i]-n;);n=i;}int d(int n){n=v[n];}};

Try it online!
Is a class F with member functions c and d for compression and decompression.
Uses xnor's algorithm.

You might be able to squeeze a few more out by defining i and j at the class scope. Stinks that the return trick doesn't work here.

146 bytes

@S.S.Anne Clever use of class scope - thanks! :-)

@S.S.Anne Check it out, the return trick does work here! :-)

It didn't when I tried it.

@S.S.Anne That's because in c return was breaking out of a for loop before golfing it to stop looping on a hit.

JavaScript (ES6), 58 bytes (with bonus: 65 bytes)
I couldn't find anything shorter than a port of xnor's answer with recursive functions.
Encoder (30 bytes)
E=n=>n&&E(n-1)+!((n^=170)&2*n)

Decoder (28 bytes)
D=(n,k=n)=>E(k)^n?D(n,k+1):k

Try it online!
Bonus-compliant version, 65 bytes
With 7 more bytes in the encoder, we can output a value in \$[0..46]\$:
E=n=>n&&E(n-1)+!((n^=170)&2*n|n&n>>7)

Try it online!

JavaScript (ES6), 68 bytes
Another version with recursive functions. The encoder is just as long, but the decoder is 10 bytes longer.
Encoder (30 bytes)
E=n=>n&&n%16*17%61%9+8*E(n>>4)

Decoder (38 bytes)
D=n=>n&&596357088>>n%8*4&15|16*D(n>>3)

Try it online!
How?
As already pointed out by G B, there are only 8 valid nibbles for the input. We apply the following formula to map each of them to a unique value in \$[0..7]\$:
$$f(n)=((n\times17)\bmod61)\bmod9$$
Which gives:
 bin  | hex | dec | *17 | mod 61 | mod 9
------+-----+-----+-----+--------+-------
 0000 |  0  |   0 |   0 |    0   |   0
 0010 |  2  |   2 |  34 |   34   |   7
 0011 |  3  |   3 |  51 |   51   |   6
 1000 |  8  |   8 | 136 |   14   |   5
 1010 |  A  |  10 | 170 |   48   |   3
 1011 |  B  |  11 | 187 |    4   |   4
 1110 |  E  |  14 | 238 |   55   |   1
 1111 |  F  |  15 | 255 |   11   |   2

Therefore, the input \$N\$ can be encoded as:
$$f(N\bmod 16) + 8\times f(\lfloor N/16\rfloor)$$
which gives a unique value in \$[0..63]\$.
The decoder retrieves the original nibbles by using the number 0x238BAFE0 (in decimal: \$596357088\$) as a lookup table.
The conversion could also be done with this code:
(n&&n<3?n+9:44/n|4)^4

Try it online!
But this is even longer.

Lua 5.3, 124 122 121 bytes
s,l=string,""for n=0,255 do l=n&n*2<1 and l..s.char(n~170)or l end
f=function(n)return l:find(s.char(n),1,1),l:byte(n)end

Try it online!
Algorithm from xnor, ported to the requested language of Lua. This will only work on 5.3+, but you can get 5.2 compatibility for 24 extra bytes:
s,l=string,""for n=0,255 do l=bit32.band(n,n*2)<1 and l..s.char(bit32.bxor(n,170))or l end
f=function(n)return l:find(s.char(n),1,1),l:byte(n)end

f() does both encoding and decoding; the first return value is for encoding and the second is for decoding. If you want separate functions for both, you can use this instead of the second line (+23 bytes):
e,d=function(n)return l:find(s.char(n),1,1)end,function(n)return l:byte(n)end

This version of the algorithm varies slightly from the original by using a string to store the map rather than a list, which allows using string.find to search for the item. string.char/string.byte also make it easy to switch between number and string formats.

Charcoal, 54 bytes
Ｆ²⁵⁶Ｆ¬＆ι⊗ι⊞υ⁻｜ι¹⁷⁰＆ι¹⁷⁰Ｉ⌕υＮ

Try the encoder online! Link is to verbose version of code.
Ｆ²⁵⁶Ｆ¬＆ι⊗ι⊞υ⁻｜ι¹⁷⁰＆ι¹⁷⁰Ｉ§υＮ

Try the decoder online! Link is to verbose version of code.
Just the usual table-driven lookup approach. Explanation:
Ｆ²⁵⁶

Loop over the 256 binary values.
Ｆ¬＆ι⊗ι

Check that no two adjacent bits are set.
⊞υ⁻｜ι¹⁷⁰＆ι¹⁷⁰

Flip the odd bits and save the result to the lookup table.
Ｉ⌕υＮ

Look up the index of the input in the table.
Ｉ§υＮ

Look up the input index in the table.
Rather than create a table of Fibbinary numbers by filtering out invalid numbers, I attempted a mathematical approach which calculates successive Fibbinary numbers, but the encoder was 48 bytes and the decoder was 40 bytes:
≔⁰η≔⁰ζＷ⁻⁻｜η¹⁷⁰＆η¹⁷⁰θ«≦⊕ζ≔⊕｜η÷η²ι≧＆±ιι≔×ι⊕÷ηιη»Ｉζ
≔⁰ηＦＮ«≔⊕｜η÷η²ι≧＆±ιι≔×ι⊕÷ηιη»Ｉ⁻｜η¹⁷⁰＆η¹⁷⁰

Explanation:
≔⁰η

Initialise the Fibbinary number h to 0.
≔⁰ζＷ⁻⁻｜η¹⁷⁰＆η¹⁷⁰θ«≦⊕ζ

(Encoder) Initialise the encoding index to 0. Repeat until the desired Fibbinary number is found. Increment the encoding index...
ＦＮ«

(Decoder) Repeat the desired number of times.
≔⊕｜η÷η²ι≧＆±ιι≔×ι⊕÷ηιη»

Find the lowest value of k where h&3<<k is zero. Clear the bottom k bits of h and increment the next bit, which gives the next Fibbinary number.
Ｉζ

(Encoder) Output the number of loops taken.
Ｉ⁻｜η¹⁷⁰＆η¹⁷⁰

(Decoder) Output the XOR of the Fibbinary number with 170.

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


text:
What does the shortest pseudo-random algorithm look like?
After seeing some impossibly short solutions in this SE, I began to wonder what code someone could come up with to build a pseudo-random number generator. Now given that I am new to programming, I have absolutely no idea what such generator should look like, or what language to write them in. But that did not stop me from trying some goofy things like writing PRNG, listing primes or prime tests.
So here's the deal, the challenge is to write a pseudo-random number generator that does the following things:
1.Accept a seed in the form of string, number, bits, or whatever, and generate a pseudo-random sequence based on that string. The initial seed should default to 0 if nothing is provided.
2.Accept some input N and generate a pseudo random sequence of length N. Straight forward enough. You can choose to name this whatever you want, or not at all.
3.Be deterministic, the same seed should generate the same sequence each time.
4.I have absolutely no idea how this is tested but the results should be reasonably random. So the results from your generator should be close to uniform distribution within your arbitrary sample space.
5.You can choose any mathematical formula/operation for your pseudo random generation, but it should update its internal state in a deterministic way and use that new internal state for the generation of another number.
You may not outsource your random number generation to any source, be it built in or online. Every variable update/ operation should be explicitly ordered. (things like random.randint() is banned, sorry I only know python)
I can't come up with some inventive way of scoring, so shortest program wins.

define "reasonably random". 1234567890123456... looks okay to me.

Also, what's the minimum allowable sample size? It's much easier to get uniform distribution across {0,1} than across {0..2^64-1}

That's too trivial. Just take a bad RNG algorithm, like Lehmer generator with small constants, and implement it. The only way it would be interesting, is if you clearly set up a threshold for a qualifying level of randomness or a period.

I don't think a uniform distribution is a good criteria for randomness.. I heard that humans are bad at random for this reason, they tend to make distribution uniform and avoid repetitions, where random should do the contrary to a statical extend

In fact, there's a whole study of getting a good uniform sampling function, and pure random sampling is one of the worst, often getting samples that are clustered close to each other while leaving huge gaps somewhere else - and the latter only gets worse in higher dimensions.

For uniformness I guess f(seed) = seed++ works perfectly if seed is allowed to overflow from 2^64-1 to 0...

Python 3, 15 bytes lambda x,s=0: 4 it is random, I swear

My arbitrary sample space is the number 0. My code outputs 0 N times. That works, right?

@RGS If you're interested in how a simple RNG works, LCG is about the simplest. Wikipedia has a good description https://en.wikipedia.org/wiki/Linear_congruential_generator

xorshift: https://en.wikipedia.org/wiki/Xorshift


text:
Implement a Caesar Cipher with a Digit Shift
I assume everyone here is familiar with the Caesar Cipher that shifts letters to a certain index. https://en.wikipedia.org/wiki/Caesar_cipher for those who still needs introduction.
But, we can all agree that plain Caesar is unfun and way too easy. So here's a version that also shifts characters around. This version first applies a cyclic position shift of a given amount to the string, for each character in the string separated with punctuations (space counts as character in this context, positive index means to the right).
For example, Hello world with shift +3 becomes rldHello wo.
Hello! World becomes lloHe!rld Wo with the same shift however because the ! separated the string.
After that, your program applies the Caesar cipher to the shifted text, and outputs the result. (easy enough)
The first example becomes uogKhoor zr after the Caesar cipher of +3.
The second example becomes iilEb!oia Tl after a Caesar shift of -3 (or +23 in alphabets)
As seen above, the index of the two shifts may or may not be equal.
Task
Write a encode and decode program or function (or whatever your language of choice calls them), they may or may not be the same one. It must implement the aforementioned rules of double shifting, and the decode function must successfully reverse it.
Conditions
Your program must at the very least function on ASCII characters, ASCII 0-9 (48-57, inclusive), A to Z (65-90), a to z (97-122) and Space (32) counts as characters in this context, with every other ASCII character counting as punctuation and breaking up the string.
Bonus points to those whose program functions on your language of choice's codebase. Since non-ASCII language contain special characters the "punctuation" rule is omitted in this use case. You only need to implement the cyclic shift and then the Caesar shift on your language's codebase.
¡¢£¤ in Jelly becomes ©¤¥¦ with a position shift of +1 and Caesar shift of -253.
You may assume:
The index input are integers. It may be negative or zero.
If only one number is provided, encode both shifts with that number.
If no number is provided, perform whatever default shifts your heart desire (except 0 and 0, that is boring).
Edit: Due to overwhelming demand, you may assume that there will be at least one number provided. Code that has defaults would still be preferred but no extra scoring.
The input string is in ASCII. Or in your language's codebase if you decide to input that to your program.
Scoring
Of course programs that successfully include their codebase will be prioritized. Include the shifted version of your program in your answer to reflect this.
The other criteria is lowest byte wins. This counts both the encoder and decoder. List the sum and respective length separately please.
Test cases
+3 -5 "Hello,world" becomes "ggjCz,mgyrj"
+10 "Implement a Caesar Cipher with a Digit Shift" becomes "sqsd Crspd Swzvowoxd k Mkockb mszrob gsdr k N"
-2 -11 "Caesar cipher, also known as Caesar's cipher, the shift cipher, Caesar's code or Caesar shift."
becomes "thpg rxewtgRp,ahd zcdlc ph Rpthpg p'rxewtgh ,wt hwxui rxewtg i,pthpg'h rdst dg Rpthpg hwxui R."

PS. Of course I am aware that the two shifts can be carried out in any order and produce the same result, it is just my way of visualizing things. Plus, the first input means position shift index.
PPS. If the test cases are wrong I apologize, I am not a good coder.

The punctuation also breaks up for the cycles? Or should I cycle the WHOLE string and then only encode the characters you mentioned?

@RGS Yes the punctuation always break the ASCII string, this for obvious reasons does not apply to your language's codebase.

"If no number is provided, perform whatever default shifts your heart desire (except 0 and 0, that is boring)." Is this mandatory? I have a solution which I was about to post, but adding this requirement would make both the encoder and decoder almost twice as large.. My current solution does work for both 1 and/or 2 shift-integers, though. PS: I would advice to let answers assume we always get three inputs (1 string and 2 integers).

edited to waive defaults

What should happen to values which push above Z in ASCII, should they map down to A or map up in the ASCII range? Also, why do spaces get special treatment in the rotation but not in the transformation? Is it ok to transform both?

we can all agree that plain Caesar is unfun and way too easy -- extremely, extremely broad generalization

"[the programs] may or may not be the same one." - If they are the same one, must we take four inputs or may we just take the negative of the shifts (the latter would probably mean everyone does). Also do we then count the bytes of the one program once or twice?

"If only one number is provided, encode both shifts with that number." - Oh this invalidates my answer, and the other Jelly answer. This is a very unusual request and seems to be unrelated to the core of the challenge.

What's the desired shift for a digit?

And lastly again, shouldn't the encoding of the second example be "sqsd CrspdSwzvowoxd k Mkockb Mszrob gsdr k N" (you have a space in Crspd Swzvowoxd) and encoding for the third example should be "thpg rxewtgRp,ahd zcdlc ph Rpthpg p'rxewtgh ,wt hwxui rxewtg i,pthpg'h rdst dg Rpthpg hwxui R."?

Can you explain more clearly what should happen on the Caesar shift when input is say Z and shift is +1? Is the result A, a or [?

So Bonus points to those whose program functions on your language of choice's codebase. Since non-ASCII language contain special characters the "punctuation" rule is omitted in this use case. You only need to implement the cyclic shift and then the Caesar shift on your language's codebase..  Are you saying that "non-ASCII languages" (please clarify exactly what that means) not only will get a "bonus" for a submission, but are also not required to fulfill a part of the challenge that "ASCII languages" are?

Above comment see Meta "Things to avoid when writing challenges", and this, and on bonuses.

"least function on ASCII characters, ASCII 0-9 (48-57, inclusive)" -> In the wiki page, the Caesar cipher' behaviour on numbers is not precised, should we assume it increments and loops on digits? (5 becomes 6; 9 becomes 0 etc?)

I think it should be noted that spaces are preserved in Caesar cipher, in case people miss it. Also I think your last example is wrong (see my answer). Oh and I loved your "Foundation" serie (probably mistaken here :)

I'd suggest eliminating the "optional" or variable parameters as I don't think it adds anything and is discouraged in challenges. Making the input simply two integers and a string is typical and would be more inclusive to all languages and platforms.  All of my comments are to say that I think this is a great challenge and if some of these issue can be corrected to conform to CCGC conventions it would receive a lot more attention and answers.

05AB1E, 23 (12+11) bytes
Uses the 05AB1E encoding for the Caesar-shifting.
Encoder:
žĆDII(._kI+è

Input order as string, shift, (optional Caesar-shift). I/O of the strings as character-list.
Try it online or try it online with debug step-by-step lines and single shift-input.
Decoder:
žĆDIkI-èI._

Input order as string, (optional Caesar-shift), shift. I/O of the strings as character-list.
Try it online or try it online with debug step-by-step lines and single shift-input.
Explanation:
              # ENCODER:
žĆ            # Push the 05AB1E codepage
  D           # Duplicate it
   I          # Push the first character-list input
    I         # Push the second shift integer
     (        # Negate it
      ._      # Shift the character-list that many times towards the left
        k     # Get the index of each character in the duplicated codepage
         I    # Push the second shift input again or the optional third Caesar-shift input
          +   # Add it to each index
           è  # And index it into the 05AB1E codepage
              # (after which the resulting character-list is output implicitly as result)

              # DECODER:
žĆ            # Push the 05AB1E codepage
  D           # Duplicate it
   I          # Push the first character-list input
    k         # Get the index of each in the duplicated codepage
     I        # Push the optional Caesar-shift or shift integer
      -       # Subtract it from each index
       è      # Index it into the 05AB1E codepage
        I     # Push the second/third shift integer
         ._   # And rotate the character-list that many times towards the left
              # (after which the resulting character-list is output implicitly as result)

Jelly, (8 + 11 = 19?) 11 + 14 = 25 bytes
Uses the code-page, no punctuation option
19 + 6 = 25 bytes handling the only 1 number option by taking a list of numbers as one of the two arguments.
Encoder +: (Shift(s), plaintext)
0ịØJ,ṙ¥yṙ⁸Ḣ

Decoder +: (Shift(s), cyphertext)
0ịNØJ,ṙ¥yṙ⁸N¤Ḣ

These Links build on the below programs:
Encoder: (Caesar shift, plaintext, Cyclic shift)
ØJ,ṙ¥yṙ⁵

Decoder: (Caesar shift, cyphertext, Cyclic shift)
NØJ,ṙ¥yṙ⁵N¤

How?
Encoder
ØJ,ṙ¥yṙ⁵ - Main Link: Caesar shift, plaintext
ØJ       - code-page characters
    ¥    - last two links as a dyad:
   ṙ     -   rotate (code-page) left by (Caesar shift)
  ,      -   (code-page) pair with (that)
     y   - (plaintext) translated using (that mapping)
       ⁵ - get program's 3rd argument (Cyclic shift)
      ṙ  - rotate (translated) left by (Cyclic shift)
         - implicit print

Decoder
NØJ,ṙ¥yṙ⁵N¤ - Main Link: Caesar shift, cyphertext
N           - (Caesar shift) negated
 ØJ         - code-page characters
     ¥      - last two links as a dyad:
    ṙ       -   rotate (code-page) left by (negated Caesar shift)
   ,        -   pair
      y     - (cyphertext) translated using (that mapping)
          ¤ - nilad followed by link(s) as a nilad:
        ⁵   -   get program's 3rd argument (Cyclic shift)
         N  -   negated
       ṙ    - rotate (translated) left by (negated Cyclic shift)
            - implicit print

Really nice use of the y link here. More for for my brain! +1

Remember, it is not the spoon that bends, it is yourself :p

sorry for asking, but are you being serious or just joking? Sometimes sarcasm flies over my head xD

@RGS just joking around. Reference to The Matrix.

ah I see! Also, well played on handling the cases where no third argument is given.

Jelly, 25 23 bytes (10 + 13)
ØJiⱮṙ+⁵ịØJ
ØJiⱮṙN}¥_⁵ịØJ

Encoder:
   Ɱ          For each character on the input string
  i           get its index on
ØJ            the Jelly code page.
    ṙ         Then rotate the list we get by as much as the cyclic shift input
     +⁵       and add to each number as much as the Caesar shift input.
       ị      Finally use those numbers to index
        ØJ    on Jelly's code page again.

Decoder:
   Ɱ             For each character on the input string
  i              get its index on
ØJ               the Jelly code page.
    ṙ            Then rotate the list of indices
     N}¥         by the symmetric of the cyclic shift input.
        _⁵       Then subtract from each number as much as the Caesar shift input.
          ị      Finally use those numbers to index
           ØJ    on Jelly's code page again.

@Jonathan saved me 2 bytes! Kudos to him :D
Inputs are the string to encode, the shift corresponding to the "rotation" of the string and the shift corresponding to the Caesar encoding. I am encoding the whole Jelly codepage.
You can try the encoder or the decoder. You can also check the encoder and decoder are the inverse of one another (swap the order of the encoder/decoder to verify they are the inverses on both sides).

I am trying to write a footer to compose both links to show that their composition is the Identity function, but I am failing to write such a footer. Can someone give me a hint in the right direction? I think I am struggling with the fact that the two links I wrote have 3 arguments and the quicks I find are for links up to dyads...

Maybe place the third argument in the register like this?

Encoder can be simplified to ØJiⱮṙ+⁵ịØJ

@JonathanAllan thanks! Can we chat for a couple of minutes? I don't fully understand the footer you used.

Also Decoder can be ØJiⱮṙN}¥_⁵ịØJ

https://chat.stackexchange.com/rooms/info/104191/jelly-footer-for-caesar-shift

Our answers fail to handle the odd rule "If only one number is provided, encode both shifts with that number." :(

@JonathanAllan I read an OP comment saying the defaults were going to be waived and I assumed we could just take the 3 arguments, as per Kevin's suggestion comment...

The edit took out the 0 numeric input case but left the 1 numeric input case. Maybe it'll be relaxed...

First version, a bit verbose yet, I'll try to optimize:

"fully cyclic caesar" (9+1 becomes 0, z+1 becomes a, Z+1 becomes A)
breaks on anything not a space or char (a-z A-Z 0-1) (I think your last example is wrong, it breaks on the last ', which is intended)
default values if missing: 1 / 1 (same value for both, could be up to 9 without extra byte)
originally planned to use PHP's char increment, convenient way to loop over alpha values ($c='Z';$c++; makes 'AA'), but decrement is not implemented (so no negative values or decoding)!
should be prioritized IMO because it supports its own codebase, UTF-8 ;)

ENCODER + DECODER = TOTAL
PHP, 430 + 71 = 501 bytes
function a($a,$b='',$c=''){$b!==''?:$b=$c;$c!==''?:$c=$b;$t="/([^a-zA-Z0-9 ]+)/";preg_match_all($t,$a,$s);$r=preg_split($t,$a);for($i=0;null!==$d=$r[$i];$i++){if($j=strlen($d)){$n=-$b%$j;$d=substr($d,$n).substr($d,0,$n);for(;$j--;){if(' '!=$e=$d[$j]){$n=($t=ctype_digit($e))?10:26;$f=$c%$n+$e=ord($e);$d[$j]=chr($t&$f>57|$f>122|$e<91&$f>90?$f-$n:($t&$f<48|!$t&$f<65|$e>96&$f<97?$f+$n:$f));}}}$r[$i]=$d.$s[1][$i];}return join($r);}function b($a,$b='',$c=''){return a($a,$b!==''?-$b:'',$c!==''?-$c:'');}

Try it online!
BONUS - Encoder with line breaks and comments: (not updated)
$a=$argv;                     //arguments short alias
$b=$a[2]?$a[2]:$a[3];         //argument 1 defaults to 2 if missing
$c=$a[3]?$a[3]:($b?$b:$b=1);  //argument 2 defaults to 1 or both default to "1"
$t="/([^a-zA-Z0-9 ]+)/";      //breaking on anything not alpha or digit or space
preg_match_all($t,$a[1],$s);  //saving breaking chars for later
$r=preg_split($t,$a[1]);      //splitting at breaks
for($i=0;null!==$d=$r[$i];){  //for any non null split
    if($j=strlen($d)){                     //if it has a length
        $n=-$b%$j;                         //modulo for shifting
        $d=substr($d,$n).substr($d,0,$n);  //the shifting
        for(;$j--;){                       //for every char
            if(' '!=$e=$d[$j]){                //which is not a space
                $n=($t=ctype_digit($e))?10:26; //char code range depending if digit or alpha
                $f=$c%$n+$e=ord($e);           //new char code and save current one
                $d[$j]=chr($t&$f>57|$f>122|$e<91&$f>90?$f-$n:($t&$f<48|!$t&$f<65|$e>96&$f<97?$f+$n:$f));    //applying char code $f or using range $n to calculate if out
            }
        }
    }
    echo$d.$s[1][$i++];       //display current split with breaking chars
}

BONUS 2 - shifted version of the program with -2 / -11:
crixdc puj($p,$q='',$r=''){$q!==''?:$q=$r;$r!==''?:$r=$q;$i="/([^p-oP-O9-8 ]+)/";tveg_irwbp_apa($i,$p,$h);$g=tveg_axihe($i,$p);gud($x=9;aacj!==$s=$g[$x];$x++){xu($y=gatchi($s)){$c=-$q%$y;$s=qhighj($s,$c).qhighj($s,9,$c);gud(;$y--;){xu(' '!=$t=$s[$y]){$c=($i=netri_vxisx($t))?09:15;$u=$r%$c+$t=sdg($t);$s[$y]=grw($i&$u>46|$u>101|$t<80&$u>89?$u-$c:($i&$u<37|!$i&$u<54|$t>85&$u<86?$u+$c:$u));}}}$g[$x]=$s.$h[0][$x];}ijgc ydxcgt($g);}crixdc quj($p,$q='',$r=''){ijgc pgt($p,$q!==''?-$q:'',$r!==''?-$r:'');}

EDIT: saved 10 bytes by refactoring to remove brackets + replaced ''!== by ''!= + replaced logical operators ||/&& by bitwise |/&
EDIT2: saved 1 byte by using $l=strlen( in for declaration instead of ''!= and reusing it after, but +4 bytes correcting a bug for $f<65 picking numbers, changed to !$t&$f<65
EDIT3: fixed bug of prematurely breaking first loop when string begins by a punctuation, forces new if to prevent division by zero, but uses split length $j to shorten second loop declaration
EDIT4: improved with a function and advices from 640KB but didn't want to go too far while questions not resolved and didn't want to end with same code - gave up default values when both arguments miss, supports now zero shifting

Is your total score 830 then?  (the sum of both encode and decode)

hint: isn't the decode function just the encode function with the opposite signs of the two shift values? (ex: function d($a,$b,$c) { return e(-$a,-$b,$c); } (if that saves you any bytes :) )

Nice job you did using parameters for preg_split! Many valid points, but it's gonna be hard not end up with your code if I use all this ;) I also implemented default values although it doesn't add to the score.. maybe a bit dumb

PHP, 398 bytes
function e($z,$x,$y=null){$y=is_null($y)?$x:$y;for($i=0,$o=preg_split('/([^A-Za-z0-9 ])/',$z,0,2);$i<count($o);$o[$i]=$s,$i+=2)for($s=substr(($s=$o[$i]).$s.$s,($l=strlen($s))-$x,$l),$j=0;$j<strlen($s);$j++)if(($c=$s[$j])!=' ')$s[$j]=(chr(ctype_digit($c)?(ord($c)+$y-38)%10+48:(ord($c)+$y-($p=ctype_lower($c)?97:65)+26)%26+$p));return join($o);}function d($z,$x,$y=null){return e($z,-$x,-($y?:$x));}

Try it online!
Submitted as two functions:

Encode: e( $string, $index_shift, [ $caesar_shift ] ) : string
Decode: d( $string, $index_shift, [ $caesar_shift ] ) : string

Yes, this is not very golfed yet, but I thought it would be helpful to post to verify my assumptions about this challenge, while waiting for answers to my questions to the OP above.
Still unclear to me is:

Case of inputs +1 "Z" == "A", +1 "z" == "a", +1 "9" == "0"?
Only UTF-8 / ASCII languages are required to implement the "punctuation delimiter" rule?
Verify output with posted test cases, which as I've pointed out, I believe the second two are incorrect.

Only downsides I see to your code is that it's not precised in the question which index number can be missing, but in your case the first one cannot be missing. It's also precised for those numbers "It may be negative or zero", so zero should be a valid input, a different case than missing (but I actually made the same mistake too)

I've updated the solution to account for this, as I'm honestly not concerned about byte counts until some of open questions are answered.

I see what you are saying -- in the example e( 'input', 1, 0 ) would imply e( 'input, 1, 1 ) the way it is now. That said, as others have pointed out, having "optional" or "default" parameters is discouraged in challenges , and I'd suggest to the OP that this be more clearly changed to confirm to Default I/O methods for challenges

updated my code, maybe you can save some bytes with default values as empty strings, it should work either if argument is empty or missing (calling with null will use default value)


text:
Write some Random English
Your Goal:
Given an odd integer input n greater than 1, generate a random English word of length n. An English word is one in which the odd (1-based) indices are consonants and the even (1-based) indices are vowels, the vowels being aeiou.
Random
For the purposes of this challenge, you are to sample from the vowels and consonants uniformly, with replacement. In other words, each possible English word must be equally likely to appear as an output.
Example Inputs/Outputs
3 -> bab, tec, yiq
5 -> baron, nariz, linog
7 -> murovay, fanafim

Winner:
Winner is the Lowest Byte Count.

Welcome to the site.  I don't really understand the challenge here.  Maybe the sandbox (linked on the right), would be a good place to get feedback.

Are we making a function that generates the words? Or should the program simply generate them when run?

Hi there. I've voted to close this as needing additional clarity, but do not fret when this gets closed! It's tough to get a challenge specified up to our standards the first few times you come up with one, so we have a sandbox for you to get feedback on them before they come to the main site. Hope you enjoy your time here, and happy golfing!

Be sure to specify what you mean by random. Also, how is the output size specified? Is it also random?

Some questions for clarification: (1) does this take input, and if so, what is the input and how exactly does it affect the output? (2) What is meant by random? Do we select vowels and consonants with replacement, so bab and babab would each be possible, or without? Does each word generated this way have equal chance of being generated, or does each word have to have a non-zero probability of appearing, or is there some other specific, well-defined distribution you're looking for? I see Luis has asked basically the same questions, but you have not yet addressed them in any way.

@Giuseppe no extra details needed... Thats what I meant. I wanted to see who could create vowel and non vowel random words in the least amount of bytes. See the number one answer, they did it right.

We have some guidelines on things to include in your challenge. If you'd like, I'd be happy to edit this question up to our standards (with your input, of course) so we can get this re-opened and get some upvotes on it! I haven't downvoted it because I think it's a good challenge; it just needs some refinement and it should get a decent amount of attention.

I've gone ahead and edited it (and voted to re-open), please make edits to it as you feel appropriate!

Reminds me of this challenge. Main difference being that this takes length as input. Actually, I'm not sure if that makes this a dupe or not.

@ValueInk He wants pronouncable words, and y itsnt a vowel, but he includes it anyways. Your able to merge AEIOU and its actually a pronouncable sound, with Y it adds an extra sectional sound, its incorrect

Jelly, 9 8 bytes
ØḄØẹḂ?X)

-1 byte thanks to @Steffan
Try it online!
Explanation:
ØḄØẹḂ?X)  # main link taking an integer

       )  # over the list [1..n]
     ?    # if
    Ḃ     # n modulo 2 is truthy
ØḄ        # yield the consonants
  Øẹ      # otherwise the vowels
      X   # get a random letter from that
```

ØḄØẹḂ?X) for 8 bytes by using Ḃ (modulo 2) instead of checking for divisibility by 2.

Another interesting 8-byter with ƭ (tie): ØḄØẹ2ƭX)

@Steffan Thank you! Didn't know Ḃ was a thing

05AB1E, 14 11 bytes
-3 bytes thanks to Kevin Cruijssen
EžN¸žMšNèΩJ

Try it online!

¸ì can be š, .R can be Ω, and the } can be removed before the join.

oh wow, thank you! @KevinCruijssen

Plain English, 485 bytes
To add any vowel to a string:
Pick a letter of the alphabet.
If the letter is any vowel, append the letter to the string; exit.
Repeat.

To add any consonant to a string:
Pick a letter of the alphabet.
If the letter is any consonant, append the letter to the string; exit.
Repeat.

To make a random string given a length:
If a counter is past the length, exit.
Add any consonant to the random string.
If the counter is past the length, exit.
Add any vowel to the random string.
Repeat.

What better way to write some random English than by using Plain English? I have applied a moderate level of golfing to this code; certain things could be shortened, but it would make this less legible, which would be a shame.
The reason I have defined three routines is because nested loops are forbidden in Plain English, so inner loops must be factored into separate routines.
Parameters and local variables are written as "a string" or "a length" (for example). These are subsequently referred to as "the string" and "the length." If you need to refer to more than one string, you could for example introduce "another string" and refer to it with "the other string." You may also name them whatever you want: "a random string" and refer to it either as "the random" or "the random string."
All arguments are passed by reference; even numbers. To output from a routine, you just modify the arguments. Then you simply refer to the object returned by the routine in the same way as you refer to parameters. For example, to use the routine defined above to output a random English word, you could:
To run:
Start up.
Make a random string given 5.
Write the random string on the console.
Wait for the escape key.
Shut down.

"To run:" is a special routine that signifies the starting point of the program. When added to the other three routines, this results in a program which will show something similar to the following when compiled and run:

I cant tell if this is a joke or not but I love it lol

@MisterSirCode That was my first reaction too! But after reading Plain English's compiler, which is written in Plain English, I was quickly disabused of that notion!

Perl 5, 69 bytes
say map{([a,e,i,o,u],[grep!/[eiou]/,b..z])[$_%2][rand$_%2*16+5]}1..<>

Try it online!

JavaScript (Node.js), 89 bytes
f=(n,b)=>(b?"aeiou":"bcdfghjklmnpqrstvwyxz")[~~(Math.random()*(b?5:21))]+(--n?f(n,!b):"")

Try it online! (includes tests)
Takes n as length and b as whether to return vowel or consonant, default consonant.
Returns consonant or vowel based on b, decrements n and recurses with opposite b value.

Stax, 10 bytes
ÇÅφ⌠↑Ñ°↕Yx

Run and debug it
Explanation
FVcVv2l@_@L

F           In range 1 to the input, do this ...
 Vv         Vowels
   Vc       Consonants
     2l     Wrap the two inside a list
       @    Index the constructed list into the counter
            Note that the counter starts at 1,
            so this picks the constants list
            before the vowels list.
        _@  Index by the current counter
            (Stax doesn't have random number support)
          L Wrap the whole stack into a list

Wow, nice job on this one

GolfScript, 36 bytes
,{['aeiou'.123,97>^]\2%=.,rand=}%''+

Try it online!

You can save some bytes by using ['aeiou'.123,97>^] instead of your long string. Generates the characters 98-123, then removes the vowels. Plus, they're in two distinct arrays too, which saves you a bunch too. the string and 21/ can be removed, meaning you're down 31 chars and up 18, netting 13.
,{['aeiou'.123,97>^]\2%=.,rand=}%''+
This worked for me.

Ruby, 76 bytes
Basic recursive function that adds a consonant and a vowel each time until there's only one character left, at which point it adds just the consonant.
f=->n{[*?b..?z].grep(/[^eiou]/).sample+(n<2?'':'aeiou'.chars.sample+f[n-2])}

Try it online!

Python, 83 bytes
lambda n:[*map(choice,["bcdfghjklmnpqrstvwxzy","aeiou"]*n)][:n]
from random import*

Attempt This Online!
Outputs a list of characters.
This is conceptually the same as grc's answer for "Generate a pronounceable word", since the questions are almost identical.

Vyxal s, 9 bytes
⟑₂¨ikvk¹℅

Try it online!
Explanation:
⟑          # Map over the range 1 to n
 ₂¨i       # If even:
    kv     #   Push the string "aeiou"
           # Otherwise:
      k¹   #   Push the lowercase consonants
        ℅  # Get a random character from the top of the stack
           # Concatenate the character list into a string with the s flag

Pip, 12 bytes
RC*[.CZVW]Ha

Try It Online!
Explanation
This should be 11 bytes; the . is a no-op to work around a bug in the current language version.
RC*[CZVW]Ha
   [    ]    List containing:
    CZ         Lowercase consonants
      VW       Lowercase vowels
          a  Command-line argument
         H   Take that many elements (cycling the list as necessary)
RC*          Random choice from each

I also found several 13-byte solutions:
RC{VW::CZ}M,a
RC[CZVW]@_M,a
LaORC(VW::CZ)

Bash, 93 89 bytes
v=aeiou]
until tr -dc a-z</dev/urandom|head -c$1|grep -E "^[^$v([$v[^$v)*[$v?$";do
:
done

Try it online!
A full command line program.
It generates random lowercase alpha strings of the required size in a loop until we find one matching the pattern ^<vowel>(<cons><vowel>)*<cons>?.

D, 124 bytes
auto f(int n){string s;for(import std;n;n--,s~=n%2?"aeiou"[uniform(0,5)]:"bcdfghjklmnpqrstvwxyz"[uniform(0,20)]){}return s;}

I'm not very good at code golf (but trying to get better) so this can probably be improved a lot
Try it online

Welcome to Code Golf, and nice first answer! Unfortunately we don't have a Tips for Golfing in D page, but it's nice to see someone using a language not regularly used on our site!

You might want to add a Try it online link so others can test your code. Note:  I don't know D and I'm probably doing this wrong.

Golfed off a few bytes. Idk what the issue with garbage bytes being appended is...

Unfortunately you can't rely on counting backwards since the vowels/consonants will swap depending on the parity of the input. You can fix this by changing s~=... to s=...~s. You can also combine the strings and indexing for 112 bytes

the issue with garbage characters was since you were using cast(char*) to convert to a C string when passing to printf. you have to use toStringz (or the better solution is just to use the write/writeln function from std.stdio)

also parity isn't an issue since the challenge specification says that the input number will always be odd

Vyxal rṀs, 8 bytes
ƛkvk⁰"i℅

Try it Online!
Fun

Factor + pair-rocket sequences.repeating, 62 bytes
[ "bcdfghjklmnpqrstvwxyz"=> "aeiou"swap cycle [ random ] map ]

Attempt This Online!
                                   ! 5
"bcdfghjklmnpqrstvwxyz"=> "aeiou"  ! 5 { "bcdfghjklmnpqrstvwxyz" "aeiou" }
swap                               ! { "bcdfghjklmnpqrstvwxyz" "aeiou" } 5
cycle                              ! { "bcdfghjklmnpqrstvwxyz" "aeiou" "bcdfghjklmnpqrstvwxyz" "aeiou" "bcdfghjklmnpqrstvwxyz" }
[ random ] map                     ! "furom"

Pyth, 19 bytes
J"aeiou"smO?%d2J-GJ

Test suite
Explanation:
J"aeiou"smO?%d2J-GJ  | Full code
J"aeiou"smO?%d2J-GJQ | with implicit variables
---------------------+--------------------------------------------------------
J"aeiou"             | J = "aeiou"
         m         Q | For each d in [0...input):
          O          |  Pick a random letter from
               J     |   J
           ?%d2      |   if d is even else
                -GJ  |    the lowercase alphabet minus J (i.e. the consonants)
        s            | Print the concatenated results

C (gcc), 61 58 bytes
c;f(n){for(;n;4370%c-n&1&&putchar(c,n--))c=97+clock()%26;}

Try it online!
-3 bytes thanks to ceilingcat!!

Raku, 67 bytes
{$!=<a e i o u>;({(('a'..'z')∖$!,$!)[$++%2].pick}...*)[^$_].join}

Try it online!

The vowels are stored in $!, one of just two special global variables that don't need to be declared.
{ ... } ... * is a lazy, infinite list, where the code between the braces generates each successive element.
('a' .. 'z') ∖ $! are the consonants.  That ∖ isn't a backslash, it's the Unicode SET MINUS character.
(('a' .. 'z') ∖ $!, $!)[$++ % 2] alternately chooses the consonants and vowels on each iteration of the generator.  The anonymous state variable $ counts how many iterations there have been so far, and the % 2 reduces that to the alternating sequence 0, 1, 0, 1, ....
.pick chooses a random vowel or consonant.
[^$_] takes a number of elements from the sequence equal to the argument passed to the function.
.join joins those elements into a single string.

Zsh --braceccl, 67 bytes
Try it Online!
shuf -n$1 <(echo {bcdfghj-np-tv-z}{aeiou}|rs 0 1)|rs -g0|cut -c -$1

Similar to the pronounceable word solution.

Japt -mP, 12 bytes
;Ck%+Ugciv¹ö

Try it
;Ck%+Ugciv¹ö     :Implicit map of each U in the range [0,input)
;C               :Lowercase alphabet
  k              :Remove
   %+            :  Append to "%"
     Ug          :  Index U into
       civ       :    "c" prepended with "v"
          ¹      :End remove ("%v"=/[aeiou]/gi "%c"=/[b-df-hj-np-tv-z]/gi)
           ö     :Random character
                 :Implicitly join & output

Nim, 148 bytes
import random
randomize()
proc x(y:int):string=
  let l="bcdfghjklmpqrstvwxyz";let a="auioe";for i in 0..y-1:result.add sample(if(i%%2)==0:l else:a)

Attempt This Online!


text:
Estimate the mean minimum Hamming distance
Task
Inputs \$b \leq 100\$ and \$n \geq 2\$.  Consider \$n\$ binary strings, each of length \$b\$ sampled uniformly and independently. We would like to compute the expected minimum Hamming distance between any pair.  If \$n = 2\$ the answer is always \$b/2\$.
Correctness
Your code should ideally be within \$\pm0.5\$ of the correct mean.  However, as I don't know what the correct mean is, for values of \$n\$ which are not too large I have computed an estimate and your code should be within \$\pm0.5\$ of my estimate (I believe my estimate is within \$\pm0.1\$ of the correct mean). For larger values than my independent tests will allow, your answer should explain why it is correct.

\$b = 99, n = 2^{16}.\$ Estimated avg. \$19.61\$.
\$b = 89, n = 2^{16}.\$ Estimated avg. \$16.3\$.
\$b = 79, n = 2^{16}.\$ Estimated avg. \$13.09\$.
\$b = 69, n = 2^{16}.\$ Estimated avg. \$10.03\$.
\$b = 59, n = 2^{16}.\$ Estimated avg. \$7.03\$.
\$b = 99, n = 2^{15}.\$ Estimated avg. \$20.67\$.
\$b = 89, n = 2^{15}.\$ Estimated avg. \$17.26\$.
\$b = 79, n = 2^{15}.\$ Estimated avg. \$13.99\$.
\$b = 69, n = 2^{15}.\$ Estimated avg. \$10.73\$.
\$b = 59, n = 2^{15}.\$ Estimated avg. \$7.74\$.
\$b = 99, n = 2^{14}.\$ Estimated avg. \$21.65\$.
\$b = 89, n = 2^{14}.\$ Estimated avg. \$18.23\$.
\$b = 79, n = 2^{14}.\$ Estimated avg. \$14.83\$.
\$b = 69, n = 2^{14}.\$ Estimated avg. \$11.57\$.
\$b = 59, n = 2^{14}.\$ Estimated avg. \$8.46\$.

Score
Your base score will be the number of the examples above that your code gets right within \$\pm0.5\$. On top of this you should add \$x > 16\$ for the largest \$n = 2^x\$ for which your code gives the right answer within \$\pm0.5\$ for all of \$b = 59, 69, 79, 89, 99\$ (and also all smaller values of \$x\$).  That is, if your code can achieve this for \$n=2^{18}\$ then you should add \$18\$ to your score. You only get this extra score if you can also solve all the instances for all smaller \$n\$ as well. The number of strings \$n\$ will always be a power of two.
Time limits
For a single \$n, b\$ pair, your code should run on TIO without timing out.
Rougher approximation answers for larger values of \$n\$
For larger values of \$n\$ my independent estimates will not be as accurate but may serve as a helpful guide nonetheless.  I will add them here as I can compute them.

\$b = 99, n = 2^{17}.\$ Rough estimate \$18.7\$.
\$b = 99, n = 2^{18}.\$ Rough estimate \$17.9\$.
\$b = 99, n = 2^{19}.\$ Rough estimate \$16.8\$.

I thought this was posted on the Sandbox earlier today.

@S.S.Anne Yes I posted it there first.  I look forward to the first answers!

The time limit is probably unnecessary as it both limits users to tio languages and needlessly disqualifies solutions that take a long time, but do solve the problem. I understand wanting to prevent brute forcing, but I’d argue that should also be valid

@ATaco I understand that point of view but it completely changes the challenge.  Brute force solutions are valid here of course. It's just a question of what score you get.  The time limit/TIO is also crucial as otherwise you will just get a higher score by having a more powerful computer or leaving it to run for longer.

Using TIO for timing is not a good idea. Had you left this in the sandbox longer, I'd have suggested you switching to requiring that submissions pass your examples within a certain time limit which you would verify (like [tag:fastest-code]). What you currently have makes it extremely difficult to determine what the score of any submission should actually be.

@FryAmTheEggman I understand the complications all too well.  [tag:fastest-code] is highly non-ideal as people can't test their code properly for speed themselves. Using TIO is non-ideal because it's not super reliable timing-wise. For this challenge where the exact timing is not so critical I decided that on balance it was the best option. Clearly if you have to report an exact time TIO is no good. It would be awesome if there were  a server we could use for timing.

Python 3, score = big(?)
from math import exp, log, log1p

def f(b, n):
    e = n * (n - 1) / 2
    m = 0
    c = 1
    s = 0
    t = 1 << b
    for k in range(b):
        s += c
        m += exp(e * (log1p(-s / t) if 2 * s < t else log((t - s) / t)))
        c = c * (b - k) // (k + 1)
    return m

Try it online!
The Hamming distance \$D_{x, y}\$ between any two of the strings (\$1 \le x < y \le n\$) is a random variable distributed as the Binomial distribution \$B{\left(b, \tfrac12\right)}\$:
$$
\Pr[D_{x, y} > k] = 1 - \frac{1}{2^b} \sum_{i=0}^k \binom bi.
$$
Furthermore, any (distinct) two of these \$\binom n2\$ random variables are independent.
If we make the incorrect but empirically useful assumption that all \$\binom n2\$ of these random variables are independent, then we can compute the distribution of their minimum \$D = \min_{1 \le x < y \le n} D_{x,y}\$ exactly:
$$
\begin{gather*}
\Pr[D > k] = \left(1 - \frac{1}{2^b} \sum_{i=0}^k \binom bi\right)^{\binom n2}, \\
\mathbb E[D] = \sum_{k=0}^{b-1} \Pr[D > k].
\end{gather*}
$$
This result can be computed extremely quickly and seems to be close enough.  Numerical evidence suggests that the absolute error is worst at \$b = 1, n = 3\$ (where we estimate the expected minimum as \$\tfrac18\$ when it is actually \$0\$), and drops off quickly to zero as \$b\$ and/or \$n\$ get large.

Awesome! And quickly done too.