text:
Create a simple line editor
In: a string without line breaks*
Allow the user to edit and submit the line
Out: the modified string (optionally with a trailing linebreak)
The line editor must at minimum allow the user to:

move a visible cursor left and right

insert and/or overwrite characters at the cursor position

remove characters at the cursor position

submit the new string, i.e. cease editing cause the modified string to be returned/printed/displayed/saved… (with no other text)

Appreciated, but not required:

explanation of your code.

link to an online testing site that can demonstrate your program/function

an animated image demonstrating usage (TIO, for instance, does not allow interactivity)

Note:

key-bindings are suggestions only

GUI or visual styling is not required

Examples
In the following, the cursor is illustrated with _.
In: Just some text
Allow the user to edit:
 Just some text_   User presses ← (left arrow key) nine times
 Just ̲some text    User presses Del four times
 Just ̲ text        User presses any
 Just any_text     User presses Enter
Out: Just any text
In: Remove me
Allow the user to edit:
 Remove me_        User presses Backspace nine times
 _                 User presses Enter
Out:  (empty string)

* To prevent trivial editor solutions, this must either be supplied via a different input method than the editing commands, or must be separated from them by a newline or similar.

Do we have to use those exact keypresses for i/o? Also, can we create a file to save the text to?

@Riker key-bindings are suggestions only. Input and output methods follow PPCG defaults.

Can the string contain newlines? And can a newline be used to "submit"?

@ConorO'Brien No; Simple line editor. Yes; The editor must at minimum allow the user to: (...) 4. submit the new string

It would be nice if you specified line in the actual body of the question, as titles on this site are not exactly specifications...

@ConorO'Brien OK?

Is it needed to respond to the Enter key? Or can I bind my edit control directly to a variable?

@sergiol The line editor must at minimum allow the user to (...) submit the new string. key-bindings are suggestions only. As long as there is a possibility for the user to signal that editing is done, it is fine.

So, Is my answer valid or not?

@sergiol Can the user click the ╳ button to stop editing and let surrounding code continue?

Clicking the X button will exit from application.

Let us continue this discussion in chat.

A nice challenge but too vulnerable to abuse

@BetaDecay I think I've managed to patch up the worst holes. Do you see any more?

I don't think so

Bash, 2 bytes: vi (jk)

@programmer5000 How do you submit?

@programmer5000 APL, 1 byte: ∇

I think this is one case where banning builtins would've been a good idea.

@12Me21 But which build-ins? Those that do the entire job? Half of it? Rather than hard-to-define bans, we need a better voting culture that promotes ingenuity

APL (Dyalog), 5 bytes
⍞←⍞⋄⍞

This is a tradfn, so to use it, do
∇a
⍞←⍞⋄⍞
∇

And then call it by using a, after which you supply the starting string, and then you can edit the string.

JavaScript (ES6), 15 14 bytes
I don't understand why this is getting so many upvotes!
s=>prompt(s,s)

Saved a byte thanks to Adám's suggestion that I display the original input in the prompt.

Try It

f=
s=>prompt(s,s)
console.log(f("Edit this ..."))

Save a byte by replacing "" with 0 or even s (so the user can still see the original text while editing -  a neat feature).

Bash 4.x, 25 characters
read -ei "$*" t
echo "$t"

Sample run:
bash-4.3$ bash interactive.sh hello world
hello golfing world
hello golfing world

(Line 2 above was the interactive editing, line 3 the output of resulted text.)

Doesn't work, for me, -bash: read: -i: invalid option? man says only ers are allowed flags.

Yeah, I was about to ask about -ei

-i was introduced in Bash 4.0 (released in February 2009) – “-i text   Use TEXT as the initial text for Readline”.

I'm wondering, would cat work?

cat just awaits for incoming stream, for which the shell will provide no editing functionality. At least not by default.

C + NCURSES, 573 bytes
#include <curses.h>
i;j;k;s;c;p;int main(a,b)char**b;{char*q;char t[999];if(a&&(q=b[1]))while(*q)t[s++]=*q++;i=s;initscr();noecho();keypad(stdscr,1);do{for(j=0;j<i;j++)addch(t[j]);addch('|');for(j=i;t[j];j++)addch(t[j]);c=getch();switch(c){case KEY_LEFT:if(i)i--;break;case KEY_RIGHT:if(i<s)i++;break;case 8:case 127:case KEY_BACKSPACE:if(i){for(k=i-1;k<s;k++)t[k]=t[k+1];i--;s--;}break;case KEY_DC:if(i<s){for(k=i;k<s;k++)t[k]=t[k+1];s--;}break;default:if(c>31&c<127){for(k=s;k>i;k--)t[k]=t[k-1];t[i]=c;i++;s++;}}clear();}while(c!=10);printw(t);getch();endwin();return 0;}

Test

Compile & Run with input Just some text.

Press Left-Arrow button nine times.

Press Delete button four times.

Press a then n then y.

Press Enter to terminate.

Detailed
#include <curses.h>

int main(int argc, char ** argv)
{
    char*q = 0;
    char t[999] = {0};
    int j = 0, k = 0;
    int i = 0; // cursor before first char
    int s = 0; // current size
    int c = 0; // current input
    int p = 0;

    // copy first command-line argument
    if(argc>0 && (q=argv[1]))while(*q)t[s++]=*q++; i=s;

    initscr(); // initiate NCURSES
    noecho(); // input does not echo on entry
    keypad(stdscr,TRUE); // handle all input

    do
    {
        // print current content with cursor
        for(j=0;j<i;j++) addch(t[j]);
        addch('|'); for(j=i;t[j];j++) addch(t[j]);

//      printw("\n\n> key %d pressed",c); // debug

        c = getch(); // read next char

        switch(c)
        {
            case KEY_LEFT: // left arrow; cursor left
            if(i > 0) i--;
            break;

            case KEY_RIGHT: // right arrow; cursor right
            if(i < s) i++;
            break;

            case 8: // backspace; remove previous char
            case 127:
            case KEY_BACKSPACE:
            if(i > 0)
            {
                for(k=i-1; k<s; k++) t[k]=t[k+1];
                i--;s--;
            }
            break;

            case KEY_DC: // delete; remove next char
            if(i < s)
            {
                for(k=i; k<s; k++) t[k]=t[k+1];
                s--;
            }
            break;

            default: // none of the above

            if(c > 31 && c < 127) // printable char
            {
                for(k=s; k>i; k--) t[k]=t[k-1];
                t[i] = c;i++;s++;
            }
        }

        clear(); // clear screen
        if(c == 10) break;
    }
    while(c);

    addch('\n');
    printw(t); // print final result
    getch(); // wait for any input
    endwin();
    return 0;
}

Can't you replace KEY_*by the respective integers to save some bytes?

HTML + JavaScript (ES6), 77 66 64 bytes
HTML
<input id=t

JavaScript
onkeyup=e=>e.which-13||alert(t.value);f=a=>t.value=a;

Saved 10 bytes thanks to Jörg Hülsermann and 2 bytes thanks to Luke.

onkeyup=e=>e.which-13||alert(t.value);f=a=>t.value=a;

f("Remove Me");
<input id=t>

you can remove the type attribut for the input Element

You should probably use oninput instead.

@SIGSEGV I don't think oninput fires when Enter is pressed

e.which==13?alert(t.value):0 -> e.which-13||alert(t.value) saves two bytes.

Bash + Vi/Vim, 14 bytes
echo $1>a;vi a

vi is aliased to vim on macOS, I don't know about other OSes.

Maybe I am missing something, but does this meet the requirement of outputting the modified string?

@GraysonKent you can save and quit by hitting :wq! or :x, so I think so. OP is a bit unclear on what qualifies as that.

Python 2, 275 200 bytes
Not a winner, but here it is:
from msvcrt import*
s=list(input())[::-1]
c=i=0
def p(a):print''.join(a)[::-1]
while'\r'!=c:p(s[:i]+['<']+s[i:]);c=getch();x=c!='\b';exec["s[i:i+1-x]=c*x","i=(i-1+2*(c<'\\t'))%-~len(s)"][x*' '>c]
p(s)

Explanation:
It works by reversing the input (with [::-1]), and excluding and inserting characters in that reversed input so that the cursor does not have to move. Reverses it again when printing.
Usage:
[Tab] key to move Right
[Ctrl+C] to move Left
[Backspace] to erase
[Return] to finish editing
Any other key, will be inserted into text
Example:
Using OP's example
In: Just some text
 Just some text>
 Just some> text User presses Ctrl+C five times
 Just > text     User presses Backspace four times
 Just any> text  User presses any
 Just any> text  User presses Enter
Out: Just any text
Inline editor version:
If you want the text to be editted inline, append ,'\r', at the end of the print statement:
def p(a):print''.join(a)[::-1],'\r',

+1 Very nice. First answer which actually implements a real editor, as opposed to relying on pre-existing functionality. I was considering posting another challenge to do just this.

Can't you save bytes by using other keys for left and right?

I could assume characters as - and + to do so, but the editor would be unable to accept those characters then

How about \t and \v?

how do i use \v? ctrl+v?

That's the user's problem, no? Control+K, maybe?

C#, 53 bytes
s=>{SendKeys.SendWait(s);return Console.ReadLine();};

Where s is a string to modify and the output is the new value.
SendKeys.SendWait: Sends the given keys to the active application, and then waits for the messages to be processed.
or 74 bytes if we are not in a Windows Forms context:
s=>{System.Windows.Forms.SendKeys.SendWait(s);return Console.ReadLine();};

VBScript, 23 40 bytes
MsgBox InputBox("",,Wscript.Arguments(0))

Ruby, 9 19 22 84 bytes
->s{r=Readline;r.pre_input_hook=->{r.insert_text s;r.redisplay};r.readline}

This creates a Readline pre input hook that inserts the text s and then redisplays. After this, irb gets messed up so make sure to run this from a file. Run as a lambda, it takes the input string as an argument and returns the output string.

puts Readline.readline

This uses the Readline library to perform line editing. My previous answer only allowed backspaces.
puts gets

This is really, really self explanatory.
Edit: I have been asked for an explanation. This is equivalent to puts(gets). gets inputs a string with a line editor. puts outputs it.

Chain the method calls: r.insert_text(s).redisplay and remove the following ;. BTW, as I understand our policy, you should mention that your code runs in irb, because otherwise you would need to require Readline in your code.

PHP + HTML, 26 Bytes
<input value=<?=$_GET[0]?>

The Browser adds automatically the closing tag
$_GET Using a url like http://example.com?0=input as Input
Creates in a HTML <input value=input
And this is the output for the string input

<input value=input

Should I assume this works? Maybe you can add an explanation, or link, or animation?

@Adám Yes you can assume this Maybe you will it improve and set the attribute autofocus to have the cursor at the beginning in it. Other HTML elements you can also edit if you set the attribute contenteditable

Input = test></input><script>alert("Hi");//some malicious code\n</script>

@RomanGräf Bad Boy. Yes it is better to filter Javascript

AHK, 32 bytes
InputBox,s,,,,,,,,,,%1%
Send,%s%

InputBox stores whatever is typed as the variable s and gives a starting prompt of the variable 1 which is the first passed parameter.
Send sends keystrokes to the current window. In this case, it'll be the contents of s.
MsgBox was an option but, for golfing, Send is 2 bytes shorter.

@Adám I misread that part. I've updated the answer.

Now it is good.

Excel VBA Immediate Window Command - 22 bytes
[a1]=inputbox(0,,[a1])

This is only a partial solution, as your initial value ("Hi") is hard-coded. The initial value must be read from somewhere (a cell or a prompt or a file...) and the final value must be put somewhere (a cell, a messagebox, a file,...).

inputbox(0,,"Hi") saves a byte

@Adám Thanks. Fixed now it's reading from cell A1

I think you need [a1]=inputbox(0,,[a1]) or something, otherwise, where does a go? Storing in a variable is not a valid output method.

It goes where it came from cell A1

Tcl, 17
puts [gets stdin]

Online interpreters just suck to demonstrate it, then I showcase some images from a Windows command shell:
Test case 1

Test case 2

Can you explain this one?

I can add images of it running on a Windows command line.

@Adám: Do you still want me to explain what the code is doing or are the images enough?

This is enough.

SmileBASIC, 138 bytes
DEF E S@L
WAIT
B=BUTTON(1)C=C-(B==4&&C)+(B>7&&C<LEN(S))I$=INKEY$()IF"\u0008"<I$THEN B=I$<"\u000E"S=SUBST$(S,C,B,I$*!B)?S?" "*C;1IF"\u0008"!=I$GOTO@L
END

Creates a function E with 1 argument and 0 outputs. (Output is displayed in the console)
The escaped characters should be the actual symbols, but they wouldn't show up here.
Controls:
Normal keys: Insert a character before the cursor.
Enter: Delete the character at the cursor.
Backspace: Submit.
D-pad left: Move cursor left.
All buttons except up, down, and left on the d-pad: Move cursor right.

Inserting/deleting characters is backwards so it's very annoying to use (but should still fulfill the requirements).
Just some text
1
'(press right 5 times)
Just some text
     1
'(press enter 4 times)
Just  text
     1
'(press a)
Just a text
     1
'(press right)
Just a text
      1
'(...)
Just any text
       1
'(press backspace)

ZX Spectrum BASIC, 7 bytes
Trivial, included for completeness (INPUT and PRINT are one byte tokens each).
INPUT a$: PRINT a$

How does it get the initial value of a$?

@Adám it gets the initial value of a$ by keyboard input; a$ will be over-written with the INPUT keyword.

Windows command interpreter, 16 bytes
set/pa=
echo %a%

This is very trivial; the command interpreter is trivially a "line editor".

Commodore BASIC (C64Mini, C64/128, VIC-20 etc...) 179 tokenized BASIC bytes
This should be typed in business mode (upper/lower case characters)
 0a$="Just some text":?"{SHIFT+CLR/HOME}"a$"_":fOi=0to1step0:getk$:on-(k$<>"")goS2:goS1:nE
 1?"{CTRL+N}{CLR/HOME}"a$"_  ";:return
 2ifasc(k$)<>20thena$=a$+k$:on-(asc(k$)=13)goS4:return
 3if-(len(a$))thena$=leF(a$,len(a$)-1):goS4:return
 4?"{ARROW LEFT}{ARROW LEFT}{ARROW LEFT}  ":return

Allows basic text editing + delete + new line. Maximum size of a$ like all strings in Commodore BASIC is 255 characters, so any more than that will crash the program. I will find a way to do > 255 characters if that is necessary.


text:
Perfect Palindromes
Your task is to determine how much of a perfect palindrome a string is. Your typical palindrome (eg 12321) is a perfect palindrome; its perfectness is 1.
To determine the perfectness of a string, you see how many sections you can split it into where each section is a palindrome. If there are ambiguities, such as with aaaa, as you can split it into [aa, aa] or [aaaa] or [a, aaa] or [aaa, a], the shortest set will override, giving aaaa a score of 1, which is the length of the shortest set.
Therefore, you must write a program or function that will take one non-empty input and output how perfect it is (which is the length of the shortest set you can split it into where each element in the set is a palindrome).
Examples:
1111 -> 1 [1111]
abcb -> 2 [a, bcb]
abcbd -> 3 [a, bcb, d]
abcde -> 5 [a, b, c, d, e]
66a -> 2 [66, a]
abcba-> 1 [abcba]
x -> 1 [x]
ababacab -> 2 [aba, bacab]
bacababa -> 2 [bacab, aba]
26600 -> 3 [2, 66, 00] [my user id] [who has a more perfect user id?]
ababacabBACABABA -> 4 [aba, bacab, BACAB, ABA]

Note that in the examples anything in square brackets shouldn't be part of the output.

Is the empty string a valid input, and if so, what should the output be?

ababacab and its reverse, bacababa, seem to be good test cases.

@Neil as well as good arguments as to whether a linear-time algorithm is possible.

@Zgarb Empty string is not valid input.

ababacabBACABABA is also a good test case (some answers fail on it).

ababacabBACABABA has a palindrome ababa

@MilkyWay90 Yes, but it would be longer as you have to do [ababa, c, a, b, BACAB, ABA] which has length 6

@Okx Oh wait, nevermind. I misread something in the rules

Brachylog, 7 bytes
~cL↔ᵐLl

Try it online!
Explanation
~cL          Deconcatenate the input into L
  L↔ᵐL       Reversing all elements of L results in L
     Ll      Output = length(L)

You beat me... on my first post lol

@LeakyNun I knew you would try it. Last months I could slack off and wait a few hours, now with you back I have to answer immediatly!

Jelly, 13 12 11 bytes

ŒṖLÞŒḂ€P$ÐfḢL
ŒṖLÞṚ€⁼$ÐfḢL
ŒṖṚ€⁼$ÐfL€Ṃ
ŒṖ            obtain partitions
      Ðf      filter for partitions which
  Ṛ€              after reversing each subpartition
    ⁼             is equal to the partition
        L€    length of each successful partition
          Ṃ   minimum

Try it online!
Specs

Input: "ababacab" (as argument)
Output: 2

Doesn't appear to work with backslashes in the input.

@Okx well you would have to escape those.

Well, I don't think it's valid if it can't accept backslashes.

@Okx It's like writing a string. You can't expect, say, a C program to work with a string input "\", because that's invalid syntax.

Welcome back, by the way. :-)

@Arnauld your profile says that you only joined this site on August 15...

True. But you were pretty much active during the 2 following weeks.

Sadly this gives different answers for ababacab and its reverse, bacababa.

Pyth, 9 bytes
lh_I#I#./

Test suite
This forms all partitions of the input, from shortest to longest. Then, it filters those partitions on invariance under filtering the elements on invariance under reversal. Finally, we take the first element of the filtered list of partitions, and return its length.
To explain that complicated step, let's start with invariance under reversal: _I. That checks whether its input is a palindrome, because it checks whether reversing changes the value.
Next, filtering for palindromicity: _I#. This will keep only the palindromic elements of the list.
Next, we check for invariance under filtering for palindromicity: _I#I. This is truthy if and only if all of the elements of the list are palindromes.
Finally, we filter for lists where all of the elements of the list are palindromes: _I#I#.

I have got a lot to learn...

Haskell, 83 bytes
f s=minimum[length x|x<-words.concat<$>mapM(\c->[[c],c:" "])s,all((==)=<<reverse)x]

Try it online!
This uses Zgarb's great tip for generating string partitions.
f s = minimum[                               -- take the minimum of the list
    length x |                               -- of the number of partitions in x
    x<-words.concat<$>mapM(\c->[[c],c:" "])s -- where x are all partitions of the input string s
    , all((==)=<<reverse)x                   -- where each partition is a palindrome.
]

Wow! This blew my mind! I definitely got a lot to learn.

JavaScript (ES6), 143 126 124 bytes
Saved 2 bytes thanks to Neil
Inspired by NikoNyrh method.
s=>(r=1/0,F=(s,i=1,p=0)=>s[p++]?([...o=s.slice(0,p)].reverse().join``==o&&(s[p]?F(s.slice(p),i+1):r=r<i?r:i),F(s,i,p)):r)(s)

Formatted and commented
s => (                          // given a string 's':
  r = 1 / 0,                    // 'r' = best score, initialized to +Infinity
  F = (                         // 'F' is a recursive function that takes:
    s,                          //   - the current string 's'
    i = 1,                      //   - a substring counter 'i'
    p = 0                       //   - a character pointer 'p'
  ) =>                          //
    s[p++] ? (                  // if we haven't reached the end of the string:
      [...o = s.slice(0, p)]    //   compute 'o' = substring of length 'p'
      .reverse().join`` == o    //   if 'o' is a palindrome,
      && (                      //   then:
        s[p] ?                  //     if there are still characters to process:
          F(s.slice(p), i + 1)  //       do a recursive call on the remaining part
        :                       //     else:
          r = r < i ? r : i     //       update the score with r = min(r, i)
      ),                        //   in all cases:
      F(s, i, p)                //     do a recursive call with a longer substring
    ) :                         // else:
      r                         //   return the final score
  )(s)                          // initial call to F()

Test cases

let f =

s=>(r=1/0,F=(s,i=1,p=0)=>s[p++]?([...o=s.slice(0,p)].reverse().join``==o&&(s[p]?F(s.slice(p),i+1):r=r<i?r:i),F(s,i,p)):r)(s)

console.log(f('1111'))      // -> 1 [1111]
console.log(f('abcb'))      // -> 2 [a, bcb]
console.log(f('abcbd'))     // -> 3 [a, bcb, d]
console.log(f('abcde'))     // -> 5 [a, b, c, d, e]
console.log(f('66a'))       // -> 2 [66, a]
console.log(f('abcba'))     // -> 1 [abcba]
console.log(f('x'))         // -> 1 [x]
console.log(f('ababacab'))  // -> 2 [aba, bacab]
console.log(f('bacababa'))  // -> 2 [bacab, aba]

Initial approach, 173 168 bytes
A pretty long recursive function that computes all possible partitions of the input string.
f=(s,b=1/(k=0))=>++k>>(L=s.length)?b:f(s,(k|1<<30).toString(2).slice(-L).match(/(.)\1*/g).some(m=>[...o=s.slice(i,i+=m.length)].reverse(n++).join``!=o,n=i=0)?b:b<n?b:n)

Formatted and commented
f = (                           // given:
  s,                            //   - a string 's'
  b = 1 / (k = 0)               //   - a best score 'b' (initialized to +Infinity)
) =>                            //   - a counter 'k' (initialized to 0)
  ++k >> (L = s.length) ?       // if 'k' is greater or equal to 2^(s.length):
    b                           //   stop recursion and return 'b'
  :                             // else:
    f(                          //   do a recursive call:
      s,                        //     using the same string 's'
      (k | 1 << 30)             //     compute an array containing the groups of identical
      .toString(2).slice(-L)    //     digits in the binary representation of 'k', padded
      .match(/(.)\1*/g)         //     with leading zeros and cut to the length of 's'
      .some(g =>                //     for each group 'g' in this array:
        [... o = s.slice(       //       compute 'o' = corresponding substring of 's',
          i, i += g.length      //       starting at position 'i' with the same length
        )]                      //       (e.g. s = 'abcd' / k = 0b1101 => 'ab','c','d')
        .reverse(n++)           //       increment the number of groups 'n'
        .join`` != o,           //       return true if this substring is NOT a palindrome
        n = i = 0               //       initialize 'n' and 'i'
      ) ?                       //     if some() returns true:
        b                       //       invalid partition -> keep the previous score 'b'
      :                         //     else:
        b < n ? b : n           //       valid partition -> use min(b, n)
    )                           //   end of recursive call

Test cases

f=(s,b=1/(k=0))=>++k>>(L=s.length)?b:f(s,(k|1<<30).toString(2).slice(-L).match(/(.)\1*/g).some(m=>[...o=s.slice(i,i+=m.length)].reverse(n++).join``!=o,n=i=0)?b:b<n?b:n)

console.log(f('1111'))      // -> 1 [1111]
console.log(f('abcb'))      // -> 2 [a, bcb]
console.log(f('abcbd'))     // -> 3 [a, bcb, d]
console.log(f('abcde'))     // -> 5 [a, b, c, d, e]
console.log(f('66a'))       // -> 2 [66, a]
console.log(f('abcba'))     // -> 1 [abcba]
console.log(f('x'))         // -> 1 [x]
console.log(f('ababacab'))  // -> 2 [aba, bacab]
console.log(f('bacababa'))  // -> 2 [bacab, aba]

If I've understood your explanation correctly, you can save a couple of bytes using ,p=0, s[p++]? and ,F(s,i,p).

@Neil Yes indeed. :-)

Clojure, 111 bytes
(defn f[s](if(=()s)0(+(apply min(for[i(range(count s))[a b][(split-at(inc i)s)]:when(=(reverse a)a)](f b)))1)))

Splits at all possible positions, and when the first part is a palindrome proceeds to find a partitioning for the remaining of the string.
Try it online.
Ungolfed, uses thread-last macro ->>.
(defn f [s]
  (if (empty? s)
    0
    (let [results (for[i (range(count s))]
                      (let [[a b] (split-at (inc i) s)]
                         (when (= a (reverse a))
                           (f b))))]
      (->> results        ; Take results (a list of integers and nils),
           (filter some?) ; remove null values (they occur when "a" is not a palindrome)
           (apply min)    ; find the minium value,
           inc))))        ; and increment by one.

An obscure version, please do not write code like this :D
(defn f [s]
   (->> (f b)
        (when (= a (reverse a)))
        (let [[a b] (split-at (inc i) s)])
        (for[i (range(count s))])
        (filter some?)
        (apply min)
        inc
        (if (empty? s) 0)))

Would this tip help? I don't know Clojure at all.

Usually yes, but in this case the function f has to call itself within the for: (f b). On a tail-call position you can use recur.

You can still replace defn with fn and just have a function.

(fn f[s]( ... ))? Oh true. You save 2 characters with that.

Jelly, 10 bytes
ŒṖŒḂ€¬$ÞḢL

Try it online!
How?
Uses the fact that
[0]<[0,0]<[0,0,0],...,<[0,...,0,1]<...
- thus if we sort the partitions by a key "is not palindromic for each part" the first entry will be all palindromic and of minimal length.
Note: any non-empty string of length n will always result in such a key with n zeros, since all length 1 strings are palindromic.
ŒṖŒḂ€¬$ÞḢL - Main link: s             e.g. 'abab'
ŒṖ         - partitions of s               [['a','b','a','b'],['a','b','ab'],['a','ba','b'],['a','bab'],['ab','a','b'],['ab','ab'],['aba','b'],['abab']]
       Þ   - sort by (create the following key and sort the partitions by it):
      $    -   last two links as a monad:  (key evaluations aligned with above:)
  ŒḂ€      -     is palindromic? for €ach   [ 1 , 1 , 1 , 1 ] [ 1 , 1 , 0  ] [ 1 , 0  , 1 ] [ 1 , 1   ] [ 0  , 1 , 1 ] [ 0  , 0  ] [ 1   , 1 ] [ 0    ]
     ¬     -     not                        [ 0 , 0 , 0 , 0 ] [ 0 , 0 , 1  ] [ 0 , 1  , 0 ] [ 0 , 0   ] [ 1  , 0 , 0 ] [ 1  , 1  ] [ 0   , 0 ] [ 1    ]
           - ...i.e.:
           -       making the sorted keys: [[ 0 , 0   ],[ 0   , 0 ],[ 0 , 0 , 0 , 0 ],[ 0 , 0 , 1  ],[ 0 , 1  , 0 ],[ 1    ],[ 1  , 0 , 0 ],[ 1  , 1  ]]
           -  hence the sorted partitions: [['a','bab'],['aba','b'],['a','b','a','b'],['a','b','ab'],['a','ba','b'],['abab'],['ab','a','b'],['ab','ab']]
        Ḣ  - head of the result             ['a','bab']
         L - length                         2

Haskell, 69 bytes
x!(a:b)|p<-a:x=p!b++[1+f b|p==reverse p]
x!y=[0|x==y]
f=minimum.(""!)

Defines a function f. Try it online!
Explanation
The infix helper function x ! y computes a list of integers, which are the lengths of some splittings of reverse x ++ y into palindromes where reverse x is left intact.
It is guaranteed to contain the length of the minimal splitting if y is nonempty.
How it works is this.

If y is nonempty, a char is popped off it and pushed into x.
If x becomes a palindrome, we call the main function f on the tail of y and add 1 to account for x.
Also, we call ! on the new x and y to not miss any potential splitting.
If y is empty, we return [0] (one splitting of length 0) if x is also empty, and [] (no splittings) otherwise.

The main function f just calls "" ! x and takes the minimum of the results.
x!(a:b)|          -- Function ! on inputs x and list with head a and tail b,
  p<-a:x=         -- where p is the list a:x, is
  p!b++           -- the numbers in p!b, and
  [1+f b|         -- 1 + f b,
   p==reverse p]  -- but only if p is a palindrome.
x!y=              -- Function ! on inputs x and (empty) list y is
  [0|             -- 0,
   x==y]          -- but only if x is also empty.
f=                -- Function f is:
  minimum.(""!)   -- evaluate ! on empty string and input, then take minimum.

JavaScript (Firefox 30-57), 97 bytes
f=(s,t=``,i=0)=>s?Math.min(...(for(c of s)if([...t+=c].reverse(++i).join``==t)1+f(s.slice(i)))):0

ES6 port:

f=(s,t=``)=>s?Math.min(...[...s].map((c,i)=>[...t+=c].reverse().join``==t?1+f(s.slice(i+1)):1/0)):0
<input oninput=o.textContent=f(this.value)><pre id=o>

It seems such a simple solution that I keep thinking I've forgotten something but it does at least pass all the test cases.

PHP, 319 Bytes
for(;$i<$l=strlen($s=$argn);$i++)for($j=$l-$i;$j;$j--)strrev($r=substr($s,$i,$j))!=$r?:$e[+$i][]=$r;uasort($e,function($a,$b){return strlen($b[0])<=>strlen($a[0])?:count($a)<=>count($b);});foreach($e as$p=>$v)foreach($v as$w){$s=preg_replace("#^(.{{$p}})$w#","$1".str_pad("",strlen($w),"ö"),$s,1,$c);!$c?:++$d;}echo$d;

Online Version
Expanded
for(;$i<$l=strlen($s=$argn);$i++)
for($j=$l-$i;$j;$j--)strrev($r=substr($s,$i,$j))!=$r?:$e[+$i][]=$r; #Make all substrings that are palindromes for each position
uasort($e,function($a,$b){return strlen($b[0])<=>strlen($a[0])?:count($a)<=>count($b);}); # sort palindrome list high strlen lowest count for each position
foreach($e as$p=>$v)
foreach($v as$w){
    $s=preg_replace("#^(.{{$p}})$w#","$1".str_pad("",strlen($w),"ö"),$s,1,$c);
    !$c?:++$d; # raise count
}
echo$d; # Output

Longer Version without E_NOTICE and Output the resulting array

This seems to give an incorrect result for ababacabBACABABA

@Zgarb Now it works

Haskell, 139 116 109 bytes
h[]=[[]]
h x=words.concat<$>mapM(\c->[[c],c:" "])x
r x=reverse x==x
g x=minimum[length y|y<-h x,and$r<$>y]

Still green at Haskell golfing but here is my best attempt I can come up with quickly.

h is a function that creates a List of all possible contiguous subsequences of a List (like a string).  It takes the input String and breaks it out for g.
r is a simple function that returns a Boolean for if a List is a palindrome
g is the main function that takes an input List, calls h to get the list of contiguous subsequence possibilities, filters on (and.map r) to remove sub lists that do not contain a palindrome, at which point length is applied to the list, and then the result is sorted so we can grab the head which is the answer.

I was thinking a better answer might be able to leverage the non-deterministic nature of Lists in Haskell through the use of Applicatives.  It might be possible to shave many bytes off of function h by using applicatives, even if we have to import Control.Applicative.  Comments for improvement are welcome.
UPDATE1
Huge savings based on Laikoni's reminder about the minimum function.  Removing sort actually allowed me to drop the Data.List import because minimum is defined in Prelude!
UPDATE2
Thanks to nimi's suggestion about using list comprehensions as a useful replacement for filter.map.  That saved me a few bytes.  Also I borrowed the neat String partition trick from Laikonis answer and saved a couple bytes there as well.

h []=[[]] and h (x:y)=map ([x]:) contain unnecessary white space. head.sort is minimum.

@Laikoni Thanks! I will update when I get back to my computer!

A list comprehension is often shorter than filter& map: g x=head$sort[length y|y<-h x,and$r<$>y].

@nimi Thank you, there are so many useful golfing tips for Haskell. I learn a new trick everytime.

source: Stack Exchange

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

sort: votes


text:
Get the decimal!
Task:
Your task is, when given three inputs:

a numerator n
a denominator d
another integer, x

Create a program/function that finds the xth digit of the number after the decimal place.
Specs:

The range of n and d is between 1 and 2^31 - 1, inclusive.
The range of x is between 1 and 10,000,000, inclusive.

You may choose to use 1-based indexing or 0-based indexing for x. Please state in your answer which one you're using.

n may be larger than d.
n, d and x are guaranteed to be positive integers (for 1-based index version of x, if you choose to use 0-based indexing for x then x can be 0).
You may take inputs in any reasonable way (I.e. any way that is not a standard loophole).

Rules:

You must return the exact xth digit, not when rounded - so the 15th digit of 1/6, for example, is not 7, but 6.
Your program must work for all x under 10 million, unless your language doesn't support decimals to 10 million places.

Example I/O:
The example input uses 0-based indexing, which means x will go from 0 to 9,999,999. As well as that, the "input" is written as a string with spaces separating the numbers.
1 2 3: 0
5 6 0: 8
5 6 1: 3
1 6 15: 6 (not 7, as it's not rounded)
1 11 2: 0
1 10000 9999999: 0
11 7 1: 7

This challenge is a subset of this one

The answers given there can be used here aswell, but instead of calculating pi, you calculate n/d. Edit: maybe subset is not the right word, but i've voted to close as a dupe for this reason

The specs say that x is at least 1, but you have an example where it's 0.

I also do not think it is a subset of the Pi one, as that one talks about 1 specific irrational number, as this one talks about every rational number

I voted to close because the challenge focuses primarily on getting the nth decimal, but Felipe is right about rationality so I'm retracting my close vote

Possible duplicate of how to find n'th number in the decimal expansion of a proper fraction?

@FelipeNardiBatista Hmmm... I might argue that this should be the opposite way around, as this challenge is more specified with the ranges and stuff (this has happened before, where an older challenge is marked as a dupe of a newer challenge). I'm not sure, though.

@FelipeNardiBatista Yeah, that one is less clear than this one, so it should be closed as a dupe of this one.

Let us continue this discussion in chat.

@Qwerp-Derp As far as I know with this limit in place it means some languages, like C#, can't even submit an answer. For languages like these would you allow submitting an answer with a disclaimer that it won't work for all x?

@TheLethalCoder Hmm... I might consider adding something in there for languages that absolutely can't support this. If your language (by default, without any third-party extensions) can support x up to 10 million, then your program has to support up to that limit. Can't edit right now, though, I need to sleep.

@Qwerp-Derp As far as I know you can't in C# but I am having a look around

Can we take input in another order (i.e. x, n, d)?

@TheLethalCoder See Ørjan's Python answer for a possible way to do it. I think you can use Math.Pow or something for **.

Can we take these numbers as unary? (but all the calculations are done with the decimal system)

@JonathanAllan Fixed!

@KritixiLithos Sure, why not.

@ØrjanJohansen Fixed.

It is possible to do the exercise, easily, even in a language that has no bignum...

@RosLuP True (and in addition to your answers, G.B.'s Ruby method doesn't require bignums), but bignums avoid the extra code for looping.

Python 2, 25 bytes
Port of my Haskell answer, since Python also supports bignums by default. As there, x is 1-indexed.
lambda n,d,x:n*10**x/d%10

Try it online! (borrowing Keerthana Prabhakaran's wrapper.)

Very nice, I spent a couple of minutes wondering "was it really so easy"? A port to Ruby would be only 21 bytes.

Mathematica 33 Bytes
RealDigits[#/#2,10,1,-#3][[1,1]]&

1-based indexing.
e.g. 10-millionth digit of Pi right of the decimal point:
%[Pi,1,10^7]
7

takes about 2 seconds on my old machine.
You can try it online at WolframAlpha
(click the equal sign)

Haskell, 26 bytes
Works for all test cases. Yay bignums!
(n#d)x takes Integers and returns an Integer. x is 1-indexed.
(n#d)x=n*10^x`div`d`mod`10

Try it online!

PHP>=7.1, 40 Bytes
<?=bcdiv(($a=$argv)[1],$a[2],$a[3])[-1];

bcdiv
Online Version

I'm getting this error when I run your code:
 Notice:  Uninitialized string offset: -1 in [...][...] on line 6

@Qwerp-Derp Sorry you need a PHP Version gte 7.1 and the site will it is  the first visit not change it to the higgest version

Jelly, 7 bytes
⁵*×:ƓDṪ

Try it online!
A function submission (but also works as a full program). Jelly functions can only take two arguments directly; thus I take the digit to return as the left argument, the numerator as the right argument, and the denominator from standard input (in lieu of using a third argument).
People used to Jelly may be aware that a full program can take more than two arguments, but doing so causes you to lose access to the tersest way to write the constant integer 10, which is fairly relevant here. As such, this sort of mixed input feels somewhat like an exploit rather than actual useful golfing; I personally disagree with it, but the rule about allowing this is presently at +40 / -12, so as long as it's in the rules, I may as well exploit it (and pretty much have to to be competitive).
A left argument of 1 refers to the digit immediately after the decimal point (the ".1s digit"), an argument of 2 to the .01s digit, and so on.
Explanation
⁵*×:ƓDṪ
⁵*        10 to the power of {the left argument}
  ×       multiplied by {the right argument}
   :      divided by
    Ɠ                standard input
      Ṫ   take the last
     D                  decimal digit

Jelly has arbitrary-precision arithmetic on integers, so by pre-multiplying by a power of 10, we're effectively moving the digit we want to the units position, where it's much easier to extract.

sed -r, 93 131 136 bytes
s/$/,/
:d
s/,.+/,/
:
s/(1+)(1*;\1;1*,)1{10}?/\21/
t
s/1*/&&&&&&&&&&/
ta
:a
s/1,/,/
td
s/.+,//

Try it online!
(See output in decimal)
Takes input in unary and outputs in unary, and the program is 1-indexed. Thankfully, this challenge has already prepared me for this one.
The concept is similar, both implement long division. Here, I perform long division x times, where x is the digit after the decimal place that I have to find. After each iteration, I discard the previous decimal places because they are no longer needed.
While doing division, the program is in the format dividend;divisor;x,result.
s/$/,/ adds this comma, the comma is required to separate the result from everything else
Then follows the main program loop
:d label d

s/,.+/,/ remove everything after the comma
: empty label

s/(1+)(1*;\1;1*,)1{10}?/\21/ perform division, adding 1 to the result each iteration, whilst simultaneously removing blocks of 10 continuous 1s in the result

t branch to the empty label, in other words, loop until the dividend has been exhausted
s/1*/&&&&&&&&&&/ multiply the dividend by 10 to prepare for the next iteration
ta branch to label a
:a label a, this line and the line above are required to make td work
s/1,/,/ subtract 1 from x

td conditional branch to d, this is triggered if there has been a successful substitution since the last conditional branch, since s/1*/&&&&&&&&&&/ is always successful, td will always get triggered, but by introducing branch a, we fix that so that it only depends on the previous substitution
s/.+,// finally, remove everything but the result

Ruby, 34 33 bytes
->n,d,x{(0..x).map{n=n%d*10};n/d}

Try it online!

REXX, 76 bytes
(Not very short but thought it would make a change to do one in REXX)
Rexx is 1-based by defintion.
arg n d x
numeric digits x+10
y=n/d
parse var y "." +(x) z
say left(z,1,"0")

Explanation:

Read input to the numbers
Guarantee enough significant digits (default is 9)
Calculate
Split. Find the decimal point, count forward "x" characters, take the following characters and put into "z"
Print out first digit. Pad with 0 to be sure.

Merging 3 and 4 actually makes it longer because of the change in syntax:
parse value n/d with "." +x z +1

For non-REXXers: Strings and numbers are totally interchangeable in REXX. They are determined by how you act on them. So you can parse a number using sting functions with no conversion.
For example
"27" + "28"

returns 55 and not 2728!

Could you add a link to an interpreter? I'd imagine many users are unfamiliar with this language.

https://www.tutorialspoint.com/execute_rexx_online.php Only problem is that I couldn't work out how to input values in the interpreter. So, for test purposes, I used assignments to set the values at the start.

It looks like that interpreter works if you give CLI input like rexx main.rexx 1 2 3. You should mention in your answer that the input is 1-indexed.

Didn't notice the input possibility cos I just clicked the execute button at the top. Duh.

Batch, 70 bytes
@set n=%1
@for /l %%x in (0,1,%3)do @set/an=n%%%2*10
@cmd/cset/an/%2

@FelipeNardiBatista Worked for me when I tried it.

Assembly Intel x86 cpu language, 50 bytes
00000940  53                push ebx
00000941  8B5C240C          mov ebx,[esp+0xc]
00000945  8B4C2410          mov ecx,[esp+0x10]
00000949  31C0              xor eax,eax
0000094B  48                dec eax
0000094C  81C102000000      add ecx,0x2
00000952  721A              jc 0x96e
00000954  81FB00000000      cmp ebx,0x0
0000095A  7412              jz 0x96e
0000095C  8B442408          mov eax,[esp+0x8]
00000960  31D2              xor edx,edx
00000962  F7F3              div ebx
00000964  49                dec ecx
00000965  7407              jz 0x96e
00000967  8D0492            lea eax,[edx+edx*4]
0000096A  01C0              add eax,eax
0000096C  EBF2              jmp short 0x960
0000096E  5B                pop ebx
0000096F  C20C00            ret 0xc

traslation in nasm
; u32 __stdcall rdiv(u32 a, u32  b, u32 c)
; 8a, 12b, 16c
      align   4
rdiv:                   ; c<0xFFFFFFFE and b!=0
      push    ebx       ; something as for(;a=10*(a%b),c--;);return a/b
      mov     ebx,  dword[esp+  12]
      mov     ecx,  dword[esp+  16]
      xor     eax,  eax
      dec     eax
      add     ecx,  2
      jc      .z
      cmp     ebx,  0
      je      .z
      mov     eax,  dword[esp+  8]
.1:   xor     edx,  edx
      div     ebx
      dec     ecx
      jz      .z
      lea     eax,  [edx+edx*4]
      add     eax,  eax
      jmp     short  .1     ; a=5*a;a+=a=>a=10*a
.z:
      pop     ebx
      ret     12

For parameter 'c' the range begin from 0; it would be 0..0xfffffffd. If parameters b=0 or c out of range 0..0xfffffffd it would return -1

Lua, 42 bytes
function a(n,x,d)
print((n*10^x/d)%10)
end

Hello, and welcome to PPCG! This is a great first answer!

Java 7, 146 139 137 133 128 122 Bytes
-3 bytes thanks to  Erik the Outgolfer, I totally forgot imports didn't have to be on their own line
-4 bytes thanks to Qwerp-Derp for moving n%d to the constructor
-6 bytes thanks Kevin Cruijssen for removing the toString()
I hope this is how the byte count is done for java functions with imports
import java.math.*;char a(int n,int d,int x){return (new BigDecimal(n%d).divide(new BigDecimal(d),x+1,1)+"").charAt(x+2);}

Uses Java's BigDecimal class to get exact representation of the decimal expansion.  Note it's not the fastest running code ever but it does eventually produce the correct output for all test cases.  Ungolfed code:
import java.math.*;
char a(int n, int d, int x){
    BigDecimal num = new BigDecimal(n%d); // reduce improper fractions
    BigDecimal div = new BigDecimal(d);
    BigDecimal dec = num.divide(div, x+1, 1); // precision of x + 1, round down
    return (dec+"").charAt(x+2); //xth char after decimal
}

Try it online!

The spaces after the commas and the newline after the semicolon can be removed I think.

I count 137 bytes

Must have miscounted thanks

Can't you just replace BigDecimal(n) with BigDecimal(n%d), and get rid of the n=n%d?

You can remove the .toString() and use +"" instead (with two additional parenthesis).

I know it's been a while, but you can golf a byte by removing the space at return(. In addition, you could save another byte by removing the import and using char a(int n,int d,int x){java.math.BigDecimal t=null;return(t.valueOf(n%d).divide(t.valueOf(d),x+1,1)+"").charAt(x+2);}. (And of course, changing it to java 10 is even shorter: (n,d,x)->{var t=new java.math.BigDecimal(n%d);return(t.divide(t.valueOf(d),x+1,1)+"").charAt(x+2);}.)

You can change the return type to int for 1 byte saved.

C, 49 43 bytes
f(a,b,i){for(;a=10*(a%b),i--;);return a/b;}

'i' argument is 0-indexing. Test code and result
main()
{int i;
 for(i=0;i<20;++i)
     printf("%u", f(12,11,i));

 printf("\nf(1,2,3)=%d\n",f(1,2,3));
 printf("f(5,6,0)=%d\n",f(5,6,0));
 printf("f(5,6,1)=%d\n",f(5,6,1));
 printf("f(1,6,15)=%d\n",f(1,6,15));
 printf("f(1,11,2)=%d\n",f(1,11,2));
 printf("f(1,10000,9999999)=%d\n",f(1,10000,9999999));
 printf("f(11,7,1)=%d\n",f(11,7,1));
}

f(1,2,3)=0
f(5,6,0)=8
f(5,6,1)=3
f(1,6,15)=6
f(1,11,2)=0
f(1,10000,9999999)=0
f(11,7,1)=7

F# (.NET Core), 30 bytes
let f n d x=n*pown 10I x/d%10I

Try it online!
(use 1-based indexing)

I count 33 bytes. I would also suggest to add a Try it Online! link.

I had the wrong function in my clipboard. Thanks.

Groovy, 30 bytes
{n,d,x->(n*10**x/d as int)%10}

x uses 1 based indexing.
Explanation:
{n,d,x->    // closure with three arguments, n, d, x
 n*10**x    // multiply n with 10 to the power of x
 /d         // divide by d
 as int     // convert from BigDecimal to int
 )%10       // modulo 10 to get the answer
}

Clojure, 39 bytes
#(mod(int(/(*(Math/pow 10 %3)%)%2))10))

anonymous function with arguments n,d,x where x uses one based indexing.

Vyxal, 6 bytes
/$›ḞṪt

Try it Online!
I do like the Sympy wrappers vyxal now has. Takes denominator, numerator then index.
Explained
/$›ḞṪt
/      # divide the numerator by the denominator. This is fine because vyxal stores floats as Rationals internally.
 $     # place the index at the top of the stack
  ›Ḟ   # Sympy.evalf(fraction, n=index+1). This avoids rounding issues
    Ṫt # get the second last item

Nibbles, 4 bytes (8 nibbles)
/\`p/*^~

Input is x, n, d.  Uses 1-based indexing.
     *      # multiply
      ^~    #   10 to the power of
            #     (implicitly) arg1
            # by
            #   (implicitly) arg2
    /       # and divide this by (implicitly) arg3
  `p        # print the number as a string
 \          # reverse it
/           # and get the first element
            # (by folding across it, each time
            # returning the left-hand of each pair)

Pyt, 7 bytes
ᴇ*⇹/1ᴇ%

Try it online!
input is x,n,d
ᴇ         raises 10 to the x
 *        multiplies by n
  ⇹/      divides by d
    1ᴇ%   modulo 10; implicit print

Python 2, 32 bytes
Uses 0-indexing
lambda n,d,x:int(10**-~x*n/d)%10

Try it online!
Edit:
Rolled back to original solution as seen in Ørjan Johansen's answer that it works, but I won't golf it any further

If it isn't valid then it should be deleted.

as most of the answers so far

@EriktheOutgolfer fixed it...

Do you use 1-indexing?

Try it online!

Python 2, 50,44,40, 36 bytes
lambda n,d,x:(`n*1./d%1`+'0'*x)[x+2]

Try it online!

does not work for 1,7,10000000

Groovy, 55 bytes
{n,d,x->z='0'*x;Eval.me("$n.$z/$d.$z").toString()[x-1]}

Explained using 1,11,2:
{
    n,d,x->          // I've already lost to Jelly by the end of this line.
    z='0'*x;         // Set z equal to 2 0's.
    Eval.me          // Evaluate as groovy code...
    ("$n.$z/$d.$z")  // 1.00g/11.00g (Automatically set precision using # 0s).
   .toString()[x-1]  // Get 2nd digit of division.
}

Ruby, 39 bytes
->n,m,o{(n*1.0/m).to_s.split(?.)[1][o]}

JavaScript (ES6), 34 bytes
(n,d,x)=>`${n/d}`.split`.`[1][x]|0

x is 0-based

f=
(n,d,x)=>`${n/d}`.split`.`[1][x]|0

console.log(f(1,2,3))
console.log(f(5,6,0))
console.log(f(5,6,1))
console.log(f(1,6,15))
console.log(f(1,11,2))
console.log(f(1,10000,10000000))
console.log(f(11,7,1))
console.log(f(2000,7,0))

Unfortunately, like my solution, this will fail with long decimals; try f(1,7,10000000), for example.

Axiom, 71 61 76 bytes
f(a:NNI,b:PI,n:NNI):NNI==(repeat(a:=10*(a rem b);n=0=>break;n:=n-1);a quo b)

n is 0-indexing [0..M]. Test code and result
(19) ->    f(1,2,3)=0
   (19)  0= 0
(20) ->     f(5,6,0)=8
   (20)  8= 8
(21) ->     f(5,6,1)=3
   (21)  3= 3
(22) ->     f(1,6,15)=6
   (22)  6= 6
(23) ->     f(1,11,2)=0
   (23)  0= 0
(24) ->     f(1,10000,9999999)=0
   (24)  0= 0
(25) ->     f(11,7,1)=7
   (25)  7= 7

JavaScript (Node.js), 23 bytes
(a,b,i)=>a*10n**i/b%10n

Try it online!

JavaScript (Node.js), 43 bytes, port
(a,b,i)=>eval(`for(;a=10*(a%b),i--;)a/b|0`)

Try it online!
JavaScript (Node.js), 51 bytes
(n,d,x)=>[...Array(x)].map(_=>[n*=10,u=n/d,n%=d])|u

Try it online!
use Array rather than recursive to avoid stackoverflow

Husk, 9 bytes
→d÷⁰*²!İ⁰

Try it online!

Thunno, \$ 9 \log_{256}(96) \approx \$ 7.41 bytes
10@*s10%,

Attempt This Online! Takes x then n then d.
Port of Ørjan Johansen's Python answer
Explanation:
10@*s10%,  # Implicit input, x then n then d
10@        # 10**x
   *       # *n
    s      # Swap so d is on top
     10%   # d%10
        ,  # Integer divide
           # Implicit output

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

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


text:
Un-average temperatures!
There was a discussion going on in TNB once about the best temperature scale, and we agreed on something: Take the average of all four main temperature scales! That is, Celsius, Kelvin, Fahrenheit, and Rankine (Sorry Réaumur).
So, now the issue is, most people don't use this system. So, I need a program to convert back from this average!
Challenge
Given the average of the Celsius, Fahrenheit, Kelvin, and Rankine representations of a certain temperature, output the individual standard representations, in any prespecified and consistent order. It turns out that this is possible, based on my whiteboard calculations. Input will be a single floating-point value in whatever range your language can handle, and output will be four floating-point values in any reasonable format. You can restrict the input to force the output to be in the range of your language, but you must be able to support down to Absolute Zero (thus, you need to be able to handle negative numbers).
Test Cases
input -> (Celsius, Fahrenheit, Kelvin, Rankine)
100 -> (-70.86071428571424, -95.54928571428565, 202.28928571428574, 364.12071428571437)
20 -> (-128.0035714285714, -198.4064285714286, 145.14642857142857, 261.2635714285714)
-10 -> (-149.43214285714282, -236.97785714285715, 123.71785714285716, 222.69214285714287)
10000 -> (7000.567857142858, 12633.022142857144, 7273.717857142858, 13092.692142857144)

These values were generated with Uriel's Python program, and I verified that they were correct.

related

I think the first three test cases are messed up somehow, the Fahrenheit and Kelvin numbers have the same decimal part, and vice versa.

Also for the last test case I get 13092.... Rankines instead of 13091...

I'm getting 364.1207142857143 for the Rankine of the first one

And how accurate must the output be?

Required precision? That directly translates into the number of decimals in the conversion factors, so it's important to know howm many decimals those factors need to have

@LeakyNun The output should be as accurate as possible; that is, to the best extent of your program's floating-point precision. However, I will require it to be within 1/100 of a unit (whatever the unit applicable is) of precision.

-11.99 Kelvin?!

@JonathanAllan :D That's why programs aren't required to hande it :P

So why is there a test case for -200 as an input then?

@JonathanAllan If your program happens to be able to calculate it correctly, you can test if you'd like, but it says that it's not necessary.

There's nothing inherently wrong with negative Kelvin temperatures in the hypothetical. They just are infinitely hotter than regular temperatures. (Note: I'm not a physicist, I just watch Youtube videos all day and pretend to be one on the internet).

Pyth, 40 37 36 bytes

-BJ+c36641 280c*5Q7 273.15-B*J1.8 459.67
-BJc+916.025*5Q7 273.15-B*J1.8 459.67
-BJc+916.025*5Q7 273.15-B*1.8J459.67

Try it online!
Specs

Input: 100
Output: [Kelvin, Celcius]\n[Rankine, Fahrenheit]

Math
kelvin = (average*5+916.025)/7

Python, 63 bytes
def f(a):x=(a+183.205)*5/7;m=x*9/5;return x-273.15,m-459.67,x,m

a is the average, returns a tuple of the results as (celsius, fahrenheit, kelvin, rankine)
Math involved:
kelvin = x
celsius = x - 273.15
fahrenheit = x * 9/5 - 459.67
rankine = x * 9/5

a = (x + x - 273.15 + x * 9/5 - 459.67 + x * 9/5) / 4 = x * 7/5 - 183.205
x = (a + 183.205) * 5/7

JavaScript (ES6), 49 bytes

f=
a=>[a=(a-199.205)/1.4,a+=273.15,a*=1.8,a-=459.67]
<input oninput=f(this.value).map(function(x,i){o.rows[i].cells[1].textContent=x})>

Celsius:

Kelvin:

Rankine:

Fahrenheit:

You spelt Celsius wrong in your snippet :)

@numbermaniac Bah, and after all the trouble I went to to double-check the spelling of Fahrenheit too...

Dyalog APL, 46 40 bytes
6 bytes saved thanks to @Adám
273.15 459.67 0 0-⍨4⍴63 35÷⍨45×183.205+⊢

Try it online!
Anonymous monad, uses the Dyalog Classic character set.

No, it uses the Dyalog Classic character set, since this will only work on Dyalog APL.

Save six bytes: 273.15 459.67 0 0-⍨4⍴63 35÷⍨45×183.205+⊢

@Adám thanks! if I may only ask, why would this not work on other APLs?

Because only Dyalog has both {dfns}, ⍨, and single-byte encoding. GNU APL has dfns, but uses UTF-8 and has no ⍨, while APL2 (which was the codepage you linked to) has neither dfns nor ⍨.

Now that you are using a tacit train, it is definitely Dyalog APL, as this is unique to Dyalog APL (and J).

PHP, 62 Bytes
Order Kelvin , Celsius , Rankine , Fahrenheit
print_r([$t=($argn+183.205)/1.4,$t-273.15,$t*=1.8,$t-459.67]);

Online Version
PHP, 64 Bytes
Order Kelvin , Rankine , Fahrenheit , Celsius
print_r([$k=($argn+183.205)/1.4,$r=1.8*$k,$r-459.67,$k-273.15]);

Online Version

dc, 37 38 bytes
[Edit 1: Added third form, per Neil's comment]
These [first two] are both the same length :(  The first one produces Fahrenheit, Celsius, Kelvin, Rankine (top to bottom on the stack), and the second one produces Fahrenheit, Rankine, Celsius, Kelvin.
9k?183.205+1.4/d1.8*rd273.15-d1.8*32+f
9k?183.205+1.4/d273.15-rd1.8*d459.67-f
9k?199.205-1.4/d273.15+d1.8*d459.67-f

Example outputs (dc uses _ to signal negative numbers on input):
[from first two forms; see edit below for third form.]
20
-198.406428572
-128.003571429
145.146428571
261.263571427

20
-198.406428573
261.263571427
145.146428571
-128.003571429

_10
-236.977857144
-149.432142858
123.717857142
222.692142855

_10
-236.977857145
222.692142855
123.717857142
-149.432142858

How it works
9k?183.205+1.4/d1.8*rd273.15-d1.8*32+f

9k sets 9-place arithmetic.
? reads input from stdin, leaving it at top of stack (TOS).
183.205+ adds 183.205 to TOS
1.4/ divides TOS by 1.4 or 7/5, giving degrees Kelvin.
d duplicates TOS.  (Ie, duplicates degrees Kelvin)
1.8*r computes Rankine from Kelvin, then reverses top two of stack.
d273.15- duplicates TOS and subtracts 273.15 to get degrees Celsius.
d1.8*32+ duplicates TOS, multiplies by 9/5, and adds 32, for Fahrenheit.
f prints contents of stack.

Edit 1, continued:
9k?199.205-1.4/d273.15+d1.8*d459.67-f

This form, suggested by Neil, begins by computing Celsius instead of Kelvin.  This saves a rotate (an r) when computing Rankin from Kelvin.
It computes Celsius = (Average - 199.205)*5/7 via 199.205-1.4/, adds 273.15 to get Kelvin, multiplies by 1.8 to get Rankin, and subtracts 459.67 to get Fahrenheit.  For example:
20
-198.406428571
261.263571429
145.146428572
-128.003571428

9k?199.205-1.4/d273.15+d1.8*d459.67-f saves 1 byte by changing the output order.

@Neil, thanks!  Edited into answer.

CJam, 38 bytes
rd5*916.025+7/_p_273.15-p1.8*_p459.67-

Kelvins = (5*input+916.025)/7
Outputs as
Kelvin
Celsius
Rankine
Fahrenheit

Try it online!

Whispers v2, 168 bytes
> Input
> 5
> 7
> 183.205
>> 2÷3
>> 1+4
>> 6⋅5
>> 7-11
>> 7⋅12
>> 9-13
> 273.15
> 1.8
> 459.67
>> Output 7
>> Output 8
>> Output 9
>> Output 10
>> Then 14 15 16 17

Try it online!
Outputs as Kelvin\nCelsius\nRankine\nFahrenheit

Python 3, 67 bytes
c=(5*float(input())-996.025)/7;t=[c,c*1.8+32,c+273.15,c*1.8+491.67]

This code does some algebra to get the temperature in Celcius, then I convert it to the other temperature units. The temperatures are stored in the list t.


text:
Fake Statistics
If you're going to invent some fake news, you'll want to fabricate some data to back it up.  You must already have some preconceived conclusions and you want some statistics to strengthen the argument of your faulty logic.  This challenge should help you!
Given three input numbers:

N - number of data points
μ - mean of data points
σ - standard deviation of data points, where μ and σ are given by:

Output an unordered list of numbers, i, which would generate the given N, μ, and σ.
I'm not going to be too picky about I/O formats, but I do expect some sort of decimals for μ, σ, and the output data points.  As a minimum, at least 3 significant figures and magnitude of at least 1,000,000 should be supported.  IEEE floats are just fine.

N will always be an integer, where 1 ≤ N ≤ 1,000
μ can be any real number
σ will always be ≥ 0
data points can be any real number
if N is 1, then σ will always be 0.

Note that most inputs will have many possible outputs.  You only need to give one valid output.  The output may be deterministic or non-deterministic.
Examples
Input (N, μ, σ) -> Possible Output [list]

2, 0.5, 1.5 -> [1, 2]
5, 3, 1.414 -> [1, 2, 3, 4, 5]
3, 5, 2.160 -> [2, 6, 7]
3, 5, 2.160 -> [8, 4, 3]
1, 0, 0 -> [0]

Should've added a truthy/falsy input for p-value so we would have to make either correlated or non-correlated data to either fake-backup or fake-disprove ahaha.

What does +ve and -ve mean?

@ChelseaG. Abbreviations for positive and negative.  I've edited to clarify.

When N=1, will σ always be 0 to make it possible?

@xnor Yes, thats right

Can the output be deterministic? That is, same input always produces the same output

@LuisMendo Yes, that's fine.

Really we pedants should be using the corrected sample standard deviation and not implementing for inputs with N=1.

@JonathanAllan we never said we were good at fake statistics

Pyth, 44 35 34 bytes

?eA.DhQ2+eQ*G,-eQJ*E@hc1thQ2+eQJ*G,-eQKE+eQK
.N?eA.DN2+T*G+LT_B*Y@hc1tN2*G+LT_BY
.N?eA.DN2+T*G+LT_B*Y@cNtN2*G+LT_BY

Try it online!
(The code above defines a function. :.* is appended on the link to invoke the function.)
The maths
This constructs the data symmetrically. If N is even, then the data are just the mean plus or minus the standard deviation. However, if N is odd, then we just opened a can of worms, since the mean has to be present for the data to be symmetric, and so the fluctuations have to be multiplied by a certain factor.
If n is even

Half of the data are μ+σ.
Half of the data are μ-σ.

If n is odd

One datum is μ.
Less than half of the data are μ+σ*sqrt(n/(n-1)).
Less than half of the data are μ-σ*sqrt(n/(n-1)).

MATL, 22 bytes
Thanks to @DigitalTrauma for a correction.
:t&1Zs/tYm-*+tZN?3G9L(

Input order is: N, σ, μ.
Try it online!
Or see a modified version that also computes the mean and standard deviation of the produced data, as a check.
Explanation
The code is divided into four parts:

: generates the array [1 2 ... N] where N is taken as implicit input.
t&1Zs/ divides those numbers by their empirical standard deviation (computed normalizing by N), and tYm- subtracts the empirical mean of the resulting values. This ensures that the results have empirical mean 0 and empirical standard deviation 1.
* multiplies by σ and + adds μ, both taken as implicit inputs.
tZN?x3G handles the special case that N = 1, σ = 0, for which the output should be μ. If this is indeed the case, then the empirical standard deviation computed in the second step was 0, the division gave inf, and multiplying by σ in the third step gave NaN. So what the code does is: if the obtained array consists of all NaN values (code tZN?), delete it (x) and push the third input (3G), which is μ.

R, 83 62 53 bytes
function(n,m,s)`if`(n>1,scale(1:n)*s*sqrt(1-1/n)+m,m)

If n=1, then it returns m (since scale would return NA), otherwise it scales the data [1,...,n] to have mean 0 and (sample) standard deviation 1, so it multiplies by s*sqrt(1-1/n) to get the correct population standard deviation, and adds m to shift to the appropriate mean. Thanks to Dason for introducing me to the scale function and dropping those bytes!
Try it online!

Can you add some tests in Try It Online so your answer may easily be verified?

yep! give me two minutes.

Could probably just use 1:n instead of rt(n,n) to save 4 bytes. And the scale function could probably be useful.

@Dason -- thanks! I learned about scale which is great.

Python, 50 bytes
lambda n,m,s:[m+s*(n-1)**.5]+[m-s/(n-1%n)**.5]*~-n

Try it online!
Uses the following n-element distribution with mean 0 and sdev 1:

With probability 1/n (i.e. 1 element), output (n-1)**0.5
With probability 1-1/n (i.e. n-1 elements), output -(n-1)**(-0.5)

This is rescaled to mean m and sdev s by transforming x->m+s*x. Annoyingly, n=1 gives a division by zero error for a useless value, so we hack it away by doing /(n-1%n)**.5, with 1%n giving 0 for n==1 and 1 otherwise.
You might think (n-1)**.5 can be shortened to ~-n**.5, but the exponentiation happens first.
A def is one byte longer.
def f(n,m,s):a=(n-1%n)**.5;print[m+s*a]+[m-s/a]*~-n

R, 50 46 bytes
function(n,m,s,l=n-1)m+s*c(rep(l^-.5,l),-l^.5)

Try it online!
(Reading the other answers now after posting, I realise that this is the same approach as xnor's Python answer)

Jelly, 20 bytes
÷_Ḃ$©$*.;N$ṁ®;0ṁ⁸×⁵+

Try it online!
Full program taking three command line arguments: n, μ, σ.
How?
Creates floor(n / 2) values equidistant from the mean and a value at the mean if n is odd such that the standard deviation is correct...
÷_Ḃ$©$*.;N$ṁ®;0ṁ⁸×⁵+ - Main link: n, μ (σ expected as third input, the 5th command argument)
   $                 - last two links as a monad:
 _                   -   n minus:
  Ḃ                  -     n mod 2            i.e. n-1 if n is odd, n if n is even
    ©                - copy value to register
÷                    - n divided by that
       .             - literal 0.5
      *              - exponentiate = (n / (n - (n mod 2))) ^ 0.5
                     -        i.e. 1 if n is even; or (n/(n-1))^0.5 if n is odd
         $           - last two links as a monad:
        N            -   negate
       ;             -   concatenate   i.e. [1,-1] or [(n/(n-1))^0.5,-(n/(n-1))^0.5]
            ®        - recall value from register
           ṁ         - mould the list like something of that length
             ;0      - concatenate a zero
                ⁸    - link's left argument, n
               ṁ     - mould the list like something of length n (removes the zero for even n)
                  ⁵  - fifth command argument, third program argument (σ)
                 ×   - multiply (vectorises)
                   + - add μ (vectorises)

JavaScript (Node.js), 56 bytes
(N,m,s)=>[...Array(N)].map(_=>N--?m-s/a:m+s*a,a=--N**.5)

Try it online!
Port of Python solution
JavaScript (Node.js)], 70 bytes
(N,u,s)=>g=(...L)=>1/L[N-1]?L:g(1/L[1]?u:u+u-L[0]||u+s*(N/2)**.5,...L)

Try it online!
Without a calculator in question I need to find one somewhere else