text:
Find the number of x-digit numbers whose product of digits is N
Given two numbers \$N\$ and \$x\$, find the number of \$x\$-digit numbers whose product of digits is \$N\$
\$N <10^6\$ and \$x <12\$
Sample Input (N x):
8 3
Sample Output:
10

shortest codelength or shortest runtime? Seems for this one, shortest runtime with codelength?<1000 (say) would be a more meaningful target.

I don't understand: 2 digits x and N, x=8, N=3 means 8 digits where the product is 3. Since 3 is prime, it can only be 3111...1, 1311...1, 113... - 8 possibilities. What am I missing?

@userunknown It's the other way round: three digits where the product is eight. (222, 811, 181, 118, and six ways to arrange 1,2,4, I believe.)

@breadbox: I meanwhile recognized that, but the description should be fixed. If I'm giving two numbers N and x, it shouldn't be claimed that I'm given two numbers x and N (which is the ordering in the headline too).

Golfscript 42 31
~10\?.10/\,>{10base{*}*1$=},,\;

Input: Expects the numbers N and x as command line arguments (separated by space).
The program can be tested here.

I tested and got a Code took longer than 5 seconds to run, so it was aborted. with the parameters reversed. :)

@userunknown You are right. The code is very inefficient when x goes above 4. For example, if I run it on my machine with the parameters 3 5 I get the result after 30+ seconds. So for 3 8 I guess it could be hours...

I never looked into this Golfscript-thingy. Is it almost always that slow?

@userunknown Golfscript's purpose is not speed and it's known to be a little slow. However, in this case it's the algorithm that's very inefficient. But the code is short :)

@userunknown I will test this algorithm in C# as well to see how it compares.

@userunknown the C# version runs for parameters 3, 8 in about 30s on my machine. See my C# answer below. Or above. :) So yes, GolfScript is kinda slow.

@userunknown, GolfScript is interpreted in Ruby. Also, all values are immutable, so there's a lot of copying involved. It doesn't tend to be fast, and can often add a power or two of n to the asymptotic runtime of algorithms which are usually analysed in the RAM model.

@PeterTaylor: Scala is of course not interpreted, but run as compiled Bytecode. But the values are almost always immutable too - this needn't be too slow. My solution uses 0 mutable vars, just immutable vals but generates f(524288, 7) or f(256, 12) in less than the 5s the online machine for Golfscript does. I was curious whether this is an endless loop.

Look at the documentation for >. I think you can shorten :z;,{z>}, to \,>

Also \1/{~}%could probably be10base`

In fact I think this can come down to 31 using ? for powers and eliminating some unnecessary complication in the second filter.

@PeterTaylor Thanks! I was way under par with that program. :)

Brachylog 2, 13 bytes
{h.&t~lℕẹ≜×}ᶜ

Try it online!
Explanation
{h.&t~lℕẹ≜×}ᶜ
{          }ᶜ   Count the number of
         ≜      values at this point
   &t           formed via taking the last element of the input,
       ℕ        generating an integer
     ~l         of that length,
        ẹ       and splitting it into digits
          ×     such that the product of those digits
 h.             is the first element of {the input}

One neat golfing trick used here is that unlike almost all metapredicates, ᶜ doesn't care at all about the actual value of . (which is normally used to construct an output for the metapredicates); as such, . can be used like any other variable (saving a byte because it appears implicitly before }). There are no implicit labelisations anywhere here, so I had to add an explicit labelisation using ≜ to give ᶜ something to count.

Scala 107:
def f(N:Int,x:Int,s:Int=1):Int=if(s==N&&x==0)1 else
if(s>N||x==0)0 else
((1 to 9).map(i=>f(N,x-1,s*i))).sum

ungolfed, debugfriendly version:
def findProduct (N: Int, sofar: Int, togo:Int, collected:String=""):Int={
  if (sofar == N && togo == 0) {
    println (collected)
    1
  } else
  if (sofar > N || togo == 0) 0 else
  (1 to 9).map (x=> findProduct (N, sofar*x, togo-1, collected + " " + x)).sum
}

Invocation with debugging output:
scala> findProduct (3, 1, 8)
 1 1 1 1 1 1 1 3
 1 1 1 1 1 1 3 1
 1 1 1 1 1 3 1 1
 1 1 1 1 3 1 1 1
 1 1 1 3 1 1 1 1
 1 1 3 1 1 1 1 1
 1 3 1 1 1 1 1 1
 3 1 1 1 1 1 1 1
res175: Int = 8

scala> findProduct (8, 1, 3)
 1 1 8
 1 2 4
 1 4 2
 1 8 1
 2 1 4
 2 2 2
 2 4 1
 4 1 2
 4 2 1
 8 1 1
res176: Int = 10

I've tested it on simplyscala.com and it's really fast. +1 for performance.

Jelly, 7 bytes
⁵Ḷṗ⁸P€ċ

Try it online!
Fun fact, this (as far as I can tell) would've worked, atom-for-atom, when ais523's answer was posted.
How it works
⁵Ḷṗ⁸P€ċ - Main link. Takes N on the left and x on the right
⁵       - 10
 Ḷ      - Ḷowered range; [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
   ⁸    - N
  ṗ     - Cartesian power; Yield all N-length sublists of [0, 1, ..., 9]
     €  - Over each:
    P   -   Take the product
      ċ - Count occurrences of x

Python, 164 bytes
from itertools import *
N,x=map(int,raw_input().split())
print len([c for c in product([d for d in range(1,10)if N%d==0],repeat=x) if reduce(lambda x,y:x*y,c)==N])

C# 128
int Z(int n,int x){var i=(int)Math.Pow(10,x-1);return Enumerable.Range(i,i*9).Count(j=>(j+"").Aggregate(1,(a,c)=>a*(c-48))==n);}

This C# method returns the number of x-digit numbers whose product of digits is n. It requires that namespaces System and System.Linq are imported in the current context.
Online version: http://ideone.com/0krup

Haskell 117 chars
import Data.Char
main = print $ f 3 8
f n t = length[x|x<-[10^(n-1)..(10^n-1)],foldr(*)1(map digitToInt $ show x)==t]

K, 49
{+/x=*/'"I"$''${x@&~x in y}.!:'"i"$10 xexp y,y-1}

.
k){+/x=*/'"I"$''${x@&~x in y}.!:'"i"$10 xexp y,y-1}[8;3]
10

J, 40 bytes
[:+/[=[:*/"1(10#~])#:(10^<:@])}.[:i.10^]

Generates all x-digit numbers, convert each to base 10, then find the product of each number, and test whether each number is equal to the left hand side, and then find the sum of each boolean.

Jelly, 12 bytes
,’⁵*r/ḊDP€ċƓ

Try it online!
Takes \$x\$ as a command line argument and \$N\$ on standard input.
Explanation
,’⁵*r/ḊDP€ċƓ
,             On {the input} and
 ’            {the input} minus 1
  ⁵*          take 10 to the power of each of those numbers
    r/        then form a range between them
      Ḋ       without its first element;
       D      treat each element as a list of digits,
        P€    take the product of each of those digit lists,
          ċ   then count the number of times
           Ɠ  the value from standard input appears

The hard part is generating the list of numbers with x digits; the lowest such number is \$10^{x-1}\$, the highest is \$10^x-1\$ The range here is generated via first generating the pair \$(x,x-1)\$, then taking 10 to the power of both of those, and then generating the range between them. The range includes both endpoints by default; just in case N happens to be 0, we need to remove the top end of the range (which comes first because it's a "backwards" range) using Ḋ.

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


text:
Find the largest value of power.
Some numbers can be represented as perfect powers of other numbers. A number x can be represented as x = base^power for some integer base and power.
Given an integer x you have to find the largest value of power, such that base is also an integer.
Sample Input:
9
Sample Output:
2

Do we have to handle 0 as an input case? What about negative integers?

What output do you expect for input 1?

Golfscript - 26 chars
~:x,{:b;x,{b?x=b*}%+}*$-1>

Rough translation to Python
x=input()
acc = []
for b in range(x):
    for _ in range(x):
        acc.append((_**b==x)*b) # most of these are zeros
print max(acc)

So it loops way more times that necessary, but that often happens with golfed answers

Does this work for 11 as input? the python version looks like it doesn't.

APL (Dyalog Extended), 13 bytes
⌈/⍳×∘(⊢=⌊)⍳√⊢

Try it online!
⌈/⍳×∘(⊢=⌊)⍳√⊢     Monadic train taking an input n:
         ⍳√⊢     Get the 1st, ..., nth roots of n.
    (⊢=⌊)        Find whether each element equals its floor; i.e. is an integer.
                Returns a list of 0s and 1s.
  ⍳              List of 1, ..., n
   ×            Multiply that with the binary list.
                Now we have a list starting with 1 (since the 1st root of n is n, an integer)
                and larger nonzero values corresponding to the other roots that are integers.
⌈/              Find the maximum.

Uiua, 11 10 bytes
Edit: -1 byte thanks to ovs
⊢⇌⍖◿1ⁿ÷⇡,1

Try it!
A different approach to Bubbler's Uiua answer, for the same number of bytes.
       ÷⇡,1   # reciprocals of 0..input
      ⁿ       # input to the power of those (so: roots)
    ◿1        # modulo 1 (so whole numbers become zero)
   ⍖          # fall: indices if it was sorted descending
              # (index of largest root that is a whole number is now last)
⊢⇌            # get the last item

pretty sure this can be ⊢⇌⍖◿1ⁿ÷⇡,1 to match Bubbler's 10

@ovs - really nice, thanks a lot!

Haskell, 63 56 characters
Handles ℤ>0 (56 characters)
main=do n<-readLn;print$last[p|p<-[0..n],b<-[0..n],b^p==n]

Handles ℤ≥0 (58 characters)
main=do n<-readLn;print$last[p|p<-[0..n+1],b<-[0..n],b^p==n]

Handles ℤ (70 characters)
main=do n<-readLn;print$last[p|p<-[0..abs n+1],b<-[n..0]++[0..n],b^p==n]

Japt -h, 9 bytes
õ f@qX v1

Try it
õ f@qX v1     :Implicit input of integer U
õ             :Range [0,U]
  f@          :Filter as X
    qX        :  Xth root of U
       v1     :  Divisible by 1?
              :Implicit output of last element

05AB1E (legacy), 9 8 4 bytes
Ó0K¿

-1 byte thanks to @Don't be a x‑triple dot.
Only works in the Python legacy version of 05AB1E, because .ï should be DïQ in the Elxiir rewrite due to a bug; and it's also way slower due to zm.
-4 bytes porting @recursive's Stax answer.
Try it online or verify all integers in the range [2,100].
Previous 9 8 bytes solution:
Lʒzm.ï}à

Try it online or verify all integers in the range [2,100].
Explanation:
Ó      # Get the exponents of the (implicit) input's prime factorization
 0K    # Remove all 0s
   ¿   # Pop and push the Greatest Common Divisor (GCD) of this list
       # (which is output implicitly as result)

\$b^{^\frac{1}a}\$ is another way to write \$\sqrt[^a]{b}\$
L      # Create a list in the range [1, (implicit) input]
 ʒ     # Filter this list of integers by:
  z    #  Pop the value and push 1/value instead
   m   #  Then take it to the power of the (implicit) input
    .ï #  And check if it's an integer without decimal values after the period
 }à    # After the filter: pop the list and push the maximum
       # (which is output implicitly as result)

@Shaggy Now it should be fixed.. <.> I'm so glad challenges like this would be closed as unclear these days without some more rules and test cases.. Some suggested test cases would be 18 (1), 36 (2), 81 (4), and 1024 (10) imo.. Anyway, thanks for letting me know. Unfortunately there isn't an x-root builtin in 05AB1E, nor is the is_int builtin working for integers with with .0 decimals.. >.>

Agreed. There are so many old challenges I skip over because their spec is ambiguous or downright unclear, which is a shame, given how few new challenges are being posted these days. When I saw your original solution it took me far too long to figure out if you were wrong or I was (and I'm still not sure!). Maybe it's time for a clearout? Go through our old challenges, close the ones that don't meet our current standards and recreate them with better specs.

@Shaggy No, you were right. I misunderstood the challenge. And perhaps we should indeed repost old challenges with updates spec, and close the old ones as duplicates. Happened a few times before; I've seen MartinEnder do it a few times (here his most recent challenge as example). Maybe we should create a meta post to ask other people's opinions? It would also mean we have more 'new' challenges to do, since lately less and less challenges are posted.

Yeah, let's take it to meta, see what everyone else thinks. I know we've had a couple of meta posts about individual challenges but I think this needs a larger effort to help inject some new life here.

Although, as I say that, I have vague recollections of an existing meta post on this but, assuming I'm not just misremembering, I think that one might have been proposing just arbitrarily closing old challenges without a set criteria for why challenges should be closed, simply in an effort to "reboot" them.

@Shaggy Was about to post it, but you're indeed right that there is already a meta post about this. So I'll read it carefully and write an answer for it instead.

Stax, 4 bytes
|n|g

Run and debug it
|n gets the prime factor exponents of the input.  |g calculates the GCD of the result.

Uiua, 10 bytes
⊢⍖=⊞ⁿ.⇡+1.

Try it online!
-1 thanks to Dominic van Essen.
⊢⍖=⊞ⁿ.⇡+1.   input: positive integer n >= 2
        ⇡+1    range from 0 to n inclusive
    ⊞ⁿ.       cartesian product with itself by power
               (the k-th row contains x^k for x = 0..n)
   =       .   for each element, 1 if it equals n, 0 otherwise
               (higher power gives 1 at an earlier position,
                so the highest power is the lexicographically highest row)
⊢⍖            index of the maximum row lexicographically

Uiua, 11 bytes
⊢⍏⊗∶⊞ⁿ.⇡+1.

Try it online!
⊢⍏⊗∶⊞ⁿ.⇡+1.    input: positive integer n >= 2
         ⇡+1    range from 0 to n inclusive
     ⊞ⁿ.       cartesian product with itself by power
                (the k-th row contains x^k for x = 0..n)
   ⊗∶       .   the index of n in each row of the matrix, n+1 if not present
                (higher power gives lower index)
⊢⍏             index of the minimum element

10 bytes, annoyingly outgolfing my own answer...

Buggy Golfscript - 59
~0\1{1{1$1$?3$={p;\)\.(.}{}if).3$=!}do;).2$=!}do;;{}{1p}if

This is my first attempt with golfscript, so it probably can be improved in length.
Now the buggy part comes from the fact that this runs perfectly on the interpreter written in perl, but in the original ruby version, I'm having a really weird bug. I spent a couple of hours trying to wrap my head around it but I can't figure it out. I decided to post anyway to maybe get some feedback.

If might help you debug if you change the inner loop to this {1$.p 1$.p?3$.p={p;\)\.(.}{}if).3$=!} you can see that this is going haywire on the second iteration of the outer loop

The ruby interpreter is broken, see this: http://stackoverflow.com/questions/3927328

A few tips -- {...}{}if can be replaced by !!{...}* or {...}* (if the value is 0/1). {}{...}if becomes !{...}*. Since the stack is outputted at the end of the program, it is usually shorter to avoid explicit outputs. {}/, {}% and {}* constructs are shorter than do loops and manually maintaining a counter.

@Nabb well that sucks :( Thanks for the tips and the heads up! @gnibbler what I found is that the last value on the stack as the outer loop finishes its first iteration, is incremented by one when the second iteration starts which is really weird.

Argh, that sucks. I think we are probably stuck with the same interpreter forever

Python, 72 chars
x=range(1,input()+1)
print max(p*sum(b**p==len(x)for b in x)for p in x)

Vyxal, 23 bitsv2, 2.875 bytes
∆ǐġ

Try it Online!
Bitstring:
00010101110010111001101

Ports Recursive's answer in Stax

 Mathematica : 61 chars
.
First try:
Max[k/.Table[Solve[Log@#/Log@b==k,k,Integers],{b,2,#}]][[1]]&

CSharp - 130 chars
void Main(){var i = Int32.Parse(Console.ReadLine());Console.WriteLine(Enumerable.Range(2,i-2).Last(k => Math.Pow(i,1.0/k)%1==0));}

APL(NARS), 34 chars, 68 bytes
{⍵≤1:∞⋄⌈/i/⍨{0=1∣⍵√w}¨i←⍳n←⌊2⍟w←⍵}

The idea is that the max possible exponent is n←⌊2⍟argument, so i build
one range on that: 1..n and to get the max possible exponent; test:
  f←{⍵≤1:∞⋄⌈/i/⍨{0=1∣⍵√w}¨i←⍳n←⌊2⍟w←⍵}
  f 25
2
  f 30
1
  f 8
3
  f  323*(2×3)
6

They want max exponent, right?

Scala, 70 bytes
Golfed version. Try it online!
x=>(for{b<-0 to x-1;a<-0 to x-1;if Math.pow(a,b).toInt==x}yield b).max

Ungolfed version. Try it online!
object Main {
  def main(args: Array[String]): Unit = {
    def f(x: Int): Int = {
      val acc = for {
        b <- 0 until x
        a <- 0 until x
        if scala.math.pow(a, b).toInt == x
      } yield b
      acc.max
    }

    println(f(9))
  }
}

source: Stack Exchange

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

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/

sort: votes


text:
Stable positive/negative separation
From SO.
You are given an array with positive and negative integers. Write a function to change the elements order in the array such that negative integers are at the beginning, the positive integers are at the end and two integers that have the same sign don't change order.
Example:

Input 1,7,-5,9,-12,15
Output -5,-12,1,7,9,15
Input 1,-2,-1,2
Output -2, -1, 1, 2

Constraints: O(n) time limit and O(1) extra memory.

@Alexandru Deleted my answer. I've misread the specifications :)

O(1) extra memory makes it impossible to solve in languages without mutable data structures (and unwieldy to solve in languages which default to immutable data structures) :-(

@sepp2k. I know, but without O(1) extra memory it is too easy.

Is it at all possible in O(1) memory?  The SO people haven't found one yet.

This question doesn't mention anything about being a code golf, yet the answers are all golfing. Can you clarify this? If it was intended to be code golf, this shows people are not specifying properly and that is a problem. If it was not, then answerers are not looking at the lack of the shortest code constraint and that is also a problem.

If instead of an array we could any kind of list, I can think of a solution. Using strictly an array, I can't come up with a linear solution.

@marcog: It is not a code golf, just a puzzle.

I think that if a solution was known it would be well-known, given the implications for quicksort.

Is this even possible? :\

It's not possible in O(1) memory unless you use a transdichotomic machine model. An index into an array of length n takes up log n space.

@FUZxxl So are the linked SO question/answers wrong?

@mbomb007 Yes. Storing an index into an array of size O(n) takes O(log n) space. none of the linked answers account for that.

@FUZxxl In that case, shouldn't the question be deleted?

I'm voting to close this question as off-topic because the challenge is not solvable.

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


text:
Calculate 500 digits of pi
Write a program to calculate the first 500 digits of pi, meeting the rules below:

It must be less than 500 characters in length.
It cannot include "pi", "math.pi" or similar pi constants, nor may it call a library function to calculate pi.
It may not use the digits "3", "1" and "4" consecutively.
It must execute in a reasonable time (under 1 minute) on a modern computer.

The shortest program wins.

To check if your digits are correct: http://www.eveandersson.com/pi/digits/

Are we allowed to print more than 500 digits with loss of accuracy after first 500?

@Alexandru, I suppose so but I would prefer to see it truncated.

@Joey no library functions TO CALCULATE PI - I would assume you can use anything from the libraries except the PI constant / function.

I think this question would have been much better off restricting the programming languages accepted.

Came here hoping to get something nice and concise for generating arbitrary length approximations of pi in python... unfortunately @Soulman's python solution is apparently tuned for 500 digits; replacing 500 with 1000 gives an incorrect answer.  I wonder if there is a good way of phrasing an alternative challenge that would produce a nice short function that is generally useful for generating an arbitrary number of digits?

Related mathematics post: https://math.stackexchange.com/q/1189820/272831

It may not use the digits "3", "1" and "4" consecutively I assume that you can do "3"+".14" or reverse(<500 digits of pi in reverse>).

Golfscript - 29 chars
6666,-2%{2+.2/@*\/9)499?2*+}*

I will post analysis later

Could you explain how this works?

Shouldn't last digit be 2 instead of 1?

@Alexandu Starting at position 499, the following digits are 91298, so I guess the difference is about starting with the leading "3.14" or with ".14"

A 29 bytes version can be found at the GolfScript homepage.

@gnibbler. Nice. I tried continued fraction formula, but it converged too slow. I might have done something wrong, though.

@hallvabo that's not a continued fraction, that's the same pi = 2 + 1/3*(2 + 2/5*(2 + 3/7*(2 + 4/9*(2 + ...)))) that everyone uses. Also, only 500*log2(10) = 1661 (*2 = 3322) iterations should be necessary for 500 digits. I imagine the 6666 is a left over from the 1000 digits problem.

@primo: I must have hallucinated... I have used this formula in my own Python codegolf solutions several times.

"I will post analysis later". (waits for 3 years)....

"I will post analysis later" *waits for more than 6 years*

@EriktheOutgolfer I was going to post that. :P

@Justin Tears...

"I will post analysis later" (waits for 8 years)

"I will post analysis later" (waits for 9 years)

Still waiting...

a momentous occasion (10 years)

"I will post analysis later" (waits for 11 years)

"I will post analysis later" (waits for 12 years)

Mathematica (34 chars): (without "cheating" with trig)
N[2Integrate[[1-x^2]^.5,-1,1],500]
So, to explain the magic here:
Integrate[function, lower, upper] gives you the area under the curve "function" from "lower" to "upper".  In this case, that function is [1-x^2]^.5, which is a formula that describes the top half of a circle with radius 1.  Because the circle has a radius of 1, it does not exist for values of x lower than -1 or higher than 1.  Therefore, we are finding the area of half of a circle.  When we multiply by 2, then we get the area inside of a circle of radius 1, which is equal to pi.

Perhaps you should insert, in your answer, an explanation of why this works (for them non-math folks).

wonderful idea.  I will see to it presently.  I'll give a basic explanation of the math involved.

Maybe you could shorten it: change sqrt[1-x^2] to (1-x^2)^.5)

and I can remove the * after the 2.  Mathematica is wonderful.

Python (83 chars)
P=0
B=10**500
i=1666
while i:d=2*i+1;P=(P*i%B+(P*i/B+3*i)%d*B)/d;i-=1
print'3.%d'%P

Python3 136
Uses Madhava's  formula.
from decimal import *
D=Decimal
getcontext().prec=600
p=D(3).sqrt()*sum(D(2-k%2*4)/3**k/(2*k+1)for k in range(1100))
print(str(p)[:502])

Python3 164
Uses this formula.
from decimal import *
D=Decimal
getcontext().prec=600
p=sum(D(1)/16**k*(D(4)/(8*k+1)-D(2)/(8*k+4)-D(1)/(8*k+5)-D(1)/(8*k+6))for k in range(411))
print(str(p)[:502])

Husk, 28 25 24 bytes
i*!500İ⁰ΣG*2mṠ/o!İ1→ḣ□70

Try it online!
Calculates the value of pi as a rational number using the first 5000 terms of the infinite series 2 + 1/3*(2 + 2/5*(2 + 3/7*(2 + 4/9*(2 + ...)))), and then extracts the first 500 digits.
The code to calculate the value of pi from a specified number of terms is only 13 bytes (ΣG*2mṠ/o!İ1→ḣ):
ΣG*2mṠ/o!İ1→ḣ
Σ                       # the sum of
 G*2                    # the cumulative product, starting at 2, of
    m                   # mapping the following function to all terms of
            ḣ           # series from 1 to ... (whatever number is specified)
     Ṡ/                 # divide by x
       o!  →            # element at index -1
         İ1             # of series of odd numbers

Unfortunately, we then need to waste 3 bytes specifying the number of terms to use:
□70                     # 70^2 = 4900

And then 8 more bytes converting the rational number (expressed as a fraction) into its digits in decimal form:
i*!500İ⁰
i                       # integer value of
 *                      # multiplying by
  !500                  # 500th element of
      İ⁰                # series of powers of 10

Java 10, 208 207 206 193 176 155 bytes
n->{var t=java.math.BigInteger.TEN.pow(499).shiftLeft(1);var p=t;for(int i=1656;i>0;)p=t.add(p.multiply(t.valueOf(i)).divide(t.valueOf(i-~i--)));return p;}

-14 bytes thanks to @ceilingcat.
-17 bytes thanks to @jeJe.
-21 bytes thanks to @Neil reverting the algorithm.
Try it online.
Or as full program (203 bytes):
interface M{static void main(String[]a){var t=java.math.BigInteger.TEN.pow(499).shiftLeft(1);var p=t;for(int i=1656;i>0;)p=t.add(p.multiply(t.valueOf(i)).divide(t.valueOf(i-~i--)));System.out.print(p);}}

Try it online.

176

Big savings by using a more accurate algorithm: Try it online!

@Neil Thanks for the golfs on both this and the 100 digits answers of mine!

Mathematica (17 bytes)
N[ArcCos[-1],500]

Proof of validity.

PARI/GP, 14
\p500
acos(-1)

You can avoid trig by replacing the second line with
gamma(.5)^2

or
(6*zeta(2))^.5

or
psi(3/4)-psi(1/4)

or
4*intnum(x=0,1,(1-x^2)^.5)

or
sumalt(k=2,(-1)^k/(2*k-3))*4

Pyth, 21
u+/*GHhyHy^T500r^3T1Z

Uses this algorithm:
pi = 2 + 1/3*(2 + 2/5*(2 + 3/7*(2 + 4/9*(2 + ...)))) found in the comments of the Golfscript answer.

This doesn't deserve a downvote...

This answer is incorrect, it generates 34247779... which, to my knowledge, is not pi.

@orlp The r operation was recently changed in a way which broke this answer. Change the 1 to a 0, and it will work in current Pyth.

Fortran, 154 144 bytes
Mangled the rosetta code solution. Saved lots of bytes using implicit integers i j k l m n, print instead of write, and shuffling things around.
Try it online!
154 bytes
integer::v(3350)=2;x=1E5;j=0;do n=1,101;do l=3350,1,-1
m=x*v(l)+i*l;i=m/(2*l-1);v(l)=m-i*(2*l-1);enddo
k=i/x;print'(I5.5)',j+k;j=i-k*x;enddo;end

Raku, 44 bytes
(2.FatRat,{++$*$_/(2*++$+1)}...*)[^1658].sum

Try it online!
A search for a series that quickly converges to pi led to this Math StackExchange answer, which I implemented in Raku.  The series consists of FatRats, which is Raku's unlimited-precision rational number type.  A little calculation and trial and error showed that 1,658 terms are sufficient to obtain 500 decimal places of accuracy.

bc -l (22 = 5 command line + 17 program)
scale=500
4*a(1)

The rules say "nor may it call a library function to calculate pi."

@Peter The problem I guess, is that "library function" is not always a well defined term, and it only get worse when you say "to calculate Pi", as you may use it to calculate intermediate results, for example  Sqrt() in Alexandru's answer.

I think this is cheating because atan calculates 1/4 pi but it is an interesting solution nonetheless.

@Thomas O: if this is cheating, where's the limit?

trig functions should have been prohibited because of answers like this. the idea is to calculate pi with an algorithm, not a built-in function. sqrt is a bit different as it's not a trig function.

Mathematica - 50
½ = 1/2; 2/Times @@ FixedPointList[(½ + ½ #)^½~N~500 &, ½^½]

Axiom, 80 bytes
digits(503);v:=1./sqrt(3);6*reduce(+,[(-1)^k*v^(2*k+1)/(2*k+1)for k in 0..2000])

for reference https://tuts4you.com/download.php?view.452;
it would be an approssimation to 6*arctg(1/sqrt(3))=%pi and it would use serie expansion for arctg
  3.1415926535 8979323846 2643383279 5028841971 6939937510 5820974944 592307816
  4 0628620899 8628034825 3421170679 8214808651 3282306647 0938446095 505822317
  2 5359408128 4811174502 8410270193 8521105559 6446229489 5493038196 442881097
  5 6659334461 2847564823 3786783165 2712019091 4564856692 3460348610 454326648
  2 1339360726 0249141273 7245870066 0631558817 4881520920 9628292540 917153643
  6 7892590360 0113305305 4882046652 1384146951 9415116094 3305727036 575959195
  3 0921861173 8193261179 3105118548 0744623799 6274956735 1885752724 891227938
  1 8301194913 01

05AB1E, 20 bytes
₄°·D.ΓN>*N·3+÷}O+₄;£

Port of my Java answer (with the 503 replaced with 1000 - anything \$\geq503\$ is fine to output the first 500 digits accurately with this approach).
Try it online or verify it's equal to the first 500 digits of PI using the builtin žs.
Explanation:
₄°              # Push 10**1000
  ·             # Double it to 2e1000
   D            # Duplicate it
    .Γ          # Loop until the result no longer changes,
                # collecting all intermediate results
                # (excluding the initial value unfortunately)
      N>        #  Push the 0-based loop-index, and increase it by 1 to make it 1-based
        *       #  Multiply this 1-based index to the current value
         N·     #  Push the 0-based index again, and double it
           3+   #  Add 3 to it
             ÷  #  Integer-divide the (index+1)*value by this (2*index+3)
     }O         # After the cumulative fixed-point loop: sum all values in the list
       +        # Add the 2e1000 we've duplicated, which wasn't included in the list
        ₄;      # Push 1000, and halve it to 500
          £     # Leave the first 500 digits of what we've calculated
                # (after which it is output implicitly as result)

APL (NARS2000), 20 bytes
{2+⍵×⍺÷1+⍨2×⍺}/⍳7e3x

I haven't been able to test this, but here's a version in Dyalog APL. The only difference between them is the suffix "x", which is used for rational numbers in NARS2000 but is not available in Dyalog (or other variants available online, as far as I know).
It's based on the pi = 2 + 1/3*(2 + 2/5*(2 + 3/7*(2 + 4/9*(2 + ...)))) formula in the comments under the accepted Golfscript answer.

Scala 3, 96 84 bytes
A port of @Kevin Cruijssen's Java 10 answer in Scala.
Saved 12 bytes thanks to @ceilingcat

Golfed version. Attempt This Online!
_=>{val t=BigInt(10).pow(499)*2;var p=t;for i<- 1656 to 1 by-1 do p=t+p*i/(2*i+1);p}

Ungolfed version. Attempt This Online!
_ => {
  val t = BigInt(10).pow(499) << 1
  var p = t
  var i = 1656
  while (i > 0) {
    val temp = 2 * i + 1
    p = t + (p * BigInt(i) / temp)
    i -= 1
  }
  p
}

APL(NARS), 213 chars
r2fs←{⎕ct←0⋄k←≢b←⍕⌊⍵×10x*a←⍺⋄k-←s←'¯'=↑b⋄c←{s:'¯'⋄''}⋄m←s↓b⋄0≥k-⍺:c,'0.',((⍺-k)⍴'0'),m⋄c,((k-⍺)↑m),'.',(k-⍺)↓m}

r←P w;i;d;e;k
r←i←0x⋄e←÷10x*w
k←1+8×i⋄d←(+/4 2 1 1÷k,-k+3..5)×÷16*i⋄→3×⍳e>∣d⋄r+←d⋄i+←1⋄→2

{⍵r2fs P⍵}500

111+13+15+59+2+13=213
p r2fs w, return a string of the rational number in w seen as float with p digits afther the point.
P p, would return a rational number enough to be traslated from r2fs to a float string with p digits of precision.
Test (the last digit is always not rounded)- output:
  3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066
  470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337
  867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153
  643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799
  6274956735188575272489122793818301194912


text:
Five aligned points and some of the pairwise distances. Infer the relative positions!
Given five points on a straight line such that their pairwise distances are 1,2,4, ..., 14,18,20 (after ordering), find the respective positions of the five points (relative to the furthest point on the left).

What do you want: shortest code? best complexity?

Best complexity and generality (number of points, distances, etc.).

The problem isn't general: there is one correct answer for the numbers given, but there is more than one answer for other combinations of five points with the first three and last three pairwise distances known. And if you increase the number of points, you will need more known distances to insure a single solution. So I don't think a general solution is possible.

Incidentally, fixing the problem to make it work as a challenge would likely just make it a duplicate of this challenge.

R
prop <- function(num_points, first_distances, last_distances)
{
    last_point = max(last_distances)
    proposal = c(0, sort(sample(1:(last_point-1), num_points-2)), last_point)
    d = sort(dist(proposal))
    num_first_distances = length(first_distances)
    num_last_distances = length(last_distances)
    num_distances = length(d)
    if(all(d[1:num_first_distances]==first_distances)&&all(d[(num_distances-num_last_distances+1):num_distances]==last_distances))
    {
        print(proposal)
        return(TRUE)
    }
    else return(FALSE)
}

while(TRUE)
{
    if(prop(5, c(1,2,4), c(14,18,20))) break()
}

Here is the source of the problem and an algorithm with R which I used for inspiration.

If you already know the answer it is best to wait a few days before posting it to give others a chance.

What is written above is using R. There may be more elegant solutions.

Indeed, there are better solutions, since the one above use random trials rather than dynamic programming.


text:
Minimum of last k
Write a function that takes two arguments: a number k and a list l, and that returns another list r such that r[i] = min(l[i-k+1:i]).
Examples

Input k=2, l=1,2,3,4,5,6
Ouput r=1,1,2,3,4,5
Input k=3, l=-1,9,7,-9,8,3,5,0,12,1,2,3,-1,-2,-3
Ouput r=-1,-1,-1,-9,-9,-9,3,0,0,0,1,1,-1,-2,-3

Constraints: O(len(l)) time complexity. Shortest code wins.

Please use the code-golf tag when asking for shortest code.

Why the complexity contraint if the goal is shortest code?

I don't really understand the formula after sucht that..., can you explain it further to me?

@FUZxxl: r[i] is minimum of the last k elements in l ending at i.

This task is probably as complex as a sort, so O(len(l)) can be obtained

Is the function allowed to just modify the original array, or does it need to return a new one?

Are arrays 0-indexed or 1-indexed? Also what does a[i:j] mean? You should clarify the semantics of the code.

Seemed j represents number of items to take, starting with i. But if i is non-positive, then i is 1 (if 1-indexed), as in this

R, 75 bytes
f=function(k,l){r=l;for(i in 1:length(l));r[i]=min(l[max(1,(i-k+1)):i]);r}

Testing:
f(3, c(-1,9,7,-9,8,3,5,0,12,1,2,3,-1,-2,-3))
[1] -1 -1 -1 -9 -9 -9  3  0  0  0  1  1 -1 -2 -3

f(2, 1:6)
[1] 1 1 2 3 4 5

Not sure how to calculate the complexity of this.

Complexity is O(N*K)

I think you can remove the ; in length(l));r[i]

SmileBASIC, 97 bytes
DEF M(K,L)DIM T[0],R[0]FOR I=1TO LEN(L)COPY T,L,MAX(I,K)-K,MIN(I,K)PUSH R,MIN(T)NEXT
RETURN R
END

Explanation:
This line uses COPY dest[],source[],start,length to get part of the list into a temporary array:
COPY TEMP,LIST,MAX(I-K,0),MIN(I,K)

Example for a list of size 6, with K=3
I|start|length
1| 0   | 1
2| 0   | 2
3| 0   | 3
4| 1   | 3
5| 2   | 3
6| 3   | 3

K, 32 bytes
{|&/',/+((x*!_(#y)%x)+/:!x)_\:|y}
Translating the symbols to meaning, that is:
reverse min over each flattened transpose (firstargument multipliedby enumerate truncate (countof secondargument) dividedby firstargument)add eachright enumerate first argument) cutby eachleft reverse secondargument
It's not as terse as J, as K is a simpler language, but it is still interesting

Welcome to PPCG! We actually don't require "non-competing" anymore. Our policy has changed in the last year. You may answer using any language you want.

I come from the future (from this future) and, since I'm learning J, I thought I'd give it a try.
J, 21 bytes (non-competing)
<./"1@([,\$&_@<:@[,])

It prefixes the list with (K - 1) infinities, partitions it in overlapping chunks of length K and then computes the minimum of those. That's O(K*len(L)) if I'm not mistaken but, AFAICT, you need stateful computation to achieve O(len(L)) which isn't very idiomatic in J.
Usage:
   2 <./"1@([,\$&_@<:@[,]) 1 2 3 4 5 6
1 1 2 3 4 5

   3 <./"1@([,\$&_@<:@[,]) _1 9 7 _9 8 3 5 0 12 1 2 3 _1 _2 _3
_1 _1 _1 _9 _9 _9 3 0 0 0 1 1 _1 _2 _3

Matlab, 72 bytes
function[r]=f(k,l),for i=1:length(l),r(i)=min(l(max(1,i-k+1):i));end;end

Try it Online!

Haskell, 92 bytes
This is a restricted-complexity question asking specifically for a program that runs in O(len(l)) time, yet all the other answers in 7½ years have ignored that constraint.  Here’s one that satisfies it.
g id
g _ _[]=[]
g h k l|(a,b)<-splitAt(k-1)l=h(scanl1 min a)++g(zipWith min$scanr1 min a)k b

Try it online!
How it works
Split the list into blocks of k − 1.  Within each block, compute all prefix minima (with a left-to-right scan) and all suffix minima (with a right-to-left scan).  Then any sublist of k numbers crosses exactly one block boundary, and can therefore be computed as the minimum of a suffix minimum from the first block and a prefix minimum from the second block.

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


text:
Integer to string with given radix
Write the shortest function to convert an integer into a numeric representation given a radix between 2 and 62. e.g.:
to_string(351837066319, 31) => "codegolf"

From the example I gather that lower case letters come first, i.e. the digits in base 62 are 0-9,a-z,A-Z in that order?

Yes, exactly, that's it.

at 0:00, dang, perfect.

@Adalynn posted at 46 seconds after midnight (Zulu), so not that perfect.

Python - 86
from string import*
def t(n,r,s=''):
 while n:s=printable[n%r]+s;n/=r
 return s or'0'

Credit due to Hoa Long Tam for the string import trick

dc - 43 chars
[sb[58-]s_[lb~dZ39*+dB3<_9+rd0<xrP]dsxxk]sf

We can shorten this a little if we assume the stack contains only the two arguments.
[[58-]s_dSb~dZ39*+dB3<_9+SadLbr0<fLaPc]sf

As a standalone program, we only need 37 characters:
?o[58-]s_[O~dZ39*+dB3<_9+rd0<xrP]dsxx

Instead of using [39+]sz9<z, we simply use Z39*+, which will add 39 for a single digit number, and 78 for a double digit number. Instead of 113, we use B3 (AD also works).

Ruby 1.8 - 75 characters, with recursion.
f=proc{|n,b|(n<b ? "":f[n/b,b])+([*'0'..'9']+[*'a'..'z']+[*'A'..'Z'])[n%b]}

Without recursion
f=proc{|n,b|d=[*'0'..'9']+[*'a'..'z']+[*'A'..'Z'];s=d[n%b];s=d[n%b]+s while(n/=b)>0;s}

(both based on Dogbert's 1.9 solution.)

Python, 93 99
from string import *
d=digits+letters
def t(n,b):
 s=''
 while n>0:s=d[n%b]+s;n/=b
 return s or '0'

EDIT: " or '0'" added for empty string case

Fails when n = 0, returns an empty string when it should return '0'. Anyway +1 for the string trick

Ruby 1.9 - 80 74 68
t=->n,b{d=*?0..?9,*?a..?z,*?A..?Z;s='';(s=d[n%b]+s;n/=b)while n>0;s}

With '0' for empty string, 95 89 82 characters:
t=->n,b,s=''{d=*?0..?9,*?a..?z,*?A..?Z;(s=d[n%b]+s;n/=b)while n>0;s.empty?? ?0: s}

Ruby 1.9 - unfortunately only works up to base 36:
t=->n,b{n.to_s(b)}

You can replace the ]+['s with ,.

Ruby - 72 70 59 chars
f=->n,b{(n<b ? "":f[n/b,b])+[*?0..?9,*?a..?z,*?A..?Z][n%b]}

Without recursion, 70 chars
f=->n,b{d=*?0..?9,*?a..?z,*?A..?Z;s=d[n%b];s=d[n%b]+s while(n/=b)>0;s}

Test
irb(main):080:0> f[351837066319, 31]
=> "codegolf"
irb(main):081:0> f[0, 31]
=> "0"

dc, 61 chars
[sr[lr~rd0<x]dsxxk[39+]sa[58-]sb[d9<ad78<b48+anz0<p]dspxIP]sf

Run as:
dc -e'[sr[lr~rd0<x]dsxxk[39+]sa[58-]sb[d9<ad78<b48+anz0<p]dspxIP]sf' -e'351837066319 31 lfx'

or:
dc -f base.dc -e '351837066319 31 lfx'

Explanation:
We take the number and base on the stack. sr saves the base in register r. The recursive function [lr~rd0<x]dsxx decomposes a number TOS into its digits in base register r. The first digit is always 0, removed from the stack by k (set precision, which by default is 0 also, so it's equivalent to a nop). Then, the recursive function [48+d57<ad122<banz0<p]dspx outputs each digit in ASCII, with the help of functions a ([39+]sa) and b ([58-]sb). IP outputs a newline. The function is stored in register f, and can be invoked by lfx.

If you move 48+ to the end it saves two (57 and 122 both drop a character). Also a minor oversight is that as a function, you can't assume there is nothing else on the stack, but the problem would be removed if you merged the loops (which would also save a few characters).

Burlesque, 4 bytes
peB!

Try it online!
Luckily a built-in in Burlesque
pe # Parse and push
B! # Convert base

Python 2, 64 bytes
f=lambda n,b:n and f(n/b,b)+chr(n%b+48+(n%b>9)*39-n%b/36*58)or''

Try it online!

Haskell, 109 characters
m=divMod
d(0,x)b=[f x]
d(r,x)b=f x:d(m r b)b
f=(!!)$['0'..'9']++['a'..'z']++['A'..'Z']
s x b=reverse$d(m x b)b

Feels a bit wrong suggesting golfs to something over 10 years old, but I may as well note that this can be shaved down a good 5 bytes, by factoring the whole d(m r b)b pattern into m  (with a bit of help from the Applicative instance for functions), then using that to convert s to pointfree.

Golfscript - 32 chars
{base{.9>39*+.74>58*48--}%''+}:f

Bash, 79 chars
f(){
dc<<<$2o$1p|perl -pe"y/A-Z/a-z/;s/ \d+/chr$&+($&<10?48:$&<36?87:29)/ge"
}

BC_BASE_MAX is documented as being 16.  I don't know what miracle makes the output right on the sample input, but it outputs garbage (i.e. non alphanum characters) for most other bases.

@J B: which bc are you using? GNU bc should work. sysconf(_SC_BC_BASE_MAX) returns 99 on my system, 16 is the minimum required.

@J B: also note that previous revisions where buggy, I had just skimmed at the question requirements.

bc 1.06.  Now you mention it, I got the figure from the manpage, but misread it.  16 is the input base limit.  The output base limit is 999.  I did first try on an earlier version, let's see that again now.

@J B. forget what I said about 16 being the minimum required. POSIX requires 99 as a minimum (_POSIX2_BC_BASE_MAX). BC_BASE_MAX is the implementation-specific minimum, and _SC_BC_BASE_MAX is the runtime minimum. Actually, the bc limits statement outputs BC_BASE_MAX = 2147483647 on my system.

Sorry, I upvoted but forgot to comment again. Sure enough, your latest version worked fine.  About limits, see my other comment: all's good.

I think this one outputs uppercase letters for bases 11-16 instead of lower case. You can save a few at the base conversion by using dc instead of bc.

@Nabb: Good catch. You also inspired me to do a pure dc version.

Befunge - 53 x 2 = 106 characters
Or 53 + 46 = 99 characters if you're willing to route other parts of your program through the bottom left.
11p01-\>:11g%\11g/:#v_$>:1+!#v_:45+`!#v_:75*`!#v_   v
       ^            <  ^,    $# +"0"  < +"'"   <-":"<

First place the number to be converted on the stack, then the radix and enter this function from the top-left going right.  Will output the string for you (since Befunge doesn't support string variables) and leave from the bottom $ going down.  Requires the (1,1) cell for radix storage.
E.g. for the example given put 351837066319 into the input and run:
&56*1+    11p01-\>:11g%\11g/:#v_$>:1+!#v_:45+`!#v_:75*`!#v_   v
                 ^            <  ^,    $# +"0"  < +"'"   <-":"<
                                       @

Jelly, 5 bytes
b‘ịØB

Try it online!
The case will be reversed (codegolf - CODEGOLF) because of Jelly built-in base characters string.
How?
b‘ịØB - Link, input x & y
b     - Convert x to base y
 ‘    - Increment (because Jelly use based-1 indexing)
  ị   - List (string) indexing
   ØB - "0-9 A-Z a-z"

Go, 76 bytes
package m
import."math/big"
func e(n int64)string{return NewInt(n).Text(62)}

bonus decode:
package m
import."math/big"
func d(s string)int64{o,_:=NewInt(0).SetString(s,62)
return o.Int64()}

Japt, 9 bytes
Follows the example of the Jelly solution in reversing the casing.
;sVîEowi%

Try it

Stax, 5 bytes
VL(:B

Run and debug it
Same size packed, a custom base conversion.

Perl 5 -Minteger -ap, 52 bytes
do{$\=(0..9,a..z,A..Z)[$_%$F[1]].$\}while$_/=$F[1]}{

Try it online!

05AB1E (legacy), 8 7 bytes
вžLšRsè

-1 byte by switching to the legacy version of 05AB1E, where the switch_case builtin was one byte (it's .š in the new version).
Inputs in the order \$radix,number\$. Output as a list of characters.
Try it online.
Old 8 bytes non-legacy 05AB1E answers (same I/O as above):

žhži«£Åв - Try it online.
вžK9Ý†sè - Try it online.

Explanation:"
в        # Convert the second (implicit) input to base-(first implicit input) as list
 žL      # Push string "zyxwvutsrqponmlkjihgfedcbaZYXWVUTSRQPONMLKJIHGFEDCBA9876543210"
   š     # Switch case: "ZYXWVUTSRQPONMLKJIHGFEDCBAzyxwvutsrqponmlkjihgfedcba9876543210"
    R    # Reverse it: "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
     s   # Swap so the list is at the top
      è  # Index each into this string
         # (after which the resulting character-list is output implicitly)

žh       # Push constant string "0123456789"
    «    # Append
  ži     # Constant string "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ":
         #  "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
     £   # Only keep the first (implicit) input amount of characters from this string
      Åв # Convert the second (implicit) input to this custom base-"0-9a-zA-Z"
         # (which basically converts it to base-length, and indexes it into the string)
         # (after which the resulting character-list is output implicitly)

в        # Convert the second (implicit) input to base-(first implicit input) as list
 žK      # Push string "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ012346789"
   9Ý    # Push list [0,1,2,3,4,5,6,7,8,9]
     †   # Filter all those characters to the front:
         #  "012346789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
      s  # Swap so the list is at the top
       è # Index each into this string
         # (after which the resulting character-list is output implicitly)

Pascal, 236 B
This function requires a processor supporting features of Extended Pascal as described by ISO standard 10206, in particular the string capabilities.
Note, the golfed version is restricted to 98 digits.
Furthermore, a character (here the sign) is always prepended.
type s=string(99);function f(n,b:integer):s;begin
f:=('- +')[ord(n>0)-ord(n<0)+2];n:=abs(n);repeat
f:=('0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ')[n mod b+1]+f;n:=n div b
until n=0;n:=length(f);f:=f[n]+f[1..n-1]end

Ungolf’d, annotated and reasonably good programming style:
    const
        { Number of binary digits required to write `maxInt` out. }
        maxIntBinaryLength = trunc(ln(maxInt) / ln(2)) + 1;
        { Known digits for `positionalNotation` function. }
        digit = '0123456789abcdefghijklmnopqrstuvwxyz' +
                          'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
        { Characters for negative sign, no sign, and positive sign. }
        sign = '− +';

    type
        { For sorting purposes starts with `integer…` prefix. }
        integerNonNegative = 0‥maxInt;
        { A string capable of representing any integer plus a sign. }
        integerString = string(maxIntBinaryLength + 1);
        { Acceptable `base` for `positionalNotation` function. }
        radix = 2‥62;

    { Returns −1, 0, or +1 depending on the sign of the argument. }
    function signum(protected n: real): integer;
        begin
            signum ≔ ord(n > 0) − ord(n < 0)
        end;

    { Retrieve positional notation of a given integer in a given base. }
    function positionalNotation(
            protected n: integer;
            protected base: radix
        ): integerString;
        { Separate string to work with, and ensure non‑negative number. }
        function position(magnitude: integerNonNegative): integerString;
            begin
                position ≔ '';
                { This is just your run‑of‑the‑mill Horner’s method. }
                repeat
                begin
                    { Prepend a digit. Note, string indices are 1‑based. }
                    position  ≔ digit[magnitude mod base + 1] + position;
                    magnitude ≔ magnitude div base
                end
                until magnitude = 0
            end;
        begin
            { The algorithm is prepending digits, but the sign must be first. }
            positionalNotation ≔ sign[signum(n) + 2] + position(abs(n))
        end

Signum function PPCG challenge │ RosettaCode │ FreePascal Wiki


text:
Fix a broken random function
A friend has an add-on card in their computer which generates a perfectly random number from 1 to 5 inclusive. Unfortunately, they spilt cola on it somehow, and it now generates only 2's for all numbers from 1 to 4. Luckily the randomness is preserved, but 2 has a probability of 80% and 5 has a probability of 20%, and there are no 1's, 3's or 4's generated. Using this random source (call it BrokenRand() or something similar), write a working random number generator which produces numbers from 1 to 5 each with an equal 20% probability with the same perfect randomness as the original source.
Shortest program wins. Bonus points awarded for the minimum number of calls to BrokenRand impartially by a demographically-selected customer service focus consultancy, broken down by age and sex - i.e. me.

JavaScript - 69 characters
This uses the von Neumann extractor to generate unbiased bits; the general algorithm is also described on the HotBits website. Three bits are used to form a number from 0 to 7. All numbers 5 and above are discarded, and 1 is added to each of the rest before they are printed. I made a simulation to show that this is not heavily biased.
You need to provide your own function r() to access the RNG.
 for(;;v<5&&alert(v+1))for(v=i=0;i<3;a-b&&(v*=2,v+=a<b,i++))b=r(a=r())

This is really well done! I like how you short circuit the increment value.

You could generate 7 bits and extract 3 random numbers to reduce the calls to BrokenRand, but that would likely cost a few more strokes

scala 79 chars:
// preparation:
val r = util.Random
def defektRNG = if (r.nextInt (5) == 0) 5 else 2

(1 to 20).foreach (_ => print (" " + defektRNG))
// first impression:
// 2 2 2 2 2 2 2 5 2 2 5 2 2 2 5 2 2 2 2 2

def rnd : Int = { val k = (1 to 5).map (_ => defektRNG)
  if (k.sum == 13) k.findIndexOf (_ == 5) + 1 else rnd }

// first impression:
(1 to 20).foreach (_ => print (" " + rnd))
// 3 3 2 3 5 2 2 5 1 1 3 4 3 2 5 3 3 1 5 4
// control:
(1 to 50000).map (_ => rnd).groupBy (identity) .map (_._2.length)
// scala.collection.immutable.Iterable[Int] = List(10151, 9997, 9971, 9955, 9926)

Now for the real golf, defektRNG alias brokenRand is renamed to b.
def r:Int={val k=(1 to 5).map(_=>b)
if(k.sum==13)k.findIndexOf(_==5)+1 else r}

How it works: Most often, b returns a sequence of 2s. But if you do 5 calls to b, you will very often end with a result of 4x2 and 1x5, it is the second most probable event, and can be 5-2-2-2-2, 2-5-2-2-2, 2-2-5-2-2, 2-2-2-5-2 and 2-2-2-2-5.
These have in common, that the sum is 4*2+5=13. The index of the first five can be used to define a valid random number. If there is more or less than one 5, a sum greater or lower 13, repeat.
A counter in 'rnd' aka 'r' can show how many calls are necessary in average to produce the numbers. There are 121 200 calls to r for 50 000 random numbers, which is not impressing. :)

><> (Fish) - 55 bytes
Updated to use the same algorithm as @user unknown in his scala answer

<v?=d+&:i&+&:i&+&:i&+&:i&:i
 0
 >1+$5(?vnao;
 ^      <

It expects the broken generator to be connected to stdin; here's the python script I used. The code matches the current Fish spec, but I used a modified version of the old interpreter.

bash:$ for i in $(seq 1000); do ./bad_rand.py | ./myfish.py rand.fish; done >res.txt
bash:$ for i in $(seq 5); do echo -n "$i : "; grep -c $i res.txt; done
1 : 193
2 : 204
3 : 198
4 : 206
5 : 199

I'd do a bigger sample but it's slow.

GolfScript, 23 bytes
Late answer, but since this just happened to pop up on the front page...
0{;[{r}5*].5?)\5-,4-}do

Uses the same algorithm as user unknown's Scala solution.  Assumes that the biased random number generator is given as a GolfScript subroutine named r; you can define a suitable biased RNG yourself e.g. as:
{5rand!3*2+}:r;

Here's a quick test demonstrating lack of bias.  Unfortunately, the online GolfScript server is kind of slow, so I had to cut the demonstration down to just 100 samples to make it complete on time.  If running the test locally with the GolfScript interpreter, try increasing the 100* to 1000* or even 10000*.
(The GolfScript server also sometimes randomly freezes and times out anyway.  If this happens for you, trying again usually solves it.  It happens with other code too, and only happens on the server, not on my own computer, so I'm confident that it's a problem with the server and not with my code.)

 Python 3, 119 bytes
def F():
  l=[]
  while 1:
    l=[]
    for i in range(5):
      l.append(B())
    if l.count(5) == 1:
      return l.index(5)

Could be golfed to below 100 probably, but it's decent for now. Have no idea how a Python answer (or one with this method) hasn't popped up. Assumes the broken random function is B.


text:
Perfect powers in more than one way?
Challenge
Your task is to write a program or function which, given a positive integer \$N\$, finds all positive integers less than or equal to \$N\$ that can be expressed as a perfect power in more than one way.
Definition
A perfect power is defined as a number \$i\$ found by \$m^k\$, where:

\$m\$ and \$i\$ are positive integers
\$m \ne k\$

Test Cases

input -> output
1000 ->  16, 64, 81, 256, 512, 625, 729
56 -> 16
999 -> 16, 64, 81, 256, 512, 625, 729
81 -> 16, 64, 81
1500 -> 16, 64, 81, 256, 512, 625, 729, 1024, 1296

Please provided a readable, commented version as well.

Does your last sentence mean that whitespace does not figure into the character count?

@sepp2k Yes! We should not count white spaces.

How does 1 fit your condition (m,n>1)?

@keith-randall I will remove that.

@fR0DDY What about whitespace the language? Ignoring whitespace characters will always make this language win.

@marcog I would love to see a solution in Whitespace. ;) Between, I asked for white spaces to be ignored for readability.

I don't think it hurts to have the odd question that can be won by a whitespace answer. We shall see how long it takes before someone can be bothered to do it.

Is there any limit on N?

I don't think significantly changing the challenge 6 years after the fact is a good idea... but there were errors in the original too. Not sure what to do.

Mathematica: 103 chars
Spaces can be removed
Select[Flatten@
       Table[
        Solve[Log@#/Log@b == k, k, Integers] /. k -> #, {b, 2, #}] & /@ Range@#,
Length@# > 2 &][[All, 1, 1]] &

Usage:
%[81]
{16, 64, 81}

Jelly, 11 meaningful bytes, language postdates challenge
ḊḟÆR *@þ Ḋ  F  fḊ

Try it online!
Here's an entirely different solution. This one's a curious hybrid of efficient and inefficient, using an efficient core algorithm in a very inefficient wrapper (so much so that it can't handle very large numbers). As before, all whitespace is meaningless.
Here's how it works. Ḋ (which appears several times) is a list of numbers from 2 to the input inclusive:
ḊḟÆR *@þ Ḋ  F  fḊ
ḊḟÆR                Ḋ, with all primes between 2 and the input removed
                    (i.e. all composite numbers from 4 to the input)
     *@þ Ḋ          Exponentiate all Ḋ elements with all ḊḟÆR elements
            F       Flatten the result (it had a nested structure)
               fḊ   Keep only elements in Ḋ

The basic observation here is that a number is a perfect power in multiple ways, only if it's a perfect power with a composite exponent (that isn't 1). We generate a list of those where the base is from 2 to the input, and the exponent is a composite number from 4 to the input; this is really slow because it generates some really big numbers, all of which are an answer to the question. Then we only keep the answers which are in range.
It'd easily be possible to modify this into a highly efficient answer, by working out what the maximum power in range was and not iterating any further, but that'd be a lot more bytes, and this is code-golf.

Perl: 68 chars
Gets the maximum (1000) in $N and returns the answer in @a.
for $x ( 2..$N ) {
    $c{$x**$_}++ for 2..log($N)/log$x
}
@a = grep { $c{$_} > 1 } keys %c

For a whole program, I need another 18 chars:
$m = shift;
for $x ( 2..$m ) {
    $c{$x**$_}++ for 2..log($m)/log$x
}
print join ' ', grep { $c{$_} > 1 } keys %c

This doesn't print in order. http://codepad.org/H0Zyau3z

@Dogbert: Printing in order is not part of the challenge. If it was, you cculd add sort  before grep. I hadn't seen codepad before, by the way. Thanks.

Ruby - 101 chars (without whitespace)
f=->l{c=Hash.new{0}
2.upto(1E4){|i|2.upto(20){|j|c[i**j]+=1}}
c.map{|k,v|v>1&&k<=l&&k||p}.compact.sort}

Works for 1 <= limit <= 100,000,000 within 5 seconds.
Test
> f[10000]
[16, 64, 81, 256, 512, 625, 729, 1024, 1296, 2401, 4096, 6561, 10000]

Jelly, 13 meaningful characters, language postdates challenge
R  µ  ọḊ *@Ḋ ċ >2  µ  Ðf

Try it online!
All whitespace here is insignificant. I used it to show the structure of my answer, as the question asks.
Here's how it works:
R  µ  ọḊ *@Ḋ ċ >2  µ  Ðf
R                     Ðf    Find all numbers n from 1 to the input, such that:
   µ               µ          (grouping marks, like {} in C)
       Ḋ   Ḋ                  Take the range from 2 to n
      ọ                       Find the number of times each divides n
         *@                   Raise the range from 2 to n to these powers
             ċ                Count the number of times n appears
               >2             and the result must be greater than 2

So for example, when testing n=256, we check the number of times each of the numbers from 2 to 256 divides into 256. The only numbers that divide more than once are 2 (which divides 8 times), 4 (which divides 4 times), 8 (which divides twice), and 16 (which divides twice). So when we raise the number of divisions to the powers determined there, we get:
2⁸, 3, 4⁴, 5, 6, 7, 8², 9, 10, 11, 12, 13, 14, 15, 16², 17, ..., 255, 256

This produces the original value, 256, a number of times equal to the way that 256 is a perfect power, plus one (the last element produces 256 because 256 = 256¹). So if we see 256 more than twice in the array (and we do in this case; 8² is 64 but the other "interesting" elements all produce 256), it must be a perfect power.


text:
Basic Calculator
You must write a program to evaluate a string that would be entered into a calculator.
The program must accept input and output the correct answer.  For languages that do not have standard input/output functions, you may assume the functions readLine and print.
Requirements

Does not use any kind of "eval" functions
Can handle floating point and negative numbers
Supports at least the +, -, *, and / operators
Can handle input containing one or more spaces between the operators and numbers
Evaluates the expression from left to right

The program that is the shortest wins.  In the event of a tie, the program that was submitted first wins.
You can assume that the input is valid and follows the correct format

Test Cases
Input
-4 + 5

Output
1

Input
-7.5 / 2.5

Output
-3

Input
-2 + 6 / 2 * 8 - 1 / 2.5 - 18

Output
-12

My calculator uses postfix. See also Evaluating Mathematical Expressions on Stack Overflow for competition (though I haven't checked if the rules are identical).

Third test case is wrong - whether you follow standard order of operations or perform all operations left to right. Looking at the second test case, does your calculator round the result of each operation?

Fixed the second and third test case, the result is not rounded.

The third test case does not follow the standard order of operations.  Are our answers supposed to?

@John, the last requirement says it needs to evaluate the string from left to right.  This means it doesn't follow the standard order of operations.

@Bass: Ok, just clarifying.

What about using command line arguments ARGV? because the shell auto-splits and lists the arguments.

This is really trivial if you're just calculating left to right, and not using standard operator precedence. I was hoping to get a chance to show off my knowledge of Dijkstra's Shunting Yard algorithm here but I guess that won't be necessary.

An advanced calculator challenge would be fun

@starbeamrainbowlabs already exists http://codegolf.stackexchange.com/q/617/148

@KevinBrown Cool! I didn't see that.

How much floating-point precision does it have to support?

May we use fixed-point or rational numbers instead of floating-point?

Ruby - 74 69 67 65 characters
a=0
("+ "+$<.read).split.each_slice 2{|b,c|a=a.send b,c.to_f}
p a

Instead of using b[0],b[1].to_f you can replace |b| with |b,c| and use b,c.to_f

Instead of a.send(b,c.to_f), use a.send b,c.to_f. It saves a char

You can use $< instead of ARGF

Befunge - 37 x 5 = 185 38 x 3 = 114 characters
This is limited to integer numbers as Befunge has no floating point support.
&v      /& _ #`&# "-"$# -#<          v
 >~:0`!#v_:" "`! #v_:","`#^_"*"`#v_&*>
 ^      ># $ .# @#<              >&+

Explanation
The biggest distinguishing feature of Befunge is that instead of being a linear set of instructions like most languages; it is a 2d grid of single character instructions, where control can flow in any direction.
The first & simply inputs the first number.  The v and > then redirect control to the main path on the second row.
~:0`!#v_

This inputs a character (~), duplicates it (:), pushes zero onto the stack (0), pops the top two elements and determines if the second is greater than the first (` I'm surprised you can't use ``` to get code backticks.), inverts the truthiness of the top element (!), then goes right if it is zero, down otherwise (#v_).
Basically it's checking whether the input is -1 representing no more input.
># $ .# @

If the input was -1 then the duplicated input value is discarded ($), the top of the stack is output as an integer (.) and the program is halted (@).
:" "`! #v_

Otherwise a similar process is repeated to determine if the input is less than or equal to a space.  If it is a space then control goes down, otherwise control heads right.
^      ># $ .# @#<

If it is a space then it's redirected left (<); the program halt (@), output (.) and right redirection (>) are all skipped using #; but the discard is executed to remove the space from the stack.  Finally it's redirected up to begin the next execution (^).
:","`#^_

If it wasn't a space the same process is used to split on if it is in [+, *] or in [-, \] going right and up respectively.
 >~                         "*"`#v_&*>
 ^                               >&+

For [+, *] it is again split to determine whether it is a + or a *.  If + it is directed down then the next number is input (&) and they are added (+), the control then wraps around and is redirected up to the main path for the next character.  If * then it inputs (&) and multiplies (*) then directly wraps around.
/& _ #`&# "-"$# -#<

For [-, \] it starts on the right heading left.  The #'s skip the character after them so the initial path is "-"`_ which simply determines if it is - or /.  If it is / then it continues left to input (&) and divide (/).  If it is - then it heads right, again skipping characters so that it executes &"-"$- resulting in the number being input (&) the - character being pushed onto the stack then discarded ("-"$) and then the subtraction being calculated (-).  The control is then redirected back to the main path.

Python 3, 105 bytes
Manages the four basic operations, but it only costs 5 characters each to add ^ or %.
f=float
x,*l=input().split()
while l:o,y,*l=l;x,y=f(x),f(y);x=[x+y,x-y,x*y,x/y]['+-*/'.find(o)]
print(x)

Precedence of operations is left to right.

Python (156)
from operator import*
while 1:
 l=raw_input().split();f=float
 while len(l)>2:l[:3]=({'*':mul,'/':div,'+':add,'-':sub}[l[1]](f(l[0]),f(l[2])),)
 print l[0]

It's prob just easier to use Python 3

C - 168 126 characters
main(c){float a,b;scanf("%f",&a);while(scanf("%s%f",&c,&b)!=-1)c=='+'?a+=b:c=='-'?(a-=b):c=='*'?(a*=b):(a/=b);printf("%f",a);}

Tcl 8.6, 57 48 chars.

Input from arguments:
lm o\ b [las $argv a] {set a [exp $a$o$b]};pu $a

From Stdin (64 53)
lm o\ b [las [ge stdin] a] {set a [exp $a$o$b]};pu $a

You have to use the interactive shell for both solutions.
I treat the input as list (Tcl uses spaces as delimiter) take the first element and assign it to a, then I walk over the rest, taking 2 elements each time, the operator and a second number, apply the operator on $a and $b and assign the result to a. At the end the result is in a.

Ideone supports at least stdin.

Finally, I beat Ruby. Unfortunately Idone does not support Tcl 8.6, but I don't need the result of lmap so foreach is a good replacement.

C++0x 205 203 198 194 chars
#include<iostream>
#define P [](F l,F r){return l
int main(){typedef float F;F r,v,(*a[])(F,F)={P*r;},P+r;},0,P-r;},0,P/r;}};std::cin>>r;for(char o;std::cin>>o>>v;)r=a[o-42](r,v);std::cout<<r;}

Nicely formatted:
#include<iostream>

int main()
{
    float r,v;
    float (*a[])(float,float)   ={  [](float l,float r){return l*r;},
                                    [](float l,float r){return l+r;},
                                    0,
                                    [](float l,float r){return l-r;},
                                    0,
                                    [](float l,float r){return l/r;}
                                 };

    std::cin>>r;
    for(char o;std::cin>>o>>v;)
        r=a[o-42](r,v);

    std::cout<<r;
}

Haskell: 124 114 characters
j[o]=o
j(u:m:b:o)=j$show((case m of{"+"->(+);"-"->(-);"*"->(*);"/"->(/)})(read u)(read b)):o
main=interact$j.words

A rather straight-forward answer, using pattern matching and a simple case statement for the heavy lifting. Usage:
> ./calc <<< "123 - 12 + -12 / 12.124 * 9.99 - 1"
80.57456285054437

Instead of ((case m of{..})(read u)(read b)) you can write ((case m of{..}$read u)$read b), 2 characters less.

C: 111 108 characters
main(c){float a,b;for(scanf("%f ",&a);~scanf("%c%f ",&c,&b);a=c^43?c%5?c%2?a/b:a*b:a-b:a+b);printf("%f",a);}

It fulfills all the requirements, usage:
> ./calc <<< "-43 - 56 + 14.123 / -13.22"
6.420348

~scanf can replace +1. Also, c^45->c%5 and c^42->c%2 should work.

@MDXF not on my machine, it passes every test case here. I'm compiling with Clang on a fairly modern Intel Macbook, and it works smashingly well (I tested it again just now, I copypasted the code from here and just compiled it without any flags). What compiler, processor architecture and OS are you using?

@Fors I believe I had some odd flags that were inducing strange behavior; my mistake, it's working for me now. Sorry to bother you.

Perl (97)

$b=shift;eval"\$b$r=$s"while($r=shift,$s=shift);print$b

read from arguments
$b=shift;$b=($r eq'+'?$b+$s:$r eq'-'?$b-$s:$r eq'*'?$b*$s:$b/$s)while($r=shift,$s=shift);print$b;

read from input
@_=split/ /,<>;$b=shift@_;$b=($r eq'+'?$b+$s:$r eq'-'?$b-$s:$r eq'*'?$b*$s:$b/$s)while($r=shift@_,$s=shift@_);print$b

PostScript (145)
Another PostScript entry (thanks to luser droog for digging the golfs interesting for PostScript!):
[/+{add}/-{sub}/*{mul}/{div}>>begin(%stdin)(r)file
999 string readline
pop{token not{exit}if
count 4 eq{3 1 roll
4 1 roll
cvx exec}if
exch}loop
=

Un-golfed:
[/+{add}/-{sub}/*{mul}/ {div}>>begin
% Read the input
(%stdin)(r)file 999 string readline pop
{                        % .. string
  token not{exit}if      % .. string token
  % If we have 4 objects on the stack, we have two operands, one operator
  % and the input string. This means, we can calculate now.
  count 4 eq{            % a op string b
    % perform operation a op b = c (where op can be +,-,*,/)
    3 1 roll             % a b op string
    4 1 roll             % string a b op
    cvx exec             % string c
  }if                    % string token (or c)
  exch                   % token string
}loop
=

You keep beating me! +1 This is very exciting.

If  you can beat my crossword, I'll give you a bounty! N.B. You can only edit 10 times before the post becomes CW and votes don't earn you rep points.

I keep beating you because I only chose the ones where I can beat you ;-). I'm not sure whether I can with the crossword grid. I'll maybe try, but only in a few weeks.

BTW, what does CW mean?

Community Wiki. It means the post has been edited so many times it now belongs to the community. Any user can edit it (bypassing the moderator approval required for the usual suggested edits), and no more points. So whatever you do, stop on Rev 9. I almost blew it on the guitar tab one.

Ignore all that CW griping. They fixed it!

Python - 308
import sys;i=sys.argv[1].split();o=[];s=[];a=o.append;b=s.pop;c=s.append
for t in i:
 if t in"+-*/":
  if s!=[]:a(b())
  c(t)
 else:a(t)
if s!=[]:a(b())
for t in o:
 if t=="+":c(b()+b())
 elif t=="-":m=b();c(b()-m)
 elif t=="*":c(b()*b())
 elif t=="/":m=b();c(b()/m)
 else:c(float(t))
print(b())

Readable version:
# Infix expression calc

import sys

# Shunting-yard algorithm
input = sys.argv[1].split()
output = []
stack = []

for tkn in input:
    if tkn in "+-*/":
        while stack != []:
            output.append(stack.pop())
        stack.append(tkn)
    else:
        output.append(tkn)

while stack != []:
    output.append(stack.pop())

# Eval postfix notation
for tkn in output:
    if tkn == "+":
        stack.append(stack.pop() + stack.pop())
    elif tkn == "-":
        tmp = stack.pop()
        stack.append(stack.pop() - tmp)
    elif tkn == "*":
        stack.append(stack.pop() * stack.pop())
    elif tkn == "/":
        tmp = stack.pop()
        stack.append(stack.pop()/tmp)
    else:
        stack.append(float(tkn))

print(stack.pop())

Takes expression as command-line argument, output on standard output.

C# (234) (231) (229) (223) (214)
class A{void Main(string[]s){var n=1;var o="";var r=0F;foreach(var t in s){if(n>0){var v=float.Parse(t);if(o=="")r=v;if(o=="+")r+=v;if(o=="-")r-=v;if(o=="*")r*=v;if(o=="/")r/=v;}o=t;n=-n;}System.Console.Write(r);}}

class A{
    void Main(string[] s)
    {
      var n = 1;
      var o = "";
      var r = 0F;

      foreach (var t in s)
      {
        if (n > 0)
        {
          var v = float.Parse(t);
          if (o == "") r = v;
          if (o == "+") r += v;
          if (o == "-") r -= v;
          if (o == "*") r *= v;
          if (o == "/") r /= v;
        }
        o = t;
        n = -n;
      }
      System.Console.Write(r);
    }
}

I'm getting '0' for '1 + 1'.  IDEONE

@Mike Input as arguments, not stdin.

Postscript (340)
/D<</+{add}/-{sub}/*{mul}/ {div}>>def/eval{/P null def{token not{exit}if exch/rem exch def
dup D exch known{/P load null ne{D/P load get exch/P exch def exec}{/P exch def}ifelse}if
rem}loop/P load null ne{D/P load get exec}if}def {(> )print flush{(%lineedit)(r)file
dup bytesavailable string readline pop eval == flush}stopped{quit}if}loop

And a little more readable:
%!
/oper<</+{add}/-{sub}/*{mul}/ {div}>>def

/eval{
    /op null def
    {
        token not {exit} if
        exch /rem exch def
        dup oper exch known {
            /op load null ne {
                oper /op load get
                exch /op exch def
                exec
            }{
                /op exch def
            } ifelse
        } if
        rem
    } loop
    /op load null ne { oper /op load get exec } if
} def

{
    (> )print flush
    {
    (%lineedit)(r)file
    dup bytesavailable string readline pop
    eval == flush
    } stopped { quit } if
} loop

JavaScript (208 characters compacted)
For clarity, this is the code before I compacted it down (JS-Fiddle of it):
function math(match, leftDigit, operator, rightDigit, offset, string) {
    var L = parseFloat(leftDigit)
    var R = parseFloat(rightDigit)
    switch (operator)
    {
        case '*': return L*R;
        case '/': return L/R;
        case '+': return L+R;
        case '-': return L-R;
    }
};

str = prompt("Enter some math:", "-2 + 6 / 2 * 8 - 1 / 2.5 - 18").replace(/ /g, "");
var mathRegex = /(\-?\d+\.?\d*)([\*\/\+\-])(\-?\d+\.?\d*)/;
while(mathRegex.test(str)) {
    str = str.replace(mathRegex, math);
}
alert(str)

Here it is compacted down to 208 characters (JS-Fiddle of it):
function m(x,l,o,r){
    L=(f=parseFloat)(l);
    R=f(r);
    return o=='*'?L*R:o=='/'?L/R:o=='+'?L+R:L-R;
};

M=/(\-?\d+\.?\d*)([\*\/\+\-])(\-?\d+\.?\d*)/;
for(s=prompt().replace(/ /g, "");M.test(s);s=s.replace(M,m)){};
alert(s)

Since I'm ending lines with semi-colons, all removable whitespace was ignored for character counting, but left in for clarity.

 Haskell - 124
let p=let f[x]=Just$read x;f(x:o:r)=lookup o[("-",(-)),("+",(+)),("*",(*)),("/",(/))]<*>f r<*>Just(read x)in f.reverse.words

The result will be wrapped in Maybe monad
λ: p"-2 + 6 / 2 * 8 - 1 / 2.5 - 18"
Just (-12.0)

Also it requires importing <*> from Control.Applicative, but imports can be done outside the code, so I hope it's allowed.

JavaScript (87 characters)
alert(prompt().split(/ +/).reduce((a,b,i)=>i%2?(o=b,a):o+1-0?a-b*-(o+1):o<'/'?a*b:a/b))

Java 10, 151 145 (as lambda function)
s->{float r=0,t,o=0,q;for(var x:s.split(" ")){if(x.length()>1|(q=x.charAt(0)-43)>4){t=new Float(x);r=o<0?r*t:o<1?r+t:o<3?r-t:r/t;}o=q;}return r;}

-6 bytes thanks to @ceilingcat.
Lambda function taking a String input and outputting a float.
Try it online.
Java 10, 241 235 bytes (as full program with asked I/O)
interface M{static void main(String[]a){float r=0,t;int o=43,q;for(var x:new java.util.Scanner(System.in).nextLine().split(" ")){if(x.length()>1|(q=x.charAt(0))>47){t=new Float(x);r=o<43?r*t:o<44?r+t:o<46?r-t:r/t;}o=q;}System.out.print(r);}}

Full program taking a String-line through STDIN and outputting to STDOUT.
Try it online.
Explanation:
interface M{                  // Class
  static void main(String[]a){//  Mandatory main-method
    float r=0,                //   Result float, starting at 0
          t,                  //   Temp float
          o=0,                //   Operator flag, starting at '+'
          q;                  //   Temp operator flag
    for(var x:new java.util.Scanner(System.in)
                              //   Create an STDIN-reader
               .nextLine()    //   Get the user input
               .split(" ")){  //   Split it on spaces, and loop over it:
      if(x.length()>1         //    If the current String length is larger than 1
                              //    (work-around for negative values)
         |(q=x.charAt(0)-43)>4){
                              //    Or the first character is an operator
                              //    (and set `q` to this first character at the same time)
        t=new Float(x);       //     Convert the String to a float, and set it to `t`
        r=                    //     Change `r` to:
          o<0?                //      If `o` is a '*':
            r*t               //       Multiply `r` by `t`
          :o<1?               //      Else-if `o` is a '+':
            r+t               //       Add `r` and `t` together
          :o<3?               //      Else-if `o` is a '-':
            r-t               //       Subtract `t` from `r`
          :                   //      Else (`o` is a '/'):
            r/t;}             //       Divide `r` by `t`
      o=q;}                   //    And at the end of every iteration: set `o` to `q`
    System.out.print(r);}}    //    Print the result `r` to STDOUT

05AB1E, 30 bytes
#ćs2ôívy`…+-*sk©i-ë®>i+ë®<i*ë/

Try it online or verify all test cases.
Explanation:
#           # Split the (implicit) input-string by spaces
 ć          # Pop the list, and push the remainder and first item separated to the stack
  s         # Swap so the remainder is at the top of the stack
   2ô       # Split it into parts of size 2 (operator + number pairs)
     í      # Reverse each pair so the numbers are before the operators
v           # Loop over each of the pairs:
 y`         #  Push the number and operator separated to the stack
   …+-*     #  Push a string "+-*"
       sk   #  Get the index of the operator in this string
         ©  #  Store this index in the register (without popping)
   i        #  If the index is 1 (the "-"):
    -       #   Subtract the numbers from each other
   ë®>i     #  Else-if the index is 0 (the "+"):
       +    #   Add the numbers together
   ë®<i     #  Else-if the index is 2 (the "*"):
       *    #   Multiply the numbers with each other
   ë        #  Else (the index is -1, so "/"):
    /       #   Divide the numbers from each other
            # (and output the result implicitly)

If an eval builtin was allowed, this could be an alternative approach (16 bytes):
#ćs2ôJv…(ÿ)y«}.E

Try it online or verify all test cases.
Explanation:
#ćs2ô    # Same as above
     J   # Join each operator+number pair together to a single string
v        # Loop over the operator+number strings:
 …(ÿ)    #  Surround the top of the stack in parenthesis
     y«  #  And append the operator+number string
}.E      # After the loop: evaluate the string using a Python-eval

This would change "-2 + 6 / 2 * 8 - 1 / 2.5 - 18" to "((((((-2)+6)/2)*8)-1)/2.5)-18" before using the eval builtin (using .E directly would give operator precedence of */ over +-, hence the conversion with parenthesis first).

ZX81 BASIC (might be cheating, so just for fun/non-competing), ~14 Tokenised BASIC bytes, 6 key entries without new line (ZX81 speak for enter)
1 INPUT A
2 PRINT A

Whilst this does not explicitly use any kind of "eval" functions, ZX81 BASIC evaluates any mathematical expressions in its ROM if you are inputing to a floating point variable of which A would be (like most 8-bit BASIC variants, string variables will have a $ at the end of the variable name). So when you enter the program and RUN it, you can type like 12+10*6 and this will output 72 (note the ZX81 keyboard has some odd key placements for +, /, - and * etc).
The byte count is as follows: as I recall, each line number is stored as 4 bytes, and INPUT is a single token, as is PRINT (you cannot free type in ZX81 BASIC to enter BASIC commands, so to enter the INPUT command, press I, and to enter the PRINT command, press P). I don't recall how many bytes are stored at the end of each BASIC line entered, but let's assume that it is a single byte, hence my estimate of 14 tokenised BASIC bytes. I'll find out the exact number at a later time (if this is not cheating).
You may try this online with the JtyOne Online ZX81 Emulator which helpfully has an interactive keyboard below the running emulator.


text:
Assembly Language Quine
Write the shortest possible assembly-language quine.
Use any ISA you want, unless it has a print-quine instruction or equivalent.  Examples include x86, MIPS, SPARC, MMIX, IBM BAL, MIX, VAX, JVM, ARM, etc.
You may link against the C standard library's _printf function (or the Java equivalent for JVM bytecode) for I/O.
Length will be judged both on instruction count and size of the data segment.  Solutions must contain at least two instructions.
The quine should print the assembly code, not the assembled machine code.

Oh wow, this sounds like a toughy

x86 Linux, AT&T syntax: 244
push $10
push $34
push $s
push $34
push $37
push $37
push $s
call printf
mov $0,%ebx
mov $1,%eax
int $128
s:.ascii "push $10
push $34
push $s
push $34
push $37
push $37
push $s
call printf
mov $0,%cebx
mov $1,%ceax
int $128
s:.ascii %c%s%c%c"

(I compiled it with this: gcc -nostartfiles -lc quine.S -o quine)

That's depressing, now :-(

I'd usually say "the right tool for the job", but then again, here it doesn't feel right :D

Seems to be more right than mine, though ;-)

can we get an explanation?

@NooneAtAll: it's the classic printf-based quine, just called from assembly instead of the more usual C.

gas for x86 Linux (89 88 bytes, seven instructions)
Technically, this is cheating.
mov $4,%al
mov $1,%bl
mov $b,%ecx
mov $89,%dl
int $128
mov $1,%al
int $128
b:.incbin"a"

Save in a file named a and assemble with the following commands to create the executable named a.out.
as -o a.o <a ; ld a.o

The directive .incbin includes a file verbatim at the current location. If you use this to include the source code itself, you get a nice quine.

@Calculuswhiz .incbin to include the source code is commonly considered off limits for quines.

Wouldn't it save a byte if you used mov $1,%al instead of mov %bl,%al?

@Calculuswhiz Indeed!

Couple things. 1. My compiler is requiring the space after the .incbin. Not sure if yours is. 2. You can get it down to 68 bytes if you get rid of the sys_exit. It segfaults, but still outputs as expected to stdout.

JVM Bytecode Assembly (via Jasmin) – 952 960 990
.class public Q
.super java/io/File
.method public static main([Ljava/lang/String;)V
.limit stack 9
getstatic java/lang/System/out Ljava/io/PrintStream;
ldc ".class public Q%n.super java/io/File%n.method public static main([Ljava/lang/String;)V%n.limit stack 9%ngetstatic java/lang/System/out Ljava/io/PrintStream;%nldc %c%s%c%nldc 3%nanewarray java/lang/Object%ndup%ndup%nldc 0%nldc 34%ninvokestatic java/lang/Integer/valueOf(I)Ljava/lang/Integer;%ndup_x2%naastore%nldc 2%nswap%naastore%ndup2%nswap%nldc 1%nswap%naastore%ninvokevirtual java/io/PrintStream/printf(Ljava/lang/String;[Ljava/lang/Object;)Ljava/io/PrintStream;%npop%nreturn%n.end method"
ldc 3
anewarray java/lang/Object
dup
dup
ldc 0
ldc 34
invokestatic java/lang/Integer/valueOf(I)Ljava/lang/Integer;
dup_x2
aastore
ldc 2
swap
aastore
dup2
swap
ldc 1
swap
aastore
invokevirtual java/io/PrintStream/printf(Ljava/lang/String;[Ljava/lang/Object;)Ljava/io/PrintStream;
pop
return
.end method

Sadly, Jasmin doesn't allow as many nice tricks as Microsoft's ilasm allows. But the JVM has a total of six different dup instructions that do all kinds of fun things. Reordering items on the stack is something .NET doesn't seem to support.
In any case, I guess none of my two entries are serious contenders for shortest code but I guess it's hard to make them much shorter. Therefore just for completeness :-)
Commented version with info about what's on the stack:
.class public Q
.super java/io/File
.method public static main([Ljava/lang/String;)V
.limit stack 9
getstatic java/lang/System/out Ljava/io/PrintStream;
ldc ".class public Q%n.super java/io/File%n.method public static main([Ljava/lang/String;)V%n.limit stack 9%ngetstatic java/lang/System/out Ljava/io/PrintStream;%nldc %c%s%c%nldc 3%nanewarray java/lang/Object%ndup%ndup%nldc 0%nldc 34%ninvokestatic java/lang/Integer/valueOf(I)Ljava/lang/Integer;%ndup_x2%naastore%nldc 2%nswap%naastore%ndup2%nswap%nldc 1%nswap%naastore%ninvokevirtual java/io/PrintStream/printf(Ljava/lang/String;[Ljava/lang/Object;)Ljava/io/PrintStream;%npop%nreturn%n.end method"
ldc 3       ; stack; System.out, string, 3
anewarray java/lang/Object    ; stack: System.out, string, Object[3]
dup
dup    ; stack: System.out, string, array, array, array
ldc 0  ; stack: System.out, string, array, array, array, 0
ldc 34   ; stack: System.out, string, array, array, array, 0, 34
invokestatic java/lang/Integer/valueOf(I)Ljava/lang/Integer;
dup_x2   ; stack: System.out, string, array, array, 34, array, 0, 34
aastore  ; stack: System.out, string, array, array, 34
ldc 2    ; stack: System.out, string, array, array, 34, 2
swap     ; stack: System.out, string, array, array, 2, 34
aastore  ; stack: System.out, string, array
dup2     ; stack: System.out, string, array, string, array
swap     ; stack: System.out, string, array, array, string
ldc 1    ; stack: System.out, string, array, array, string, 1
swap     ; stack: System.out, string, array, array, 1, string
aastore  ; stack: System.out, string, array
invokevirtual java/io/PrintStream/printf(Ljava/lang/String;[Ljava/lang/Object;)Ljava/io/PrintStream;
pop
return
.end method

History:

2011-02-07 02:09 (990) – First working version.
2011-02-07 02:11 (960) – ldc is shorter than bipush or iconst_*.
2011-02-07 02:30 (952) – Who says I need to inherit from java.lang.Object? Other class names are so much shorter :-)

GAS x86-64 for Linux (verified on GCC 10.1):
13 12 5 instructions
148 136 129 0 byte data section
298 274 260 51 49 byte source code
Self-imposed rules/assumptions:

No standard library (including printf and main) allowed.
No .incbin allowed. This is commonly considered input in quine challenges.
In a similar vein, I disallowed using the -D flag as this would likely trivialize the problem as well as any file-content accessing flags. All other flags are fair game.
If it's loaded in program memory, it's fair game. As long as no files are accessed.

lea .+174,%rsi;inc %di;lea 49,%dx;inc %ax;syscall

Annotated version:
// We rely on Linux initializing all GP registers to 0.

// The filename is loaded into memory at this location:
lea .+174,%rsi
inc %di
// Length
lea 49,%dx
inc %ax
// Write string
syscall
// Since there are no valid instructions after this, it crashes.
// Since Segfault info is not program output, we're good.

The ELF has no ".data" section. The program reads from the ".debug_line" section as if it were one, so that's why it's 0 bytes. This requires some setup.
The Hacks Voodoo Magic Setup
Save the file as lea .+174,%rsi;inc %di;lea 49,%dx;inc %ax;syscall.sx (ie, source + .sx) and compile with:
% qFile='lea .+174,%rsi;inc %di;lea 49,%dx;inc %ax;syscall.sx'
% gcc -g1 -nostdlib -no-pie $qFile -o quine

Explanation:

-g1 adds debugging info to ELF, which handily injects the filename too! This also means it gets loaded into memory at runtime!
-no-pie is required for two reasons:

We want to load a non-RIP-relative address
The debugging info doesn't get ASLR'ed away.

-nostdlib means we don't have to use main.

Verify with diff:
% ./quine > quineresult.sx; diff $qFile quineresult.sx
[1]    52466 segmentation fault (core dumped)  ./quine > quineresult.sx

The filename is not part of the true source code, as it is not part of the file's contents, which is why I only output this source one time. I originally penalized my source code because the filename is vital to the quine, but I realized that this was moot because the rules aren't scoring on source code size anyway. I guess this means I beat the accepted answer without printf!

Reading the edits, it seems like magic

No magic. Just hax.

Windows .COM Format: 307 characters
Assembles, using A86, to 51 bytes. Requires no external libraries other than the DOS Int21 AH=9 function (write string to stdout).
db 185
db  51
db   0
db 190
db   0
db   1
db 191
db  47
db   1
db 172
db 178
db  10
db 199
db   6
db  45
db   1
db  32
db  32
db 180
db   0
db 246
db 242
db 128
db 196
db  48
db 136
db  37
db  79
db  10
db 192
db 117
db 242
db 180
db   9
db 186
db  42
db   1
db 205
db  33
db 226
db 221
db 195
db 100
db  98
db  32
db  32
db  51
db  49
db  10
db  13
db  36

I'm afraid I count 357 bytes.  (and your program actually outputs 408)  Nice implementation, though.  You might want to include un-db'd assembly source so other viewers get a direct look.

@J B: I didn't include CR\NL. Looking at it now, I really should have put the data into a single db line. That would make it smaller.

NASM, 223 bytes
%define a "%define "
%define b "db "
%define c "%deftok "
%define d "a, 97, 32, 34, a, 34, 10, a, 98, 32, 34, b, 34, 10, a, 99, 32, 34, c, 34, 10, a, 100, 32, 34, d, 34, 10, c, 101, 32, 100, 10, b, 101, 10"
%deftok e d
db e

Beating the accepted answer!

.NET CIL – 623 669 691 723 727
.assembly H{}.method void M(){.entrypoint.locals init(string)ldstr".assembly H{0}{1}.method void M(){0}.entrypoint.locals init(string)ldstr{2}{3}{2}stloc 0ldloc 0ldc.i4 4newarr object dup dup dup dup ldc.i4 0ldstr{2}{0}{2}stelem.ref ldc.i4 1ldstr{2}{1}{2}stelem.ref ldc.i4 2ldc.i4 34box char stelem.ref ldc.i4 3ldloc 0stelem.ref call void[mscorlib]System.Console::Write(string,object[])ret{1}"stloc 0ldloc 0ldc.i4 4newarr object dup dup dup dup ldc.i4 0ldstr"{"stelem.ref ldc.i4 1ldstr"}"stelem.ref ldc.i4 2ldc.i4 34box char stelem.ref ldc.i4 3ldloc 0stelem.ref call void[mscorlib]System.Console::Write(string,object[])ret}

A single line, no line break at the end.
Formatted and commented first version (even though it isn't a quine anymore) – it's unlikely that I deviate much from the general concept:
.assembly H{}
.method void M() {
  .entrypoint
  .locals init (
    string,
    object[]
  )
  // the string
  ldstr".assembly H{0}{1}.method void M(){0}.entrypoint.locals init(string,object[])ldstr{2}{3}{2}stloc.0 ldloc.0 ldc.i4.4 newarr object stloc.1 ldloc.1 ldc.i4.0 ldstr{2}{0}{2} stelem.ref ldloc.1 ldc.i4.1 ldstr{2}{1}{2} stelem.ref ldloc.1 ldc.i4.2 ldc.i4 34 box char stelem.ref ldloc.1 ldc.i4.3 ldloc.0 stelem.ref ldloc.1 call void[mscorlib]System.Console::Write(string,object[])ret{1}"
  stloc.0   // store in first local var
  ldloc.0   // load again. Going to be the first argument to Console::Write
  ldc.i4.4 newarr object stloc.1   // create new array and store in local var
  ldloc.1 ldc.i4.0 ldstr"{" stelem.ref   // we need a literal brace
  ldloc.1 ldc.i4.1 ldstr"}" stelem.ref   // closing, too
  ldloc.1 ldc.i4.2 ldc.i4 34 box char stelem.ref   // double quote
  ldloc.1 ldc.i4.3 ldloc.0 stelem.ref   // our format string from before
  ldloc.1 // load array
  call void[mscorlib]System.Console::Write(string,object[]) // output
  ret
}

History:

2011-02-06 16:48 (727) – First working version.
2011-02-06 17:14 (723) – I don't need a space after a string literal.
2011-02-06 17:21 (691) – dup is shorter than writing ldloc.1 every time.
2011-02-06 17:24 (669) – I don't need spaces after any literal and things like ldloc.1 can be written as ldloc 1 to make the last token a literal. The resulting bytecode is likely larger, but it's about the assembler code so I couldn't care less :-)
2011-02-06 17:34 (623) – I don't need the object[] as a local variable; I can do all that on the stack directly. Nice.

Seems like you've removed the object[] from the unformatted version, but not the formatted one...

@Aurel: Indeed, as noted, the formatted is the very first version. The idea is still the same so I won't update it again.

gas for x86 Linux, 184 176 bytes
.globl main
main:movw $34,B+87
push $B
call printf
call printf
pop B
ret
.data
B:.ascii".globl main
main:movw $34,B+87
push $B
call printf
call printf
pop B
ret
.data
B:.ascii"

Build with gcc -m32 -o a.out quine.S. (The -m32 is optional if your OS is already 32-bit.)
Edited to add: If we modify the rules to allow puts to be called instead of printf then it can be done in 182 174 bytes:
.globl main
main:movw $34,B+86
push $B+1
call puts
call puts
pop B
ret
.data
B:.ascii"
.globl main
main:movw $34,B+86
push $B+1
call puts
call puts
pop B
ret
.data
B:.ascii"

(Note that this one, unlike the previous one, has a terminating newline.)

I appreciate the shortness.  But I do feel cheated by the fact that in addition to printf/puts, you actually depend on the standard C prolog/epilog, which isn't explicitely allowed.  And IMHO wasn't meant to be; but I've got the top answer: obviously I'm biased :-)

Well, one could argue that using the C prolog/epilog is implicitly allowed, due to the mention of using printf(). libc functions don't always behave reliably if you bypass the C prolog/epilog. In fact on my system, your version doesn't work if I pipe the output to a file, because stdout only gets flushed in the C epilog code. (Had we instead used write(), which is just a wrapper around a syscall, it would have worked either way.)

It's a been pretty long time now, but I seem to recall the C functions' being allowed was a surprise to me back then: it did make the problem sound kind of impure.  OP hasn't been around in a long time either; it's going to be hard to request clarification now.

Note that the ABI allows printf to clobber its args on the stack.  It's not technically safe to just call it again and expect the same args, but it works in practice because gcc / clang never use args slots as scratch space, AFAIK.

Also, in general it's not safe to call printf from _start (e.g. in a static binary), so that is a good argument for writing a main instead of a _start.  This answer explains the various ways of linking libc from static or dynamic binaries.  (In a Linux dynamic binary, the dynamic linker will run glibc's initializer functions, so you can use printf from the _start entry point, but that's not the case on cygwin IIRC.)

You could strike a balance here and call the libc exit(3) function instead of returning from main, so you're not taking advantage of the CRT code to exit your process.  That will flush output buffers for you.

Also, I think (B+90) doesn't need the parens.  B+90 is a memory operand in AT&T syntax.

@PeterCordes Argh, of course. Thanks for pointing that out.

Bootable ASM, 660 bytes
[bits 16]
mov ax,07C0h
mov ds,ax
mov ah,0
mov al,03h
int 10h
mov si,code
call p
jmp $
p:mov ah,0Eh
r:lodsb
cmp al,0
je d
cmp bx,0x42
jne s
c:int 10h
jmp r
s: cmp al,94
je re
cmp al,63
je q
jmp c
q:mov al,34
jmp c
re:push si
mov bx,0x42
mov si,code
call p
mov bx,0
pop si
jmp p
d:ret
code:db "[bits 16]\mov ax,07C0h\mov ds,ax\mov ah,0\mov al,03h\int 10h\mov si,code\call p\jmp $\p:mov ah,0Eh\r:lodsb\cmp al,0\je d\cmp bx,0x42\jne s\c:int 10h\jmp r\s:cmp al,94\je re\cmp al,63\je q\jmp c\q:mov al,34\jmp c\re:push si\mov bx,0x42\mov si,code\call p\mov bx,0\pop si\jmp p\\d:ret\\code:db ?^?\times 510-($-$$) db 0\dw 0xAA55"
times 510-($-$$) db 0
dw 0xAA55

Originally by jdiez17, golfed by yours truly.

NASM defaults to bits 16 so you can drop that from your source.

x86-64, System V AMD64 ABI, GASM: 432
.att_syntax noprefix
.globl main
main:
pushq rbp
movq rsp, rbp
mov $.Cs, rdi
mov $0xa, rsi
mov $0x22, edx
mov $.Cs, ecx
mov $0x22, r8d
mov $0xa, r9d
xor eax, eax
call printf
xor eax, eax
leave
ret
.Cs: .string ".att_syntax noprefix
.globl main
main:
pushq rbp
movq rsp, rbp
mov $.Cs, rdi
mov $0xa, rsi
mov $0x22, edx
mov $.Cs, ecx
mov $0x22, r8d
mov $0xa, r9d
xor eax, eax
call printf
xor eax, eax
leave
ret%c.Cs: .string %c%s%c%c"

You don't need a space after the comma between operands.  And you don't need xor eax,eax at all if you don't care about the exit status of your program.  It still prints itself, even if it exits with a non-zero status.  You can also use push instead of pushq.  Actually, why are you even making a stack frame at all?  Drop the push rbp / mov rsp, rbp and leave.   You could also use shorter label names.  .Cs is 3 characters when 1 would be fine.

After that, .att_syntax noprefix probably doesn't pay for itself anymore.  .intel_syntax noprefix would let you drop those six $ prefixes, too. but probably still not worth it.  (You could use lea ecx,.Cs instead of the intel-syntax mov ecx,offset .Cs)

80x86 TASM, 561 bytes
MODEL TINY
.CODE
.STARTUP
DB 177
DB 076
DB 186
DB 044
DB 001
DB 172
DB 180
DB 036
DB 179
DB 004
DB 191
DB 080
DB 001
DB 079
DB 136
DB 037
DB 212
DB 010
DB 004
DB 048
DB 134
DB 196
DB 075
DB 117
DB 244
DB 180
DB 009
DB 205
DB 033
DB 178
DB 071
DB 226
DB 228
DB 178
DB 038
DB 205
DB 033
DB 195
DB 013
DB 010
DB 069
DB 078
DB 068
DB 036
DB 077
DB 079
DB 068
DB 069
DB 076
DB 032
DB 084
DB 073
DB 078
DB 089
DB 013
DB 010
DB 046
DB 067
DB 079
DB 068
DB 069
DB 013
DB 010
DB 046
DB 083
DB 084
DB 065
DB 082
DB 084
DB 085
DB 080
DB 013
DB 010
DB 068
DB 066
DB 032
END

I wrote this in assembly on paper and assembled it into machine code by hand with an opcode chart. I then entered the machine code into the program editor on the TI-84 Plus CE and executed it with asm(. It starts at it's own load address, copies that byte into the accumulator, then makes a system call that prints the contents of the accumulator in ascii on the display and repeats for every byte of the program, essentially printing it's own machine code.... Is it technically a quine because I didn't use a computer to assemble it and because the exact code I entered into the calculator is printed by the program itself?
This is ez80 machine language on a TI-84 Plus CE:
34 bytes. First byte loads @ D1A881, whitespace ignored:
181F
50
7E
23
0602
4F
07070707
E60F
C630
FE3A
3802
C607
CDB80702
79
10EF
42
10E2
C9
C9

Welcome to Code Golf! This looks like a very impressive answer!

Can you edit in the score per the scoring criteria? (Instruction count and data segment size)

TAL
push puts
push \100
push {push puts
push \100
push {@}
dup
strmap
invokeStk 2}
dup
strmap
invokeStk 2

To execute it, call ::tcl::unsuppoted::assemble with the code as argument.
Tcl 8.6 only.

You should include the byte count.