text:
What calculator is this datafile for?
The challenge today is very simple. The task is to determine the TI calculator for which the submitted datafile was made.
The datafiles always start with a string **TI, the version (described below), and other data you can ignore.
Now, the versions you need to recognize are:
95* => TI-95
92P => TI-92+
92* => TI-92
89* => TI-89
86* => TI-86
85* => TI-85
84P => TI-84+
84* => TI-84
83* => TI-83
83P => TI-83+
82* => TI-82
81* => TI-81
74* => TI-74
73P => TI-73+

Examples
**TI95*   => TI-95
**TI83P   => TI-83+
**TI73P   => TI-73+
**TI85*   => TI-85
**TI83PGG => TI-83+
**TI86*asdf*9**TI92Pasd => TI-86

Rules
You can assume the input is always correct, is at least 7 characters long, and has been crafted for one of the TI calculators listed above.
This is code golf, so the shortest answer wins.
I/O rules and loopholes apply.

Just to be sure: is ** a constant string? or a placeholder for 2 random characters?

Since the rest of the data can ignored, can we assume it isn't given, or do we have to remove it?

yes, it's a constant string.

@Adám ">You can assume the input is always correct, is at least 7 characters long" - the input can be longer than 7 characters, and for the output to be correct, you can't output any gibberish other than the version.

Perhaps if gibberish can be there, and should be ignored, you can 1) indicate where that gibberish can occur, and 2) add some more examples.

sure thing, feel free to take this hexdump: https://pastebin.com/zGBWJjd7

Suggested test case (contains another version string in the gibberish): **TI86*asdf*9**TI92Pasd

@Zgarb done, added!

Suggested test case: Multiple valid answers separated by newlines, such as **TI95*blah blah<NEWLINE>**TI83P (assuming that's a valid input). (I'm aware that several answers currently use the newline as a method of separating test cases, and want clarification as to whether that is valid or not)

I should have bought a TI calculator... You know TI-BASIC?

@pppery albeit this is a valid testcase, it would invalidate a lot of currently existing answers, so I'll let it pass :p

You should explicitly clarify that that corner case is not a valid input in the question body.

TI-BASIC (TI-83), 40 39 bytes
Saved a byte thanks to @iPhoenix.
Ans→Str1
sub(Ans,5,2
If sub(Str1,7,1)="P
Ans+"+
"TI-"+Ans

Takes input as a string via Ans (allowed by default). The character count differs from the byte count because TI-BASIC is tokenised: Str1 and sub( are 2-byte tokens; Ans, →, If , and all other characters used (including newlines) are 1-byte tokens.
Sample output
Uses this emulator.

Explanation
Ans→Str1             # store input in Str1
sub(Ans,5,2          # overwrite Ans with 2-digit calculator ID (5th and 6th input characters)
If sub(Str1,7,1)="P  # if the 7th input character is 'P'...
Ans+"+               # then add '+' to Ans
"TI-"+Ans            # full calculator name (printed implicitly)

you can save a byte off the end of the line with your if statement if you split the then-block off into a second line and remove the : and closing " accordingly

@iPhoenix Nice one, thanks!

brainfuck, 39 38 35 bytes
Saved 3 bytes thanks to @Dorian.
,+++>,>,.,.<<.-->>,.,.,[-<->]<[<.<]

Try it online!
This abuses the fact that the characters *,+, and - are very close to each other in ASCII.
Ungolfed:
,+++>  create a minus from the first asterisk
,>      store the second asterisk for comparison later
,.      display T
,.      display I
<<.-->> display the minus from line 1 and turn it into a plus
,.      display first number
,.      display second number

,[-<->]<[  if the last char is not an asterisk from line 2
  <.<      display the plus from line 5
]

Original 38 byte solution:
>,+++>,>,.,.<<.-->>,.,.,<[->-<]>[<<.<]

Original 39 byte solution:
,+++>,>,.,.<<.-->>,.,.,<[->-<]>[<<.[-]]

Really nice code. 34 bytes with a few unnecessary commands removed.

@Dorian That doesn't work, it outputs a trailing (some unprintable byte) at the end.

For the TIO implementation at least it's possible to delete the first > because the tape wraps around.

Oh, you're right, it outputs a nul char after the plus sign. Well then 35 bytes ;-)

I didn't even think about tape wrapping - nice optimizations! Thanks!

Python 3, 52, 43 36 bytes
lambda x:"TI-"+x[4:6]+"+"*(x[6]>"*")

Try it online!

Nice, you can save a few bytes using "+" * condition instead of condition and.. or... Try it online!.

Well done! for the future, TIO has a separate section for codegolf submissions in the link section, which you can just copy and paste into the answer for a nice, preformatted submission

@Dion thank you, that makes formatting my answers a lot easier

TI-Basic (TI-84 Plus CE), 54 bytes (50 tokens) 61 bytes (56 tokens)
"TI-"+sub(Ans,5,3
If sub(Ans,6,1)="P
Then
sub(Ans,1,5)+"+
Else
sub(Ans,1,5
End
Ans
Usage: "**TI89*":prgmNAME if the program is named NAME.
TI-Basic is a tokenized language, the sub( token is two bytes and all the other tokens used here are one byte (e.g. digits, punctiation, newline, Ans, If, Then, Else, End).
Takes the input in Ans and implicitly prints the result stored in Ans.
Encodes the - with the subtraction - (0x71), not the negative - (0xB0)
Explanation:
"TI-"+sub(Ans,5,3  # 19 tokens, 21b: "**TIXX?..." -> "TI-XX?"
If sub(Ans,6,1)="P # 12 tokens, 13b: If the "?" above is "P"
Then               #  2 tokens,  2b: Then
sub(Ans,1,5)+"+    # 11 tokens, 12b:   Replace "P" with "+"
Else               #  2 tokens,  2b: Else
sub(Ans,1,5        #  7 tokens,  8b:   Remove the last character
End                #  2 tokens,  2b: End If
Ans                #  1 tokens,  1b: Last line's Ans is implicitly printed

Can you give a quick example on how (before calling the program) one can set Ans to have the value we want?

@IsmaelMiguel Sure, "**TI89*":prgmNAME if the program is named NAME. I added this to the answer

Thank you, I didn't knew you could do that :O over 10 years later and I'm still learning stuff about these calculators.

perl -pl, 24 bytes
s;(\d..).*;-$1;;y;P*;+;d

Try it online!
Keep the first digit and the next two characters, removes anything after that, and inserts a - before the first digit. Replaces any P with a +. Removes any *.
Reads lines from STDIN, writes versions to STDOUT.
Editted to deal with trailing garbage.

JavaScript (ES6), 34 bytes
s=>'TI-'+s[4]+s[5]+[{P:'+'}[s[6]]]

Try it online!
Commented
s =>         // s = input string: **TIddp[…]
             //                   0123456
  'TI-' +    // append the prefix
  s[4] +     // append the first digit (5th character)
  s[5] +     // append the second digit (6th character)
  [          // wrapper to make sure that undefined is turned into an empty string
    {P: '+'} //   define an object with a single key 'P' mapped to the value '+'
    [s[6]]   //   and attempt to retrieve this '+', using the 7th character
             //   (which is either 'P' or '*')
  ]          // end of wrapper

Nice, I ended up with the exact same code. I don't think there's a shorter version in js. +1 for ""+[undefined]

05AB1E, 16 bytes
Sorry, didn't understand the comment...
7£¦¦…*PI„ +„I-ª‡

Try it online!
Explanation
7£               Take a 7-char prefix.
  ¦¦             Remove the first 2 characters.
    …*PI         "*PI"
        „ +„I-ª  With: [" ", "+", "I-"] respectively
               ‡ Transliterate

Yeah it does? Maybe my comment wasn't too clear (sorry about that), but I meant to replace „*P„ +‡'I¡„I-ý with …*PI„ +„I-ª‡ for -2. The 7£¦¦ still remains as is. Try it online: 7£¦¦…*PI„ +„I-ª‡.

Keg, -ir, 15 bytes
__,,\-,,,P=[\+,

Try it online!
Huh, who'da thunk a simple stack approach would beat everyone else?
Explained
__,,\-,,,P=[\+,
__              # Pop the two asterisks at the start
  ,,            # Print the "TI"
    \-,         # Followed by a dash
       ,,       # Then the number embedded in the input
         P=     # See if the last character is P
           [\+, # If it is, print a "+", otherwise, do nothing and end execution

Now you're a total genius. I can't even golf it.

Hexagony, 28 bytes
,,..34{<{__5|..,;,;#@$_#_.@;

Try it online!
Accepts input on stdin and prints to stdout.
Explanation

I'll use the test case **TI83P for illustration.
Execution starts at the top left corner and follows instruction pointer 0 (IP0) along the red path.

,, reads and discards the first two asterisks from stdin.
,; reads the T from stdin and prints it to stdout.
,; does the same but for the letter I.

At this point, the current memory edge holds the integer 73 (the ASCII character I).

# takes the current memory edge modulo 6 (1 in this case) and transfers control to the corresponding instruction pointer.

This pauses IP0 at the @ command and picks up execution in the top right corner, following IP1 along the blue path.

{ moves the memory pointer to its left neighbor.
Memory edges are 0 by default, so this is easier than trying to zero the previous edge.
45; prints - to stdout.
,;,; reads the two digits of the model number and prints them.
The zigzag pattern allows reuse of the same instructions that printed the letters TI.
{ moves the memory pointer again.
This instruction is superfluous, however, because
, overwrites the current memory edge with the next character read from stdin.

This character is either * (ASCII 42) or P (ASCII 80).

If it is *,

# transfers control back to IP0 (because 42 mod 6 = 0).
IP0 picks up at the @ instruction, which finally terminates the program.

If it is P,

# transfers control to IP2 (because 80 mod 6 = 2), which starts in the right corner and follows the grey path.
$ skips the ; instruction to avoid printing P to stdout instead of +.
{43; prints + to stdout.
@ terminates the program.

I had a lot of fun (ab)using the # instruction with this solution.
Image courtesy of Timwi's HexagonyColorer.

QuadR, 21 bytes
I
^\*.|\*.*
P.*
I-

+

Try it online!

Looks like you can do ^.. instead of ^\*.

str, 21 bytes
2G2G'-:2G:g'P='+x:O;q

Explanation:
2G                     Read the `**` at the beginning (this stays on the stack for the entire program, but does nothing)
  2G                   Read the string `TI`
    '-:                Concatenate a - to it, to get `TI-`
       2G:             Read the next two characters (the version number) and concatenate them to the assembled string
          g            Read the next character (either `P` to signify I need to add a plus sign, or garbage)
           'P=         Check if it's equal to `P`, producing a zero or one
              '+x:     Repeat the string `+` a number of times equal to the number on top of the stack (zero or one in this case), and concatenate it to the assembled string
                   O;q Output the result, then tell the interpreter to ignore the rest of the input

Try it online!

Retina 0.8.2, 19 bytes
1M!`TI..P?
P
+
I
I-

Try it online! Link includes test cases. Explanation:
1M!`TI..P?

Extract the TI, 2 digits, and a possible trailing P.
P
+

If there was a P then change it to a +.
I
I-

Add a - after the I.
Retina 1 saves a byte because it uses 0L instead of 1M!.

@pppery Ugh, that means I'm going to have to add a header to the test suite...

J, 24 bytes
'TI-',4 5&{,'+'#~'P'=6&{

Try it online!
How it works
'TI-',4 5&{,'+'#~'P'=6&{
                 'P'=6&{ 6th position = 'P'?
            '+'#~        either take 0 or 1 '+' and
      4 5&{,             append it to the 4th and 5th char
'TI-',                   prepend 'TI-'

nb: out of pure boredom, I engineered an unpacker for programs too, written in J, and this has inspired me for this challenge. extract =: (2=('**TI'-:4$])+[:+/(14 3$'95*92P92*89*86*85*84P84*83*83P82*81*74*73P')-:"1~14 3$4(}.)7{.]){[:>'Incorrect datafile.';~[:(_2&}.)73}.]

Charcoal, 16 bytes
TI-§θ⁴§θ⁵×+⁼P§θ⁶

Try it online! Link is to verbose version of code. Explanation:
TI-

Print the initial TI-.
§θ⁴§θ⁵

Print the 4th and 5th characters of the input (0-indexed).
×+⁼P§θ⁶

Print as many +s as there are Ps equal to the 6th character of the input.

Vyxal, 20 bytes
Port of @Daniel H.'s answer.
`TI-`?46fiJ?6i×≠\+*J

Try it online!
Explained
`TI-`?46fiJ?6i×≠\+*J
`TI-`                 # Stack "TI-"
     ?46fi            # Stack input[4:6]
          J           # Join
           ?6i×≠\+*J  # Stack "+" and join if input[6] is equal to "*"

Basically my first vyxal answer, thanks so much to all who helped me, including @lyxal.
13 bytes @lyxal
7Ẏ‛P+*×P\-2Ṁ

Try it online!

I got this down to 16 bytes for you

12

@DialFrost \-2Ṁ is insert "-" at position 2

MathGolf, 16 bytes
7<2/╞├'-⌐~'P='+*

Try it online.
Explanation:
7<                 # Leave the first 7 characters of the (implicit) input-string
  2/               # Split it into parts of size 2
    ╞              # Discard the first part (the "**")
     ├             # Remove and push the first part to the stack (the "TI")
      '-          '# Push "-"
        ⌐          # Rotate the stack once towards the left (so the remaining pair is at
                   # the top again)
         ~         # Pop and dump its contents onto the stack (the number and "*"/"P")
          'P=     '# Check if the top of the stack equal "P" (1 if truthy; 0 if falsey)
             '+*  '# Repeat "+" that many times ("+" if it was "P"; "" if not)
                   # (output the entire stack joined together implicitly as result)

Rust macro, 135 bytes
macro_rules!f{(* * T I$($n:literal)*P$($x:tt)*)=>{[84,73,45,$($n+48,)*43]};(* * T I$($n:literal)**$($x:tt)*)=>{[84,73,45,$($n+48),*]};}

Defines a macro f that takes a list of tokens and returns an array of integers (ASCII chars).
try it online
Explanation
macro_rules! f {
    (                  // if the input has the following tokens:
        * * T I        //  * * T I
        $($n:literal)* //  zero or more literals (called n)
        P              //  P
        $($x:tt)*      //  anything
    ) => {             // expand to this:
        [              //  an array
           84, 73, 45, //   with the ASCII codes for TI-
           $($n+48,)*  //   add 48 to each n and append a comma
           43          // the ASCII code for +
        ]
    };
    (                  // if the input has the following tokens:
        * * T I        //  * * T I
        $($n:literal)* //  zero or more literals (called n)
        *              //  *
        $($x:tt)*      //  anything
     ) => {            // expand to this:
        [              //  an array
           84, 73, 45, //   with the ASCII codes for TI-
           $($n+48),*  //   add 48 to each n and join with commas
        ]
    };
}

PHP, 39 38 36 bytes
fn($s)=>"TI-$s[4]$s[5]".'+'[$s[6]<P]

Try it online!
Basically a port of Arnauld's answer with a bit of inspiration from Sqepia's one for the "+".. Let's say that's what I would have done anyway ;)
EDIT: saved 1 byte using < instead of !=
EDIT2: Thanks to Ismael Miguel for saving another 2 bytes using vars in double quotes!

'TI-'.$s[4].$s[5] can be written as "TI-$s[4]$s[5]", to save 2 bytes.

Befunge-93, 27 bytes
~~~,~,"-",~,~,~"P"-#@_"+",@

Try it online!
Read two characters (and ignore them). Read a char (T) and print it. Read another char (I) and print it. Print a -. Read a char (a digit) and print it. Read another char (a digit) and print it†. Read a char, end the program if it's not a P, else print a + and end the program.
†We cannot just read a number and print a number, as that will be printed with an additional trailing space.

Haskell, 35 bytes
f s="TI-"++s!!4:s!!5:['+'|s!!6>'*']

Try it online!

Java 8, 35 bytes
a->"TI-"+a[4]+a[5]+(a[6]>79?"+":"")

Try it online.
Explanation:
a->           // Method with character-array parameter and String return-type
  "TI-"       //  Return "TI-"
  +a[4]+a[5]  //  Appended with the (0-based) 4th and 5th characters of the input
  +(a[6]>79?  //  And if the (0-based) 6th character is larger than 'O' (thus 'P'):
     "+"      //   Append a "+"
    :         //  Else:
     "")      //   Append nothing more

C# .NET, 35 bytes
s=>"TI-"+s[4]+s[5]+(s[6]>79?"+":"")

Only difference is the => instead of ->, and the input parameter is a string instead of character-array. Apart from that it's the same as the Java lambda above.
Try it online.

Whitespace, 150 bytes
[S S S N
_Push_0][S N
S _Dupe_0][S N
S _Dupe_0][S N
S _Dupe_0][T    N
T   S _Read_as_character_(*1)][T    N
T   S _Read_as_character_(*2)][T    N
T   S _Read_as_character_(T)][T T   T   _Retrieve][S N
S _Dupe][S N
S _Dupe][T  N
S S _Print_as_character][T  N
T   S _Read_as_character_(I)][T T   T   _Retrieve][S N
S _Dupe][S N
S _Dupe][T  N
S S _Print_as_chartacer][S S S T    S T T   S T N
_Push_45_-][T   N
S S _Print_as_character][T  N
T   S _Read_as_character_(digit1)][T    T   T   _Retrieve][S N
S _Dupe][S N
S _Dupe][T  N
S S _Print_as_character][T  N
T   S _Read_as_character_(digit2)][T    T   T   _Retrieve][S N
S _Dupe][S N
S _Dupe][T  N
S S _Print_as_character][T  N
T   S _Read_as_character_(*/P)][T   T   T   _Retrieve][S S S T  S T S S S S N
_Push_80][T S S T   _Subtract][N
T   S N
_If_0_Jump_to_Label_P][N
N
N
_Exit][N
S S N
_Create_Label_P][S S S T    S T S T T   N
_Push_43_+][T   N
S S _Print_as_character]

Letters S (space), T (tab), and N (new-line) added as highlighting only.
[..._some_action] added as explanation only.
Try it online (with raw spaces, tabs and new-lines only).
Explanation in pseudo-code:
Character c = STDIN as character   (the first leading "*")
c = STDIN as character             (the second leading "*")
c = STDIN as character             (the "T")
Print c as character to STDOUT
c = STDIN as character             (the "I")
Print c as character to STDOUT
Print '-' as character to STDOUT
c = STDINT as character            (the first digit)
Print c as character to STDOUT
c = STDIN as character             (the second digit)
Print c as character to STDOUT
c = STDIN as character             (the '*'/'P')
If(c == 'P'):
  Print '+' as character to STDOUT

SimpleTemplate, 52 bytes
So far, it is the 2nd longest answer, but works...
{@setA argv.0}TI-{@echoA.4,A.5}{@ifA.6 is equal"P"}+

Just naively grabs the characterss from the string, at a predefined position. Nothing fancy...

Ungolfed:
Both codes behave exactly the same:
{@set argument argv.0}
{@echo "TI-", argument.4, argument.5}
{@if argument.6 is equal to "P"}
    {@echo "+"}
{@/}

Everything outside the code is just printed out.
Basically, TI- and {@echo "TI-"} do the same exact thing.

You can try this on http://sandbox.onlinephpfunctions.com/code/1a2faee21e43109e148b057df65d2f119780ca45
I've implemented this version, and an aditional version as a function, to compare outputs.

Bash, 51 bytes
read a
b=${a:6:1}
b=${b%\*}
echo TI-${a:4:2}${b:++}

Try it online!
Uses standard input and output.
a holds the first line, any other input is ignored.
b holds the * or P after the number, and then the * is removed.
data is assumed to be correct.
The echo outputs the three pieces, adding the + only if b is non-blank.

C (gcc), 50 48 47 bytes
Thanks to Arnauld for the initial suggestion.
Not much to say here except that I conditionally print a plus sign at the end of the string if a P is in the seventh position.
f(char*s){printf("TI-%.2s%s",s+4,"+"+s[6]%80);}

Try it online!

Ruby, 33 bytes
Port of Daniel H.‘s Python answer.
->s{"TI-"+s[4,2]+(s[6]>?*??+:"")}

Attempt This Online!

Pyth, 21 bytes
++"TI-":z4 6*\+q@z6\P

Test suite

Go, 95 bytes
import."strings"
func f(s string)string{R:=Replace
return"TI-"+R(R(s[4:7],"P","+",1),"*","",1)}

Attempt This Online!

Knight, 29 bytes
O+"TI-"+G=sP4 2*"+">Gs 6 1'*'

Try it online!

Gs 6 1 -> Gs 6T


text:
What is the fastest safe way down a mountain?
Intro
Help! I'm stuck on a snow-covered mountain and I need to get down as fast as possible, preferably without dying. I have a map showing how high each part of the mountain is above the normal ground.
I am a novice skier, which means I like to stick to slopes that aren't too steep. I'm willing to go down just two moderately steep sections, however - but not back to back!
Rules
Your program's job is to, given a n x m matrix of height values, navigate from the skier's current position (the top left corner) to the base (the bottom right corner). Height values will be given as integers between 0 and 25, with 25 being the highest possible point and 0 being the base of the mountain. It should be noted the mountain does not have to start at 25 units high, but will always finish at the 0 in the bottom right corner.
There are a few constraints:

The skier can move up, down, left, or right on the map. No diagonals.
The skier is usually only comfortable on slopes that bring him down 2 units or less.
The only exception to the above rule is that the skier can go down a maximum of two sections that will bring him down 3 or 4 units.
The skier can move upwards if necessary, but only one unit at a time. The skier also cannot go upwards or flat then immediately thereafter go down a steep slope of 3 or 4 units, he must already be headed downwards before taking a steep slope. Also, his first move cannot be to go down a steep slope, and he cannot do two steep slopes back to back.
It is possible for the skier to visit a location twice (as seen in the fourth example - this is due to the fact that the skier cannot go down two steep slopes in a row)

Input
As mentioned above, the map will be given by a matrix containing integer values from 0 to 25, with a 0 in the bottom left corner (there could be zeroes in other places on the map). These maps will always have at lease one best solution but could have several worse solutions. These matrices will always have spaces and line breaks as separators - double spaces will be used if the integer is just one character (see examples below)
Output
Your program is to output a sequence of moves (the format of this sequence does not matter so long as it is coherent) that shows the best way down the mountain - meaning fewest moves on the map. These moves can be represented by any strings, numbers, or characters you like, so long as they are distinct and are described in your solution. A sample output might look like RRDDRRRURRDDDDRR, where R means right, D means down, U means up, and L means left.
Test cases
Input 1:
10 13 13 13 13
8  9  11 13 25
0  7  11 12 23
6  5  2  2  0

Sample output 1:
DRDDRRR

Input 2:
16 12 12 10 8 6
14 12 6  8  0 4
10 20 4  2  1 2
8  20 10 8  4 0
9  8  9  25 2 0

Sample output 2:
DDDDRRURRDR or DRURRRRDDDD
Input 3:
20 19 15 11 0  9  15 6
18 20 13 12 11 9  18 12
16 25 9  7  6  2  1  1
12 20 10 4  4  4  3  2
13 12 13 0  0  0  0  0

Sample output 3:
RRDDRRDRRRD

Input 4:
20 18 10 11 12 0
19 11 1  4  5  0
18 16 3  3  3  3
19 8  7  17 19 3
18 20 11 12 13 3
17 17 16 16 14 2
20 21 11 14 11 0

Sample output 4:
DDDDDRRRRULLULRURRRDDDD

Scoring:
This is code-golf. Shortest answer wins - get creative!

@Arnauld good idea, edited!

Is it possible a position is visited twice?

Can you include an example where the solution contains Us and Ls? Now it seems the skier will never move "away" from the goal.

@Abigail it is possible to visit a location twice, however this will be a very rare case. I'll add a case with L's as well once I have one made

@Abigail I've added a fourth test case that uses all four directions and also needs to visit a position twice. This test case is a lot harder and will definitely catch a lot of people who try to skip out on some of the criteria. Hope this clarifies things!

How does the first test case work at the end going up 1 and then down 3?

@Noodle9 the skier cannot go down a steep slope immediately after going up. I'll add the word immediately to the rules, thank you for pointing that out!

@Noodle9 oh whoops, I never saw that. I'll fix that by changing the 3 to a 2, tyvm

The introduction mentions "preferably without dying", but the challenge requires us to keep them alive :(

'The skier also cannot go upwards then immediately thereafter go down a steep slope of 3 or 4 units, he must already be headed downwards before taking a steep slope' - slightly ambiguous: must the skier be headed downwards, or can he be going flat (neither up nor down) before embarking on a steep slope?

@DominicvanEssen he must be headed downwards before taking a steep slope - this means he can't be going flat beforehand (nor can he take a steep slope as his first move)

Not that clear to me, maybe a state graph?

JavaScript (ES6),  223 ... 205  199 bytes
f=(m,x=o=0,y=0,n=2,V,s,p='',r=m[y]||0,v=r[x],h=V%32-v%32|0)=>63>>h+1&v<64&!p[o.length-1]?h<3||s*n--?1+r[x+!m[y+1]]?[...'LURD'].map((c,d)=>r[f(m,x+--d%2,y+~-d%2,n,r[x]+=32,6>>h&1,p+c),x]=v)&&o:o=p:0:0

Try it online!
Commented
The 5 least significant bits of the cells are left unchanged. The upper bits are used to count the number of times a cell has been visited in a given path.
We need quite a lot of variables to fully describe the skier status at any given time, notably the possibility to do a big steep slope.
Header
f = (                      // a recursive function taking:
  m,                       //   m[] = input matrix
  x =                      //   (x, y) = current position, starting at (0, 0)
  o = 0,                   //   o = output string, initialized to a numerical value
  y = 0,                   //
  n = 2,                   //   n = remaining number of big steep slopes
  V,                       //   V = value of the previous cell
  s,                       //   s = a flag that is set if a big steep slope is allowed
                           //       for this turn
  p = '',                  //   p = current path string
  r = m[y] || 0,           //   r[] = current row (using 0 as a fallback)
  v = r[x],                //   v = value of the current cell (or undefined)
  h = V % 32 - v % 32 | 0  //   h = height between the previous and the current cell
) =>                       //       (0 if V is undefined)
  (...)                    //

Tests
63 >> h + 1 &              // if the height is greater than or equal to -1 and less
                           // than or equal to 4 and
v < 64 &                   // v is defined and less than 64 and
!p[o.length - 1] ?         // the current path is shorter than the best solution or
                           // we don't have a solution yet (in which case o.length - 1
                           // is NaN):
  h < 3 ||                 //   if the height is less than 3 or
  s * n-- ?                //   a big steep slope is allowed and we can still do one:
    1 + r[x + !m[y + 1]] ? //     if we haven't reached the bottom-right cell,
                           //     i.e. m[y + 1] is defined or 1 + r[x + 1] is not NaN:
      (...)                //       process the recursive calls
    :                      //     else:
      o = p                //       update the solution to this path
  :                        //   else:
    0                      //     do nothing
:                          // else:
  0                        //   do nothing

Recursive calls
[...'LURD'].map((c, d) =>  // for each direction character c at index d:
  r[                       //   we will eventually restore r[x]
    f(                     //     recursive call:
      m,                   //       m[] is unchanged
      x + --d % 2,         //       add dx to x
      y + ~-d % 2,         //       add dy to y
      n,                   //       n is unchanged
      r[x] += 32,          //       add 32 to the current cell
      6 >> h & 1,          //       set s if h is either 1 or 2
      p + c                //       append c to the path
    ),                     //     end of recursive call
    x                      //     restore r[x] to ...
  ] = v                    //   ... v
) && o                     // end of map(); yield o

Impressive! Its output for the second test case is of the same length, so it's correct. I'll add this new solution as a possible solution for this case.

I can't seem to grow tired of reading your JS submissions. Always impressive work.

J, 185 bytes
Far from perfect, but it's something. Could theoretically save 17 bytes by omitting the check for revisiting places, but then the last example ran out of memory on my machine and I couldn't truthfully say all examples were verified. :-)
Takes in the map and outputs a list of offset coordinates 1 0,0 1,_1 0,0 _1 that I've mapped to DRUL in TIO for easier comparison.
}.@{.@(((](\:+/"2)@#~[*/@((4((1>=&3-_1|.2=])*>&0*3>[:+/\3=])@:|(+:<:i.4)I.0,2-/\({~ ::_"_ 0<"1))*3>[:+/[:="1/~<"1@])0 2+/\@|:])[:,/((,-)=i.2),~"1 2/])^:(0=<:@$@[-:+/@{.@])^:_&(1 1 2$0))

Try it online!
How it works
(1 1 2$0)

We keep the routes as a list of offsets, starting with 0 0.
(…)^:(0 = <:@$@[ -: +/@{.@])^:_

Do until the head of the list – which is nearest the bottom right – equals the dimensions of the map - 1.
[: ,/ ((,-)=i.2) ,~"1 2/ ]

Each route gets the 4 offsets added, so we have 4 times as many routes: (0 0,1 0),(0 0,0 1),(0 0,_1 0),(0 0, 0 _1). Then we have to filter these routes based on several checks.
0 2 +/\@|: ]

List of offsets -> List of absolute coordinates, transposed so each routes' first points are in one list, then each routes' second points are in one list, etc:
0 0,0 0, 0 0,0  0
1 0,0 1,_1 0,0 _1

This format seems more suitable for the checks, but maybe a (…)"2 would have been enough. However, now each check can build up a matrix saying which coordinate is ok and which not and in the end we can easily reduce it.
3 > [: +/ [: ="1/~ <"1@]

No place should be visited 3 times. This check is just to keep the number of routes from exploding.
0, 2 -/\ ({~ ::_"_ 0<"1)

Gets the height values from the map at the absolute coordinates. If something is out of range, it will be replaced with infinity. Then we'll get the diff between neighboring heights and prepend 0 so the matrix will align with the previous one. Now we have (given the first map):
0  0 0 0
2 _3 _ _

With
4 …@| (+:<:i.4) I.

we sort the height diffs into 4 categories: 0 = not reachable, 1 = climb up, 2 = gentle slope, 3 = steep slope.
3 > [: +/\ 3=]

Less then 3 steep slopes.
>&0

Point must be reachable
1 > =&3 - _1 |. 2 = ]

3 is only allowed if 2 was in front of it.
] …@ #~ [ */

A route is only taken if all of its coordinates passed all tests.
(\:+/"2)

Sort the routes based on their last, absolute coordinate.
}.@{.

Finally the loop has ended and the first route contains the best route written in offsets, with only a 0 0 at the top that gets dropped.

This is great! May I ask, when programming in languages that are so non-human-readable like J, how do you not lose your mind? Do you write the program in a more readable language then transcompile somehow?

This was mostly written in the J REPL. :-) If you roughly know what you want to do (recurse, add offsets, check and filter routes, sort) it's just writing them step by step in small functions. Until then it's perfectly readable if you know J. Only in the final phase I format this in a written out way and see if I can reorder some stuff to save some bytes.

Python3, 425 bytes
E=enumerate
M=[('R',0,1),('L',0,-1),('U',-1,0),('D',1,0)]
def f(B):
 d={(x,y):v for x,r in E(B)for y,v in E(r)}
 q=[(0,0,{},'',2,0,0)]
 for x,y,D,m,l,s,u in q:
  if(x,y)==(len(B)-1,len(B[0])-1):return m
  for T,X,Y in M:
   if(N:=(x+X,y+Y))in d:
    a,b=d[(x,y)],d[N]
    L=a-b in[3,4]and l and not u and m and not s
    if N not in(U:=D.get((x,y),[]))and(0<=a-b<3 or L or b-a==1):q+=[(*N,{**D,(x,y):U+[N]},m+T,l-L,L,b-a==1)]

Try it online!

source: Stack Exchange

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

sort: votes


text:
Represent n as an expression containing all the digits
Related Challenge: Single Digit Representations of Natural Numbers
Task
Write a program/function that when given a non-negative integer \$n \le 100000\$ outputs an expression which uses all the digits from \$0\$ to \$9\$ exactly once and evaluates to \$n\$
The expression outputted by your program may only use the operations listed below:

addition
subtraction and unary minus (both must have the same symbol)
multiplication
division (fractional, i.e. 1/2 = 0.5)
exponentiation
parentheses

Note: Concatenation is not allowed
Output Format

Output can be a string, list of operations and numbers or a list of lists in place of brackets.
You may choose the precedence of the operators but it must be consistent for all outputs produced by your program/function
Output may be in polish, reverse polish or infix notation but it must be consistent for all outputs produced by your program/function.
You can use custom symbols for representing the digits and operations but the symbols used for representing the digits and operations should be distinct.

Scoring
This is code-golf so shortest bytes wins
Sample Testcases
0 -> 0 ^ (1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9)
4 -> (0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8) / 9
7 -> 0 * (1 + 2 + 3 + 4 + 5 + 6 + 8 + 9) + 7
45 -> 9 + 8 + 7 + 6 + 5 + 4 + 3 + 2 + 1 + 0
29 -> 1 + 2 + 7 + 6 + 5 + 4 + 3 + 0 + (9 - 8)
29 -> (((9 + 8 + 7 + 6) * 0) + 5 + 4) * 3 + 2 * 1
100 -> (9 * 8) + 7 + 4 + 5 + 6 + 3 + 2 + 1 + 0

A proof by exhaustion (also contains program used to generate the proof) that shows that all number less than or equal to \$100000\$ have an expression that uses all the digits.

Seeing as the very first thing you do is link to a challenge that allows it, I think you should explicitly state that concatenation isn't permitted here.

A test case or 2 with input <10 would be handy, too.

Is not including concatenation really different enough to make this not a duplicate?

This challenge is literally just asking people to brute force putting digits and symbols together until the output matches. It is pointless because you made the rules so loose.  Either add a time limit per execution or simply state that brute force is not an option because these programs will never fully execute in reasonable time

@pppery, please read the other question it is pretty different.

@JBernardo, yes the challenge is just asking for a brute force, that is how i ment this challenge to be.

So I guess you will run these programs til the end of times to see if they produce right results?

@JBernardo Code golf are usually like that. It's possible to set a time limit condition (either "the program must run in 10 seconds on my machine" or "you must be able to run the program to completion"), but people don't usually do that here.

@Mukundan314 - Thanks for the info that division isn't required up to 100k, and the updated proof-by-exhaustion.  I notice that your proof, as well as my own R answer, both use fully-nested parentheses in infix (equivalent to alternating digits & operators in RPN).  This isn't required by the challenge, so it seems still possible that other operators might become superfluous by re-arranging the parehtneses...  unless you know something that I don't...

@DominicvanEssen yes that is correct other operators might not be necessary when having more complicated parentheses but if you do submit an answer which uses more complicated parentheses and fewer operators then please also include a proof of why your answer can generate expressions for all numbers from 0 to 100k

Unfortunately I'm afraid that it would probably make my code (even) longer and (even) slower...

05AB1E, 25 24 bytes
9Ýœ"+-*m"9ãðδšδ.ιJ˜.Δ.VQ

Brute-force approach, so obviously extremely slow.
Outputs in reverse Polish notation, with the characters +-*m for addition, subtraction, multiplication, and exponentiation respectively. Division isn't necessary for the \$[0,100000]\$ range we have to support.
Try it online with additional (first) input to specify the digit-range \$[0,n]\$ instead of \$[0,9]\$, for which I've used 4 right now as example.
Explanation:
9Ý           # Push a list in the range [0,9]
  œ          # Get all possible permutations of this list
"+-*m"       # Push string "+-*m"
      9ã     # Get all possible combinations of size 9 with the cartesian product
         δ   # Map over each string of operations:
        ð š  #  Convert it to a list of characters, and prepend a space
δ            # Apply double-vectorized with both lists of lists:
 .ι          #  Interleave the lists
J            # Then join each inner list together to a string
.Δ           # Find the first string which is truthy for:
  .V         #  Evaluate/execute the string as 05AB1E code
    Q        #  And check if the result is equal to the (implicit) input-integer
             # (after which the found result is output implicitly)

If we are allowed to output all possible results instead of just one, the .Δ (find first) could be ʒ (filter) for -1 byte. Although in that case it would become even slower than it already is..

@Downvoter: care to explain why? I don't mind being downvoted, but I'd like to know why so I can improve and keep this in mind in the future.

there's been a spate of downvotes on solutions in golfing languages this week.

@Shaggy Ah, it's that time of year again.

division isn't actually required. plus, minus, multiply and exponentiation are enough to get all number from 0 to 100000

@Mukundan314 Is it also true that all numbers can be achieved by executing each operation in turn i.e. you never have to do e.g. (a+b)*(c+d)?

@Neil yes that is correct.

R, 249 244 234 224 220 200 bytes
Or R+arrangements library, 237 232 222 212 208 188 bytes (and somewhat faster)
Multiple edits: -15 bytes thanks to Mukundan314 (no division needed), -4 bytes thanks to 'my pronoun is monicareinstate', -10 bytes by outputting in Polish (prefix) notation, and (latest) -20 bytes by outputting as error message
function(n){apply(gtools::permutations(10,10)-1,1,function(k)apply(expand.grid(rep(list(1:4),9)),1,function(l){for(m in 10:1)F=c(`+`,`-`,`*`,`^`)[[c(l,1)[m]]](F,k[11-m])
if(F==n)stop(letters[l],k)}))}

Try it online!
Outputs as error message, in Polish notation using 'a' to denote plus, 'b' to denote minus, 'c' to denote multiply, and 'd' to denote exponentiation.
Commented version before golfing (with more-readable output that can be copy-pasted to directly check):
make_number=function(n,with=0:9) {
    i=arrangements::permutations(with)          # all the permutations of the digits 0..9
    j=as.matrix(expand.grid(rep(list(1:5),length(with)-1)))
                                                # all the combinations of 1..5 (for the 5 operators)
    o=c("+"=`+`,"-"=`-`,"*"=`*`,"/"=`/`,"^"=`^`)
                                                # the 5 operators that we can use
    for(k in 1:nrow(i)){for(l in 1:nrow(j)){    # cycle through the permutations of digits & operators
        t=i[k,1]                                # total starts as first digit
        for(m in 2:length(with)-1){t=o[[j[l,m]]](t,i[k,m+1])}
                                                # apply all the operators using each next digit
        if(!is.na(t)&&(t==n)){                  # if we get the answer we're looking for...
                                                # return a string with the calculation
            return( paste0( paste0(rep("(",ncol(j)),collapse=""),paste0(c("",names(o)[j[l,]]),i[k,],collapse=")")))
        }
    }}
}

> make_number(1)
[1] "(((((((((0)-1)-2)-3)*4)-5)+6)+7)+8)+9"
> make_number(99)
[1] "(((((((((0)+1)/2)+3)+4)+5)*6)+7)+8)+9"
> make_number(1234)
[1] "(((((((((0)*1)+2)+3)^4)/5)+6)+7)*9)-8"

Note that this algorithm will always find first (and stop at) a solution with the smallest rearrangment of the digits from the starting order of 0..9.

division isn't actually required. plus, minus, multiply and exponentiation are enough to get all number from 0 to 100000

Is there really any reason to stop at 262144 and not simply iterate until 1e9? (I don't know R)

That number is the columns in the matrix of permutations of operators. There are 4 operators, assigned to 9 positions, so 4^9=262144. This saves a character compared to writing ncol(j).  It's an inner loop, so it needs to terminate correctly.

But it's a good suggestion for the outer loop (currently ncol(i)), which should never go beyond the end because it should have already found a solution. Thanks!

It works for me (on the only test case) if I replace 262144 with 3e5.

TLDR - you're probably right, but it's risky without proving it for all 100001 cases.  3e5 will crash for any number (eg 163) that can't be solved with the digits in 0..9 order, since the inner loop will over-run.  2e5 won't crash, but it won't sample all the possible permutations of operators.  Due to the order of the operator list and the fact that 2e5 > 3/4 * 262144, the only permutations that will be missed are those with exponentiation as the first-used operator.  It seems very likely to me that this will still allow all numbers up to 100k to be generated, but I don't have a proof.

Note that I've now found a way to avoid defining these loop sizes altogether (enabled by outputting in an error message...), which will hopefully avoid the need to generate the 'no-first-exponentiation' proof just to save 3 bytes...

Charcoal, 84 bytes
Ｎθ≔”y⁰¹²³⁴⁵⁶⁷⁸⁹”ε≔ＶεηＷ¬ω«≔⭆◧Ｉηχ§εΣκζ≦⊕η¿⬤ε№ζκＦＸ⁴¦⁹«≔⭆⁹§”y⁺×⁻Ｘ”÷κＸ⁴λδ¿⁼Ｖ⁺δ⪫ζ´¦θ≔δω»»ωζ

Don't try it online! Link is to verbose version of code. Outputs prefix notation using Charcoal operators and digits (note that it's not valid Charcoal code due to the omission of ¦ separators between the digits, and it still wouldn't be useful without the Ｉ cast operator). Explantion:
Ｎθ

Input n.
≔”y⁰¹²³⁴⁵⁶⁷⁸⁹”ε

Assign the list of Charcoal's digits.
≔⁰η

Start checking starting at 0000000000 and working up.
Ｗ¬ω«

Repeat until we have an answer.
≔⭆◧Ｉηχ§εΣκζ

Convert the current trial index to a 10-digit number in Charcoal digits.
≦⊕η

Increment the trial index.
¿⬤ε№ζκ

If this is a permutation of the 10 digits, then...
ＦＸ⁴¦⁹«

Loop over all operator combinations,
≔⭆⁹§”y⁺×⁻Ｘ”÷κＸ⁴λδ

convert each into a string of operators,
¿⁼Ｖ⁺δ⪫ζ´¦θ

compare the value with n,
≔δω

and set the result if it matches.
»»ωζ

Output the resulting operator string and digits.
96-byte version that can actually finish in under a minute on very simple examples:
Ｎθ≔”y⁰¹²³⁴⁵⁶⁷⁸⁹”ε≔ＶεηＷ¬ω«≔⭆◧Ｉηχ§εΣκζ≦⊖ι≦⊕η¿⬤ε№ζκＷ∧¬ω‹ιＸ⁴¦⁹«≔⭆⁹§”y⁺×⁻Ｘ”÷ιＸ⁴λδ¿⁼Ｖ⁺δ⪫ζ´¦θ≔δω≦⊕ι»»ωζ

Try it online! Link is to verbose version of code.

Python 3, 200 194 186 178 bytes
-6, -2, -6, -8 bytes, and a test runner thanks to @Mukundan314.
lambda n:next(s for o in product(*[[*"+-*","**"]]*9)for l in permutations("0123456789")if eval(s:="("*8+l[9]+')'.join(o[i]+str(l[i])for i in range(9)))==n)
from itertools import*

Try it online! (5 digits case)
Outputs in infix notation with parentheses, using +-* respectively for addition, subtraction, and multiplication; uses ** and exponentiation. The program generates Python code that gets eval'd to check for equivalence to n.
Slightly more-readable version with a variable for the number of digits:
L=9
import itertools as i
def g(n):
    for l in i.permutations(map(str,range(1,L+1))):
        for o in i.product("+-*m",repeat=L-1):
            s=l[L-1]
            for j in range(L-1):
                s='('+s+o[j]+l[j]+')'
            s=s.replace("m","**")
            if eval(s)==n:
                return s

@Mukundan314 incorporated those last two edits and saved an extra 2 bytes by rewriting into a one-liner

In your current code 0**<negative number> is possible this throws an error halting the program

My code only proves that all number till be 100k can be formed with expression of the form <9 operators><a permutation of 0123456789> in polish notation . it does not prove that all number till 100k can be formed with expression of the form alternating digit and operator in polish notation

@Mukundan314 Oh, I see. I happened to change it from left-associative infix to right-associative infix, which switched polish and reverse polish notation. I switched association order now, so it is now fixed and raises StopIteration for unobtainable n (the 0** only happened in rare cases because it only reached that state after 0+(...), which could normally yield a solution).

Wow, the 3.8 assignment expr is going to be very useful; it seems like it was made for golfing

-4 bytes by merging the for loops

160 bytes

Jelly, 21 26 bytes
+5 bytes for a fix based on Kevin Cruijssen
“+×*_”ṗ9
⁵ḶŒ!p¢ż/€Ẏ€V=¥ƇḢḢ

Brute force, like the 05AB1E answer, so it is also extremely slow.
Outputs in infix notation with +×*_ to represent addition, multiplication, exponentiation, and subtraction respectively. All operators have equal precedence. Similarly to my Python answer, this generates an expression and evals it to find what it evaluates to.
Try it online (in a version that allows you to enter the number of digits) The value for n should be provided as the first argument, while the input should consist of two lines: the first equal to the number of digits; the second less by one.
Explanation (going to update soon, I should be able to golf a bit off):
“+×*_”ṗ9           # literal string "+×*_" (Jelly arithmetic symbols) Cartesian power 9

⁵ḶŒ!p¢ż/€Ẏ€V=¥ƇḢḢ
⁵Ḷ                 # lowered_range(10): [0,1,2,3,...,9]
  Œ!               # all permutations of these digits
    p              # Cartesian product with
     ¢             # the list of all permutations of 9 arithmetic symbols
      ż/€Ẏ€        # zip and tighten each to squeeze together (golfportunity?)
           V=¥Ƈ    # Filter for those that evaluate to
               Ḣ   # n (surely there is a way around this)
                Ḣ  # get the first one

If no string works (which could occur if n is too large or the number of digits is decreased), then it outputs 0.

@KevinCruijssen working on fixing the duplicate number, but 80 was the first test case I tried that worked well with 4 digits

@KevinCruijssen Fixed the issue (80 is slightly-humorously unobtainable with 4 digits). The 26-byte version involved almost completely rewriting from scratch, but I have a 28-byte version that is less-modified from the previous attempt: https://tio.run/##y0rNyan8///Y5Ic7thU8apijfXi6VvyjhrnFJkcnFRydpPioaY1bMVB25zQgK8z20NJj7Q93LAKi//9NuCz@GxoAAA

Looks good. +1 from me, and I've deleted my comments. :) Looking forward seeing that updated explanation. PS: Jelly doesn't have a find_first builtin, instead of the filter + head? I indeed couldn't find one on the Wiki page, but maybe I looked past it.

@KevinCruijssen Good idea. There is # for find_first_n, which should save me 1 byte

Pyth, 23 bytes
hfqQ.vjdsT*^"+-*^"9.pUT

Try it online! (5 digit case)
Explanation
hfqQ.vjdsT*^"+-*^"9.pUT
h                        : first element of
 f                       : filter on
          *              : cartesian product of
           ^"+-*^"9      : all 9 length string that can be formed with the chars +, -, * and ^
                   .pUT  : and all permutations of [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
  qQ                     : for equality of input and
    .vjdsT               : evaluated result of operators and permutation joined with spaces

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


text:
Find the busiest hour for each stackexchange site
Input
Name of a stackexchange site or any way to uniquely identify the site.
Output The hour of the day that had the largest number of answers posted over the previous 24 hours. E.g. 14:00-15:00 GMT.
You can take the input and give output in any easily human readable format.
Your code can access the Internet but only the site's API. Previous 24 hours should be from the start of the current hour.
Out of politeness, please don't test your code on stackoverflow where the number of queries may need to be high.

Is the input the API name of the site? e.g. webapps.meta for Web Applications Meta

@Arnauld Good point. Yes.

We can access the web, right? But only the site's API, correct? You may want to mention that in the challenge. Also, does "previous 30 days" mean with respect to today (June 17, 2020) or to the time when the program is run?

@LuisMendo Thanks. Question amended.

Great, upvoted!

I'm not very familiar with the API, so I may be wrong. But it seems like we need to retrieve all answers posted during 30 days in order to extract the relevant timestamp and build the hourly stats. For Stack Overflow, that's ~6800 answers per day and ~200K answers for 30 days. The maximum number of results per request is 100, so that's ~2000 calls to the API, which I think is unreasonable for a recreational challenge.

I’m voting to close this question because it is off-topic due to asking for malicious code. Cf. https://codegolf.meta.stackexchange.com/q/4829/43319

@Adám I amended the question. Hopefully OK now (I clearly don't want malicious code!)

@Arnauld Question amended. Thanks for pointing that out.

@Anush I don't think so. Per Arnauld's numbers, that'd still be up to 70 calls to the API per solution, not to mention the testing phase when developing one's solution.

Let's discuss in chat.

@Arnauld Isn't the simple solution to not run the code on SO?

@user202729 yes. I will edit to say that.

@user202729 I don't know for sure. I suspect that the number of API calls will still be pretty high for many other sites.

@Arnauld  https://i.stack.imgur.com/0LCr0.png suggests the difference is really huge so the number of queries needed for any other site will be pretty limited.

@Adám Could you explain how this is or was asking for malicious code?

@pppery It was asking to hammer SE with API requests.

This is very sad :(  It definitely looks like a programming challenge/code-golf question to me.


text:
Get to the Zone!
You are playing a famous game called \$1\text{D Array BattleGround}\$. In the game, the player can be stationed in any position from \$0\$ to \$10^5\$.
You are a Paratrooper in the game and have the ability to do two types of operation \$-\$

Advance, which would multiply your position by \$2\$
Fall-back, which would decrease your current position by \$1\$

Each type of operation requires \$1\$ second.
You are stationed in \$N\$ and want to go to \$M\$ in the minimum time possible, (\$1≤ N, M ≤10^4\$).
Find out the minimum time you need to Get to \$M\$.
Note: After each operation, you must remain in the zone from \$0\$ to \$10^5\$.
Sample
Input : 4 6
Output: 2

Input : 10 1
Output: 9

Input : 1 3
Output: 3

Input : 2 10
Output: 5

Input : 666 6666
Output: 255

Input : 9999 10000
Output: 5000

This is a code-golf challenge so code with lowest bytes wins!

You should note by Advance operation you are multiplying your current position by 2, so you can not go from 9998 to 10000 using Advance operation.

Ah, my bad. I read that as increase, but it clearly says multiply. Sorry about that.

What happens if you Fall Back at 0? What happens if you Advance at 5001?

By Fall Back to 0, you can not advance further. If you Advance to 5001 it's within the game area, so nothing happens.0 to10^5 is the designed game positions, overflow will break the game, so this range is set.

Is this challenge from another site?

No, I made it myself.

It seems like there should be a number theory equivalent to this.

Could you wrap a bold around the multiply? I read it as increase too!

@streetster Thank you for pointing it out :)

JavaScript (ES6), 30 bytes
Takes input as (N)(M).
N=>g=M=>M>N?M%2-~g(M+1>>1):N-M

Try it online!
How?
Instead of going from \$N\$ to \$M\$, we go from \$M\$ to \$N\$.
While \$M\$ is greater than \$N\$:

if \$M\$ is odd, increment it and divide it by \$2\$ (2 operations)
if \$M\$ is even, just divide it by \$2\$ (1 operation)

When \$M\$ is less than or equal to \$N\$, the remaining number of operations is \$N-M\$.
Example for \$N=666\$, \$M=6666\$:
  M   | transformation     | operations | total
------+--------------------+------------+-------
 6666 | M / 2       = 3333 |      1     |   1
 3333 | (M + 1) / 2 = 1667 |      2     |   3
 1667 | (M + 1) / 2 = 834  |      2     |   5
 834  | M / 2       = 417  |      1     |   6
 417  | M + 249     = 666  |     249    |  255

With inverse operations in reverse order, this gives:
$$((((666-249)\times 2)\times 2-1)\times 2-1)\times 2=6666$$
The idea behind that is that it's always cheaper to process the greatest number of fall-back operations at the beginning of the process (i.e. when \$N\$ is still small) rather than exceeding \$M\$ by too large a margin with hasty advance operations and doing fall-backs afterwards.

Is there a proof that this procedure gives the minimum number of steps?

@LuisMendo Oh yes ... Yes, there is! ... hurried footsteps ... door slamming ...

This looks right, I think I have an argument why it always works.

When considering going from M to N like you're doing, the reversed operations are halving (only for evens) and incrementing. Once M is below N, the only thing to do is to increment it up to N, since making it smaller first would be silly. Before that, we never want to increment twice in a row, since later we'll halve, and increment-increment-halve can be shortened to with halve-increment. This leaves us with only sequences made of halve and increment-halve. These can only be applied to even and odd numbers respectively, and so can be chosen based on parity as in your procedure.

(And the limit of 10,000 never comes up because it's even, so you never increment above it.)

C (gcc), 53 34 bytes
Saved a whopping 19 bytes thanks to the man himself Arnauld!!!
f(N,M){M=M>N?M%2-~f(N,-~M/2):N-M;}

Try it online!
A port of Arnauld's JavaScript answer.

A more direct port would work as well. :)

@Arnauld Wow! Was wondering if recursion would help and does it ever - thanks! :D

This doesn't return the answer, merely calculate it. Is it required for code gold answers to return output?

@Chipster It most certainly does return the answer! Click on Try it online and see for yourself.

Hmm, I see it. Does C return things implicitly?

Looks like you might be using UB unless I'm mistaken.

@Chipster A lot of code golfing is all about exploiting UB, notice that you have to state which compiler you use. If what you're exploiting is version specific, you state the version too.

APL (Dyalog Unicode), 24 bytes SBCS
Recursive dfn as per Arnauld's answer.
{⍵≤⍺:⍺-⍵⋄(2|⍵)+1+⍺∇⌈⍵÷2}

Try it online! We take Arnauld's approach but we use APL's nice builtins to make a single recursive call instead of having to choose the recursive call that we want to make (which would depend on the parity of M):
{⍵≤⍺:⍺-⍵⋄(2|⍵)+1+⍺∇⌈⍵÷2} ⍝ dfn taking N on the left and M on the right
{⍵≤⍺:                    } ⍝ if N is less than or equal to M
      ⍺-⍵                  ⍝ just return N - M
          ⋄                 ⍝ otherwise
                   ⍺∇⌈⍵÷2  ⍝ divide M by 2, round up and call this function recursively
                 1+         ⍝ to which we add 1 unconditionally
          (2|⍵)+            ⍝ and to which we add the parity of M, i.e. add one more iff M is odd.

Husk, 11 bytes
←V€⁰¡ṁ§eD←;

Try it online! Arguments are in reversed order (first target, then initial position).
Explanation
Brute force turned out shorter than more efficient methods.
←V€⁰¡ṁ§eD←;  Inputs: M (stored in ⁰) and N (implicit).
          ;  Wrap in list: [N]
    ¡        Iterate, returning an infinite list:
     ṁ         Map and concatenate:
         ←       Decrement and
        D        double,
      §e         put the results in a two-element list.
 V           1-based index of first list that
  €⁰         Contains M.
←            Decrement.

This solution is producing tle for the last case where $N=9999 $ and $ M= 10000.$ Were you able to produce a result from that case?

@JubayerAbdullahJoy TIO cuts execution time at 60 seconds. It should eventually finish if I run it locally. I can try that tomorrow.

@JubayerAbdullahJoy Well, the program quickly filled my computer's memory and I had to kill it. I maintain that it's correct in the sense that given enough time and memory, it will eventually output 5000, even though it's practically untestable.

oh, I am new to code-golf. What should we do if a solution can't be verified? Can it be accepted? :(

There has been some discussion on our meta site (here and here) about untestable answers. The consensus seems to be that an explained solution that works on small inputs and seems scalable is acceptable, unless of course someone finds inputs on which it fails. OTOH, since Husk and JavaScript are like apples and oranges, consider not accepting any answer.

Japt, 15 14 bytes
Heading tag now includes the completely unnecessary space SE are forcing on us for no good reason
Well, seeing as everyone else is taking Arnauld's approach ...! Be sure to +1 him if you're +1ing this.
Takes input in reverse order.
>V?¢ÌÒß°Uz:UnV

Try it
>V?¢ÌÒß°Uz:UnV     :Implicit input of integers U=M and V=N
>V                 :Is U greater than V
  ?                :If so
   ¢               :  Convert U to base-2 string
    Ì              :  Get last character
     Ò             :  Subtract the bitwise negation of
      ß            :  A recursive run of the programme with argument U (V remains unchanged)
       °U          :    Increment U
         z         :    Floor divide by 2
          :        :Else
           UnV     :  U subtracted from V

The missing space in your header is an offense to our new Commonmark overlords!

What missing space, @Arnauld? Noticed it's not being formatted; I'm guessing something's broken in their parser.

Although, it is being formatted in other solutions. Retyped mine from scratch, still the same. Tried h2 instead, still the same. :\

Our site has been migrated to CommonMark yesterday. The space after a # is now mandatory.

Ah. Well, that's seems to be a pretty moronic and unnecessary change, particularly the change to headings.

Jelly, 13 bytes
Took quite a while to find an approach which could be implemented in under 16 bytes.
‘:Ḃȯ⁹>$Ɗ?Ƭ2i’

A dyadic Link accepting M on the left and N on the right which yields the time you need to manoeuvre.
Try it online!
How?
‘:Ḃȯ⁹>$Ɗ?Ƭ2i’ - Link: M, N
          2   - use two as the right argument (R) of:
         Ƭ    -   collect up, starting at M, while results are distinct:
        ?     -     if...
       Ɗ      -     ...condition: last three links as a monad - i.e. f(current_value):
  Ḃ           -       LSB (i.e. is current_value odd?)
      $       -       last two links as a monad:
     ⁹        -         chain's right argument, N
    >         -         greater than? (i.e. is current_value less than N?)
   ȯ          -       logical OR (i.e. is current_value either odd or less than N?)
‘             -     ...then: increment
 :            -     ...else: integer divide by R (2)
          i  - 1-based index of first occurrence of N in that
           ’ - decrement

For case three where $N = 1$ and $M = 3$ this code gives result $2$. The expected result is $3$. I hope you will be able to figure out this case :)

OK sorted it. Thanks for spotting that.

Why less than 16 bytes, specifically?

Found a few different solutions for 16 along the way.

05AB1E, 18 bytes
[ÐÆd#`DÉD½+;‚¼}Æ¾+

Inspired by @Arnauld's JavaScript answer, so make sure to upvote him!
Try it online or verify all test cases.
Explanation:
[         # Start an infinite loop:
 Ð        #  Triplicate the pair at the top
          #  (which will use the implicit input in the first iteration)
  Æ       #  Reduce it by subtracting (N-M)
   d      #  If this is non-negative (>=0):
    #     #   Stop the infinite loop
  `       #  Pop and push both values separated to the stack
   D      #  Duplicate the top value `M`
    É     #  Check if it's odd (1 if odd; 0 if even)
      ½   #  If it's 1: increase the counter_variable by 1
     D    #  (without popping by duplicating first)
     +    #  Add this 1/0 to `M`
      ;   #  And halve it
       ‚  #  Then pair it back together with the `N`
 ¼        #  At the end of each iteration, increase the counter_variable by 1
}Æ        # After the infinite loop: reduce by subtracting again (N-M)
  ¾+      # And add the counter_variable to this
          # (after which the result is output implicitly)

perl -alp, 62 bytes
$;=pop@F;{$_<$;||last;$"+=1+$;%2;$;+=$;%2;$;/=2;redo}$_+=$"-$;

Try it online!
This uses the same logic as most other solutions.

Befunge-98, 75 bytes
The program keeps a running total of moves at (0, 0) and remembers N at (1, 0). It definitely could be golfed some more.
p&01p&>:01g-0\`|>:2%|
2/1  v  >0g+.@ >^   >
1+2/2v  ^0-\g10<    >
0+g00<^p0

Try it online! Edit: I had to add some extra arrows for it to run on TIO for some reason. See comments.
I used the logic from Arnauld's JavaScript answer.

Do you have a TIO link with an example? If I try that program in TIO, I can't find an input where the program finishes within a minute. Even simple cases like 1 1, or 1 2 seem to run forever.

@Abigail I spent awhile trying to get it to run in TIO, but couldn't identify the issue (wrapping around doesn't work correctly?). It works fine locally and also on: http://qiao.github.io/javascript-playground/visual-befunge93-interpreter/

That link is to a Befunge-93 interpreter, not Befunge-98. If I use TIO with Befunge-93, I have some success, that is, some inputs give the right answer, but some inputs seem to get stuck in a loop trying to divide by 0. 666 6666 for instance TIO link

Ah, I found the problem. You are writing the input numbers in the Befunge space. But they take a signed tinyint. The TIO interpretation is strict, and putting a 666 into a cell means -102 is actually put there. The link you post allows writing large numbers into cells.

@Abigail Thanks for looking into this. According to the specification, Funge-98 programs can have values up to 2bil. I only use Funge-93 commands, but run in Funge-98 to handle the large characters

@Abigail I got it working with this TIO. It really seems like there is an issue with how wrapping works. This code is identical to the above, but with extra arrows at the beginning.

Charcoal, 24 bytes
Ｎθ⊞υＮＷ¬№υθ≔⁺⊖υ⊗υυＩ⊖Ｌ↨Ｌυ²

Try it online! Link is to verbose version of code. Takes inputs in the order M, N. Horribly inefficient breadth-first search, so don't bother putting in large numbers. Explanation:
Ｎθ

Input M.
⊞υＮ

Push N to the predefined empty list.
Ｗ¬№υθ

Repeat until M is present in the list...
≔⁺⊖υ⊗υυ

... concatenate the decremented list with the doubled list.
Ｉ⊖Ｌ↨Ｌυ²

Calculate the number of concatenations.

Batch, 153 bytes
@echo off
@set/an=%1,c=0
:l
@if %n%==%2 echo %c%&exit/b
@set/a"c+=1,p=~-%2/n+1,q=p&p-1,r=n*p-%2,n-=1
@if %q%==0 if %r% lss %p% set/an=n*2+2
@goto l

Explanation:
set /a n=%1, c=0

Initialise n from the first parameter and clear the loop count.
if %n% == %2 echo %c% & exit /b

Output the count once the target in the second parameter is reached.
set /a " c += 1, p = ~-%2 / n + 1, q = p & p - 1, r = n * p - %2, n -= 1

Increment the loop count
Calculate the number of advances needed
Calculate how near to the target advances would get
Assume that we'll fall back

if %q% == 0 if %r% lss %p% set /a n = n * 2 + 2

If the advances would get near to the target then undo the fall back and advance instead.

bc, 61 bytes
define f(n,m){if(n>=m)return n-m;return 1+m%2+f(n,(m+m%2)/2)}

Try it online!
Given n, and m, return n - m if n is greater than or equal to m. Else, it returns 1 plus 1 (if m is odd), plus the result of (n, m / 2), with the division rounded upwards. The latter is done with a recursive call.

Erlang (escript), 65 bytes
Port of Arnauld's answer.
f(X,Y)->if X>Y->X-Y;true->1+(Y rem 2)+f(X,(Y+(Y rem 2))div 2)end.

Try it online!

J, 22 bytes
A port of RGS' APL answer with J's hooks and forks.
-`(($:>.@-:)+1+2|])@.<

Try it online!


text:
Can this polyomino tile the toroidal grid?
Inspired by certain puzzles on Flow Free: Warps.
Background
We all know that L-triominos can't tile the 3x3 board, and P-pentominos can't tile the 5x5 board. But the situation changes if we allow the board to wrap around in both dimensions:
L-triominos can tile 3x3 toroidal grid
The 3rd tile wraps around through all four edges.
┌ ┌─┐ ┐
  │ │3
┌─┤ └─┐
│ │2  │
│ └─┬─┘
│1  │
└───┘ ┘

P-pentominos can tile the 5x5 toroidal grid
The 5th tile wraps around through all four edges.
┌ ┌───┬─┐ ┐
  │   │ │
┌─┘   │ └─┐
│  1  │2  │
├─────┤   │
│  3  │   │
│   ┌─┴─┬─┤
│   │   │ │
└─┬─┘   │ ╵
  │  4  │5
└ └─────┘ ┘

Note that, in both cases, wrapping around in only one dimension doesn't allow such tiling.
In case the Unicode version is hard to read, here is the ASCII version:
3 2 3
1 2 2
1 1 3

5 1 1 2 5
1 1 1 2 2
3 3 3 2 2
3 3 4 4 5
5 4 4 4 5

Challenge
Given a polyomino and the size (width and height) of the toroidal grid, determine if the polyomino can tile the toroidal grid. The polyomino can be flipped and/or rotated.
A polyomino can be given in a variety of ways:

A list of coordinates representing each cell of polyomino
A 2D grid with on/off values of your choice (in this case, you cannot assume that the size of the grid defining the polyomino matches that of the toroidal grid)

The output (true or false) can be given using the truthy/falsy values in your language of choice, or two distinct values to indicate true/false respectively.
Standard code-golf rules apply. The shortest code in bytes wins.
Test cases
The polyomino is given as the collection of # symbols.
Truthy
# (singleton, a.k.a. monomino)
5x7 (or any size)
--------
## (domino)
4x3 (or any even size)
--------
#
## (L-triomino)
3x3 (as shown above)
--------
##
### (P-pentomino)
5x5 (as shown above)
--------
##
 ## (Z-tetromino)
4x4 (left as an exercise to the reader)
--------
###
#
# (V-pentomino)
5x5
--------
####
   #
   ### (a polyomino larger than the grid is possible)
4x4
--------
###
  ###
    ### (single polyomino can cover the entire grid, and can wrap multiple times)
3x3

Falsy
## (domino)
3x5 (or any odd sizes)
--------
###
#
1x8
--------
# #
### (U-pentomino)
5x5

Nice challenge. I find the ASCII art hard to read, could you add the alternative of having 1, 2, 3, etc as each of the # shapes given in the two corresponding examples?

@JonathanAllan I added a pure ASCII version of the top two examples, though I doubt I understood your request correctly. (Or do you want something like this?)

what you posted is perfect, thanks

Python 2, 300 265 163 bytes
-35 bytes after suggestions from @xnor, @ovs, and largely @user202729 (removing evenly divisible check allowed for a one-liner + lambda)
-102 bytes following encouragement + general suggestions by @user202729
lambda l,w,h:all(w*h-len({((e-(p&4)*e//2)*1j**p+p/8+p/8/w*1j)%w%(1j*h)for e in l for p in c})for c in combinations(range(8*w*h),w*h/len(l)))
from itertools import*

Takes input as a list of complex coordinates of each cell of the polyomino. Outputs False for Truthy and True for Falsey (quirky de Morgan optimization).
Try it online with many testcases. Since this brute-forces, I have commented out a few cases to run fast enough for TIO.
Thoroughly commented:
lambda l,w,h:
    all(                        # we want any configuration to work, but De Morgan gives any(L==len) <==> not all(L!=len) <==> not all(L-len)
        w*h-len(                      # if two polyominos in a configuration overlap, then there are duplicate cells
                                    #   so the length of the set is less
                {                   # create a set consisting of each possible position+orientation of L/len(l) polyominos:
                    (                   # here, e is a single cell of the given polyomino
                        (               # reflect e across the imaginary axis if p >= 4 (mod 8)
                            e-          # e-e.real*2 = e-e//.5 reflects across the Im axis
                            p&4             # Only reflect if the 2^2 bit is nonzero: gives 4* or 0* following
                            *e//2           # floor(z) = z.real when z is complex, so
                        )                   # e//2 (floor division) gives z.real/2 (complex floor division only works in Python 2)
                        *1j**p          # rotate depending on the 2^0 and 2^1 bits. i**x is cyclic every 4
                        +p/8              # translate horizontally (real component) by p>>3 (mod this later)
                        +p/8/w*1j           # translate vertically (im component) by p>>3 / w
                    )%w%(1j*h)          # mod to within grid (complex mods only work in Python 2)
                    for e in l      # find where each cell e of the given polyomino goes
                    for p in c      # do this for each c (each set of position+orientation integers)
                }
        )
        for c in combinations(           # iterate c over all sets of w*h/len(l) distinct integers from 0 to 8*L-1
            range(8*w*h)              # each of these 8*L integers corresponds to a single position/orientation of a polyomino
                                    # Bits 2^0 and 2^1 give the rotation, and 2^2 gives the reflection
                                    # The higher bits give the position from 0 to L=w*h-1  ==> (0,0) to (w-1,h-1)
            ,w*h/len(l)        # w*h/len(l) is the number of polyominos needed since len(l) is the number of cells per polyomino
                                    # can't switch to *[range(8*w*h)]*(w*h/len(l)) because Python 3 does not allow short complex operations as above
        )
    )
from itertools import*

A new 169-byte solution that replaces combinations with recursion:
g=lambda l,w,h,k=[]:all(g(l,w,h,k+[((e-(p&4)*e//2)*1j**p+p/8+p/8/w*1j)%w%(1j*h)for e in l])for p in range(8*w*h))if w*h>len(k)else len(set(k))-w*h
from itertools import*

This has the advantage of removing combinations (12 characters on its own) and one for loop, but the self-invocation takes many bytes. Currying would not save length.

Because of the weird way Python handles complex mod, you can actually do e%w%(1j*h) in place of (e.real%w,e.imag%h).

k-k.imag*2jfor ... is 2 bytes shorter than k.conjugate()for .... (Or 2*k.real-k for ... at the same length)

@user202729 Thanks for all the suggestions! I ended up being able to reduce many nested comprehensions (the sum(p,[])'s sole purpose was to undo a nest, and range(8*L) combines 3 loops), so string-replace-exec became unnecessary. I'm not sure what your last comment does because it reflects the translation, not the whole polyomino, but I think it's irrelevant now.

@user202729 Oh, I reasoned out that /8j would work because it's just a vertical shift in the opposite direction, but complex divisor also changes it to normal division instead of floor division. It would be great if there was a way to distribute out the p/8 somehow

Fixed (same number of bytes after using combinations)

JavaScript (ES7), 233 bytes
Takes input as (w)(h)(p), where \$p\$ is a binary matrix describing the polyomino. Returns \$0\$ or \$1\$.
Similar to my original answer, but uses a more complex expression to update the cells of the matrix instead of explicitly rotating the polyomino.
w=>h=>g=(p,m=Array(w*h).fill(o=1))=>+m.join``?(R=i=>i--?m.map((F,X)=>(F=k=>p.map((r,y)=>r.map((v,x)=>k|=v?m[Z=i&2?p[0].length+~x:x,~~(X/w+(i&1?Z:W))%h*w+(X+(i&1?W:Z))%w]^=1:0,W=i&4?p.length+~y:y))&&k)(F()||g(p,m)))|!o||R(i):0)(8):o=0

Try it online!

JavaScript (ES7),  311 ... 252  250 bytes
Takes input as (w)(h)(p), where \$p\$ is a binary matrix describing the polyomino. Returns a Boolean value.
Not quite as desperately long as I was expecting. :p
w=>h=>g=(p,m=Array(w*h).fill(o=1),P)=>+m.join``?[...13**7+''].some(i=>(p.sort(_=>i-7).map((r,y)=>r.map((v,x)=>(P[x]=P[x]||[])[y]=v),P=[]),m.map((F,X)=>(F=k=>P.map((r,y)=>r.map((v,x)=>k|=v?m[~~(X/w+y)%h*w+(X+x)%w]^=1:0))&&k)(F()||g(p,m))),p=P,!o)):o=0

Try it online!
How?
The following code builds all possible transformations \$P\$ of the polyomino \$p\$:
[...13 ** 7 + '']         // this expands to ['6','2','7','4','8','5','1','7']
.some(i =>                // for each value i in the above list:
  ( p.sort(_ => i - 7)    //   reverse the rows of p[], except when i = '8'
    .map((r, y) =>        //   for each row r[] at position y in m[]:
      r.map((v, x) =>     //     for each value v at position x in r[]:
        ( P[x] =          //       transpose p[y][x]
          P[x] || [] )    //              to P[x][y]
        [y] = v           //
      ),                  //     end of inner map()
      P = []              //     start with an empty array
    )                     //   end of outer map()
    (...)                 //   more fun things happen here!
    p = P,                //   get ready for the next transformation
    !o                    //   success if o is cleared
  )                       //
)                         // end of some()

We use a flat array of \$w\times h\$ entries to describe the matrix. All of them are initially set to \$1\$.
The function \$F\$ inserts the polyomino in the matrix at the position \$(X,Y)\$ by XOR'ing the cells. It returns \$0\$ if the operation was done without setting any cell back to \$1\$.
F = k =>                  // expects k undefined for the first call
  P.map((r, y) =>         // for each row r[] at position y in P[]:
    r.map((v, x) =>       //   for each value v at position x in r[]:
      k |=                //     update k:
        v ?               //       if v is set:
          m[~~(X / w + y) //         toggle the value at (X + x, Y + Y),
            % h * w +     //         taking the wrapping around into account
            (X + x) % w   //
          ] ^= 1          //         k is set if the result is not 0
        :                 //       else:
          0               //         leave k unchanged
    )                     //   end of inner map()
  ) && k                  // end of outer map(); return k

For each position \$(X,Y)\$ in the matrix:

We do a first call to \$F\$. If successful, it is followed by a recursive call to the main function \$g\$.

We just need to call \$F\$ a second time to remove the polyomino -- or to clear the mess if it was inserted at an invalid position.

Hence the code:
F(F() || g(p, m))

The recursion stops when there's no more \$1\$'s in the matrix (success) or there's no more valid position for the polyomino (failure).

Charcoal, 120 115 bytes
ＮθＮηＷＳ⊞υ⌕Ａι#≔⟦⟧ζＦθＦηＦ²«≔ＥθＥη⁰εＦＬυＦ§υμ¿λ§≔§ε⁺κν﹪⁺ιμη¹§≔§ε⁺ιμ﹪⁺κνη¹Ｆ²Ｆ²⊞ζ↨⭆⎇μ⮌εε⪫⎇ν⮌ξξω²»≔…ζ¹υＦυＦζＦ¬＆ικ⊞υ｜ικ⁼⊟υ⊖Ｘ²×θη

Try it online! Link is to verbose version of code. Takes inputs in the order width, height, newline-terminated polyomino and outputs a Charcoal boolean i.e. - only if the polyomino tiles the torus. Explanation:
ＮθＮη

Input the size of the grid.
ＷＳ⊞υ⌕Ａι#

Input the polyomino and convert it to a list of horizontal indices.
≔⟦⟧ζ

Start building up a list of polyomino placements.
ＦθＦηＦ²«

Loop through each vertical and horizontal offset and direction.
≔ＥθＥη⁰ε

Start with an empty grid.
ＦＬυＦ§υμ

Loop over each cell of the polyomino...
¿λ§≔§ε⁺κν﹪⁺ιμη¹§≔§ε⁺ιμ﹪⁺κνη¹

... place the optionally transposed cell in the grid, but offset by the outer indices.
Ｆ²Ｆ²⊞ζ↨⭆⎇μ⮌εε⪫⎇ν⮌ξξω²

For each of four reflections of the grid, push the grid to the list of placements, represented as a base 2 integer (e.g. a grid with just the bottom right square filled would be 1 etc.)
»≔…ζ¹υＦυ

Start a breadth first search using the first placement.
Ｆζ

Loop over each placement.
Ｆ¬＆ικ

If this placement does not overlap the grid so far...
⊞υ｜ικ

... then push the merged grid to the list of grids.
⁼⊟υ⊖Ｘ²×θη

Check whether we pushed a completed grid. (This must be the last entry because any incomplete grid must by definition have fewer polyominoes and would therefore have been discovered earlier.)


text:
Find the date that is n days from January 1st 1984
This challenge is a relatively simple concept that I'm surprised has not been done yet. You will be given only an integer as an input. Your task is to find the date that is this number of days from January 1st, 1984. This challenge is uniquely for the Gregorian calendar (which is standard almost everywhere).
One restriction
The twist on this challenge is that you should not use a built-in function that deals with the date and time - because then this challenge would be trivial for a few languages. Your program must do this calculation entirely on its own - keep in mind leap years exist and have special rules:

every year that is a multiple of four is a leap year
the exception to the above rule is any year that is a multiple of 100 but not a multiple of 400

Output format
You must output the year, month, and day of the month in any order you want so long as the number for the year and day of the month are not conjoined. You can use any character (not numeric or alphabetical), or none, as a separator. The name of the month must be given as a word instead of a number. Examples for this format are shown in the test cases.
Input
You will be given an integer as an input. You can assume this integer will be smaller in magnitude than 700000 - this means negative integers are also accepted.
Test cases
input | accepted output (which is relatively flexible)
13318 | June 18 2020
2 | JanUaRy03(1984)
656979 | 3782september29
-30 | DECEMBER 02 1983
-589001 | 00371may15 (leading zeroes may be used)
0 | 1984 1 january
Scoring
This is code-golf. Shortest code wins!

05AB1E, 111 106 103 bytes
•3zb•2ôI5°7*+F©`т‰0Kθ4ÖUD2Qi\28X+ë<7%É31α}‹i®ć>šë®1¾ǝDÅsD12‹i>1ǝë<sθ>ª]εNi”……‚æ‡‰…ä†ï€¿…Ë…ê†Ä…æ…Ì…Í”#sè

Output as a triplet [day, "Month", year].
Try it online. (Sort of, since it times out for any input above \$\geq-650000\$..)
Explanation:
Since 05AB1E doesn't have any date builtins, I've calculated things manually before. I've used the code of going to the next day from this answer of mine, which in turns also uses the leap year calculation of this answer of mine.
Since this challenge also asks to go back in time, I would need to implement something to go to a previous day as well for negative inputs, which would cost a lot of bytes. Instead, since the challenge input is limited to the range \$[-700000,700000]\$, I used that to my advantage and start going upwards in days from date June 21st, 0067 onward, which is 700,000 days before January 1st, 1984.
In pseudo-code, I therefore do the following steps:
1   Date currentDate = [21,06,0067]
2   Loop input + 700000 amount of times:
3*   currentDate += 1;  # Set currentDate to the next date in line
4   Convert month-integer to month-string and output the result

Where step 3 is divided into substeps:
a   Integer isLeapYear = ...;
b   Integer daysInCurrentMonth = currentDate.month == 2 ?
c                                 28 + isLeapYear
d                                :
e                                 31 - (currentDate.month - 1) % 7 % 2;
f   If(currentDate.day < daysInCurrentMonth):
g     nextDate.day += 1;
h   Else:
i     nextDate.day = 1;
j     If(currentDate.month < 12):
k       nextDate.month += 1;
l     Else:
m       nextDate.month = 1;
n       nextDate.year += 1;

Transforming that into code:
1) Date currentDate = [21,06,0067] is done like this:
•3zb•     # Push compressed integer 210667
     2ô   # Split it into parts of size 2: [21,06,67]
...
©         #  Store the current date in variable `®` (without popping)

2) Loop input + 700000 amount of times: is done like this:
I         # Push the input-integer
 5°       # Push 10 to the power 5: 100000
   7*     # Multiply that by 7: 700000
     +    # Add it to the input-integer
      F   # Loop that many times:

3a) Integer isLeapYear = ...; is done like this:
`         # Pop and push the day, month, and year separated to the stack
 т‰       # Take the divmod of 100
   0K     # Remove all 0s
     θ    # Pop and leave its last value
      4Ö  # And check if it's divisible by 4 (1 if it's a leap year; 0 if not)
        U # Pop and store this in variable `X`

3b) currentDate.month == 2 ? and 3c) 28 + isLeapYear:
D         # Duplicate the month that is still on the stack
 2Qi      # If it's equal to 2 (thus February):
    \     #  Discard the duplicated month from the stack
     28X+ #  And add 28 and `X` (the isLeapYear check) together

3d) : and 3e) 31 - (currentDate.month - 1) % 7 % 2;:
ë         # Else:
 <        #  Month - 1
  7%      #  Modulo-7
    É     #  Is odd (short for modulo-2)
     31α  #  Absolute difference with 31
}         # Close the if-else statement

3f) If(currentDate.day < daysInCurrentMonth)::
‹         # Check if the day that is still on the stack is smaller than this value
 i        # If it is:

3g) nextDate.day += 1;:
®         #  Push the entire date from variable `®` again
 ć        #  Extract its head (the days); pop and push [month,year] and day separated
  >       #  Day + 1
   š      #  Prepend it back in front of the list

3h) Else: and 3i) nextDate.day = 1;:
ë         # Else:
 ®        #  Push the entire date from variable `®` again
  1       #  Push a 1
   ¾      #  Push index 0
    ǝ     #  Insert the 1 at index 0 (to replace the day) in the list `®`

3j) If(currentDate.month < 12)::
D         # Duplicate it
 Ås       # Pop and push the middle item (the month)
   D12‹   # Check if the month is below 12:
       i  # And if it is:

3k) nextDate.month += 1;:
>         # Month + 1
 1        # Push index 1
  ǝ       # Insert the month + 1 at index 1 (to replace the month) in the list `®`

3l) Else:, 3m) nextDate.month = 1; and 3n) nextDate.year += 1;:
ë         # Else:
 <        #  Decrease the month by 1 to 11
  s       #  Swap so list `®` is at the top of the stack again
   θ      #  Pop and push its last item (the year)
    >     #  Year + 1
     ª    #  Convert the 11 to list [1,1] and append the year + 1

4) And finally we convert the month-integer to month-string in the resulting date, and output the result:
]         # Close both if-else statements and the infinite loop
 ε        # Map the resulting date to:
  Ni      #  If the (0-based) index is 1 (thus the month)
    ”……‚æ‡‰…ä†ï€¿…Ë…ê†Ä…æ…Ì…Í”
          #   Push the dictionary string of months ("December January ... November"
     #    #   Split it on spaces to a list of strings
      s   #   Swap so the month is at the top of the stack
       è  #   And index it into the list (0-based and with wraparound,
          #   which is why "december" is the first item)
          # (after which the resulting date is output implicitly)

See this 05AB1E tip of mine (sections How to use the dictionary? and How to compress large integers?) to understand why •3zb• is 210667 and ”……‚æ‡‰…ä†ï€¿…Ë…ê†Ä…æ…Ì…Í” is "December January February March April May June July August September October November".

T-SQL, 333 311 bytes
Added some line feeds to avoid scrolling
DECLARE @ int=0WHILE~@i<724671SELECT
@+=iif(d=iif(m=2,28-sign(1/~(y%4)*y%25+1/~(y%16)),
31+~m%9%2),iif(m=12,320,51-d),1),@i-=1FROM(SELECT
@/50%18m,@%50d,@/900y)x
PRINT concat(@/900,choose(@/50%18,'january','february',
'march','april','may','june','july','august',
'september','october','november','december'),@%50)

Try it online

Perl 5, 333 bytes
eval'sub f{my(N,Y,B,C)=@_;X=sub{B=~/4|6|9|11/?30:B!=2?31:Y%400?Y%100?Y%4?28:29:28:29};if(!C){B--;C=&X}if(C>&X){B++;C=1}if(!B){B=12;Y--}if(B>12){B=1;Y++}@_==1?f(N,1984,1,1):N<0?f(N+1,Y,B,C-1):N>0?f(N-1,Y,B,C+1):Y.[qw(January February Mars April May June July August September October November December)]->[B-1].C}'=~s,[NXYBC],\$$&,gr;

Try it online!
Ungolfified:
sub f {
  my($n,$y,$m,$d) = @_;
  my $M = sub{$m=~/4|6|9|11/?30:$m!=2?31:$y%400?$y%100?$y%4?28:29:28:29};
  if( $d==0  ){ $m--; $d=&$M }
  if( $d>&$M ){ $m++; $d=1 }
  if( $m==0  ){ $m=12; $y-- }
  if( $m==13 ){ $m=1; $y++ }
  @_==1 ? f($n,1984,1,1)
 :$n<0  ? f($n+1,$y,$m,$d-1)
 :$n>0  ? f($n-1,$y,$m,$d+1)
 :        "$y-".[qw(January February Mars April May June July August September
                    October November December)]->[$m-1]."-$d"
}

Test:
use Test::More tests=>6;
my @tests = (
    [13318,    '2020-June-18'],
    [2,        '1984-January-3'],
    [656979,   '3782-September-30'],     #was 29
    [-30,      '1983-December-2'],
    [-589001,  '371-May-16'],            #was 15
    [0,        '1984-January-1'] );
for(@tests){
    my($n,$expect) = @$_;
    my $got = f($n);
    is($got, $expect, sprintf"   n=%-12d $expect",$n);
}

Output:
ok 1 -    n=13318        2020-June-18
ok 2 -    n=2            1984-January-3
ok 3 -    n=656979       3782-September-30
ok 4 -    n=-30          1983-December-2
ok 5 -    n=-589001      371-May-16
ok 6 -    n=0            1984-January-1

JavaScript (Node.js), 330 300 bytes
a=>{for(n=a<(d=m=0),y=1984,a*=n?-1:1;a-->0;){s="3"+((y%400)?((y%100)?((y%4)?(0):1):0):1)+"3232332323";v=27+(+s[m]);if(n&&!d--){m=m?(m-1):11;m==11&&y--;d=v}if(!n&&d++==v){d=0;m=m^11?(m+1):0;!m&&y++;}};return y+['January','February','March','April','May','June','July','August','September','October','November','December'][m]+(d+1)}

Try it online!
String improvement (and removed parentheses):
a=>{for(n=a<(d=m=0),y=1984,a*=n?-1:1;a-->0;){v=27+(+("3"+(y%400?(y%100?(y%4?0:1):0):1)+3232332323)[m]);if(n&&!d--){m=m?m-1:11;m==11&&y--;d=v}if(!n&&d++==v){d=0;m=m^11?m+1:0;!m&&y++;}}return y+"January February March April May June July August September October November December".split(" ")[m]+(d+1)}

Try it online!
Tests:
console.log(f(13318))
console.log(f(2))
console.log(f(656979))
console.log(f(-30))
console.log(f(-589001))
console.log(f(0))

Results:
2020June18
1984January3
3782September30
1983December2
371May16
1984January1

Ungolfified:
a=>{
    for(n=a<(d=m=0),y=1984,a*=n?-1:1;a-->0;){
        v=27+(+("3"+(y%400?(y%100?(y%4?0:1):0):1)+3232332323)[m]);
        if(n&&!d--){
            m=m?m-1:11;
            m==11&&y--;
            d=v
        }
        if(!n&&d++==v){
            d=0;
            m=m^11?m+1:0;
            !m&&y++;
        }
    }
return y+"January February March April May June July August September October November December".split(" ")[m]+(d+1)
}

Is there something I can do with the hard-coded ['January','February','March','April','May','June','July','August','September','October','November','December'] ?