text:
The Double Slit Experiment
A lazy physicist has the job to perform the double slit experiment. However, they are lazy and can't be bothered to set up all the equipment themselves and so are going to simulate the effects. They can't program though so are going to need some help. As they are lazy your program should be as short as possible.

Given an odd positive integer n (n >= 1 and n % 2 == 1), perform the simulation.
How it works
You will start off with an empty canvas and each frame a single particle of light will go through the slits and land on the canvas. The particle will land at a maxima with a chance of:
n = 1:
+-----+
|     |
| 1/2 |
|     |
+-----+

n = 3:
+-----+ +-----+ +-----+
|     | |     | |     |
| 1/4 | | 1/2 | | 1/4 |
|     | |     | |     |
+-----+ +-----+ +-----+

n = 5:
+-----+ +-----+ +-----+ +-----+ +-----+
|     | |     | |     | |     | |     |
| 1/8 | | 1/4 | | 1/2 | | 1/4 | | 1/8 |
|     | |     | |     | |     | |     |
+-----+ +-----+ +-----+ +-----+ +-----+

etc.
For example for n=5 we check the middle box, there's a 50% chance of falling in it. If it falls end of frame, if not move to the next two, there's a 25% chance of falling in those. If it falls end of frame, if not move to the next two, there's a 12.5% chance of falling in those. If it doesn't fall it doesn't matter, it's still the end of the frame.
There has been some confusion over how to calculate the chances, most of this is due to people thinking of them as probabilities that should add up to 1. Remove that idea from your mind and it should clear it up a bit for you.

At most one particle will lad per frame, this means a particle may not land at all on that frame.
A particle can be represented by any printable character.
The particle will land anywhere in the box with a random chance.
The width of the boxes should be 2n-1 the size of the canvas. So for n=5 they should be 1/9th of the canvas's width.
The height of the boxes should be the height of the canvas.
The particle should not land outside of the boxes at all.
If a particle has already landed at a spot that is chosen that doesn't matter it can land there again.
The above ascii boxes are for clarity, they should not be drawn.
You may choose your own canvas size as long as it is reasonable. For example, it mustn't just be a few pixels high. It also should be able to fit all of the boxes on it.
If your code sleeps between frames you do not need to add that into your byte count.

There should be gaps between each of the maxima, a minima. This should be the same width as a box but no particles will land there. See the following diagram:
+---+---+---+---+---+
|   |   |   |   |   |
|max|min|max|min|max|
|   |   |   |   |   |
+---+---+---+---+---+

The program should run until it is stopped manually.
Rules

A pseudo random number generator (pRNG) is fine.
Standard loopholes are forbidden.
Input may be taken by any reasonable format.
You should output to STDOUT.
This is code-golf so the shortest answer wins.

Example
The following GIF is an example run for n = 5. I only knocked it up quickly so the chances may be off slightly.

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

Python 2, 207 200 bytes
There is a method to this madness, I promise. Follows the probability interpretation I commented in the OP.
Edit: -7 bytes through some clever lazy evaluation (and removing some signs)
import time  # not counted for byte total
import random as R,curses as C
r=R.randint
c=C.initscr()
h,w=c.getmaxyx()
n=input()
w/=2*n-1
while 1:
 all(r(0,1)or c.addch(r(0,h-1),(i*(2-4*r(0,1))+n)*w-r(1,w),42)for i in range(n/2+1))
 c.refresh()
 time.sleep(0.1)  # not counted for byte total

BASH, 396 - 11 = 385 bytes
E='echo -en';$E "\e[2J\e[99A";while :;do sleep 0.01;for i in `seq $((($1+1)/2)) -1 1`;do p=$(((($1+1)/2 - $i)));[ $p -lt 0 ]&&p=$((-$p));p=$((2**(p+1)));if [ $RANDOM -lt $((32768/$p)) ];then [ $(($RANDOM%2)) -eq 1 ]&&i=$((($1+1)-i));sector=$(((i*2-1)-1));C=`tput cols`;R=`tput lines`;SS=$((C/($1*2-1)));SX=$((SS*sector));X=$((SX+(RANDOM%SS)));Y=$((RANDOM%R));$E "\e[$Y;${X}H*";break;fi;done;done

Unfortunately I cannot demonstrate this on TryItOnline because of the endless loop & ANSI escape sequences that move cursor, but you can still copy-paste it into your terminal!
Unminified version:
E='echo -en'
$E "\e[2J\e[99A"

while :
do
    sleep 0.01
    for i in `seq $((($1+1)/2)) -1 1`
    do
        p=$(((($1+1)/2 - $i)))
        [ $p -lt 0 ] && p=$((-$p));
        p=$((2**(p+1)))
        if [ $RANDOM -lt $((32768/$p)) ]
        then
            [ $(($RANDOM%2)) -eq 1 ] && i=$((($1+1)-i));
            sector=$(((i*2-1)-1))
            C=`tput cols`
            R=`tput lines`
            SS=$((C/($1*2-1)))
            SX=$((SS*sector))
            X=$((SX+(RANDOM%SS)))
            Y=$((RANDOM%R))
            $E "\e[$Y;${X}H*"
            break
        fi
    done
done

Check out the tips for golfing in bash.  There are quite a few easy low-hanging fruit for you to harvest here - e.g. $[ ] instead of $(( )).  Instead of for i in \seq $((($1+1)/2)) -1 1`;do ...;done, try for((i=($1+1)/2;i>0;i--));{ ...;}. Instead of [ $(($RANDOM%2)) -eq 1 ], try ((RANDOM%2)). sector, SS`, etc should be replaced with 1 char variable names.

Mathematica, 231 bytes
(R=RandomInteger;p=20(#+1)+10;s=Array[0&,{20,6p-3}];i=(#+1)/2;Monitor[While[1<2,y=RandomChoice[Join[q=Riffle[Array[2^#&,i,0],Table[0,i-1]],Reverse@Most@q]->Array[Range[4#+1]&,i,0][[i]]];s[[R@19+1,10y-R@9]]=1;s],Grid[s//. 0->" "]])&

input

[5]

output

This appears to be invalid, for n=5 there should only be 5 boxes, you have 9

I realised that I counted like {...3,2,1,2,3...}.I can fix it if it is not accepted

@TheLethalCoder Fixed! Improved! Golfed!

Looks good, upvote from me

C# (.NET 4.5), 319 254 bytes
Saved 65 bytes thanks to TheLethalCoder!
namespace System{using static Console;n=>{for(var r=new Random();;)for(int w=WindowWidth/(2*n-1),i=(n-1)/2,c=0,m=2,l;i>-1;i--,c+=2)if((l=r.Next(0,(m*=2+1)*2))<2){SetCursorPosition((i+(l<1?c:0))*2*w+r.Next(0,w),r.Next(0,WindowHeight));Write('*');break;}}}

Phew, that was a lot of work, but it works somehow.
Since this uses Console specific functions and Thread sleeping, it won't work on TIO, sadly.

Compile to an Action<int> to save bytes, while(true)->(while(1>0)->for(;;). using C=Console; or using static Console;.

That application is allowed to be a delegate aswell? Didn't know that. I'll update it in a sec.

Programs/functions are allowed by default and anonymous lambdas count as functions (Though the rules on them get a bit deeper when you need to call them).

255 bytes namespace System{using static Console;n=>{for(var r=new Random();;)for(int w=WindowWidth/(2*n-1),i=(n-1)/2,c=0,m=2,l;i>-1;i--,c+=2)if((l =r.Next(0,(m*=2+1)*2))<2){SetCursorPosition((i+(l<1?c:0))*2*w+r.Next(0,w),r.Next(0,WindowHeight));Write('*');break;}}}

@TheLethalCoder That code doesn't work :/ Just gives alot of Variable is not existing in the current context errors.

Have you checked for the zero width characters that SE likes to add in?

@TheLethalCoder Didn't even know that SE does that. I updated it, it's 256 on my counter though.

254 still, There's one after Next at r.Next(0,WindowHeight) and one in the Write at Write('*')

@TheLethalCoder You were right.

Clojure + Quil, 394 bytes
(use '[quil.core])(defn -main[n](let[w 999 h 100 c(/ w(-(* n 2)1))s(range 0 w c)a(vec(take-nth 2 s))v(fn[x](<(rand)x))q(fn[a b](+ a(rand-int(- b a))))g(for[i(range(int(/ n 2))-1 -1)][i(- n 1 i)])z(for[[j i](map vector(range 1(inc(count g)))g)][(/ 1(Math/pow 2 j))i])](defsketch m :size[w h]:draw #(loop[[[p i]& r]z](when p(if(v p)(let[o(a(rand-nth i))](point(q o(+ o c))(q 0 h)))(recur r)))))))

Well, I certainly didn't win, but this was a good brain workout! I may have picked a overly roundabout way of doing this, but it works! Basically, how it works is:

The x-values of each column are calculated based on n. Then, the "active colums" that will contain the dots are filtered out. The columns are then zipped with the possibilities that they'll be chosen.

The animation starts, and each frame, a loop is entered. Starting from the middle, each pair of columns is tried. Once one pair of columns is chosen, one column from the pair is randomly chosen.

A dot is drawn at a random position within the chosen column, the inner loop exits, and a new frame begins.

Uses the Quil graphics library, which is essentially a Processing wrapper for Clojure.
Note, the golfed code doesn't produce the same animation as shown in the GIF. In the golfed code, the background is grey, and the window and dots are smaller. It has the same effect, it's just not as pretty.

See the ungolfed code for an in-depth explanation:
(ns bits.golf.interference.interference
  (:require [quil.core :as q]))

; Canvas size
(def width 1800)
(def height 800)

(defn -main [n]
  (let [col-width (/ width (- (* n 2) 1))
        ; The left-most x of each column
        col-starts (range 0 width col-width)

        ; The columns that need to be drawn. Need "vec" so I can index it later.
        active-cols (vec (take-nth 2 col-starts))

        ; Function taking a decimal percentage, and returning whether or not it's satisfied.
        ; (chance? 0.5) would be used to simulate a coin toss.
        chance? (fn [perc] (< (rand) perc))

        ; Function that returns a random int between a and b
        r-int (fn [a b] (+ a (rand-int (- b a))))

        ; Generates index pairs for each complimentary column.
        indices (for [i (range (int (/ n 2)) -1 -1)]
                  [i (- n 1 i)])

        ; Zips each index pair from above with the chance that it will be" chosen"
        zipped-perc (for [[j i] (map vector (range 1 (inc (count indices))) indices)]
                      [(/ 1 (Math/pow 2 j)) i])]

    ; Animation boilerplate
    (q/defsketch Interference
      :size [width height]
      :draw
      ; The animation loop. It contains a loop over each complimentary column. It tries each column pair starting
      ;  from the middle, and works outward. Once it picks a pair of columns, it randomly chooses one of them.
      #(loop [[[p i] & r] zipped-perc]
         (when p
           ; Pick this column?
           (if (chance? p)
             ; Pick one of the column pairs
             (let [col (active-cols (rand-nth i))]
               ; Set the coloring and dot size
               (q/fill 0 0 0)
               (q/stroke-weight 5)
               ; And finally draw the dot
               (q/point (r-int col (+ col col-width))
                        (r-int 0 height)))

             ; If the column wasn't chosen, loop again to try the next one
             (recur r)))))))

C#, 238 bytes
namespace System{using static Console;n=>{for(var r=new Random();;)for(int i=0,p=1,w=WindowWidth/(2*n-1),x;i<n+1;i+=2)if(r.Next(p*=2)<1){SetCursorPosition(r.Next(x=(n-1+(r.Next(2)<1?i:-i))*w,x+w),r.Next(WindowHeight));Write("*");break;}}}

Try it online! (It won't work but y'know).
Full/Formatted version:
namespace System
{
    using static Console;

    class P
    {
        static void Main()
        {
            Action<int> f = n =>
            {
                for (var r = new Random(); ;)
                {
                    for (int i = 0, p = 1, w = WindowWidth / (2 * n - 1), x; i < n + 1; i += 2)
                        if (r.Next(p *= 2) < 1)
                        {
                            SetCursorPosition(r.Next(x = (n - 1 + (r.Next(2) < 1 ? i : -i)) * w, x + w), r.Next(WindowHeight));
                            Write("*");
                            break;
                        }

                    Threading.Thread.Sleep(25);
                }
            };

            f(5);
        }
    }
}


text:
Find the longest run of consecutive digits
Simple challenge: given a series of positive integer numbers, find the number that contains among its digits the longest run of consecutive digits. The trick? It's allowed for the digits in the runs to wrap around the possible values (0123456789) and to run backwards. So both 2345, 89012 and 5432109 are valid runs of consecutive digits (but not 3456765 nor 321090123 as the run must be always in the same direction, although 3456765 can be considered as two runs: 34567 and 765). In the case of ties, return the first one.
Test cases:
Input:  [3274569283, 387652323, 23987654323648, 2345687913624]
Output: 23987654323648
        (The run is 98765432; run length: 8)

Input:  [123012363672023, 098761766325432, 15890123456765]
Output: 15890123456765
        (The run is 8901234567; run length: 10)

Input:  [43, 19, 456]
Output: 456

Input:  [5, 9, 0]
Output: 5

Input:  [71232107, 7012347]
Output: 7012347

Input:  [1234, 32109876]
Output: 32109876

Input:  [9090, 123]
Output: 123

Notes:

There will be at least one number in the input.
Input numbers can contain leading zeroes.
Input and output can be in any reasonable format. So input numbers can be taken as strings, lists of digits/characters...
Output can contain trailing and/or leading whitespaces and newlines as long as the number is printed.
This is code-golf, so may the shortest program/function for each language win!

Related.

Just to be sure, the list itself cannot wrap, right? (I misunderstood the digit wrapping as list wrapping) so [7,8,1,6] has a maximal run of [7,8] rather than [6,7,8], yes?

@JonathanAllan yes, the maximal run is 78 in that case.

Jelly, 18 bytes
I9,-;N¤yŒgỊS€ṀµÐṀḢ

Try it online!
Takes and returns as list of digits so as to preserve leading zeroes.

Similar problem to mine - try this out for size (I believe it returns the wrong result - I've suggested it as a test case just to be sure).

@JonathanAllan I think that's the right output? (there's 3210 in the first number btw)

Ah oops, this, sorry!

@JonathanAllan Oh I see what you mean...it's probably because of the A in there.

@JonathanAllan Fixed.

Jelly,  18 16  15 bytes
I%⁵Œg%8ċ€1ṀµÐṀḢ

A monadic link taking a list of lists of digits, and returning the leftmost one containing a maximal run as described.
Try it online! or see a test suite (with processing to make I/O look like it is in the question).
How?
I%⁵Œg%8ċ€1ṀµÐṀḢ - Link: list of lists of integers (digits) from [0-9]
           µÐṀ  - keep elements for which the link to the left is maximal:
I               -   incremental differences (i.e. [a2-a1, a3-a2, ...])
  ⁵             -   literal 10
 %              -   modulo by (i.e. [(a2-a1)%10, (a3-a2)%10, ...])
                -     this equates deltas of -9 and -1 with 1 and 9 respectively
   Œg           -   group runs of equal elements
     %8         -   modulo by 8; vectorised (9s become 1s, others unaffected)
       ċ€1      -   count number of 1s in €ach group
          Ṁ     -   maximum
              Ḣ - head (get the first one of those that were maximal)

V€ not sure about that, you may have to count leading zeroes.

That does count leading zeros of the sting input, however I see we may take lists of lists of digits...

I think you're supposed to support leading zeroes.

I do support leading zeros

I read that as "That doesn't count..."

Oh and you don't need the € in I€. (edit: I see you deleted the answer...yeah wasn't really sure about the ṙ in there)

This fails on input [[1,2,3,4],[3,2,1,0,9,8,7,6]].

@Zgarb Ah yes it will - I read "wrap around" with respect to the list not the numbers (that's why I do ṙJ at the beginning). Oh well back to the drawing board!

@Zgarb Fixed - much easier to do what was actually asked, it costs 5 bytes less.

JavaScript (ES6), 104 102 98 bytes
Takes input as a list of lists of digits. Returns the best one.
a=>a.map(s=>s.map(n=>(i=(d=(x-(x=n)+11)%10)&&d-2?0:d-p?(p=d,1):i+1)>j&&(r=s,j=i),p=x=-10),j=-1)&&r

Test cases

let f =

a=>a.map(s=>s.map(n=>(i=(d=(x-(x=n)+11)%10)&&d-2?0:d-p?(p=d,1):i+1)>j&&(r=s,j=i),p=x=-10),j=-1)&&r

console.log(JSON.stringify(f([[3,2,7,4,5,6,9,2,8,3], [3,8,7,6,5,2,3,2,3], [2,3,9,8,7,6,5,4,3,2,3,6,4,8], [2,3,4,5,6,8,7,9,1,3,6,2,4]])))
console.log(JSON.stringify(f([[1,2,3,0,1,2,3,6,3,6,7,2,0,2,3], [0,9,8,7,6,1,7,6,6,3,2,5,4,3,2], [1,5,8,9,0,1,2,3,4,5,6,7,6,5]])))
console.log(JSON.stringify(f([[4,3], [1,9], [4,5,6]])))
console.log(JSON.stringify(f([[5], [9], [0]])))

Python 2, 118 bytes
Takes a list of lists of digits a; returns one of its lists.
lambda a:max(a,key=lambda l:len(max(re.findall('1+|9*',`[(x-y)%10for x,y in zip(l,l[1:])]`[1::3]),key=len)))
import re

Try it online!

Fails on input [[9,0,9,0],[1,2,3]].

@Zgarb Oops, you’re right. Back to an old version I go.

Husk, 20 bytes
←Ö¤>(→Of€1†%8gẊo%10-

Takes and returns a list of lists of digits.
Try it online!
Explanation
←Ö¤>(→Of€1†%8gẊo%10-  Implicit input.
←                     Return first element of
 Ö                    the input sorted in a stable manner
   >                  in descending order
  ¤ (                 with respect to the following function:
                       Argument is list of digits, say [5,2,1,0,9,1,0].
                   -   Differences
               o%10    mod 10
              Ẋ        of all adjacent pairs: [7,9,9,9,2,1]
             g         Group adjacent equal elements: [[7],[9,9,9],[2],[1]]
          †%8          Vectorized mod 8: [[7],[1,1,1],[2],[1]]
       f€1             Keep those runs where 1 occurs: [[1,1,1],[1]]
      O                Sort in ascending order: [[1],[1,1,1]]
     →                 Take last element (gives [] on empty list): [1,1,1]
                       This is a list of 1s with length one less than
                       the longest run of consecutive digits.

Doesn't seem to give the right answer for multiple test cases.

@Razetime Fixed. I'm not sure, but I suspect that either Ö or < has been changed since this challenge, since the fix was so simple.

MATLAB, 130 bytes
Take input to array, array of column differences [X(2)-X(1),...,X(n)-X(n-1)], check the most frequent value in the array (1 ascending order -1 otherwise), get the index for either the most frequent value or -9 multiplied by the most frequent value (-9 occurs in ascending order, 9 otherwise), find the consecutive indices (i.e. whose difference is equal to 1) and sum it please, because it's late.
Output the largest.

a=input('')
t=[]
for i=1:numel(a)
b=diff(num2str(a(i))-'0')
c=mode(b)
t=[t sum(diff(find(b==c|b==-9*c))==1)]
end
[t,I]=max(t),a(I)

Try it online!

source: Stack Exchange

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

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

sort: votes


text:
Primes other than Optimus
Challenge
Given an input integer n > 0, output the number of primes (other than n, if n itself is prime) that can be produced by altering one digit in the decimal expansion of n (without changing the number of digits).
Examples
For example, n = 2. By altering one digit in the decimal expansion of 2, we can come up with three additional prime numbers, 3, 5, 7, so a(n) = 3.
For another example, n = 13. By altering one digit, you can get primes 11, 17, 19, 23, 43, 53, 73, 83, so a(13) = 8.
For a final example, n = 20. By altering one digit, you can get primes 23, 29, so a(20) = 2.
Sequence
Here are the first 20 terms to get you started. This is OEIS A048853.
4, 3, 3, 4, 3, 4, 3, 4, 4, 4, 7, 4, 8, 4, 4, 4, 7, 4, 7, 2
Rules

The input and output can be assumed to fit in your language's native integer type.
The input and output can be given in any convenient format.
Ignore leading zeros (for example, 03 is not a prime number under this formulation).
Either a full program or a function are acceptable. If a function, you can return the output rather than printing it.
If possible, please include a link to an online testing environment so other people can try out your code!
Standard loopholes are forbidden.
This is code-golf so all usual golfing rules apply, and the shortest code (in bytes) wins.

I'm trying to think of the smallest n for which the output is 0. I think it's n = 200. I also think they come in bunches: 200,202,204,206,208, 320,322,...,328, 510,...,518, 620,...628, 840,...,848, etc.

Does "The input and output can be assumed to fit in your language's native integer type" states that we are not allowed to take input as string?

@DeadPossum No, that's allowed. Just that you don't need to worry about 2^100 as input if you only are using 32-bit integers, for example.

Do let me know if I'm going overboard... I have 3 different submissions now

@EngineerToast The bunches happen because a number >7 ending in one of 0,2,4,5,6,8 cannot be prime. However it might be possible to have a single prime number that still gives output 0, and has no such bunch because that prime itself gives 1 for the others. However, I tried searching (rather inefficiently) up to 99999 and didn't find any.

@ØrjanJohansen I just searched for when the list of primes skipped over an entire range 10n to 10(n+1) and then picked every even within that range. Picking the even values forces you to change just the ones digit since leaving it guarantees the result won't be prime. Anything you could change it to won't be prime, either, since there's no other prime in those ten numbers.

+1 for the title (and the excellent challenge as well of course).

@EngineerToast You can also include the number ending in 5. What I'm saying is that there could be a number with output 0 not of that type, if we're extremely lucky. (It seems hard to avoid hitting other primes, but only for statistical reasons.)

@EngineerToast After finding the first example prime (294001), I finally thought of looking it up on OEIS: A192545 and A158124. Also relevant: A143641.

@ØrjanJohansen It's too bad we can't give bounties for comments. That's great work!

05AB1E, 17 16 14 11 bytes
ā°`<Ÿʒ.L}pO

Explanation:
ā             Push inclusive range from 1 to the length of the input
 °            Raise 10 to the power of each element
  `           Push each element to the stack
   <          Decrement the topmost element
    Ÿ         Inclusive range
              For 13, this creates an array like [10 11 12 13 14 .. 98 99]
     ʒ.L}     Only keep elements with a levenshtein distance to the input of
              exactly one
         p    Check each element for primality
          O   Sum

Try it online! or up to 100.

.L? Seriously? .L?!?!

@EriktheOutgolfer L.

I mean, there's a builtin for levenshtein distance!

@EriktheOutgolfer ¯\(ツ)/¯

I know it's been a while, but you can remove the < to save a byte. Even if the filter doesn't remove the 100/1000/10000/etc., it's never a prime anyway so won't affect the output.

Python 2, 146 136 127 121 118 bytes
Thanks to @Mr.Xcoder for suggestions
lambda I:sum(all(i%v for v in range(2,i))*sum(z!=x for z,x in zip(I,`i`))==1for i in range(1+10**~-len(I),10**len(I)))

Explanation:
Generate numbers with length equal to input length, skipping first (1,10,100,1000,... )
for i in range(1+10**~-len(I),10**len(I))

Check that generated number differs from input by only one digit
sum(z!=x for z,x in zip(I,`i`))==1

Check for prime
all(i%v for v in range(2,i))

Count
sum(...)

Try it online!

Might it be shorter to not make this a lambda, and do r=range, since you use it many times...?

Does this work for things like 143? Because I see range(1,10), that excludes 0, and 103 is prime

@Mr.Xcoder fixed

You do not need 0 in r(0,10). r(10) suffices.

Also, I suggest putting it as such: lambda I,r=range:

I see the range idea was helpful for all the answers here :D

@Mr.Xcoder a bit to be proud of :D

Jelly, 21 18 15 bytes
3 bytes thanks to Dennis.
æḟ⁵æR×⁵$DnDS€ċ1

Try it online! or Verify all testcases.

æḟ⁵æR×⁵$DnDS€ċ1 saves a few bytes.

The alternative range is quite clever.

Javascript (ES6) 148 bytes
Takes the input as a string and returns as a number
n=>(n.replace(/./g,"$`a$' ").split` `.map(s=>s&&[..."0123456789"].map(d=>r+=+(t=s.replace(/a/,d))[0]&&t^n&&(p=v=>t>1&(--v<2||t%v&&p(v)))(t)),r=0),r)

Example code snippet:

f=
n=>(n.replace(/./g,"$`a$' ").split` `.map(s=>s&&[..."0123456789"].map(d=>r+=+(t=s.replace(/a/,d))[0]&&t^n&&(p=v=>t>1&(--v<2||t%v&&p(v)))(t)),r=0),r)

for(var k=1;k<=20;k++)
  o.innerText+=f(""+k)+" "

JavaScript (ES6), 153 142 139 bytes
n=>([...n].map((c,i,[...a])=>[...''+1e9].map((u,j)=>s+=j+i&&j!=c?p((a.splice(i,1,j),a.join``)):0),s=0,p=q=>eval('for(k=q;q%--k;);k==1')),s)

Accepts input as a string. Undefined behavior for invalid input, though it should terminate without error on any string I can think of. Not necessarily before the heat-death of the universe though, particularly for long strings.
Demo

f=
n=>([...n].map((c,i,[...a])=>[...''+1e9].map((u,j)=>s+=j+i&&j!=c?p((a.splice(i,1,j),a.join``)):0),s=0,p=q=>eval('for(k=q;q%--k;);k==1')),s)
console.log([...''+1e19].map((_,i)=>f(i+1+'')).join())
i.onchange=()=>console.log(f(i.value))
<input id=i>

Improvements
Saved 11 bytes by refactoring the reduce() calls into map() calls, and by implicitly copying the array a in the function parameter, instead of in within the context of the splice() call.
Saved 3 bytes thanks to @Neil's suggestion to convert [...Array(10)] to [...''+1e9].
Unminified code
input => (
  [...input].map(
    (char, decimal, [...charArray]) =>
      [...'' + 1e9].map(
        (unused, digit) => sum +=
          digit + decimal && digit != char ?
            prime(
              (
                charArray.splice(decimal, 1, digit)
                , charArray.join``
              )
            ) :
            0
      )
    , sum = 0
    , prime = test => eval('for(factor = test; test % --factor;); factor == 1')
  )
  , sum
)

Explanation
The function uses a two-level map() to sum the amount of permutations that pass the primality test, which was borrowed and modified from this answer.
(Original answer)
reduce((accumulator, currentValue, currentIndex, array) => aggregate, initialValue)

So for example, to calculate the sum of an array, you would pass an initialValue of 0, and return an aggregate equal to accumulator + currentValue. Modifying this approach slightly, we instead calculate the number of permutations that pass the primality test:
reduce(
  (passedSoFar, currentDecimal, currentIndex, digitArray) =>
    isValidPermutation() ?
      passedSoFar + prime(getPermutation()) :
      passedSoFar
  , 0
)

That is essentially the inner reduce(), which iterates all the permutations of the digitArray by changing each decimal to a specific permutatedDigit. We then need an outer reduce() to iterate all possible permutatedDigit's with which to replace each decimal, which is just 0-9.
Abnormalities in implementation
[...''+1e9].map((u,j)=>... was the shortest way @Neil could think of to iterate an argument 0 through 9. It would be preferable to do so with u, but u is not useful for each element in the array, in this case.
i+j in the ternary condition checks to ensure that 0 is not a possible permutation of the leading digit, as per the challenge specification. j!=c ensures that the original n is not a candidate to go through the primality test.
(a.splice(i,1,j),a.join``) is kind of a mess. splice() replaces the digit at decimal == i with the permutatedDigit == j, but since splice() returns the removed elements (in this case, would be equal to [a[i]]) instead of the modified array, we must use the comma operator to pass the modified array a to the primality test, but not before join()ing it into a number string.
Lastly, the eval() is to save a byte since, compared to the more canonical approach, it is shorter:
q=>eval('for(k=q;q%--k;);k==1')

q=>{for(k=q;q%--k;);return k==1}

The reference to the prime test p is initialized in an unused argument to the map() call.

I think the tips page says [...''+1e9] is shorter.

Mathematica, 105 bytes
F=Count[Range[f=IntegerDigits;g=10^Length@f@#/10,10g],n_/;PrimeQ@n&&MatchQ[f@n-f@#,{x=0...,_,x}]&&n!=#]&;

Try it online!
Function which expects a positive integer #. Sets f equal to the function IntegerDigits which returns the list of digits of its input. We take the Range from g to 10g (inclusive), where g=10^Length@f@#/10 is the largest power of 10 less than or equal to the input #, then Count the n such that PrimeQ@n&&MatchQ[f@n-f@#,{x=0...,_,x}]&&n!=#. PrimeQ@n checks whether n is prime, MatchQ[f@n-f@#,{x=0...,_,x}] checks whether the difference between the list of digits of n and # is of the form {0..., _, 0...}, and n!=# ensures that n and # are Unequal.

Python 2, 134 bytes
lambda x,r=range,l=len:sum(~-f*(~-l(x)==sum(`f`[t]==x[t]for t in r(l(x))))and all(f%v for v in r(2,f))for f in r(10**~-l(x),10**l(x)))

Try it online!
More elegant, longer version:
lambda x,r=range,l=len:l(filter(lambda f:(~-f*(~-l(x)==sum(`f`[t]==x[t]for t in r(l(x)))))*all(f%v for v in r(2,f)),r(10**~-l(x),10**l(x))))

The input is taken as a String.

Explanation (older version)

lambda x,r=range,l=len: - Defines a lambda with a String parameter x and two constant parameters r=range and l=len.

sum(1...) - Get the length, which saves 1 byte over len([...]).

for f in r(10**~-l(x),10**l(x)) - Generates absolutely all the numbers with the same order of magnitude as the input (expect for 0). For instance, an input of 3, would result in [1, 2, 3, 4, 5, 6, 7, 8, 9].

sum(1for t in r(l(x))if`f`[t]==x[t])==~-l(x)and f>1 - Checks if the current number is exactly 1 digit away from the input, and that it is higher than 1.

all(f%v for v in r(2,f)) - Checks if the current number is prime.

You cound change sum(1for..ifBOOL) to sum(BOOLfor) to save some bytes

Are we allowed to take input as string? Looking at "The input and output can be assumed to fit in your language's native integer type" I'm not sure

@DeadPossum Some of the answers do. Why wouldn't it be allowed?!

I'm ran out of votes for today, but will +1 asap :D

@DeadPossum Sure. Don't forget or I'll ping you! (</joke>)

Duty fulfilled!

@DeadPossum Thanks, well done :P

Husk, 32 bytes
Lof§&ȯ=1Σzo±≠d⁰o=Ld⁰L↑o≤Ld⁰Lmdİp

Try it online!
Ungolfed/Explanation
                              İp  -- get all primes
                            md    -- and convert them to list of digits
                     ↑o≤   L      -- take as long as the lenghth of these digit lists are ≤ ..
                        Ld⁰       -- .. the number of digits of input
 of                               -- from those primes filter:
               o=Ld⁰L             --   same number of digits as input
   §&                             --   and
        Σz                        --   the number of..
          o±≠d⁰                   --   .. digits that differ from input digits ..
     ȯ=1                          --   .. must be one
L                                 -- finally count them

JavaScript (ES6), 137 bytes

i=(a=prompt()).length;s=0;while(i--)for(j=0;j<=9;j++){(b=[...a]).splice(i,1,j);k=b=b.join('');while(b%--k);s+=i+j&&a[i]!=j&&k==1}alert(s)

Adapts my other answer into a full-program submission using the Web API methods prompt() and alert().

Bean, 126 bytes
00000000: a64d a065 8050 80a0 5d20 8001 a64d a06f  ¦M e.P. ] ..¦M o
00000010: 8025 39b5 cb81 2065 27a6 4da0 6680 2581  .%9µË. e'¦M f.%.
00000020: 0035 cb81 2066 27a6 53d0 80cd a05e 8043  .5Ë. f'¦SÐ.Í ^.C
00000030: cf20 5d00 2080 82a0 65a5 3a20 66a6 4da0  Ï ]. .. e¥: f¦M
00000040: 6780 4da0 5e80 53d0 80a0 5e20 807b 2300  g.M ^.SÐ. ^ .{#.
00000050: b5cc a05e 8f4b c120 6728 264d a06f 814e  µÌ ^.KÁ g(&M o.N
00000060: cecc a065 8b20 6681 4cd0 84a0 5d20 6581  ÎÌ e. f.LÐ. ] e.
00000070: 2066 814c a067 8025 3a26 206f b130        f.L g.%:& o±0

Try it online!
An adaption of my full-program JavaScript submission.
JavaScript Equivalent
i=a.length
s=0
while(i--){
  j=10
  while(j--){
    (b=[...a]).splice(i,1,j)
    k=b=b.join('')
    while(b%--k);
    s+=i+j&&a[i]!=j&&k==1
  }
}
s

Explanation
a is implicitly initialized as the first line of input as a string and the last statement s is implicitly output, which contains the sum of prime permutations.

PHP, 151 147 141 140 136 134 129 128 bytes
-6 bytes thanks to @Einacio; -1 byte thanks to @Titus
<?php for($i=$m=10**strlen($n=$argv[1]);$i-->$m/10;)if(levenshtein($n,$i)==$f=$t=1){while($t<$i)$f+=$i%$t++<1;$c+=$f==2;}echo$c;

Try it online!
Formatted, with comments:
<?php
// Work through each integer with the same number of digits as the input $argv[1].
for ($i = $m = 10 ** strlen($n = $argv[1]); $i-- > $m / 10;)
    // Is it exactly one digit different from the input?
    if (levenshtein($n, $i) == $f = $t = 1) {
        // Count its factors.
        while ($t < $i) $f += $i % $t++ < 1;
        // If there are exactly 2 factors then it's a prime, so increment the counter.
        $c += $f == 2;
    }
// Print the final count.
echo $c;

To keep it as short as I could, I've:

combined assignments $f = $t = 1;
snook in a ++ increment as part of another expression $f += $i % $t++ == 0 (the increment is executed after the modulus operation and so does not affect its result);
and rather than using an if statement for a conditional increment have utilised the fact that boolean true when cast as an integer becomes 1, using $c += $f == 2; rather than if ($f == 2) $c++;.

you don't need to define $c, it counts as 0 on the first +=

@Einacio What are the golf rules? Is that allowed, as it gives an undefined variable warning notice?

@Einacio Apparently any output to STDERR can be ignored, so thanks for the suggestion.

+1 for use of levenshtein. Nice idea! $i%$t++<1 is shorter than $i%$t++==0.

Japt, 28 23 bytes
-5 bytes thanks to @ETHproductions.
¬x@AÇ|Y©+UhYZsÃâ kUn)èj

Takes a string as input.
Try it online!

Perhaps another couple with ¬x@AÇ|Y©+UhYZsÃâ kUn)èj?

Perl 6, 83 bytes
{+grep &is-prime,m:ex/^(.*)(.)(.*)$/.map:{|map
.[0]~*~.[2],grep *-.[1],?.[0]..9}}

Try it online!

How about using X~ instead of map? 81 bytes

PHP, 100+1 bytes
for(;~($a=$argn)[$i];$i++)for($d=-!!$i;$d++<9;$c+=$k==1)for($a[$i]=$d,$k=$a;--$k&&$a%$k;);echo$c-$i;

Run as pipe with -nR or try it online.
breakdown
for(;~($n=$argn)[$i];$i++)  # loop through argument digits, restore $n in every iteration
    for($d=-!!$i;               # loop $d from 0 (1 for first digit)
        $d++<9;                 # ... to 9
        $c+=$k==1                   # 3. if divisor is 1, increment counter
    )
        for($n[$i]=$d,              # 1. replace digit
            $k=$n;--$k&&$n%$k;      # 2. find largest divisor of $n smaller than $n
        );
echo$c-$i;                  # print counter - length

Java 8, 201 194 bytes
n->{String s=n+"";int r=0,i=0,j,k,t,u,l=s.length();for(;i<l;i++)for(j=0;++j<10;r+=n==u|t<2?0:1)for(u=t=new Integer(s.substring(0,i)+j+(i<l?s.substring(i+1):"")),k=2;k<t;t=t%k++<1?0:t);return r;}

Explanation:
Try it here.
n->{                        // Method with integer as parameter and return-type
  String s=n+"";            //  String representation of the input-int
  int r=0,                  //  Result-integer
      i=0,j,k,              //  Index-integers
      t,u,                  //  Temp integers
      l=s.length();         //  Length of the String
  for(;i<l;i++)             //  Loop (1) from 0 to `l` (exclusive)
    for(j=0;++j<10;         //   Inner loop (2) from 1 to 10 (exclusive)
        r+=                 //     And after every iteration, raise the result by:
           n==u             //      If the current number equals the input
           |t<2?            //      or it is not a prime:
            0               //       Add nothing to the result-counter
           :                //      Else:
            1)              //       Raise the result-counter by one
      for(                  //    Inner loop (3)
          u=t=              //     First set both `u` and `t` to:
              new Integer(  //      Convert the following String to an integer:
               s.substring(0,i)
                            //       Get the substring from 0 to `i` (exclusive)
               +j           //       + `j`
               +(i<l?       //       + If `i` is smaller than the String-length:
                  s.substring(i+1)
                            //          The substring from 0 to `i` (inclusive)
                 :          //         Else:
                  "")),     //          Nothing
          k=2;              //     And start `k` at 2
              k<t;          //     Continue looping as long as `k` is smaller than `t`
        t=t%k++<1?          //     If `t` is divisible by `k`:
           0                //      Change `t` to 0
          :                 //     Else:
           t                //      Leave `t` as is
      );                    //    End of inner loop (3)
                            //    (`t` remained the same after loop 3? -> It's a prime)
                            //   End of inner loop (2) (implicit / single-line body)
                            //  And of loop (1) (implicit / single-line body)
  return r;                 //  Return the result-counter
}                           // End of method

new Integer(s.substring(0,i)+j+(i<l?s.substring(i+1):"") will result in these integers:
For 0-9: 1, 2, 3, 4, 5, 6, 7, 8, 9.
For 10: 10, 20, 30, 40, 50, 60, 70, 80, 90, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19.
For 11: 11, 21, 31, 41, 51, 61, 71, 81, 91, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19.
etc.

JavaScript (ES7), 118 bytes
Takes input as a string.
n=>[...2**29+'4'].map(d=>n.replace(/./g,c=>s+=d+i>0&(P=k=>N%--k?P(k):N-n&&k==1)(N=p+d+n.slice(++i),p+=c),i=p=0),s=0)|s

Try it online!
Commented
n =>                        // n = input number (as a string)
  [...2**29 + '4']          // generate "5368709124" (all decimal digits)
  .map(d =>                 // for each digit d in the above string:
    n.replace(/./g, c =>    //   for each digit c in n:
      s +=                  //     increment s if the following code yields 1:
        d + i > 0 & (       //       if this is not the first digit of n or d is not "0":
          P = k =>          //         P = recursive function taking k and using N:
            N % --k ?       //           decrement k; if k is not a divisor of N:
              P(k)          //             do recursive calls until it is
            :               //           else:
              N - n &&      //             return true if N is not equal to n
              k == 1        //             and k is equal to 1 (i.e. N is prime)
          )(                //         initial call to P ...
            N =             //           ... with N defined as:
              p +           //             the current prefix p
              d +           //             followed by d
              n.slice(++i), //             followed by the trailing digits
                            //             (and increment the pointer i)
            p += c          //           append c to p
          ),                //         end of initial call
          i = p = 0         //         start with i = p = 0
    ),                      //   end of replace()
    s = 0                   //   start with s = 0
  ) | s                     // end of map(); return s

Ruby with -rprime, 101 bytes
-rprime imports the Prime module into Ruby. Get all primes up to \$10^{floor(log_{10} n)+1}\$ and count how many have the same number of digits from \$n\$ and are also 1 digit off.
->n{d=n.digits;Prime.each(10**l=d.size).count{|x|d.zip(e=x.digits).count{|a,b|a==b}==l-1&&e.size==l}}

Try it online!

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


text:
Efficient Robot Movement

Disclaimer: The story told within this question is entirely fictional, and invented solely for the purpose of providing an intro.

My boss has gotten a new toy robot, and he wants me to help program it.  He wants to be able to enter simple arrow instructions to get it to move.  These instructions are: ^ (for move forward) < (for turn left), and > (for turn right).  However, now that I've programmed the robot, he wants additional functionality.  He wants me to transform any sequence of arrows he inputs, so that rather than having the robot take the path indicated, it moves to the desired location, indicated by the place it would end up if it had taken the inputted path, as efficiently as possible.  I appeal to you, the members of PP&CG, to help me with this task.
Your Task:
Write a program or function to convert a string made up of arrows into a string that will get to the location indicated by the input as quickly as possible.  Turning takes exactly as long as moving backwards or forwards.
Input:
A string of arrows, as indicated above.  If you wish, different characters may be substituted for the arrows, but be sure to include the fact that you do so in your answer.  All test cases use the arrows normally.
Output:
A string of arrows (or your equivalent characters), that take the robot to the desired destination as efficiently as possible.
Test Cases:
Note that the solutions offered are only possibilities, and that other solutions may be valid.
>^<<^^>^^    -> ^^<^
^^^^>^^^^    -> ^^^^>^^^^
>>>^^^^^^    -> <^^^^^^
>^>^>^>^     -> (empty string)
^<^^<^^<^^^^ -> >^^>^

Scoring:
The robot's memory is limited, so your program must have the lowest byte count possible.

Because in the input the robot ends up exactly where it started, so no commands are necessary to move it there as efficiently as possible.

Oh, misread the string. My bad.

Test case request ^<^^<^^<^^^^ -> >^^>^?

@JungHwanMin, done

Can input use multiple characters for a single direction? i.e. -1 for <

@pizzakingme, sorry, but my boss is very lazy and only wants to type in one character per movement.

There has got to be a way to get this <100.

Wow, this is on HNQ already.

So the inputs must be a single character each, but does your boss care about the characters?  Perhaps 0 to turn left, 1 for straight, 2 for right?  They are technically less physical buttons pressed, and therefore easier to enter for a lazy boss...

No, my boss has a special keyboard with extra keys and no shift/caps lock so he only has to press one key per character.

So, he doesn't care what characters you use.

I program competitive robots and I can confirm this is exactly how they work.

A little more complex perhaps, but basically the same.

Retina, 103 74 71 bytes
<
>>>
+`(>(\^*>){3})\^
^$1
+`\^(>\^*>)\^
$1
>>(\^*)>(\^+)
<$2<$1
<?>*$

Try it online! Link includes test cases. Explanation:
<
>>>

Turn left turns into triple right turns.
+`(>(\^*>){3})\^
^$1

Reduce all turns modulo 4.
+`\^(>\^*>)\^
$1

Cancel out movements in opposite directions.
>>(\^*)>(\^+)
<$2<$1

Turn a triple right turn back into a left turn. This also handles the case of >>^>^ which needs to become <^<^.
<?>*$

Delete unnecessary trailing turns.

Impressive.  I knew there had to be a way to get this sub 100 bytes in some language, and your answer was so close before.  +1

Mathematica, 135 bytes
{a="^"~Table~Ramp@#&;a@#,s=If[#2>0,">","<"],a@Abs@#2,If[#<0,s,""],a@-#}<>""&@@ReIm[j=0;i=1;Switch[#,">",i*=I,"<",i/=I,"^",j+=i]&/@#;j]&

Takes a List of strings as input.
Explanation
j=0;i=1

Set j to 0, and set i to 1.
/@#

For each character in input...
Switch[#,">",i*=I,"<",i/=I,"^",j+=i]

If the character is >, multiply i by the imaginary unit. If the character is >, divide i by the imaginary unit. If the character is ^, add i to j.
ReIm[ ... ;j]

Take the real and imaginary parts of j. This gives the Cartesian coordinate of the robot.
... &@@

Apply the following to this result:

a="^"~Table~Ramp@#&;

Set a to a function that generates a string with (input) or 0 character ^s, whichever is larger.
{ ... }

A List consisting of...
a@#

a applied to the first input (real part of j)
s=If[#2>0,">","<"]

If the second input (imaginary part of j) is larger than 0, >. Otherwise, <. Set s to the resulting character.
a@Abs@#2

a applied to the absolute value of the second input.
If[#<0,s,""]

If the first input is less than 0, s. Otherwise, empty string.
a@-#

Apply a to the input times negative one.
... <>""

Join the strings.

J, 90 bytes
solution
t=.{&' ><'@*
g=.'^'#~|
(t,g@{.,t@-@(*/),g@{:`g@{:,t@{.,g@|@{.@.(0<:{:))@+.@(+/)@(=&1*j.**/\)

explanation
there's a neat trick using complex numbers (multiplying by i is a 90 degree left rotation, and -i gives you a right one).
so we take our input as complex numbers: a 1 represents "walk forward" and i / -i represent left and right turns.
the final position is calculated effortlessly with this representation.  Note this is the first (rightmost) part of my final expression above:
(+/)@(=&1*j.**/\)

That short line above is what solves the problem.  Everything else is just figuring out how to format the answer, and could surely be golfed down significantly more.
To understand the short line above, note that */\ (the scan of partial products) gives you list of the positions you are facing at each index in the input: i is north, 1 and -1 are east and west, and -i is south.  But since we start facing north, we have to multiply all of those by i which, in J, is represented by j. (chew on that sentence for a moment).
We only actually "move" when the original input is 1, so we then multiply that result elementwise by the boolean array which is 1 where the original input is 1 and 0 otherwise: =&1*.  The result of that multiplication is an array of "directional steps".  Our final position is simply the sum of those steps: +/
testing
Unfortunately I can't get this working in TIO for some reason, but pasting the following into J console will verify that it works:
t=.{&' ><'@*
g=.'^'#~|
f=.(t,g@{.,t@-@(*/),g@{:`g@{:,t@{.,g@|@{.@.(0<:{:))@+.@(+/)@(=&1*j.**/\)

NB. test cases
NB. format input as complex numbers
convert=. {&0j1 0j_1 1@:('<>^'&i.)

s=. '^<^^<^^<^^^^'  NB. >^^>^
echo f convert s
s=. '>^<<^^>^^'     NB. ^^<^
echo f convert s
s=. '^^^^>^^^^'     NB. ^^^^>^^^^
echo f convert s
s=. '>>>^^^^^^'     NB. <^^^^^^
echo f convert s
s=. '>^>^>^>^'      NB. empty string
echo f convert s

Mathematica 119 Bytes
JungHwan's final position to path code was shorter than mine, so using that. I think there is probably an even shorter way to do this...
I use the built-in AnglePath function to decide the final position.  I also define the symbols L, F, and R for "<", "^" and ">", to save a few quote characters.
L={0,Pi/2};R=-L;F={1,0};{a="F"~Table~Ramp@#&;a@#,s=If[#2>0,"L","R"],a@Abs@#2,If[#<0,s,""],a@-#}<>""&@@Last@AnglePath@#&

Usage:
%@{R,F,L,L,F,F,R,F,F}

Output:
FFLF

Ruby, 130 bytes
->s{w,d=0,1;s.bytes{|b|b>93?w+=d:d*=1i*(b<=>61)};r,c=w.rect;[w=(d=">><"[c<=>0])+?^*c.abs,?^*r.abs+w,w+d+?^*r.abs][r<=>0].chomp ?>}

How it works
->s{
    # We start from (0,0i), direction is +1
    w,d=0,1

    s.bytes{|b|
        # If it's ASCII 94, go one step forward,
        # else multiply direction by +i or -i
        b>93?w+=d:d*=1i*(b<=>61)
    }

    # Get the rectangular representation of the result
    r,c=w.rect

    # Now, create 2 strings of "^" (call them x and y) for horizontal and vertical moves
    # And a single ">" or "<" (call it d) for the direction change
    # If x>0, output x+d+y
    # If x==0, output d+y
    # If x>0, output d+y+d+x
    [w=(d=">><"[c<=>0])+?^*c.abs,?^*r.abs+w,w+d+?^*r.abs][r<=>0]

    #If y==0 we get an extra ">" sometimes
    .chomp ?>
}

Try it online!

C# (.NET Core), 349 bytes
n=>{int a=0,b=0,x=0,y=1,t=0,j=0,k=0,w,e,r;var p="";foreach(var c in n){if(c==62){t=x;x=y;y=-t;}if(c<61){t=x;x=-y;y=t;}if(c>63){a+=x;b+=y;}}while(a!=j|b!=k){w=0;e=a-j;r=b-k;if(r>=e&r>=-e){w=b-k;k+=w;}else if(r<=e&r<=-e){p+=">>";w=k-b;k-=w;}else if(r>=e&r<=-e){p+="<";w=j-a;j-=w;}else if(r<=e&r>=-e){p+=">";w=a-j;j+=w;}p+=new string('^',w);}return p;}

Try it online!
Takes a string as an input and outputs the shortest path that the input would take.

Ungolfed & Commented
n =>
{
    // First, calculate the route that the robot is going to take, represented by xy
    int a = 0, b = 0; // The current coordinates (a=x, b=y)
    int x = 0, y = 1; // The movement vector
    int t = 0; // A temp variable
    var p = ""; // The path we are going to return
    // Calculate the path the robot is going to take by input
    foreach (var c in n)
    {
        if (c == '>') { t = x; x = y; y = -t; } // Turn movement vector right
        if (c == '<') { t = x; x = -y; y = t; } //                      left
        if (c == '^') { a += x; b += y; }       // Move forward
    }
    int j = 0, k = 0; // The new movement coordinates (j=x,k=y)
    // While the target position is not reached, move the robot
    while (a != j | b != k)
    {
        int w = 0; // The forward variable, counting how many times we have to go forward
        int e = a - j, r = b - k; // The target position minus the current position (e=x,r=y)
        if (r >= e & r >= -e) { w = b - k; k += w; } // Up
        else if (r <= e & r <= -e) { p += ">>"; w = k - b; k -= w; } // Down
        else if (r >= e & r <= -e) { p += "<"; w = j - a; j -= w; } // Left
        else if (r <= e & r >= -e) { p += ">"; w = a - j; j += w; } // Right
        p += new string('^', w);
    }
    // Return the final path
    return p;
}

JavaScript (Node.js), 187 bytes
s=>{x=y=t=0;r=x=>"^".repeat(x<0?-x:x);for(c of s){t-=b=c<">"||-(c<"^");if(!b)[z=>++y,z=>++x,z=>--y,z=>--x][t&3]()}t=x<0?"<":">";return (y>0?r(y):"")+(x?t+r(x):"")+(y<0?(x?t:t+t)+r(y):"")}

Try it online!
Golfed version with whitespace
-14 bytes by @Neil

Ungolfed:
s=>{
  // convert turns to up/down/left/right movements to final destination
  let directions = [
    z=>++y, // up
    z=>++x, // right
    z=>--y, // down
    z=>--x  // left
  ];
  let x = y = direction = 0;
  for(c of s){
    let relativeDirection = "<^>".indexOf(c)-1; // relative turn offset: -1 = left, 1 = right
    direction += relativeDirection;
    if(direction<0){direction+=4} // make sure direction%4 > 0
    if(c==="^"){directions[direction%4]()} // do the movement if going forwards
  }
  // convert destination back to turns
  // the most efficient output has up before left/right before down
  let absoluteRepeat = num => "^".repeat(Math.abs(num));
  let turn = x<0 ? "<" : ">";
  let outp = "";
  if (y>0) { outp += absoluteRepeat(y) } // handle up before left/right
  if (x) { outp+=turn+absoluteRepeat(x) } // handle left/right
  if (y<0) { outp += (outp?turn:turn+turn)+absoluteRepeat(y)) } // handle down (including w/o left/right)
  return outp;
}

Use t&3 instead of t%4 because that works with negative t so you can remove the 4+ and the ()s. (x?"":t)+t can be written (x?t:t+t) for a 1-byte saving. The direction-moving code looks far too long. Also I think you should probably replace indexOf and Math.abs with comparisons.

@Neil Thanks! Could you elaborate a bit on replacing indexOf with a comparison?

Best I could do was t-=b=c<'>'||-(c<'^').

Python 2, 174 169 165 bytes
Edit 1: -5 bytes by allowing the direction to be outside the range 0-3, and removing whitespace.
Edit 2: -4 bytes by changing input to (1, 2, 3) instead of (<, ^, >) since the OP allowed it, as well as changing my coordinate system to allow me to reduce my distance calculation.
n,d=[0,0],0
for c in input():exec'd-=1 n[d%2]+=(-1)**(d/2%2) d+=1'.split()[ord(c)-49]
print'2'*n[0]+'13'[n[1]>0]*any(n)+'2'*abs(n[1])+'13'[n[1]>0]*(n[0]<0)+'2'*-n[0]

Try it online!
Determines final coordinates via the dictionary's values being executed, then just prints the direct path to the end goal.

JavaScript (document.getElementById() kind), 343 chars
function b(s){s=s.split('');c=[0,0];r=0;p='';w='<';e='>';n='^';for(i in s){r+=s[i]==e?.5:s[i]==w?-.5:0;r=r>1?-.5:r<-.5?1:r;c[1-Math.ceil(Math.abs(r%1))]+=s[i]==n?r>0?1:-1:0;}x=c[0];y=c[1];j=x<0?-x:x;k=y<0?-y:y;f=function(a){p+=a==j?x<0?w:x>0?e:'':j>k?y<0?w:y>0?e:'':y>0?e+e:'';for(i=0;i<a;i++){p+=n}};if(j>k){f(j);f(k)}else{f(k);f(j)}alert(p)}

expanded:
function b(s){

s = s.split('');
c = [0, 0];
r = 0;
p = '';
w = '<';
e = '>';
n = '^';

for(i in s){

    r += s[i] == e ? .5 : s[i] == w ? -.5 : 0;
    r = r > 1 ? -.5 : r < -.5 ? 1 : r;

    c[1 - Math.ceil( Math.abs( r%1 ) )] += s[i] == n ? r > 0 ? 1 : -1 : 0;

}

x = c[0];
y = c[1];
j = x < 0 ? -x : x;
k = y < 0 ? -y : y;

f = function(a){

    p += a == j ? x < 0 ? w : x > 0 ? e : '' : j > k ? y < 0 ? w : y > 0 ? e : '' : y > 0 ? e+e : '';

    for( i = 0; i < a; i++){
        p += n
    }

};

if( j>k ){

    f(j);
    f(k)

} else {

    f(k);
    f(j)

}

alert(p)

}
Usage:
b('^<^^<^^<^^^^')

alerts: >^^>^
A robot with reverse would have been useful.

Perl 5, 185 + 1 (-p) = 186 bytes
/</?$d--:/>/?$d++:/\^/?$m[$d%4]++:0for/./g;$y=$m[0]-$m[2];$x=$m[1]-$m[3];$q='^'x abs$x;$_=A.$q.B.('^'x-$y);$x<0?y/AB/</:$x?y/AB/>/:0;$_=('^'x$y).($x<0?'<':$x>0?'>':'').$q if$y>0;y/AB//d

Try it online!


text:
Swap the Sequence
Your task is to write some code that outputs an OEIS sequence, and contains the name of the sequence in the code (A______).  Easy enough right?  Well here's the catch, your code must also output a second separate sequence when the name of the sequence in the code is changed to the name of the second sequence.
Input Output
Your code can be a function or complete program that takes n via a standard input method and outputs the nth term of the sequence as indexed by the provided index on the OEIS page.
You must support all values provided in the OEIS b files for that sequence, any number not in the b files need not be supported.
Scoring
This is code-golf. Your score will be the number of bytes in your code, with less bytes being better.
Example
Here's an example in Haskell that works for A000217 and A000290.
f x|last"A000217"=='0'=x^2|1>0=sum[1..x]

Try it online!

To clarify: Your code should work for two sequences where putting the name of the sequence in that part of the code will output the number of that sequence?

@HyperNeutrino Yes.  When the name of the sequence is substituted in it should change the function of the program to be the second sequence.

Do the sequences in the code have to have leading zeros.

@ppperry Yes it should.

Is the A required?

@Okx Yes it is.

If the sequence number appears more than once, does every instance change to the new sequence number?

@EngineerToast No it does not have to.

JavaScript (ES6), 16 15 bytes
n=>4&~0xA000004

Works with A000004 (all 0s) and A010709 (all 4s).
Previous 17-byte solution works with A010850 to A010859 inclusive:
n=>~-0xA010850%36

Previous 25-byte solution works with A010850 to A010871 inclusive:
n=>"A010850".slice(5)-39

This is just showing off (I don't know OEIS well enough to see how clever this is :P)

Strange -- two answers started at 25 bytes and were both golfed to 17 bytes in a minute

@ppperry Heh, but I could port your answer and it would be only 15 bytes...

JS tied with Jelly?! Very nicely done

@Shaggy Nope; a new shorter jelly answer was posted.

@ppperry, let us JSers have our moment! :p

@Shaggy Tell Erik the Outgolfer ...

C#, 28 bytes
n=>n*n*("A000290"[6]<49?1:n)

Works with A000290 (Squares) and A000578 (Cubes).
Try it online!

Nice job using a non-constant sequence.

Haskell, 28 bytes
f x|"A000012"!!6<'3'=1|1<2=x

The second sequence is A007953. Try it online!

cQuents, 16 bytes
=A000007//5#|A:0

Try it online!, A000007, 1,0,0,0,0...
=A000004//5#|A:0

Try it online!, A000004, 0,0,0,0,0...
Explanation
                    Implicit input A
=A000007            First item in the sequence equals A * 7
        //5                                                 intdiv 5 = 1
           #|A      n equals A
              :     Mode : (sequence): output nth item (1-based)
               0    Rest of the sequence is 0

                    Implicit input A
=A000004            First item in the sequence equals A * 4
        //5                                                 intdiv 5 = 0
           #|A      n equals A
              :     Mode : (sequence): output nth item (1-based)
               0    Rest of the sequence is 0

Thanks to Conor O'Brien for 4//5 = 0 and 7//5 = 1.
If the spec was more flexible, it would be O7A$ and O4A$.

Cubix, 28 bytes
I:uU**...L..A000578@O\s<s(;?

returns the perfect cubes, a(n)=n^3.
Try it online!
On the other hand,
I:uU**...L..A068601@O\s<s(;?

returns the perfect cubes minus one, a(n)=n^3-1.

dc, 13 bytes
Edit: Apparently OEIS lists the powers from 0th to 30th - I just did a search on these sequences and it turns out the original 13 byte solution is the golfiest. But I found another solution for just 1 byte more that works for 9 sequences.
Solution for A000012 (constant 1's sequence):
?A000012 4%^p

Try it online!
Solution for A001477 (non-negative integers):
?A001477 4%^p

Try it online!
Solution for A000290 (perfect squares sequence):
?A000290 4%^p

Try it online!
Ungolfed/Explanation
These solutions make use of the fact that dc interprets A as 10, so A001477 becomes the value 10001477. Further it exploits that the sequences are n^0, n^1 and n^2 which coincides with 10000012 % 4 == 0, 10001477 % 4 == 1 and 10000290 % 4 == 2.
So these sequences are xyz(n) = n ^ (xyz % 4).
Command          Description          Example (3)
?              # Push the input       [3]
 A000290       # Push sequence name   [3,10000290]
         4%    # Top %= 4             [3,2]
           ^   # Pop x,y & push y^x   [9]
            p  # Print the top        [9]

14 byte solution for 9 sequences
The idea is still the same, this time we need to do a % 97, to get the right power - it works for sequences A010801, A010802, A010803, A010804, A010805, A010806, A010807, A010808 and A010809 (these are the sequences n^13,...,n^21).
Here's the first one:
?A010801 97%^p

Try it online!

+1 for supporting more than two sequences!

Neim, 10 9 bytes
A000012ᛄ>

Explanation:
A            Push 42
 000012      Push 4
 or
 A007395     Push 7395
        ᛄ     Modulo 2
         >    Increment

A000012 (all ones) and A007395 (all twos)
A function that takes the input on the top of the stack and leaves the output on the top of the stack.
Try it online!

Python 2, 25 17 bytes
print'A000012'[5]

Works for A000004 and A000012. (input is ignored because the sequences are all constant terms).

Befunge 98, 10 bytes
#A000012$q

Also works for A000004. Output by exit code.

Jelly, 17 bytes
“A000578”OS%⁵ạ6*@

Try it online!
“A000578”OS%⁵ạ6*@  Main link
“A000578”          String
         O         Codepoints
          S        Sum (364 for A000290, 373 for A000578)
           %⁵      Modulo 10 (4 for A000290, 3 for A000578)
             ạ6    Absolute Difference with 6 (2 for A000290, 3 for A000578)
               *@  [left argument] ** [result of last link (right argument)]

Also works with A000290

Good job using non-constant sequences.

PowerShell, 23 bytes
+(0xA000012-eq160mb+18)

Try it online!
Uses A000012 (the all ones sequence) and A000004 (the all zeros sequence).
Leverages several neat tricks. We use 0x as the hexadecimal operator onto the sequence which gives us 167772178. That's compared to see if its -equal to 160mb+18 using the mb operator (160mb is 167772160). That Boolean result is then cast as an int with + to output the proper 1 or 0. Note that any sequence in the code other than A000012 will result in 0 being output.

Gaia, 9 bytes
A000012₉/

Works with A000012 and A000004.
Try A000012!
Try A000004!
Explanation
A          Undefined (ignored)
 000012    Push 12
       ₉   Push 9
        /  Integer division, results in 1

A          Undefined (ignored)
 000004    Push 4
       ₉   Push 9
        /  Integer division, results in 0

Why does everyone keep posting A00004 and A00012?

@ppperry  A000004 is the zero sequence and A000012 is the ones sequence. Simply floor divide the numbers by 9 and output the result forever.

PowerShell, 12 bytes
'A000012'[5]

Try it online!
Works for A000012 (the all ones sequence) and A000004 (the all zeros sequence).
Port of ppperry's Python answer.

05AB1E, 9 bytes
A000004¨θ

Try it online!
Works for A000004 and A000012.

Jelly, 10 bytes
6ị“A000004

Try it online!
Works for A000004 and A000012.

Actually, 10 bytes
A000004X.⌂

Try it online!
Works for A000004 and A000012.

Pyth, 11 bytes
@"A000004"5

Try it here.
Supports A000004 and A000012.

Husk, 16 bytes
Both solutions are 1-indexed.
This works for A000351 (powers of 5):
!¡*i!6"A000351"1

Try it online!
And this one for A000007 (powers of 0):
!¡*i!6"A000007"1

Try it online!
Explanation
It makes use that the names A000351, A000007 contain the right digit D at the position 6, such that the sequence is D^0,D^1,D^2,...:
                  -- implicit input N
   i!6"AxxxxDx"   -- get the right digit D and convert to number,
 ¡*            1  -- iterate (D*) infinitely beginning with 1,
!                 -- extract the value at Nth position

Husk, 20 bytes
This one returns a bit more interesting sequences, again solutions are 1-indexed.
This works for A000040 (the prime numbers):
!!i→"A000040"e:0İfİp

Try it online!
And this one for A000045 (the Fibonacci numbers):
!!i→"A000045"e:0İfİp

Try it online!
Explanation
This makes use of the fact that the last digit of the sequence names have a different parity:
                      -- implicit input N
             e        -- construct a list with:
              :0İf    --   list of Fibonacci numbers (prepend 0)
                  İp  --   list of the prime numbers
  i→"Axxxxx?"         -- get the last character and convert to number,
 !                    -- use it as modular index (0 -> primes, 5 -> Fibonacci)
!                     -- get the value at the Nth index

AHK, 40 bytes
a:=SubStr("A000004",6)//9
Loop
Send %a%,

Output: 0,0,0,0,0,0,0,0,0,0,0,0,...
a:=SubStr("A000012",6)//9
Loop
Send %a%,

Output: 1,1,1,1,1,1,1,1,1,1,1,1,...
This might not be the shortest code but I bet it's the shortest sequence pair we can find. A000004 is the zero sequence and A000012 is the ones sequence. Simply floor divide the numbers by 9 and output the result forever.

QBIC, 28 bytes
p=!_s@A000035`,-1|!?:%2+5-p

This switches between the sequences A000034 (1, 2, 1, 2, 1 ...) and A000035 (0, 1, 0, 1, 0, 1 ...)
Explanation
p=                  Set p to
  !            !    A numeric representation of
   _s         |     a substring of
     @A000035`      our sequence code (either A0035 or A0034)
     ,-1            taking just one character from the right.
?:%2                PRINT <n> MOD 2 (gives us a either 0 or 1)
    +5-p            Plus 1 for seq A24 (5-4), or plus 0 for A35

MATL, 14 bytes
A000027 The positive integers
A000027 3\Gw-&

Try it online!
A001477 The nonnegative integers
A001477 3\Gw-&

Try it online!


text:
Reverse ASCII character map
In Map inputted ASCII characters, I asked you to .. map inputted ASCII characters. This time, you will do the opposite, by immediately mapping all ASCII characters, and then mapping spaces over them.
This program will have practical uses, such as seeing what characters you have left in a restricted-source challenge submission.
Challenge
Your job is to write a program that un-maps inputted ASCII characters. As soon as the program is run, it will display this exact map (except color, font, size, etc.):

Each time the user inputs a printable ASCII character, you will print a space over it.

Rules

The initial output must be exactly as shown in the first image above: a 6x16 grid with  ASCII characters in their respective positions, with the space (32) at the top left and the tilde (126) at one character left from the bottom right.
Your program only needs to display the printable ASCII characters, 0x20 to 0x7E.
Your program must not terminate and continue to print spaces over characters until all printable ASCII characters have been overwritten. From here, your program can either terminate or run off into Neverland.
Your reverse map must be updated in realtime (as soon as it receives user input).
If your program does not read input silently, it must put the cursor out of the way, so the text won't get in the way of the map.

Here's a useful ASCII table for reference.
Scoring
The answer with the least bytes in each language wins. Have fun!

Note to potential DV-ers or duplicate voters - it would be more difficult to port an answer on https://codegolf.stackexchange.com/q/124306/61563 to here than it would be to write your own answer. The answers over there read input and then use the input to print to the screen. Answers here have to print to the screen without input (using a different loop mechanism) and then test each inputted character for its location, then print a different character.

Can we assume that the user presses enter after he entered 1 character?

@Mr.Xcoder Yes, that's fine for languages that cannot take input in realtime.

@Mr.Xcoder See rule 1 - Your program only needs to display the printable ASCII characters, 0x20 to 0x7E

Do we need to preserve new lines alignment exactly like on your image? Can we display all characters on a single line? Also, do we need to put spaces between characters?

@ThePirateBay Updated.

@MDXF It's still strikingly similar to the original challenge. I just need to print the ascii characters to the correct positions, then, instead of putting the user's input in the correct spot, I just use a space instead.

@dzaima Oh, oops, I didn't look at the tag wiki properly. Edited.

SOGL V0.12, 23 bytes
] ~Δ8«n"5αx2⁰³⁄¹‘→č@ŗ░T

Try it Here!
Takes input in the input box. I hope that it isn't too big of an issue that characters can be deleted :p
Explanation:
]                   do.. while (popping (which makes the stack not blow up luckily :D))
  ~Δ                push the ascii characters (range("~"))
    8«n             split into lines of length 16
       "...‘        push "inputs.value" (could be 2 bytes less if my dictionary contained the word "inputs". I even added "input", but only now realise that the input box is id=inputs :/)
            →       evaluate as JavaScript, then push the result
             č      chop into characters
              @ŗ    replace each of the characters in the array with space
                ░   clear the output
                 T  output without popping (so do..while continues looping)

x86-16 Machine Code, 62 bytes
Hex dump:
BC0100B101B07EBAFE0581EAE00080EA02B402CD1085E4750830E439C5750A30C0B40ACD1084C074094884D275E085D275D831C031E4CD1630E489C5EBC7

Assembly:
mov sp, 0x0001           ; Stack pointer is used as a flag; 0 - Print all characters, 1 - Delete specific character
mov cl, 0x01             ; Number of characters to print per interrupt call

printString:
  mov al, 0x7E           ; Last character to print
  mov dx, 0x05FE         ; Row: 0x05, Collumn: 0xFE
  printRow:
    sub dx, 0x00E0       ; Decrement row number + 2 extra characters
    printChar:
      sub dl, 0x02       ; Decrement collumn index + 1 space
      mov ah, 0x02       ; Prepare for interrupt call, 0x02 - Set cursor position
      int 0x10           ; BIOS interrupt

      test sp, sp        ; Are we printing all characters or removing specific character
      jnz print          ; In first case just print it and go on
      xor ah, ah         ; Otherwise reset the upper byte of ax (shorter than "and ax, 0x00FF")
      cmp bp, ax         ; Is the current character same as the input character
      jne after          ; If no, continue searching
      xor al, al         ; If yes, remove it

      print:
        mov ah, 0x0A     ; Prepare for print
        int 0x10         ; Print

      test al, al        ; If we found target character
      jz loop            ; then stop searching

      after:
        dec ax           ; Shorter than "dec, al"
        test dl, dl      ; Is it the last character in the row
        jnz printChar    ; If no, continue searching
    test dx, dx          ; Is it last char
    jnz printRow         ; If no, go to next row

loop:
  xor ax, ax             ; Remove "ah" cache
  xor sp, sp             ; Reset sp (it will never become 1 again)
  int 0x16               ; BIOS interrupt for reading keyboard input
  xor ah, ah             ; Again reset "ah", because BIOS may change it
  mov bp, ax             ; Save it in stack base pointer
  jmp printString        ; Remove the character from the list

C++ (Visual C++), 253 (@Step Hen) 261 bytes
#include<cstdlib>
#include<iostream>
#include<conio.h>
int main(){char a[0x5E];for(int i=0;i<0x5E;i++)a[i]=(char)(i+0x20);while(true){system("cls");for(int i=0;i<0x5E;i++)if(i&&!(i%16))printf("\n%c ",a[i]);else printf("%c ",a[i]);a[_getch()-0x20]=' ';}}

Welcome to PPCG! I believe you can remove the spaces after the #includes, as well as i + 0x20 -> i+0x20. I could be wrong though.

Python 2, 132 bytes
Saved 4 bytes thanks to @alleks!
s=''
for i in range(32,128,16):s+=' '.join(map(chr,range(i,i+16)))+'\n'
while 1:print s[:-2];i=2*ord(input())-64;s=s[:i]+' '+s[i+1:]

Try it online!

This prints a 0x7f after the tilde, just fyi

@ConorO'Brien Oops, fixed

Any reason you couldn't just add [:-2] after print s instead?

@alleks that makes too much sense that's why

Python 3, 116 bytes
o='\n'.join(''.join(map(chr,range(i,16+i)))for i in range(32,124,16))[:-1]
while 1:print(o);o=o.replace(input()," ")

Try it online!

JavaScript (ES6) + HTML, 139 136 116 + 10 16 = 132 bytes
-3 bytes thanks to @Shaggy.
-14 bytes inspired by @Arnauld.

for(i=32;i<127;)O[h="innerText"]+=String.fromCharCode(i++)+(i%16?" ":`
`);onkeypress=e=>O[h]=O[h].replace(e.key," ")

Closing pre tag is required in this case, since we need the innerText value to start totally empty.

Save 2 bytes with O[h="innerHTML"]=a=[...Array(95)].map().

And I think you can save another byte by getting rid of a completely.

@Shaggy Thanks, I was using the extra a variable because innerHTML was turning & into &, along with some others. Switching to innerText fixed that.

You can move i to the global scope to save 2 bytes: map(_=>String.fromCharCode(i++)+(i%16?...),i=32)

@Arnauld Using that idea, I could just remove the whole array mapping and use a for loop instead. Thanks!

QBasic, 107 bytes

An anonymous function that takes as keystrokes, and erases an ASCII table
FOR x=32TO 126
L x
?CHR$(x)
NEXT
DO
L ASC(Input$(1))
?" "'<- `"` included for highlighting only
LOOP
SUB L(x)
LOCATE x\16-1,2*(x MOD 16)+1
END SUB

-8 bytes thanks to @DLosc

@DLosc - I had not even considered using a Sub there - Great solution. Unfortunately, we do have to count the End Sub as the community has decided that autocompletion is not valid (at least with VBA, but I am sure that it applies here as well)

Huh, that's interesting--I hadn't realized there was a distinction between autoformatting and autocompletion. Good to know.

C# (.NET Core), (138 + using System;) 151 bytes
()=>{var j="";for(int i=32;i<127;i++){if(i%16<1)j+='\n';j+=(char)i+" ";}while(1>0){Console.Write(j);j=j.Replace(Console.ReadLine()," ");}}

Try it online!

130 bytes

Oh but you need to include using System; into your byte count if you haven't already (I forgot to add it into the count above).

@TheLethalCoder That's why it says 138+using System;

I mainly meant it because I forgot to add in the using into my byte count above.

Oh. Didn't see your first comment there. I like the abuse of the infinite for loop there :)

Node.js 233 212 bytes
Saved 21 bytes thanks to @thePirateBay
This works, I'm still trying to find an online option as all the repls I've found hijack stdin.
a=[];l=_=>console.log(a.join``);for(i=32;i<127;i++)(x=String.fromCharCode(i)),a.push(i%16?x:x+'\n');l();b=require('readline');b.createInterface(process.stdin).on('line',c=>(a=a.join``.replace(c,' ').split``),l())

Try it online

Online version can be found on TIO. Just a few notes: you can save more than 30 bytes by rearranging your identifiers and removing unnecesary parts. You don't need variable b at all, and you are also using uninitialized identifier readline (not sure if it is compatible with version on TIO). You also don't need variable r at all, instead of && at the end, you can use , and rearrange parentheses. Same with the && at the beginning. Also, no need for process.stdout in readline interface, etc...........

@ThePirateBay without process.stdout it throws (at least on my version of node).  The readline thing was a typo (hit ctrl-z too many times). I'll change the &&s.

Readline module doesn't require process.stdout. You can read the specification. It may throw an error if you messed something up with the rest of your code or if you are using old/inconsistent version of Node.js.

@thePirateBay Must be my node, I'm 6.9.1 on MacOS... just tried it again and createInterface apparently returns undefined if you omit the second param. I went ahead and removed it though per the docs you linked. As far as TIO goes, how do you make it interactive?

Here is using only 191 bytes, but I am sure at least 10 more bytes can be saved. Sorry, im too bored now to continue golfing this: for(a=[],l=_=>console.log(a.join``),i=32;i<127;x=String.fromCharCode(i++),a.push(i&15?x:x+'\n'));l();require('readline').createInterface(process.stdin).on('line',c=>(a[a.indexOf(c)]=' ',l)())

65c02 machine code + Apple //e ROM, 52 (47?) bytes
Hex dump:
8000- 20 58 FC A9 A0 20 20 80
8008- 20 ED FD 1A C9 FF D0 F5
8010- AD 00 C0 10 FB 8D 10 C0
8018- 20 20 80 20 57 DB 80 F0
8020- 48 38 E9 A0 48 29 0F 0A
8028- 85 24 68 4A 4A 4A 4A 20
8030- 5B FB 68 60

Commented assembly:
 1 HTAB     =     $24        ; HORIZONTAL POSITION OF CURSOR
 2 SETVTAB  =     $FB5B      ; SETS VERTICAL POSITION OF CURSOR FROM ACC
 3 COUT     =     $FDED      ; OUTPUTS CHARACTER IN ACC
 4 HOME     =     $FC58      ; CLEARS SCREEN
 5 OUTSP    =     $DB57      ; APPLESOFT ROUTINE THAT OUTPUTS A SPACE
 6 KBD      =     $C000      ; KEY LAST PRESSED
 7 KBSTROBE =     $C010      ; ACCESS TO RESET "NEW KEY PRESSED" INDICATOR
 8          ORG   $8000
 9          JSR   HOME
10 * PRINT INITIAL CHARACTER MAP
11          LDA   #" "
12 LOOP     JSR   CHARPOS
13          JSR   COUT
14          INC              ; INCREMENT ACCUMULATOR
15          CMP   #"~"+1
16          BNE   LOOP
17 * WAIT FOR KEYPRESS
18 GETCH    LDA   KBD        ; GET LAST KEY PRESSED
19          BPL   GETCH      ; READ AGAIN IF KEYPRESS IS NOT NEW
20          STA   KBSTROBE   ; RESET "NEW KEYPRESS" INDICATOR
21          JSR   CHARPOS
22          JSR   OUTSP
23          BRA   GETCH
24 * SUBROUTINE TO POSITION CURSOR TO PRINT OVER CHARACTER IN ACCUMULATOR
25 CHARPOS  PHA              ; PRESERVE ACC
26          SEC              ; MAKE SURE CARRY IS SET TO SUBTRACT
27          SBC   #" "       ; SUBTRACT CHAR CODE OF SPACE
28          PHA              ; SAVE ACC
29          AND   #$0F       ; GET LOWER 4 BITS TO GET CURSOR X POSITION
30          ASL              ; SHIFT LEFT TO MAKE SPACES BETWEEN CHARS
31          STA   HTAB
32          PLA              ; GET OLD ACC
33          LSR              ; SHIFT HIGH NIBBLE
34          LSR              ; INTO LOW NIBBLE
35          LSR              ; TO GET CURSOR Y POSITION
36          LSR
37          JSR   SETVTAB
38          PLA              ; RESTORE ACC
39          RTS

This has no cursor whatsoever. I also have a 47 byte version which might be valid, depending on what is meant by "put the cursor out of the way, so the text won't get in the way of the map":
8000- 20 58 FC A9 A0 20 1B 80
8008- 20 ED FD 1A C9 FF D0 F5
8010- 20 0C FD 20 1B 80 20 57
8018- DB 80 F5 48 38 E9 A0 48
8020- 29 0F 0A 85 24 68 4A 4A
8028- 4A 4A 20 5B FB 68 60

This puts a cursor at the character after the character you type (which is the space between characters), so it won't overwrite any of the actual characters in the map. Whether this is valid or not is up to the creator of the challenge.

Python 2, 96 bytes
from textwrap import*
a=fill(str(bytearray(range(32,127))),16)
while 1:a=a.replace(input(a),' ')

Try it online! Output looks iffy on TIO (because input is passed from a file), but it’s fine interactively. I hope 'A'\n, 'B'\n etc is an okay input format.