text:
What are my dimensions?
Task: Given the area of a triangle, find a Heronian triangle with that area. Any Heronian triangle with the specified area is allowed.
A Heronian triangle is a triangle with integer sides and integer area. By Heron's formula, a triangle with sides lengths a,b,c has area
sqrt(s*(s-a)*(s-b)*(s-c))

where s=(a+b+c)/2 is half the perimeter of the triangle. This can also be written as
sqrt((a+b+c)*(-a+b+c)*(a-b+c)*(a+b-c)) / 4

If no such triangle exists, output with a consistent falsey value.
Input: A single, positive integer representing the area of the triangle.
Output: Any three side lengths for such a triangle OR a falsely value.
Examples:
Input -> Output
6 -> 3 4 5
24 -> 4 15 13
114 -> 37 20 19
7 -> error

Standard loopholes apply
This is code golf, shortest answer in bytes wins.

Can you write a relatively concise definition of a Heronian triangle in your challenge?

@Okx: Is it not clear that it is a triangle with integer sides and integer area?

@Okx: That is the idea. All you need to do is find one such example for the given area if it exists.

From the Wikipedia link: "A Heronian triangle is a triangle that has side lengths and area that are all integers."

I understand now, but you might want to make it clearer in the question.

Could you please explain what is confusing about the definition in the question?

@NeilA. I think what people were looking for were the relevant formulas without needing to follow a link. I editing those in.

Jelly, 17 16 bytes
-1 byte thanks to Erik the outgolfer (make use of the quick, ¥)
SHð;_P
ṗ3Ç⁼¥Ðf²Ḣ

Brute force application of Heron's formula.
Try it online! (reaches the 60s time out for the 114 tests case. Takes 3m 30s locally - it does check 1143 = 1,481,544 triples)
How?
A true golf solution - given an area a it finds all tuples of three integers between 1 and a (even with repeated triangles and ones of no area), gets their area and filters for those with the desired area (it doesn't even stop as soon as one is found, it ploughs through them all and pops the first result afterwards). Yields 0 if none exists.
SHð;_P - Link 1, get the square of the area of a triangle: list of sides
S      - sum the sides (get the perimeter)
 H     - halve
  ð    - dyadic chain separation (call that p)
    _  - subtraction (vectorises) =    [p-side1,  p-side2,  p-side3]
   ;   - concatenate              = [p, p-side1,  p-side2,  p-side3]
     P - product                  =  p*(p-side1)*(p-side2)*(p-side3)
                                  = the square of Heron's formula = area squared

ṗ3Ç⁼¥Ðf²Ḣ - Main link: number a (area)
ṗ3        - third Cartesian power (all triples of [1,area] : [[1,1,1],[1,1,2],[1,2,1],[1,2,2],[2,1,1],[2,1,2],[2,2,1],[2,2,2], ... ,[a,a,a]]
       ²  - square a
     Ðf   - filter keep if:
    ¥     -   last two links as a dyad:
  Ç       -     call last link (1) as a monad f(list of sides)
   ⁼      -     left (that result) equals right (square of a)?
        Ḣ - head - get the first one (an empty list yields 0, perfect for the falsey case)

I figured someone would try to brute force this, nice!

@NeilA. I imagine most golf submissions will be brute force for this challenge - but some may manage to be golfed while being less ridiculously inefficient than this one.

You can replace ç with Ç⁼¥ and remove the second line entirely.

@EriktheOutgolfer Oh, thanks, I was wondering how to go about that...

JavaScript (ES7), 109 102 100 98 bytes
Returns either an array of 3 integers or false. Like the Jelly answer, this is brute forcing Heron's formula.
A=>[...Array(A**3)].some((_,a)=>A*A/(r=[b=a/A%A|0,c=a/A/A|0,a%=A],p=a+b+c>>1)/(p-a)/(p-b)==p-c)&&r

Test cases

let f =

A=>[...Array(A**3)].some((_,a)=>A*A/(r=[b=a/A%A|0,c=a/A/A|0,a%=A],p=a+b+c>>1)/(p-a)/(p-b)==p-c)&&r

console.log(JSON.stringify(f(6)))
console.log(JSON.stringify(f(24)))
console.log(JSON.stringify(f(114)))
console.log(JSON.stringify(f(7)))

Recursive version, 83 bytes
Returns an array of 3 integers or throws a recursion error. Sadly, it only works for small inputs.
f=(A,n)=>A*A/(r=[a=n%A,b=n/A%A|0,c=n/A/A|0],p=a+b+c>>1)/(p-a)/(p-b)==p-c?r:f(A,-~n)

Demo

f=(A,n)=>A*A/(r=[a=n%A,b=n/A%A|0,c=n/A/A|0],p=a+b+c>>1)/(p-a)/(p-b)==p-c?r:f(A,-~n)

console.log(JSON.stringify(f(6)))
console.log(JSON.stringify(f(24)))

Haskell, 69 bytes
f a=take 1[t|t<-mapM(\_->[1..a])":-)",a*a==product[sum t/2-x|x<-0:t]]

Try it online!
Outputs a singleton of a list of three triangle sides like [[3.0,4.0,5.0]]. Impossible inputs give []. Technically only False is Falsey for Haskell, but because Haskell requires all possible outputs to be of the same type, it can't be used. If an error could be used as Falsey, [...]!!0 would save 3 bytes over take 1[..].
Tries all triples t of possible side lengths each ranging from 1 to the area a. Heron's formula is used to check if the area matches via (s-0)(s-x)(s-y)(s-z)==a*a where s=(x+y+z)/2 is sum t/2. The product (s-0)(s-x)(s-y)(s-z) is expressed as a product with elements taken from 0:t, i.e. the triple as well as 0.

+1 for smiley face, even if it's sorta a noop

Python 2 (PyPy), 131 123 118 bytes
n=input()
t=n*3;r=i=c=0
while c<t:
 i+=1;a,b,c=i%t,i/t%t,i/t/t;s=a+b+c>>1
 if(s-a)*s*(s-b)*(s-c)==n**2:r=a,b,c
print r

Try it online!
While this also works on CPython, PyPy is a lot faster and is able to compute the triangle for 114 in the time limit on TIO.
Timings from my machine:
$ echo 114 | time pypy2 d.py
        0.55 real         0.52 user         0.02 sys
$ echo 114 | time python2 d.py
       52.46 real        51.76 user         0.27 sys

F#, 170 156 152 bytes
let f(a,b,c)=
 let s=(a+b+c)/2.0
 s*(s-a)*(s-b)*(s-c)
let g A=[for a in 1.0..A do for b in a..A do for c in b..A do yield a,b,c]|>List.find(f>>(=)(A*A))

Try it online!
"Ungolfed"
let calculateArea (a, b, c) =
    let s = (a+b+c)/2.0
    s*(s-a)*(s-b)*(s-c)

let getTriangle A =
    [  for a in 1.0..A do
       for b in a..A do
       for c in b..A do yield a,b,c
    ]
    |> List.find(calculateArea>>(=)(A * A))

If there are no results found, the program will fault. If this is not desired, I have to replace List.find with either List.filter (+2 bytes) which will produce an empty list in case nothing is found or List.tryFind (+3 bytes), returning None in case no triangle was found.
I always find that a golfed F# version is still reasonable legible.

I don't know F#, but I imagine you could dispense with the System.Math.Sqrt and compare the resulting value to A * A?

@Sean Of course! Thanks for the tip :)

Replacing 1.0..A [...] 1.0..A [...] 1.0..A with 1.0..A [...] a..A [..] b..A should save you a couple bytes and speed you up a little (if it works; I have very minimal F# experience).

@CAD97 It does! Thanks for pointing that out.

Wolfram Language (Mathematica), 59 bytes
Solve[Area@SSSTriangle[a,b,c]==#>c>b>a>0,{a,b,c},Integers]&

Try it online!

Pyth - 23 bytes
/mu*G-/sd2Hd/sd2^UQ3^Q2

Which prints a truthy/falsy value, or
fq^Q2u*G-/sT2HT/sT2^UQ3

which prints out all possible solutions, and is horribly slow for large inputs.  Put 'h' at the beginning to only print one.
Explanation:
fq^Q2u*G-/sT2HT/sT2^UQ3
                    UQ    # List of numbers from 0 to input-1
                   ^  3   # All triples of these numbers
f                         # Filter this by the following test (on variable T, based on Hero's formula)
     u*G-/sT2HT/sT2       # s*(s-a)*(s-b)*(s-c), where s is the sum of the triple over 2 (calclated as /sT2 )
 q^Q2                     # Test if equal to input ^2

Try it

Perl 6, 54 bytes
->\a{first {a*a==[*] .sum/2 «-«(0,|$_)},[X] ^a xx 3}

Brute force search of all possibles sides up to one less than a, the input area.

^a is the range of numbers from 0 to a - 1.
[X] ^a xx 3 reduces, by cross product, three copies of that range, producing all triplets from (0, 0, 0) to (a - 1, a - 1, a - 1).
We look for the first triplet such that the area of the triangle with those sides equals a, using Heron's formula.

Within the code block given to first:

$_ is the triplet.  Call it (x, y, z) here.
(0,|$_) is the same triplet but with 0 prepended: (0, x, y, z).
.sum / 2 is half the perimeter (a quantity which is named s in the usual expression of Heron's formula).
.sum / 2 «-« (0, |$_) is the subtraction hyperoperator with s on the left and the (0, x, y, z) on the right, giving (s - 0, s - x, s - y, s - z).
[*] then reduces that quadruplet with multiplication, giving the square of the area.
a * a == looks for a squared area equal to the square of the given area.

If no triplet is found, Nil (which is falsey) is returned.

Mathematica, 77 bytes
with mathematica's Solve
s=(a+b+c)/2;d=Sqrt[s(s-a)(s-b)(s-c)];Solve[d==#&&0<a<b<c<#,{a,b,c},Integers]&

Mathematica, 117 bytes
brute force
s=(a+b+c)/2;l="error";(For[a=1,a<#,a++,For[b=1,b<a,b++,For[c=1,c<b,c++,If[Sqrt[s(s-a)(s-b)(s-c)]==#,l={a,b,c}]]]];l)&

Mathematica doesn't have a builtin? Surprising.

@ovs you can save one byte on that with Area@SSSTriangle[a,b,c] too.

Haskell, 76 bytes
f s=[[a,b,c]|a<-[1..s],b<-[1..a],c<-[1..b],a*a*c*c-(a*a+c*c-b*b)^2/4==4*s*s]

This outputs a list of lists containing all possible integral sizes that generate the correct area via brute force (outputting the empty list if there are none). The caveat being it outputs them as doubles because of that division in the middle but their fractional part is always 0.
If you for some reason can't take that,
f s=[[a,b,c]|a<-[1..s],b<-[1..a],c<-[1..b],4*a*a*c*c-(a*a+c*c-b*b)^2==16*s*s]

This will output the answers as a list of integer lists for 89 77 bytes total or 13 1 extra bytes. (Thanks to Neil)
If you need / want only the first element just putting !!0 at the end will give you only the first element if there are numbers that apply and an error if there's none for 3 more bytes and take 1 at the beginning will take the first element without erroring out for 6 more bytes.
Try it online!

If you want to avoid doubles can't you just multiply the equation by 4 on each side?

TI-Basic, 70 69 bytes
Prompt A
For(B,1,A
For(C,1,B
For(D,1,C
(B+C+D)/2
If A2=Ansprod(Ans-{B,C,D
Then
Disp B,C,D
Return
End
End
End
End
/
Displays the three side lengths if there is a triangle, throws a syntax error if there isn't (thanks to the / at the end).
-1 byte thanks to Sean's comment on a different answer

Actually, 22 bytes
;╗R3@∙⌠;Σ½;)♀-π*╜²=⌡░F

Try it online!
Explanation:
;╗R3@∙⌠;Σ½;)♀-π*╜²=⌡░F  (implicit input: A)
;╗                      store a copy of A in register 0
  R                     range(1, A+1)
   3@∙                  ternary Cartesian product (all triples with values in [1, A])
      ⌠;Σ½;)♀-π*╜²=⌡░   filter: take triples where function returns truthy
       ;Σ½                make a copy of the triple, compute s = (a+b+c)/2
          ;)              make a copy of s, move it to the bottom of the stack
            ♀-            subtract each value in the triple from s
              π*          product of those values and s (s*(s-a)*(s-b)*(s-c))
                ╜²        A*A
                  =       compare equality (does area of triangle with given dimensions equal input?)
                     F  take first triple that satisfies the filter (or empty list if none)

Casio Basic, 123 bytes
For 1⇒a To n
For 1⇒b To n
For 1⇒c To n
If(s*(s-a)*(s-b)*(s-c)|s=(a+b+c)/2)=n^2
Then
Print{a,b,c}
Stop
IfEnd
Next:Next:Next

Standard brute force solution. 122 bytes for the code, 1 byte to specify n as a parameter.

Perl 5, 119 + 2 -pa = 121 bytes
for$a(1..$_){for$b(1..$_){map{($t=($s=($a+$b+$_)/2)*($s-$a)*($s-$b)*($s-$_))>0&&"@F"==sqrt$t&&($\="$a $b $_")}1..$_}}}{

Try it online!

JavaScript (Node.js), 90 bytes
S=>(g=(a,b,c,r=(a+b+c)/2)=>r*(r-a)*(r-b)*(r-c)^S*S?!c&&g(S,a,b)||--a&&g(a,b,c):[a,b,c])(S)

Try it online!
JavaScript (Node.js), 92 bytes
S=>(g=(a,b,c,r=(a+b+c)/2)=>(c?r*(r-a)*(r-b)*(r-c)==S*S&&[a,b,c]:g(S,a,b))||--a&&g(a,b,c))(S)

Try it online!
Usual search
Where's the proof every length <= area?

Uiua, 54 Bytes
Standard bruteforce solution. Returns all possible results.
▽=⊙:≡(√/×⊂-:⊙:.÷2/+.).☇1+1⇡⊂⊂...

Try It
Explanation:
▽=⊙:≡(√/×⊂-:⊙:.÷2/+.).☇1+1⇡⊂⊂...
                       ☇1+1⇡⊂⊂... # generate tuples [1, a]^3
                      . # save a copy to output
    ≡(√/×⊂-:⊙:.÷2/+.) # for each side length tuple calculate the area
                    . # save a copy of the current tuple so we can do s-a,s-b,s-c later
                ÷2/+ # calculate s by summing and dividing by 2
               . # copy s so we can multiply by it later
           :⊙: # bring the saved tuple to the top of the stack
          - # calculate s-a,s-b,s-c
         ⊂ # join s to the array containing [s-a,s-b,s-c]
       /× # reduce multiply to get the product of all of the elements
      √ # final square root to calculate area
  ⊙: # bring area we are looking for up to the second position in the stack
 = # create a boolean mask which selects all areas which matched
▽ # keep the tuples that had the correct area


text:
Who's that Polygon?
A convenient and useful way to represent topological surfaces is with a fundamental polygon.  Each side on a polygon matches to another side and can be either parallel or anti-parallel.  For instance the here is the fundamental polygon of a torus:

To figure out why this is a torus we could imagine our polygon being a sheet of paper.  To make the proper surface we want to bend our paper so that the corresponding edges line up with their arrows going the same way.  For our torus example we can start by rolling the paper into a cylinder so that the two blue edges (labeled b) are connected.  Now we take our tube and bend it so that the two red edges (labeled a) connect to each other.  We should have a donut shape, also called the torus.
This can get a bit trickier.  If you try to do the same with the following polygon where one of the edges is going in the opposite direction:

you might find yourself in some trouble.  This is because this polygon represents the Klein bottle which cannot be embedded in three dimensions.  Here is a diagram from wikipedia showing how you can fold this polygon into a Klein bottle:

As you may have guessed the task here is to take a fundamental polygon and determine which surface it is.  For four sided polygons (the only surfaces you will be required to handle) there are 4 different surfaces.
They are

Torus
Klein Bottle
Sphere
Projective plane

Now this is not image-processing so I don't expect you to take an image as input instead we will use a convenient notation to represent the fundamental polygon.  You may have noticed in the two examples above that I named corresponding edges with the same letter (either a or b), and that I gave the twisted edge an additional mark to show its twisted.  If we start at the upper edge and write down the label for each edge as we go clockwise we can get a notation that represents each fundamental polygon.
For example the Torus provided would become abab and the Klein Bottle would become ab-ab.  For our challenge we will make it even simpler, instead of marking twisted edges with a negative we will instead make those letters capitalized.
Task
Given a string determine if it represents a fundamental polygon and output a value that corresponding to the proper surface of it is.  You do not need to name the surfaces exactly, you just need 4 output distinct values each representing one of the 4 surfaces with a fifth value representing improper input.  All of the basic cases are covered in the Simple Tests section, every car will be isomorphic to one of the or invalid.
Rules

Sides will not always be labeled with a and b, but they will always be labeled with letters.
Valid input will consist of 4 letters, two of one type and two of another.  You must always output the correct surface for valid input.
You should reject (not output any of the 4 values representing surfaces) invalid input.  You may do anything when rejecting an input, as long as it is distinguishable from the 4 surfaces
This is code-golf so the goal is to minimize the number of bytes in your source code.

Tests
Simple Tests
abab Torus
abAb Klein Bottle
abaB Klein Bottle
abAB Projective Plane
aabb Klein Bottle
aAbb Projective Plane
aabB Projective Plane
aAbB Sphere
abba Klein Bottle
abBa Projective Plane
abbA Projective Plane
abBA Sphere

Trickier Tests
ABAB  Torus
acAc  Klein Bottle
Emme  Projective Plane
zxXZ  Sphere
aaab  Bad input
abca  Bad input
abbaa Bad input
ab1a  Bad input

Why is abab a torus and aabb a Klein bottle?

@Neil abab is the example in the first paragraph, you can look there for an explanation.  Here is an image showing why aabb is the same as abAb which is a Klein bottle.

Does this have to do with your new language Klein by the way?

"...but they will always be labeled with letters" what does this add to the challenge, why not allow any base four representation as input?

@JonathanAllan I'm not sure what you mean by base four representation.  I chose letters because other symbols usually don't have upper and lower case versions.

You have a representation for which valid input is a subset of the four digit base four numbers (i.e. your digits are a, b, A, and B).

@JonathanAllan I don't think I would want to do that.  The challenge is really an input processing challenge, there is not a lot of actual math going on behind the scenes.  I think turning it into a base 4 challenge would make it too simple.  The challenge is pretty simple as is.

Well I have not worked out all the rules, but maybe I am simple :p

What bad inputs do we have to handle and identify as bad? All possible strings? Printable ASCII? Any limits on length? If we write a function, might it be passed a non-string object? Really, this whole input processing business strikes me as a chameleon challenge.

@xnor You will only receive strings other than that they may contain anything.  Don't get me wrong this challenge is an input processing challenge.  Any reasonable solution will do very little actual math.

@WheatWizard In that case, can you please make that clear in the title and body? It reads like math all the way until Rules, and even there it's easy to miss the gamechanging requirement to validate rather than just classify.

Separately, I think an explanation is missing of what makes a string be classified into a given category, since you seem not to expect people to do out the math behind the classification. I think I could puzzle out the rules from test cases, but that's far from ideal.

@xnor I've hopefully made it clear it's a input processing challenge if it's not feel free to inform me or edit it yourself. However I can't implement your second suggestion at this moment.  I assure you every possible shape is covered in the simple cases section with the only variation being choice of letter or inferring the case on a pair, but I'll try to make it clear later.

so a sphere is a polygon?

Retina, 123 bytes
i`(.)(\1..)
$2$1
iG`^([a-z])(?!\1)([a-z])(\1\2|\2\1)$
(..)\1
T
.*(.).\1.*|(.)(.)\3\2
B
(.)..\1|.(.)\2.
P
i`(.)..\1
S
....
P

Try it online! Thanks to @JonathanAllen for pointing out a bug in my code and also how to save some bytes; I also golfed some more bytes myself so I can't credit him for a specific figure. Explanation:
i`(.)(\1..)
$2$1

If the first two letters are the same (ignoring case), move the first letter to be fourth. This reduces the number of cases that I need to test.
iG`^([a-z])(?!\1)([a-z])(\1\2|\2\1)$

If there are not exactly four letters, or the first two letters are the same, or the last two letters do not duplicate the first two, then delete everything.
(..)\1
T

The torus is the easy case: a pair of letters, repeated matching case.
.*(.).\1.*|(.)(.)\3\2
B

If one of the pair matches case (in which case other of the pair must mismatch case), then that is a Klein bottle. Alternatively, if the pair matches case but is reversed, then it is also a Klein bottle.
(.)..\1|.(.)\2.
P

If on the other hand the pair is reversed, but only one of the pair matches case, then that is a projective plane.
i`(.)..\1
S

And if the pair is reversed but neither matches case, then that is a sphere. (i`.(.)\1. would also work.)
....
P

Everything else is a projective plane.

@JonathanAllan Thanks for the tip; hopefully this version has better validation.

If only I could work out the logic myself :p

Jelly, 52 51 58 bytes
+7 bytes, I found that the mapping I'd used did not work for some (off example) case change scenarios.
“nḲ⁾⁶ƥ¦ṃṗḋ’b4s4‘µṙJ;U$µ€
,ŒsṢÞṪµŒlĠL€⁼2,2ȧ⁸i@€ṢeÐ€¢TṪ’:3,8

A monadic link taking a string and returning the following five distinct, consistent values:

[-1,-1] - invalid input
[0,0] - projective plane
[1,0] - Klein bottle
[2,0] - sphere
[2,1] - torus

Try it online! or see the test suite.
How?
Any fundamental polygon is:

unchanged under rotation - one may turn the paper like a steering wheel
unchanged under reflection - one may turn the paper over
unchanged under case reversal - one may swap as and As and/or swap bs and Bs with no effect - since we want to match the directions the actual label is inconsequential.

As such there are nine equivalence classes. The code creates lists of four integers each representing an example of one of the nine equivalence classes, creates the four rotations of each, reflects each of those and then checks if a translated form of the input exists in each list. The classes are ordered P,P,P,K,K,K,S,S,T, so taking the 0-based index integer divided by each of [3,8] yields the four valid outputs (indexing is 1-based and the atom e returns 0 for non-existence, so subtracting 1 and integer dividing by each of [3,8] yields [-1,-1] for the invalid case).
“nḲ⁾⁶ƥ¦ṃṗḋ’b4s4‘µṙJ;U$µ€ - Link 1, symmetries of the 9 equivalence classes: no arguments
“nḲ⁾⁶ƥ¦ṃṗḋ’              - base 250 number                 1704624888339951310984
           b4            - convert to base 4               [1,1,3,0,1,2,2,0,1,2,3,0,0,2,2,0,1,3,1,0,2,1,2,0,2,3,1,0,3,1,2,0,2,0,2,0]
             s4          - split into 4s                   [[1,1,3,0],[1,2,2,0],[1,2,3,0],[0,2,2,0],[1,3,1,0],[2,1,2,0],[2,3,1,0],[3,1,2,0],[2,0,2,0]]
               ‘         - increment (vectorises)          [[2,2,4,1],[2,3,3,1],[2,3,4,1],[1,3,3,1],[2,4,2,1],[3,2,3,1],[3,4,2,1],[4,2,3,1],[3,1,3,1]]
                µ     µ€ - for €ach:                       ...e.g. [2,2,4,1]:
                  J      -   range of length               [1,2,3,4]
                 ṙ       -   rotate left by (vectorises)   [[2,4,1,2],[4,1,2,2],[1,2,2,4],[2,2,4,1]]
                     $   -   last two links as a monad:
                    U    -     upend (reverse each)        [[2,1,4,2],[2,2,1,4],[4,2,2,1],[1,4,2,2]]
                   ;     -     concatenate                 [[2,4,1,2],[4,1,2,2],[1,2,2,4],[2,2,4,1],[2,1,4,2],[2,2,1,4],[4,2,2,1],[1,4,2,2]]

,ŒsṢÞṪµŒlĠL€⁼2,2ȧ⁸i@€ṢeÐ€¢TṪ’:3,8 - Main link: string s      e.g. "xOxO"
 Œs                               - swap case                     "XoXo"
,                                 - pair with s                   ["xOxO","XoXo"]
    Þ                             - sort by:
   Ṣ                              -   sort                        ["xOxO","XoXo"]
     Ṫ                            - tail                          "XoXo"
      µ                           - monadic chain separation, call that v
       Œl                         - convert to lowercase          "xoxo"
         Ġ                        - group indices by value        [[2,4],[1,3]]
          L€                      - length of each                [2,2]
             2,2                  - 2 pair 2                      [2,2]
            ⁼                     - equal? (1 if so, 0 if not)    1
                 ⁸                - link's left argument, v       "XoXo"
                ȧ                 - and (v if equal, 0 if not)    "XoXo"
                     Ṣ            - sort v                        "XoXo"
                  i@€             - first index for €ach          [1,3,1,3]
                         ¢        - call the last link (1) as a nilad
                       Ð€         - map over right:
                      e           -   exists in?                  [0,0,0,0,0,0,0,0,1]
                          T       - truthy indexes                [                9]
                           Ṫ      - tail (empty list yields 0)    9
                            ’     - decrement                     8
                              3,8 - 3 pair 8                      [3,8]
                             :    - integer division (vectorises) [2,1]

Note: 11 bytes (ŒlĠL€⁼2,2ȧ⁸) only validate the input string as being of the correct form - without this code every example case passes except that ab1a is evaluated as if it were abBa, a projective plane.

source: Stack Exchange

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

sort: votes


text:
ASCII Exact Cover with Rectangles
Challenge
Given a rectangular area arrange a group of rectangles such that they cover the rectangular area entirely.
Input

An integer denoting the height.

An integer denoting the width.

The dimensions of the rectangles consisting
of the following form: axb,cxd,... where a,b,c, and d are integers - any reasonable format is acceptable.

Output
An exact cover of the rectangular area.
Rectangles used to cover the area are represented in the following way:
2x3
00
00
00

or
000
000

1x3
0
0
0

or
000

Each rectangle is represented using a character 0-9 where 0 is used for the first rectangle inputted 1 for the second and so on. The max number of rectangles given in input is therefore 10.
Test Cases
Input 1
5
7
4x2,3x2,3x2,5x2,5x1

Output 1
0000111
0000111
2233333
2233333
2244444

Input 2
4
4
3x2,2x1,2x2,2x2

Output 2
0001
0001
2233
2233

Input 3
2
10
4x2,3x2,3x2

Output 3
0000111222
0000111222

Clarifications

The dimensions of the rectangles used to cover the region are interchangeable e.g. for axb a could be the height or width same goes for b.
If there are multiple solutions any of them is acceptable (just display 1).
Assume all inputs are valid.
You can have a full program or a function (inputs may be treated broadly as 3 separate arguments).
Output to stdout (or something similar).
This is code-golf so shortest answer in bytes wins.

How do you handle cases with no solution/invalid input?

@JulianLachniet all inputs are assumed to be valid. I'll add this to post.

@JonathanAllan edited in "Clarifications" not sure if that's sufficient, if not I can try again.

@JonathanAllan I could paste in an edit if you have one. Sorry for the annoyance.

@JonathanAllan yeah that's great. Thanks

Related

Python 3, 262 bytes
from numpy import*
def g(h,w,t,m,i):
 if[]==t:print(m);return
 u,v=t[0]
 for _ in'12':
  for r,c in argwhere(m<0):
   if(m[r:r+u,c:c+v]<0).all()and u+r<=h and v+c<=w:e=copy(m);e[r:r+u,c:c+v]=i;g(h,w,t[1:],e,i+1)
  u,v=v,u
f=lambda h,w,t:g(h,w,t,zeros((h,w))-1,0)

Called like: f(4,4,[(3,2),(2,1),(2,2),(2,2)]).  It uses a brute force, recursive function that prints all solutions (uses fewer bytes).

APL (Dyalog Unicode), 76 bytes
⎕CY'dfns'
{⍺⍴v+.×(X m)⌿m←⊃⍪/(⍺∘{⍪↑,(⍳⍺)↓¨⊂⌽⊖⍺↑⍵⍴1}¨⊢∘⌽\2/⍵),⍤1¨2/↓∘.=⍨v←⍳≢⍵}

Try it online!
Dyalog APL comes with a built-in Exact Cover solver X, so the main part of the code is construction of the constraint matrix.
A constraint matrix is a boolean matrix where a column indicates a constraint, and a row indicates an action that satisfies some of the constraints. In the case of rectangle cover, an action is positioning of a specific rectangle at certain position and orientation, which satisfies two kinds of constraints: a specific rectangle is consumed, and the certain cells are covered by that rectangle.
For example, consider positioning a 2×3 rectangle in a 4×4 rectangular space. There are 12 ways to place it inside the space:
Horizontally
OOO. .OOO
OOO. .OOO
.... ....
.... ....

.... ....
OOO. .OOO
OOO. .OOO
.... ....

.... ....
.... ....
OOO. .OOO
OOO. .OOO

Vertically
OO.. .OO. ..OO
OO.. .OO. ..OO
OO.. .OO. ..OO
.... .... ....

.... .... ....
OO.. .OO. ..OO
OO.. .OO. ..OO
OO.. .OO. ..OO

If it is the second rectangle out of four rectangle pieces, a part of the constraint matrix would look like this (where type 1 constraints mark the rectangle used, and type 2 mark the cells occupied):
            <--           Type 2           -->
<-Type 1->  <-r1-->  <-r2-->  <-r3-->  <-r4-->
0 1 0 0     1 1 0 0  1 1 0 0  1 1 0 0  0 0 0 0
0 1 0 0     0 1 1 0  0 1 1 0  0 1 1 0  0 0 0 0
0 1 0 0     0 0 1 1  0 0 1 1  0 0 1 1  0 0 0 0
0 1 0 0     0 0 0 0  1 1 0 0  1 1 0 0  1 1 0 0
0 1 0 0     0 0 0 0  0 1 1 0  0 1 1 0  0 1 1 0
0 1 0 0     0 0 0 0  0 0 1 1  0 0 1 1  0 0 1 1
...

In the actual code, the fact that "there will always be a solution" is abused for the sake of golfing. It actually generates a matrix where type 2 comes before type 1, and the rectangle pieces are allowed to be partially overflowed to the top left. It still works since using an overflowed piece will always fail to cover the entire rectangular area.
⍝ Load dfns library to use the function X
⎕CY'dfns'

⍝ An inline function; ⍺←area (w,h), ⍵←n pieces
{
  v←⍳≢⍵    ⍝ Generate 0..n-1
  ↓∘.=⍨    ⍝ Generate Type 1 constraints as a nested array
  2/       ⍝ Two copies of each, to match with two orientations of each rect
  ,⍤1¨     ⍝ Concatenate row-wise with
  (...)    ⍝ the Type 2 constraints:
  2/⍵      ⍝   Two copies of each rectangle
  ⊢∘⌽\     ⍝   Flip the rows and columns at odd (0-based) indices
  ⍺∘{...}¨ ⍝   Generate boolean matrices for each rectangle:
  ⍺↑⍵⍴1    ⍝     Create the rectangle-shaped 1s, 0-filled to the size of the space
  ⌽⊖       ⍝     Reverse in both dimensions, so the 1s go to the bottom right
  (⍳⍺)↓¨⊂  ⍝     The above with leading rows/columns dropped in all possible ways
           ⍝     (all combinations of 0..h-1 rows and 0..w-1 columns dropped)
  ⍪↑,      ⍝     Format the result as Type 2 constraint sub-matrix
  m←⊃⍪/    ⍝ Vertically concatenate all the constraint sub-matrices
           ⍝ generated for each rectangle
  (X m)⌿m  ⍝ Solve the Exact Cover problem, and extract the rows
           ⍝ (the collection of rectangles that actually cover the area)
  v+.×     ⍝ Number the cells by the containing rectangle's 0-based index
  ⍺⍴       ⍝ Reshape the cells to the shape of the area
}

nice solution !

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

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


text:
Don't break the bridges!
Introduction:
You are a worker, who is in charge of managing a set of bridges, connecting a square grid of "nodes":
N - N - N
|   |   |
N - N - N
|   |   |
N - N - N

(the grid here is 3 by 3, but they can be larger).
Each of the bridges has a set capacity from 1 to 10, and each of the bridges has a number of cars over them, also from 1 to 10.

If a bridge has a higher capacity than the number of cars on that bridge, then it is considered "safe", and you can cross over it.
If a bridge's capacity and number of cars going over it are equal, then it is considered "stable". It won't collapse, but you can't cross over it.
If a bridge has a lower capacity than the number of cars on that bridge, then it is considered "collapsing", and you only have a limited amount of time to fix it.

When a bridge has n capacity and m cars, with n smaller than m, the time it takes to collapse is:
      m + n
ceil( ----- )
      m - n

You must take materials (and therefore reduce the bridge's capacity) from other bridges and arrive to those bridges on time to fix them! To get materials from a bridge, you must cross over it. For example, take this small arrangement:
A - B

The bridge between A and B (which we'll call AB) has 3 capacity, and let's say you're on A, and want to take 1 material. To take the material, simply cross from A to B.
Note: You don't have to cross the bridge multiple times to get multiple materials, you can take as much material as you want from a bridge in one go, as long as it doesn't cause the bridge to start to collapse.
Now, AB has 2 capacity, and you have 1 material on you. You may only cross over bridges that are "safe", though (or if you're fixing a bridge, which is explained in the next paragraph).
To fix a bridge, you must go over it, thereby depositing all materials needed to fix the bridge. For example, in the example above, if AB had 1 capacity and 2 cars currently on it, and you had 2 material on you, once you cross the bridge you will have 1 material, because that is all that's required to fix the bridge.
You must fully cross a collapsing bridge before the bridge collapses, otherwise it will break. Each crossing of a bridge takes 1 hour, and the time it takes for the bridge to collapse is shown in the formula above. For example:
A
|
B
|
C - D

In this example, if your starting node was A, and CD only had a "lifespan" of 2 hours, the bridge would collapse before you can get to it (crossing AB takes 1 hour, crossing BC takes another hour).
Task:
Your task is to make a program that calculates, given a list of bridges, which are represented themselves as lists of two elements (first element is capacity, second element is cars on the bridge), whether or not it's possible to fix all of the bridges. The bridges work from top-to-bottom, left-to-right - so an input of
[[3 2] [3 2] [2 5] [5 1]]

means that the actual grid looks like this:
    3
 A --- B
 |  2  |
3|2   2|5
 |  5  |
 C --- D
    1

So AB has a capacity of 3 and 2 cars, AC has a capacity of 3 and 2 cars, BD has a capacity of 2 and 5 cars, and CD has a capacity of 5 and 1 car.
Rules / Specs:

Your program must work for, at least, 10 * 10 grids.
Your program may accept the input as either a string with any delimiter, or a list of lists (see example I/O).
Your program must output the same value for true for all true values, and it must output the same value for false for all false values.
You can either submit a full program or a function.

Example I/O:
[[5 5] [5 5] [1 1] [3 3]] => true
[[2 5] [2 2] [3 3] [1 2]] => false
[[3 2] [3 2] [2 5] [5 1]] => true

NOTE, you can take the input like this as well:
[[3, 2], [3, 2], [2, 5], [5, 1]] (Python arrays)
3,2,3,2,2,5,5,1                  (Comma-separated string)
3 2 3 2 2 5 5 1                  (Space-separated string)

This is code-golf, so shortest code in bytes wins!

If you want to take multiple materials from the same bridge, do you have to cross it multiple times?

@GregMartin Sorry for the late reply - no, you don't have to cross it multiple times.

Can you only fix it to just enough?

Python3, 560 bytes:
R=range
def V(b,x,y,X,Y):
 try:return[(b[x][y],b[x+X][y+Y])]
 except:return[]
def f(r):
 K,w=0,int(len(r)**.5);b=[[K:=K+1for _ in R(w)]for _ in R(w)];e=dict(zip([l for x in R(w)for y in R(w)for l in V(b,x,y,0,1)+V(b,x,y,1,0)],r));q=[(e,0)]
 while q:
  e,c=q.pop(0);E=e.values()
  if all(a>=b for a,b in E):return 1
  if c<min(-(-((b+a)/(b-a))//1)for a,b in E if a<b):
   for(j,k),(a,b)in e.items():
    if a>b:
     for J,K in e:
      if(j,k)!=(J,K)and{j,k}&{J,K}:
       for s in R(a-b):
        Q=eval(str(e));Q[j,k][0]-=s;Q[J,K][0]+=s;q+=(Q,c+1),
 return 0

Try it online!

560

542 with horrible abuse

(j,k)!=(J,K)and{j,k}&{J,K}->len({j,k}&{J,K})==1? Seems fine on the test cases, but I can't follow the logic well enough to tell if there's any case where (j,k)==(K,J) where it would be incorrect


text:
Find the Oxidation States
Challenge
Find the oxidation states of each of the atoms in a given molecule. These can be output as a list or otherwise.
Rules
The total oxidation state of a molecule will always be zero. The total oxidation state is the sum of the oxidation states of each of the individual atoms in the molecule.
The following atoms have constant oxidation states:

Hydrogen, H, always has state +1
Oxygen, O, always has state -2
All Group 1 elements have a state +1
All Group 2 elements have a state +2
Fluorine, F, always has state -1
Chlorine, Cl, always has state -1

In monatomic molecules (such as H2 or S8), all of the atoms always have a state 0. I.e. (H2 is 0, 0 and S8 is 0, 0, 0, 0, 0, 0, 0, 0)
The Group 1 elements are: Li, Na, K, Rb, Cs, Fr. The Group 2 elements are: Be, Mg, Ca, Sr, Ba, Ra.
You will be able to work out the states of every atom in the molecule given. There will be no ambiguous inputs (i.e. you won't be given H2O2 or P4Br6).
You should output the oxidation states of the individual atoms, not the total state.
If there is an element which is not listed in the list above in the molecule, you need to work out its oxidation state yourself since the sum of the oxidation states of all the atoms adds up to zero.
The molecules do not have to exist in real life.
You will never get a single atom such as Ti or F.
Built-in functions which access data about oxidation states are disallowed.
Examples
Input > Output
H2O > +1, +1, -2
CO2 > +4, -2, -2
CH4 > -4, +1, +1, +1, +1
H2SO4 > +1, +1, +6, -2, -2, -2, -2
NaHCO3 > +1, +1, +4, -2, -2, -2
XeF8 > +8, -1, -1, -1, -1, -1, -1, -1, -1
TiCl2 > +2, -1, -1
P4 > 0, 0, 0, 0

Winning
The shortest code in bytes wins.

For H2O, can we output +1, +1, -2? Also, are we allowed to output without the + for positive integers?

@Okx Yes, you can output +1, +1, -2 and yes, you don't need the positive sign

Can we accept input with an multiplier after every Atom: H2O1 or C1O2

@RomanGräf Nope, you must take input as it is shown

Shouldn't the output of CH4 be -4, +1, +1, +1, +1?

(okay this might be cheating) Are we allowed to assume there will always be less than 10 of the same atom in a molecule, as my solution breaks with double digits it? :P

The total oxidation state should always add up to zero. H2O2 adds up to -2.

@JonathanAllan Final sum should always be zero.

Argh, so much confusing wording. It says in one place that H "always" has constant oxidation state +1. Then it says that that in H2, all of the atoms "always" have state 0.  And "If there is an element which is not listed in the list above in the molecule, you need to work out its oxidation state yourself." is really confusing - I assume what you mean is, there may be one single atom in the molecule which is not defined somewhere, so you need to deduce what its state is, given the other rules.

@SteveBennett Yes, you're right. I've cleared that up a bit

@BetaDecay Could you answer my reply further up?

@Okx Oh sorry, no, you must support any number of atoms

Can you add a testcase with a number >9 ?

Ruby, 245 bytes
->m{h={[?O]=>-2,%w[F Cl]=>-1,%w[H Li Na K Rb Cs Fr]=>1,%w[Be Mg Ca Sr Ba Ra]=>2};a=m.scan /([A-Z][a-z]*\d*)/;r=a.flat_map{|(b)|b=~/(\D+)(\d*)/;[a[1]?h[h.keys.find{|v|v.include?$1}]:0]*[1,$2.to_i].max};r.map{|j|j||-((r-[p]).inject:+)/r.count(p)}}

Try it online!
As I prepare this post, with a ton of optimizations, sudee's answer gets an update xD
Which reduces my changes to two :

a.size==1 becomes a[1] with an inverted consequence. This is because we know that the string is well formed and so a.size != 0
($2=='' ? 1:$2.to_i) becomes [1,$2.to_i].max

Both of these save 5 bytes.

The max solution is pretty nice, didn't occur to me. I was hesitant about a[1] but then I dismissed it for some reason. :D We could also replace .inject:+ with .sum for newer versions of Ruby to save a few bytes. (Doesn't work with TIO sadly.)

Ruby, 288 255 bytes
->m{h={[?O]=>-2,%w[F Cl]=>-1,%w[H Li Na K Rb Cs Fr]=>1,%w[Be Mg Ca Sr Ba Ra]=>2};a=m.scan /([A-Z][a-z]*\d*)/;r=a.flat_map{|(b)|b=~/(\D+)(\d*)/;[a.size==1?0:h[h.keys.find{|v|v.include?$1}]]*($2=='' ? 1:$2.to_i)};r.map{|j|j||-((r-[p]).inject:+)/r.count(p)}}

Try it online!

Saved 1 byte thanks to Jenkar
Saved 32 more bytes by inlining definitions and removing parentheses

Ungolfed
oxidation_state = -> molecule {
    h = {
        %w[H] => 1,
        %w[O] => -2,
        %w[F] => -1,
        %w[Cl] => -1,
        %w[Li Na K Rb Cs Fr] => 1,
        %w[Be Mg Ca Sr Ba Ra] => 2,
    }
    find_oxidation = -> a {
        k = h.keys.find { |as| as.include?(a) }
        h[k]
    }
    atoms = molecule.scan(/([A-Z][a-z]*\d*)/)
    r = atoms.flat_map { |(a)|
        a.match(/([^\d]+)(\d*)/)
        [atoms.length == 1 ? 0 : find_oxidation[$1]] * ($2=='' ? 1 : $2.to_i)
    }
    r.map { |j|
        sum = r.compact.inject(:+)
        !j ? -sum / r.count(nil) : j
    }
}

Jenkar suggests saving one byte with [?O] instead of %w[O].

Python 3, 272 bytes
s=input()+'A';n='';l=[1]
for i in s:
 if'Z'<i:l[-1]+=i
 elif'9'<i:l+=[l.pop()]*int(n or 1)+[i];n=''
 else:n+=i
i=lambda s:s.split().count
l=[i('Li H Na K Rb Cs Fr')(s)+i('Be Mg Ca Sr Ba Ra')(s)*2-i('F Cl O O')(s)for s in l[1:-1]]
print([k or-sum(l)//l.count(0)for k in l])

Try it online!

Doesn't work with more than one digit in a number.

@Okx fixed it .


text:
Solve sin(θ) = x in the range a ≤ θ ≤ b
Challenge
Given a number, x where -1 ≤ x ≤ 1, and the integers a and b, where b > a, solve the equation sin(θ) = x for θ, giving all solutions in the range a° ≤ θ ≤ b°.
Rules
x will have a maximum of three decimal places of precision. The output, θ, must also be to three decimal places, no more, no less.
Your output may be as a list or separated output.
You may use built-in trig functions.
You may not use radians for a and b.
You will never be given invalid input.
Output may be in any order.
Examples
x, a, b => outputs
0.500, 0, 360 => 30.000, 150.000
-0.200, 56, 243 => 191.537
0.000, -1080, 1080 => 0.000, 180.000, 360.000, 540.000, 720.000, 900.000, 1080.000, -1080.000 -900.000, -720.000, -540.000, -360.000, -180.000

Winning
Shortest code in bytes wins.

Maths homework this time?

@Okx Of course xD

Grrr, angular degrees are evil.

Can we go beyond 3 decimal places? 2. Do the outputs have to be in ascending order?

@HyperNeutrino 1. No, you must stick to 3 decimal places. 2. Outputs can be in any order

One can use arcsin()?

Can we return 1.0 instead of 1.000?

@mbomb007 I've fixed the examples

@Uriel Not particularly

I think the 3 points precision here is ruining the challange, because it becomes a brute force instead of angles translation

@Uriel Huh, that's a shame. When you don't specify a challenge enough, people complain, when you specify the challenge, the challenge is a bit rubbish :P

For me less is specified better it is

APL, 51 46 40 39 bytes
3 bytes saved thanks to @KritixiLithos
6 7 bytes saved thanks to @Adám
{3⍕⍵/⍨1E¯6>|⎕-1○○⍵÷180}⊢+1E3÷⍨(⍳1001×-)

Called as a dyad with a as left argument and b as right argument, prompts for x.
Requires ⎕IO←0.
How?
                         ⊢+1E3÷⍨(⍳1001×-)  ⍝ build the range a to b with step of 0.001
                                  1001×-   ⍝ 1001 * (b - a)
                                 ⍳         ⍝ range
                           1E3÷⍨           ⍝ divide every element by 1000
                         ⊢+                ⍝ add a back

{3⍕⍵/⍨1E¯6>|⎕-1○○⍵÷180}                  ⍝ filter the solutions
                  ○⍵÷180                   ⍝ convert to radian - π * ⍵ / 180
                1○                          ⍝ compute sine
             |⎕-                           ⍝ distance from x
       1E¯6>                                ⍝ small enough
    ⍵/⍨                                    ⍝ compress with the original list
 3⍕                                        ⍝ format to 3 decimal places

Mathematica, 60 bytes
NumberForm[t/.NSolve[Sin[t/180Pi]==#&&#2<=t<=#3,{t}],{9,3}]&

input

[0, -1080, 1080]

output

{-1080.000,-900.000,-720.000,-540.000,-360.000,-180.000,0.000,180.000,360.000,540.000,720.000,900.000,1080.000}

Note that this solution doesn't work for large integers, for two reasons: the 9 limits the accuracy for large solutions, and also NumberForm displays the answer in scientific notation which erodes the accuracy (a constant annoyance from Mathematica). That being said, do you need ,Reals at all? You can also save a byte by replacing t Degree with t/180Pi, which (despite appearances) evaluates to πt/180.

Fortran 95 (gfortran), 180 bytes
#define G >=i)write(*,'(f9.3)')
#define H read(*,*)
program a
H x
H i
H j
o=ASIN(x)*57.2957
p=o-180+o
q=o-360*999
do
r=q-p
if(r<=j.and.r G r
if(q>=j)exit
if(q G q
q=q+360
enddo
end

Structure ungolfed:
program a
        implicit none
        real :: x
        integer :: i
        integer :: j
        real :: o
        real :: r
        real :: q
        real :: p

        read(*,*) x
        read(*,*) i
        read(*,*) j

        o=ASIN(x)*57.2957
        p=o-180+o
        q=o-360*999

        do
                r=q-p
                if(r<=j.and.r >=i) then
                        write(*,'(f9.3)') r
                endif
                if(q>=j) then
                        exit
                endif
                if(q >=i) then
                        write(*,'(f9.3)') q
                endif
                q = q + 360
        end do
end program a

PHP>=7.1, 88 Bytes
for([,$s,$f,$t]=$argv;$f<=$t;$f+=.001)round(sin(deg2rad($f)),5)!=$s?:printf("%.3f_",$f);

Online Version

Python 2, 100 bytes
from math import*
x,a,b=input()
while a<=b:
    if round(sin(pi*a/180),5)==x:print a
    a=round(a+.001,3)

Try it online

Axiom, 266  215 210 bytes
g(y,a,b)==(r:List Float:=[];t:=y+truncate((a-y)/360)*360;repeat(t>b=>break;if t>=a then r:=append(r,[t]);t:=t+360);r)
f(x,a,b)==(abs(x)>1 or a>b=>[];y:=asin(x)*180/%pi;z:=180-y;sort(append(g(y,a,b),g(z,a,b))))

ungolf and test
-- g/180=r/pi  => r=pi*g/180
--y+k*360=a
--    a-y
-- k=------
--    360
-- find all angles of the same class of angles [y+k*360] in interval [a,b]
gg(y,a,b)==
   r:List Float:=[]
   t:=y+truncate((a-y)/360)*360 --truncate(1.9)=1, truncate(-3.1)=-4 is ok
   repeat
     t>b=>break
     if t>=a then r:=append(r,[t])
     t:=t+360
   r

-- ff returns the list of solution y of sin(y)=x with y in the interval [a,b]
ff(x,a,b)==
   abs(x)>1 or a>b =>[]
   y:=asin(x)*180/%pi -- z and y are the only 2 solutions in one 360 Len interval
   z:=180-y
   sort(append(gg(y,a,b),gg(z,a,b)))

(6) -> f(0.5, 0, 360)
   (6)  [30.0,150.0]
                                                         Type: List Float
(7) -> f(-0.2, 56, 243)
   (7)  [191.5369590328 1548769]
                                                         Type: List Float
(8) -> f(0.0, -1080, 1080)
   (8)
   [- 1080.0, - 900.0, - 720.0, - 540.0, - 360.0, - 180.0, 0.0, 180.0, 360.0,
    540.0, 720.0, 900.0, 1080.0]

(14) -> m:=f(-0.1, -2035, -243)
   (14)
   [- 1974.2608295227 33214, - 1805.7391704772 66786, - 1614.2608295227 33214,
    - 1445.7391704772 66786, - 1254.2608295227 33214, - 1085.7391704772 66786,
    - 894.2608295227 332137, - 725.7391704772 667863, - 534.2608295227 332137,
    - 365.7391704772 667863]
                                                         Type: List Float
(15) -> map(x+->sin(%pi*x/180), m)
   (15)
   [- 0.0999999999 9999999987, - 0.1000000000 0000000016,
    - 0.0999999999 9999999986 2, - 0.1000000000 0000000028,
    - 0.0999999999 9999999985 4, - 0.1000000000 0000000018,
    - 0.0999999999 999999999, - 0.1000000000 0000000019,
    - 0.0999999999 9999999989 2, - 0.1000000000 0000000014]
                                                         Type: List Float

R, 74 bytes
function(x,a,b,u=seq(a,b,.001))sprintf("%.3f",u[abs(sinpi(u/180)-x)<1e-6])

Try it online!
The tolerance 1e-6 was chosen to fit the second test case, so is somewhat arbitrary. This answer takes advantage of R's vectorized functions.


text:
Expand elastic tabs
Background
The tabs versus spaces war in programming has been going on a long time, basically because spaces are too low-level to have all the properties you'd want for alignment and indentation, but tabs can't be relied upon to work in all contexts (with some programs optimizing the use of tabs for indentation whilst making them unusable for tabulation, some optimizing the use of tabs for tabulation whilst making them mostly unusable for indentation, and pretty much all programs unable to reasonably use tabs for alignment).
A proposed solution was that of elastic tabstops; basically a method of dynamically adapting the meaning of a tab character so that it would be usable for indentation, tabulation, and alignment. The idea is that a tab in one line tabs to the same place as the corresponding tabs in neighbouring lines (if any exist), stretching if necessary to make the columns line up. Unfortunately, very few programs support them by default, meaning that they aren't widely used. (If only the "elastic tab" character were in Unicode!) In this task, we're bringing elastic tabstops to the world of codegolf.
The task
Brief description
Replace tabs with a minimal number of spaces, in such a way that for each n, the rightmost end of the nth tab on any given line is the same as the rightmost end of the nth tab on the neighbouring lines (assuming those tabs exist), and such that tabs tab to positions at least two spaces apart.
Precise description
Write a program or function whose input and output are multiline strings (you may take these as lists of single-line strings if you prefer). The input and output should be identical, except that each tab character (ASCII/Unicode 9) must be replaced with one or more spaces, subject to the following conditions:

Create a list of numbers corresponding to each line of output (its tabstops); specifically, for each tab character that was expanded on that line, take the column number of the last space that was expanded from that tab (here, "column number" = the number of characters on that line up to and including that character). So for example, if you expanded a␉b␉c to a   b  c, the list would be [4,7]. The lists must have the following properties:

For each pair of consecutive lines, one of those lines' tabstops list must be a prefix of the other's (a list is a prefix of itself, e.g. [4,7] and [4,7] is OK, as are [4,7,9] and [4,7], as are [4] and [4,7], but [4,5] and [4,7] would not be allowed).
For each number in each list, it must be greater by at least 2 than the number to its left (if it's the first element, treat the hypothetical "zeroth element" to its left as having a value of 0). (We're using a value of 2 for the purposes of this challenge because it gives good results for tabulation and alignment and decent results for indentation. Sorry, 4-space or 8-space indentation fans.)

The answer produced must be as short as possible while complying with the above restriction.

Example
Input
␉ represents a literal tab character, because literal tabs don't show up well on Stack Exchange.
// Elastic tabs handle indentation...
{
␉foo;
␉{
␉␉bar;
␉}
}
// alignment...
int␉foo␉(int),
␉bar␉(void),
␉baz;
float␉quux␉(float),
␉garply;
// tabulation...
␉1␉2␉3␉4
1␉1␉2␉3␉4
2␉2␉4␉6␉8
3␉3␉6␉9␉12
4␉4␉8␉12␉16
// and all three at once.
while True:
␉numbers␉=␉one␉and␉two
␉␉and␉three␉or␉four

Output
I've added extra information to the right of this output to show the tabstops on each line. Those aren't part of the expected output, they're just there to help explain what's going on.
// Elastic tabs handle indentation...       []
{                                           []
  foo;                                      [2]
  {                                         [2]
    bar;                                    [2,4]
  }                                         [2]
}                                           []
// alignment...                             []
int   foo (int),                            [6,10]
      bar (void),                           [6,10]
      baz;                                  [6]
float quux (float),                         [6,11]
      garply;                               [6]
// tabulation...                            []
  1 2 3  4                                  [2,4,6,9]
1 1 2 3  4                                  [2,4,6,9]
2 2 4 6  8                                  [2,4,6,9]
3 3 6 9  12                                 [2,4,6,9]
4 4 8 12 16                                 [2,4,6,9]
// and all three at once.                   []
while True:                                 []
  numbers =   one   and two                 [2,10,14,20,24]
          and three or  four                [2,10,14,20,24]

Clarifications

The input won't contain a tab character at the end of a line (basically because this is an uninteresting case which wouldn't make a visual difference to the output).
The input will only contain printable ASCII (including space), plus newline and tab. As such, it's up to you whether you treat the input as bytes or characters; the two will be equivalent.
This is, in its spirit, a challenge about formatting output for display on the screen. As such, this challenge uses the rules for ascii-art challenges (e.g. you're allowed to output a string out of order via the use of terminal cursor motion commands if you wish), even though it technically isn't about ASCII art.
Despite the previous point, outputting the answer via displaying it on the screen isn't necessary (although you can certainly output like that if you want to); you can use any method of outputting a string that PPCG allows by default (e.g. returning it from a function).
The input will not contain trailing whitespace (except for, if you wish, a single trailing newline). Trailing whitespace on the output will be irrelevant from the point of view of correctness (i.e. you can add trailing whitespace or leave it off, it doesn't matter). Again, this is because it wouldn't show up on a screen.

Victory condition
This is code-golf, so shorter is better.

For people who can see deleted posts: the Sandbox post was here.

It seems to me that the example has a space too much before each ( in the alignment section. And the output for public:␉char␉c; is missing.

@ØrjanJohansen: thanks, looks like some typos made as I was fixing the test cases before, fixed now.

Retina, 132 130 bytes
+m`(^|	)
$1
{+sm`^(([^	¶])*)(	.*^(?<-2>[^	¶])*(?(2)(?!))[^	¶]+	)
$1 $3
+sm`^(([^	¶])*	.*^(?<-2>[^	¶])*(?(2)|(?!)))
$1
%1`

Try it online! Link includes test suite. Explanation:
+m`(^|␉)␉
$1␠␉

Insert spaces before leading tabs and between consecutive tabs. This ensures tabs are at least two spaces apart. Then while tabs still exist:
{   Repeat these stages until all tabs have been processed
 +  Repeat this stage until the first line has the longest indentation
  sm`^(([^␉¶])*)(␉    Look for a line with a tab
                   .*^     Look for another line
                      (?<-2>[^␉¶])*(?(2)(?!))[^␉¶]+␉)   With more indentation
$1␠$3   Add indentation to the first line

Find the line with the most text before a tab and add spaces to the first line until it aligns. (If the first line already has the longest indentation, this might add spaces to another line, but the next stage would have added them anyway.)
+   Repeat this stage until all lines have the same indentation
 sm`^(([^␉¶])*␉ Look for a line with a tab
                .*^  Look for another line
                   (?<-2>[^␉¶])*(?(2)|(?!)))␉    With less indentation
$1␠␉    Add indentation to that line

Add spaces to the remaining lines until they all align.
%1`␉
␠

Replace the first tab on each line with a space.

This gives the wrong output for a couple of lines (most notably the bar; line). I'm not sure how easily fixable that is.

@ais523 Conveniently the fix saved me a couple of bytes!


text:
Show me the nearest demon
A demonic number is a positive integer whose decimal representation consists of only 6. The list of demonic numbers starts with 6, 66, 666, 6666.
Given a positive integer, output the nearest demonic number. If there are two, output the bigger one.
Testcases:
n   output
1   6
2   6
3   6
6   6
35  6
36  66
37  66
100 66
365 66
366 666
666 666
999 666

This is code-golf. Shortest answer in bytes wins.

What is the maximum number we have to support?

@Mr.Xcoder as large as you can support.

@LeakyNun, while I'm not a regular if PPCG, I would say that rule isn't really great, because I can just say "I can only support up numbers to 34 because I wanted to have the shortest code"

@Ferrybig as large as you can support, so basically as large as the language limits you.

Are we allowed to return the result as string instead of integer?

@KevinCruijssen yes.

Interesting fact about 666: Its totient is equal to the product of its digits.

Apparently the nearest demon is Jörg W Mittag.

Python 2, 28 bytes
lambda n:'6'*len(`-~n*3/11`)

That's a neat solution.

Wow that's impressive. Mine was 105 bytes using the trivial method rip. Nice!

Very cool. How did you come up with this algorithm?

That's awesome. The equivalent in JS is a bit longer: x=>'6'.repeat((''+-~(x*3/11)).length)

@DavidZ Hint: the average of 666 and 6666 is 3666. 3.6666... = 11/3.

Here's a ruby port: ->n{?6*"#{-~n*3/11}".size} (also 28 bytes :)

@SteveBennett Your javascript doesn't work, it works for small values if you change the 11 to a 12 but that breaks down too eventually

JavaScript (ES6), 31 29 bytes
f=(x,s='6')=>x<3+s?s:f(x,s+6)

f=(x,s='6')=>x<3+s?s:f(x,s+6)

;[1,2,3,6,35,36,37,100,365,366,666,999,1000].forEach(x=>console.log(x,f(x)))

“That is why, I delight in weaknesses […] For when I am weak, then I am strong.”

Wow, for once Javascript's type conversion is exactly what you need :) That's awesome.

“That is why, I delight in weaknesses […] For when I am weak, then I am strong.” ~~ 2 Corinthians 12:10

@JohnDvorak " Therefore I take pleasure in infirmities [...] for when I am weak, then am I strong." sounds better.

Brachylog, 8 bytes
;I≜+{6}ᵐ

Try it online!
Explanation
;I          The list [Input, I]
  ≜         Assign a value to I: 0, then 1, then -1, then 2, etc.
   +        Sum Input with I
    {6}ᵐ    All its digits must be 6

Java 7, 96 93 66 bytes
String c(int n){String r="";for(n*=11/3;n>1;r+=6,n/=10);return r;}

Port of @orlp amazing Python 2 answer.
Try it here.
I guess my 66-byte-count is a demon as well. ;)
(Not the shortest Java answer btw, see @JollyJoker's answer for that instead.

Using integer arithmetic must be shorter.

C'mon, golf just one more byte please! :p

None of your testcases is correct.

@OlivierGrégoire Needs r="" as a bugfix anyway, so you get your wish :)

@LeakyNun Oops.. Copied the incorrect code.. the "6" should have been "".

Still, I believe that it will be shorter if you use integer arithmetic.

Jelly, 9 bytes
Ẇa6ḌạÐṂ⁸Ṫ

A monadic link.
Try it online! - Almost no point in this link (see below)!
How?
In true golfer's style this is truly inefficient - it hits the 60s time out at TIO for the 365 test case! Locally this finishes in 37s.
Ẇa6ḌạÐṂ⁸Ṫ - Main link: n
Ẇ         - all sublists - this has an implicit make_range on it's input
          -   so, for example, an input of 3 yields [[1],[2],[3],[1,2],[2,3],[1,2,3]]
          -   the important things are: that it contains both a list of the length of the
          -   decimal number, and a list 1 shorter; and that it's lists only contain
          -   non-zero numbers and are monotonically increasing in length.
  6       - literal 6
 a        - and (vectorises), this changes all the values to 6s
          -    so, the example above becomes [[6],[6],[6],[6,6],[6,6],[6,6,6]]
   Ḍ      - convert to decimal (vectorises)  [ 6,  6,, 6,  66,   66,   666   ]
       ⁸  - link's right argument, n
     ÐṂ   - filter keep those with minimal:
    ạ     -   absolute difference (for 366 this keeps 66 AND 666; same goes for 3666; etc.)
        Ṫ - tail - get the rightmost result (for 366 keeps 666, since it's longer)

A patch to make the same algorithm run within the 60s limit for 365 and 366 on TIO is to avoid the implicit vectorisation of Ḍ with Ẇa6Ḍ€ạÐṂ⁸Ṫ (try that), however this will now seg-fault for an input of 999 (Triangle(999) is only 499,500 but each is a list of integers, making a total of Tetrahedral(999) = 166,666,500 integers, not memory efficient, at least in Python).

05AB1E, 10 9 bytes
- 1 byte thanks to Riley
6×ŒΣI-Ä}¬

Try it online!
The above code can have performance issues, here is a slightly more efficient version with 10 bytes: TIO alternative
Explanation
6×ŒΣI-Ä}¬   Main link. Argument n
6×          Push string containing '6' n times
  Œ         Push substrings
   Σ   }    Sort by result of code
    I-Ä     Absolute difference between n
        ¬   Head, implicit output

Yeah, but then it had performance issues on the last testcase. The 60 sec maximum on TIO weren't enough to run it through ):

@Riley thanks, I updated my answer :)

Jelly, 10 bytes
RD6ṁḌạÐṂ¹Ṫ

Try it online!

Wouldn't a port be shorter?

I tried and got 10 as well.

oh, is the problem that a space needs to be inserted between 11 and 6?

Not sure how you'd put 11 and 6 next to each other; maybe I'm missing something. I got ‘×3:11Ṿ”6ṁ for string output, ‘×3:11D6ṁḌ for integer.

C, 118 bytes
Try Online
a;b;d(n,m){return(m*6)+(n>0?d(n-1,m*10):0);}
f(n){a=d((int)log10(n)-1,1);b=d((int)log10(n),1);return(n-a<(b-a)/2)?a:b;}

97 bytes

JavaScript (ES6), 41 bytes
f=(n,i=0,j=6)=>n*2<j?i||6:f(n-j,i+j,j*10)

Test cases

f=(n,i=0,j=6)=>n*2<j?i||6:f(n-j,i+j,j*10)

console.log(f(1))   // 6
console.log(f(2))   // 6
console.log(f(3))   // 6
console.log(f(6))   // 6
console.log(f(35))  // 6
console.log(f(36))  // 66
console.log(f(37))  // 66
console.log(f(100)) // 66
console.log(f(365)) // 66
console.log(f(366)) // 666
console.log(f(666)) // 666
console.log(f(999)) // 666

Mathematica, 36 Bytes
Pure function:
Max[NestList[6+10#&,6,#]~Nearest~#]&

Explanation:
    NestList[6+10#&,6,#]

Iterative create a list of length equal to the input using NestList following the pattern 6+10x(previous_value) starting from the value of 6.
                        ~Nearest~#

Then find the value in this list closest to the input.
Max[                              ]

Lastly take the maximum value from the list of nearest values.
Whilst the list length is super inefficient as mathematica can work with arbitrary precision length numbers this program is only limited by physical memory.

Templates Considered Harmful, 118 bytes
Fun<Ap<Fun<If<lt<A<1>,Add<A<2>,A<3>>>,A<3>,Ap<A<0>,A<1>,Mul<A<2>,I<10>>,Add<Mul<A<3>,I<10>>,I<6>>>>>,A<1>,I<30>,I<6>>>

Try it online!
Ungolfed:
Fun<Ap<Fun<If<lt<A<1>, Add<A<2>, A<3>>>,
           A<3>,
           Ap<A<0>, A<1>, Mul<A<2>, I<10>>, Add<Mul<A<3>, I<10>>, I<6>>>>>,
       A<1>, I<30>, I<6>>>

Neim, 12 10 bytes (non-competing)
-1 byte thanks to steenbergh
Γ6Θℝ)₁>

Explanation:
               Implicit input: [366]
               Push the length of the input
                [3]
               Inclusive range
                [[1, 2, 3]]
   Γ            For each
       ℝ         Repeat
    6            6
     Θ           currently looped value times
                 [[6, 66, 666]]
          )     End for each
               Get the closest value to
           ₁    The first line of input...
            >   ...incremented by one
                [666]
                Implicitly print entire stack

Unfortunately,  will return the lower value in a list if two numbers have the same difference, so we had to add 2 bytes to account for that.
Non-competing as >, < and ℝ were added after this question was asked (and  was fixed to work with numbers, not just lists)
Note: Will not work for numbers with a length equal to 19 or more - as they get too big for Java's longs to handle. (but this is quite a large value, and should be fine)
Try it

Surely you can make this answer competing....

e.g. would it work if you replace Γ6Θℝ) with ΓΘΓ6))?

@LeakyNun I'll take a look at it.

@LeakyNun No, I don't think there's a way to make it competing, as there was a bug (now fixed) with embedded loops.

Who downvoted, and why?

Mathematica, 76 bytes
Max[Take[LinearRecurrence[{11,-10},{0,6},IntegerLength[#]+1],-2]~Nearest~#]&

I didn't see this question in the feed, and only stumbled over it by accident. Here's my answer anyway:
JavaScript (ES6), 34 bytes
n=>`${-~n*3/11|0}`.replace(/./g,6)

Add 1 byte for a numeric answer. Originally based on this ungolfed ES7 answer (37 bytes, already numeric):
n=>(10**(Math.log10(-~n*3/11)|0)*2-2)/3

Annoyingly OP wants 36 to be nearer to 66 than 6. Explanation: 11/3=3.666..., so dividing by this scales the ranges 7..36, 37..366 etc. to the ranges 1..9.9, 10..99.9 etc. This can be solved purely numerically by taking 2/3 of one less than the next higher power of 10, although it's golfier to truncate, convert to string, then change all the characters to the digit 6. (Although still not as golfy as that really clever recursive answer.)

CJam, 25 bytes
Not as slow as the Jonathan Alan's Jelly submission, but requires O(n²) memory, where n is the input number. Yeah.
ri)__{)'6*i}%f-_:z_:e<#=-

This is equivalent to the following Python:
num = int(input()) + 1                                      # CJam: ri)__
demondiffs = [int("6" * (i + 1)) - num for i in range(num)] # CJam: {)'6*i}%f-
absdiffs = [abs(i) for i in demondiffs]                     # CJam: _:z
mindex = absdiffs.index(min(absdiffs))                      # CJam: _:e<#
print(num - demondiffs[mindex])                             # CJam: =-

Alternative solution, 12 bytes
ri)3*B/s,'6*

This is a translation of orlp's algorithm into CJam.
Explanation:
ri           e# Read integer:       | 36
  )          e# Increment:          | 37
   3*        e# Multiply by 3:      | 111
     B/      e# Divide by 0xB (11): | 10
       s     e# Convert to string:  | "10"
        ,    e# String length:      | 2
         '6  e# Push character '6': | 2 '6
           * e# Repeat character:   | "66"
e# Implicit output: 66

Java 8, 37 bytes
 n->(""+-~n*3/11).replaceAll(".","6");

Going by Kevin Cruijssen's example and just returning a String.
Do the *3/11 trick to get the right length, then replace all with sixes.

@LeakyNun Of course, had to add the -~ that I should have seen ten times on this page if I'd paid attention...

I count 36 bytes. Your code has an unnecessary trailing semicolon and leading space.

QBIC, 37 27 bytes
≈!@36`!<=:|A=A+!6$]?_sA,2,a

Instead of using Maths™ this now uses string manipulation to find the breaks in the Demonic Domains (36, 366, ...). Inspired by @eush77 's JS answer.
Explanation
≈         |  WHILE <condition>
 !    !        a numerical cast of
  @  `         the string literal A$
   36          starting out as "36"
       <=    is smaller than or equal to
         :   cmd line argument 'a'
A=A+ 6       Add a 6 to the end of A$ (36 ==> 366 ==> 3666)
    ! $         as a string-cast
]            WEND (ends the WHIOLE loop body)
?_sA         PRINT a substring of A$            n=37, A$ = 366
  ,2           starting at index 2                          ^
  ,a           running well past the end of the string      66

dc, 46 bytes
dsxZ1-10r^d11*2-3/dsylx[0r-]s.<.3*ly+d[6]s.0=.

Try it online!
dsxZ1-10r^d11*2-3/dsylx[0r-]s.<.3*ly+d[6]s.0=.
   Z1-10r^                                      Nearest power of 10
           11*2-3/                              The number in between 6ⁿ and 6ⁿ6
          d          lx[0r-]s.<.                Check which side we're on
                                3*ly+           Get the answer for x≥3
                                     d[6]s.0=.  Return 6 for x<3

C#, 142 bytes
a=>{var c=(a+"").Length;return int.Parse(a<int.Parse(3+new string('6',c==1?2:(c==10?1:c)))?new string('6',c-1):new string('6',c==10?c-1:c));};

It uses the fact, that we need to jump to the next deamonic number at every 36666...
In a more readable form:
var c = (a + "").Length;
    return int.Parse(a < int.Parse(3 + new string('6',
        c == 1 ? 2 : (c == 10 ? 1 : c)))
        ? new string('6', c - 1)
        : new string('6', c == 10 ? c - 1 : c));

I think using integer arithmetic instead of String can save you a lot of bytes.

well, you can convert a number to a string in c# just by adding a string to it because it has an overloaded + operator, as shown in my 102 bytes answer.. I also don't think you need to parse it back to an int as the question just asked us to " output the nearest demonic number"

PHP, 49 Bytes
trim the character 6

for(;trim($x=$argn+$i,6)>"";)$i=($i<1)-$i;echo$x;

Try it online!
Instead of trim($x=$argn+$i,6)>"" you can use a Regex solution !preg_match("#^6+$#",$x=$argn+$i) +11 Bytes or
a string length equal to count 6 comparision strlen($x=$argn+$i)-strspn($x,6) +10 Bytes

braingasm, 15 bytes
;3*11/z+[6:10/]

Using the arithmetic from orlp's Python solution:
;                   Read an integer from stdin
 3*11/              Multiply by 3 and divide by 11
      z+            If result is zero, add one
        [6:10/]     While not zero, print '6' and divide by 10

LOLCODE 1.4, 471 bytes
HAI 1.4
CAN HAS STRING?
I HAS A i
GIMMEH i
I HAS A l ITZ I IZ STRING'Z LEN YR i MKAY
I HAS A s ITZ "3"
IM IN YR a
BOTH SAEM I IZ STRING'Z LEN YR s MKAY AN l
O RLY?
YA RLY
GTFO
OIC
s R SMOOSH s AN 6
IM OUTTA YR l
I HAS A o
DIFFRINT i AN BIGGR of i AN 4
O RLY?
YA RLY
VISIBLE 6
NO WAI
BOTH SAEM i AN SMALLR of i AN s
O RLY?
YA RLY
o R DIFF OF l AN 1
NO WAI
o R l
OIC
I HAS A f
IM IN YR b UPPIN YR k TIL BOTH SAEM k AN o
f R SMOOSH f AN 6
IM OUTTA YR b
VISIBLE f
OIC
KTHXBYE

Wow. Here's that Ungolfed and Explained:
HAI 1.4
CAN HAS STRING?
I HAS A input
GIMMEH input
I HAS A length ITZ I IZ STRING'Z LEN YR input MKAY BTW this is using the length function of the STRING library.
I HAS A sixes ITZ "3" BTW the average of for example [6...] and 6[6...] is 3[6...].
IM IN YR foreverloop BTW this loop fills the sixes variable.
    BOTH SAEM I IZ STRING'Z LEN YR sixes MKAY AN length # In LOLCODE, a statement containing only an expression assigns the implicit variable IT.
    O RLY? # Tests the current value in IT.
      YA RLY
        GTFO
    OIC
    sixes R SMOOSH sixes AN 6 BTW SMOOSH automatically casts things to YARN. It also does not need a MKAY unless there's something after it on the line.
IM OUTTA YR foreverloop
I HAS A outputlength
DIFFRINT input AN BIGGR of input AN 4 BTW LOLCODE doesn't have a built-in inequality operator. This just means input < 4
O RLY?
  YA RLY
    VISIBLE 6 BTW If it's less than 4, the algorithm of comparing to the nearest 3.6*10^n.
  NO WAI
    BOTH SAEM input AN SMALLR of input AN sixes BTW input<=sixes
    O RLY? BTW This if statement makes sure that if the input is less than 3.6*10^length, it goes to the previous place value's demon number.
      YA RLY
        outputlength R DIFF OF length AN 1
      NO WAI
        outputlength R length
    OIC
    I HAS A final
    IM IN YR forloop UPPIN YR iterator TIL BOTH SAEM iterator and outputlength
        final R SMOOSH final AN 6
    IM OUTTA YR forloop
    VISIBLE final
OIC
KTHXBYE

Still wow. Here's some pseudojavascrython for you.
hello()
import string
var i
i=input()
var l=string.len(i)
var s="3"
while True:
  if(string.len(s)==l):
    break
  s=s+6
var o
if(i!=max(i,4)): # Basically if(i<4)
  print 6
else:
  if(i==min(i,s)): # Basically if(i<=s)
    o=l-1
  else:
    o=l
  var f
  for(var k=0;k<o;k++):
    f=f+6
  print(f)
exit()

Still don't get it? This program basically just (excluding inputs 1-3) compares the input to the 3.6*10^n, n being the length of the input. If it is smaller than that number, it prints the number of 6s one less than the length. If it is greater than or equal to that number, the number of sixes is the current length.
Would love some help golfing!

Haxe, 70 bytes
function(x){x*=3;x/=11;do{Sys.print('6');}while((x=Std.int(x/10))>0);}

Input has to be passed as type Float despite being an integer, otherwise Haxe will complain about trying to divide an integer (yes haxe will refuse to compile if you divide an integer by anything)
Same as all the other answers. Multiply by 3, divide by 11, print 1 6 for every digit.

Brainfuck, 315 bytes
,+>+++[>>+<<-]>>[<<<[>+>+<<-]>>[<<+>>-]>-]<+++++++++++<[>>+<<-]>>[<[>>+>+<<<-]>>>[<<<+>>>-]<[>+<<-[>>[-]>+<<<-]>>>[<<<+>>>-]<[<-[<<<->>>[-]]+>-]<-]<<<+>>]<[-]+<[>-]>[<+>->]++++++[<+++++++++>-]<<<[-]++++++++++>[>.<[<<+>>-]<<[>[<<+<+>>>-]<<<[>>>+<<<-]>[<+>>-[<<[-]<+>>>-]<<<[>>>+<<<-]>[>-[>>>-<<<[-]]+<-]>-]>>>+<<]>>]

Run it here. Select a cell size that can handle values of 3*(n+1), so for all of the test cases to work, select 16. Dynamic (infinite) Memory must be turned on for this to work. This allows the tape to expand to the left. To input an integer, type the input like \366 for n=366.
Ungolfed:
Uses the same algorithm as this solution. The algorithms used for each  individual step are taken from this page. All algorithms used are non-wrapping, so that the program won't break for larger inputs.
,+ # n = n plus 1
>+++ # 3
[>>+<<-]>>[<<<[>+>+<<-]>>[<<+>>-]>-] # n = n*3
<+++++++++++ # 10
<[>>+<<-]>>[<[>>+>+<<<-]>>>[<<<+>>>-]<[>+<<-[>>[-]>+<<<-]>>>[<<<+>>>-]<[<-[<<<->>>[-]]+>-]<-]<<<+>>] # n = n/10
<[-]+<[>-]>[<+>->] # if (n == 0) { n = n plus 1 }
++++++[<+++++++++>-] # '6' (54)
<<<[-]++++++++++> # 10
[ # while (n above 0)
  >.< # print '6'
  [<<+>>-]<<[>[<<+<+>>>-]<<<[>>>+<<<-]>[<+>>-[<<[-]<+>>>-]<<<[>>>+<<<-]>[>-[>>>-<<<[-]]+<-]>-]>>>+<<]>> # n = n/10
]

Surely the n=n*3 can be golfed to something like [->+++<]? And the divmod algorithm to divide by 10?

134 bytes, which could be improved further

@JoKing You have to use non-wrapping algorithms to support the larger test cases, so your solution doesn't actually work. There's a reason why I didn't use TIO.

Oops, I'll remove the wrapping part, which was only the number. 140 bytes (TIO because it's easier to give the code) (EOF = 0)

C#, 102 bytes
string a(int j,int k=0)=>(j+"|"+(k=k==0?j:k)).Split('|').Where(s=>s.All(c=>c=='6')).Max()??a(j+1,k-1);

Kinda disappointed in the length of this, could do exactly the same as the shorter answer in Java but I did not really understand it because I am a lazy, stupid .NET developer :)

Japt, 9 bytes
_ì e¥6}cU

Try it

05AB1E, 7 bytes
6s×ηs.x

Try it online!

Program # Input ====================|> 2
--------#---------------------------+--------
6s×     # Push N 6's as a string.   | 66
   ηs   # Prefixes of this.         | [6, 66]
     .x # Closest element to input. | 6


text:
It's Anagram Quine, not just Quine!
The Task
In this challenge, your task is to write a program, which takes in no input, with as many anagrams that are quine of themselves as possible.
Your score will be the number of anagrams of your program's source code that are valid quines divided by the total number of anagrams possible, i.e. the percentage of the anagrams that are valid quines.
Standard Loopholes and rules of standard quines apply.
Note: Your program must have at least 3 characters (not 3 bytes).

Input
Each anagram (or permutation) of your program which is quine of itself (i.e. the anagrams which you are including in your score) must not take any input. If your language requires input as a necessity, then you can assume that your program will be given a String consisting of the lowercase letter A. However, you must not make any use of the input in any way.

Output
n number of distinct anagrams of your program's source-code must be valid quines, where n represents the number of those anagrams that you are including in your score, i.e.

Those quine-anagarams can output in any way except writing the output to a variable. Writing to file, console, screen etc. is allowed. Function return is allowed as well.

Scoring Example
Suppose your program's source code is code. And,

code outputs code.
coed outputs coed.
cdoe outputs cdoe.
cdeo outputs cdeo.
cedo outputs cedo.
ceod outputs ceod.
ocde outputs ocde.
oced outputs oced.
odce outputs odce.
odec does not output odec or produces error.
oedc does not output oedc or produces error.
oecd does not output oecd or produces error.
doce does not output doce or produces error.
doec does not output doec or produces error.
dcoe does not output dcoe or produces error.
dceo does not output deco or produces error.
deco does not output deco or produces error.
deoc does not output deoc or produces error.
eodc does not output eodc or produces error.
eocd does not output eocd or produces error.
edoc does not output edoc or produces error.
edco does not output edco or produces error.
ecdo does not output ecdo or produces error.
ecod does not output ecod or produces error.

The score of this solution will be

Winning Criterion
The solution with the highest score wins! In case of a tie, the answer with higher char-count (not byte-count) wins (hence the code-bowling)! If a tie still persists, then the solution which was posted earlier wins!

I believe this is a duplicate of https://codegolf.stackexchange.com/questions/121522/rotation-safe-quine

@NeilA. I'm a lot more confident that a rotation-safe quine can actually be written in other languages than Unary (although not in many languages and it will still be hard).

It's probably too late to change the specs now, but you should probably have specified that the original program doesn't count, because otherwise this essentially seems to be a duplicate of our vanilla quine question.

Unary, 100%
This is essentially the same as the Lenguage answer because of how the two are related. I think it's worth noting, though. I scored it as 100% because every permutation of the code will result in a quine of itself and I see that as X/X * 100 = 100%.
5.71728886e+3431 zeroes. The full number can be found in this snippet:

571,728,886,299,524,079,667,110,831,585,172,705,903,242,988,869,730,233,666,941,239,930,957,383,634,990,884,017,758,011,673,661,456,375,420,014,789,453,910,279,412,516,365,039,911,616,569,776,194,653,994,845,706,814,330,810,597,741,840,830,026,333,447,578,878,492,702,908,613,882,908,168,867,637,282,596,648,914,407,902,821,648,635,054,942,485,156,519,086,239,517,305,702,705,783,520,430,327,882,724,649,323,623,993,252,952,774,346,675,694,385,891,810,563,667,798,834,846,369,950,692,136,274,353,903,969,878,343,229,031,870,459,050,270,140,433,402,333,183,995,076,273,934,316,316,041,923,055,208,568,854,697,194,015,046,079,301,420,468,901,769,118,098,230,767,460,924,846,552,476,679,293,134,684,448,847,449,288,151,944,932,525,087,248,192,275,095,934,337,598,653,981,534,386,220,451,824,875,829,915,842,538,357,082,913,137,430,485,883,178,947,004,702,124,084,633,123,544,060,730,650,995,512,745,030,590,989,195,409,454,379,726,020,068,090,543,485,377,485,846,396,271,958,108,709,617,635,354,477,293,970,464,272,097,575,501,779,386,668,756,938,340,200,794,894,015,824,708,091,428,944,573,831,257,244,094,409,870,775,301,993,104,432,870,895,478,408,037,450,837,230,273,086,589,639,225,269,690,034,191,664,788,952,560,282,035,550,980,217,998,364,096,267,637,012,870,557,015,775,372,943,770,232,826,937,792,678,659,741,977,391,285,036,126,978,266,614,181,473,074,907,458,591,514,305,961,253,806,814,023,933,864,985,407,267,169,604,856,107,931,116,888,268,748,039,451,683,353,551,414,447,462,928,850,923,445,503,652,021,793,168,648,510,513,597,305,336,955,173,718,471,931,736,313,986,020,652,567,023,366,257,316,037,210,037,318,158,858,503,724,736,280,981,391,398,280,363,850,853,361,932,459,586,164,155,418,666,917,331,478,035,204,211,067,642,357,524,068,995,687,396,230,593,421,768,310,516,964,395,591,974,018,305,173,396,770,508,740,001,527,520,092,344,197,005,623,355,537,596,657,473,766,544,801,370,212,627,256,410,732,664,011,822,421,191,103,127,619,073,582,845,123,484,719,578,718,376,300,070,162,355,969,718,786,766,544,705,666,866,547,241,576,008,751,585,319,953,584,072,266,931,915,765,118,041,170,749,844,694,686,800,072,822,536,450,477,293,767,227,280,278,303,598,479,313,816,303,539,184,630,996,668,979,230,004,925,749,414,158,627,159,671,600,379,023,203,894,575,932,729,998,748,035,419,783,450,180,418,397,923,824,642,227,478,374,530,825,875,117,414,862,969,170,359,605,774,864,660,165,183,532,258,493,867,754,625,154,388,052,741,695,648,070,594,472,531,159,793,952,847,078,816,841,601,345,611,759,202,959,380,748,999,978,577,549,942,317,774,738,570,775,404,426,481,919,733,186,968,468,431,270,431,605,972,498,637,946,956,126,022,229,614,797,087,117,225,823,565,342,748,501,153,741,450,722,494,697,466,495,557,622,414,355,168,111,360,033,562,039,346,636,733,121,121,610,857,454,876,606,487,443,794,811,222,591,756,267,144,914,006,412,918,432,311,781,300,777,103,610,374,114,091,997,695,742,108,877,002,082,862,282,098,075,681,749,979,978,446,425,489,037,395,541,763,956,873,201,738,020,809,689,085,082,333,652,677,837,122,632,903,083,224,964,125,736,624,491,672,540,404,024,051,399,430,701,347,505,739,704,581,760,444,853,708,889,328,730,053,965,944,499,104,791,856,210,999,740,898,398,825,918,657,619,888,095,865,548,102,735,913,913,094,386,735,714,696,418,726,741,576,678,447,905,375,266,819,534,780,270,705,492,733,528,843,064,273,668,310,355,948,806,085,914,998,909,078,430,123,434,842,644,353,766,593,108,209,757,731,578,915,664,389,676,321,477,765,937,156,616,387,196,395,610,946,243,206,146,663,560,610,797,140,874,906,254,178,018,061,181,083,047,209,661,789,909,286,724,851,898,477,573,800,702,633,601,175,620,396,600,949,134,122,178,276,685,812,142,120,568,127,180,096,273,903,971,758,009,993,201,718,908,993,673,764,199,386,800,398,143,178,502,530,082,660,500,014,722,964,981,864,977,851,706,298,981,882,062,478,994,083,243,364,559,882,663,594,491,418,634,537,443,259,947,411,981,605,363,306,172,530,522,346,606,185,828,881,879,282,631,498,937,150,281,652,951,729,913,616,393,089,658,674,346,663,853,707,461,126,940,124,422,764,766,614,384,500,640,200,165,833,857,590,144,741,546,981,402,879,612,572,412,230,319,659,934,882,344,598,744,566,237,876,680,653,747,327,784,600,034,796,624,136,727,679,072,247,471,775,907,417,517,609,655,422,229,860,544,695,004,718,249,668,190,489,544,232,936,202,367,307,609,329,582,839,156,431,588,444,789,676,252,562,273,585,535,627,566,417,124,298,941,319,814,273,113,830,010,077,536,882,402,273,792,934,052,604,658,425,046,299,684,558,311,449,368,519,016,440,435,219,777,519,127,752,414,574,327,366,464,226,160,312,027,143

The Brainf*ck equivalent is in this snippet:

>+++++>++>++++++>+>+++++>+++++>+>++++++>+>+++++>+>++++++>+>+++++>+>++++++>+++>+++++>+++++>+>+++>++>+
+++>++++++>++>++++++>+++>+++++>++>++++++>++>+++++>++>++++++>+>+++++>+++++>+>++++++>+>+++++>+>++++++>
+>+++++>+>++++++>++>+++>+++++>+++++>+>+++>++>++++>++++++>++>++++++>+++>+++>+++>+++++>++>++++++>++>++
+++>++>++++++>+>++++>++++++>+>++++++>+>+++++>+>++++++>+>+++++>++++>+++++>++>+++>+>++++>++++++>+>++++
++>++>++>+++++>++>++++++>+>+++++>+++++>+++++>+>++++++>+>+++>++>++>+++++>++>++++++>+>++++>++++++>+>++
+++>+>++++++>+++>+>++++>+++++>++++>+++++>++++>+++++>++++>+++++>++++>+++++>++++>+++++>++++>++>++++>+>
+>+>+++++>+>+>+>++++++>+++>+++>+>+>+>+++>+>+>+>+++>+++++>++>++>++>++++++>+>++++++>++>+++++>++++>+>+>
+>+++++>+>+>+>++++++>+++>+++>+>+>+>+++>+++>+>+>+>+++>+++>+++++>++>++>++>++++++>++++++>+>++++++>++>++
+++>++++>+>+>+>+++++>+>+>+>++++++>+++>+++>+>+>+>+++>+++>+>+>+>+++>+++++>++>++>++>++++++>++++++>+>+++
+++>++>+++++>++++>+>+>+>+++++>+>+>+>++++++>+++>+>+>+>+++>+++>+>+>+>+++>+++>+++++>++>++>++>++++++>+++
+++>+>++++++>++>+++++>++++>+>+>+>+++++>+>+>+>++++++>+++>+>+>+>+++>+++>+>+>+>+++>+++++>++>++>++>+++++
+>++++++>+>++++++>++>+++++>++++>+>+>+>+++++>+>+>+>++++++>+++>+>+>+>+++>+>+>+>+++>+++>+++++>++>++>++>
++++++>++++++>+>++++++>++>+++++>++++>+>+>+>+++++>+>+>+>++++++>+++>+>+>+>+++>+>+>+>+++>+++++>++>++>++
>++++++>++++++>++>+++++>++>++++++>+>++++++>+++>+++>++>+++>+++++>++>+++>+>+>+++++>+++++>+>+++>+>+++>+
+>++>++++>++++++>+>+++++>++>+++>+>++++>++++++>+>++++>+++++>++++>+++++>++++>+>+++++>+>+++>+>+++>++>++
>++++>++++++>+>+++++>++>+++>+>++++>++++++>+>+++++>++>+++>+>++++>+++++>++>++++>+>+++++>++++>++++++>++
++++>++++++>++>+++++>++++>++>++++>+>+>+>+++++>+>+>+>++++++>++>++>++>+++++>+++++>+>+>+>+++>++>++>++>+
+++>++++++>++>++>++>++++++>+>+>+>+++>+++>+++>++>++>++>+++>+++>+++>++>++>++>++++>++++>++++>++>++>++>+
++++>++>++>++>++++++>+>++++>+>+>+++++>+>+>+>++++++>+++>+++++>+>+>+>++++++>+>++++++>++>++>++++++>++++
++>+>++++++>++>++>++>+++++>++>++>++>++++++>+>+++++>++>++>+++>+>+++>+>++++>++++++>++>++>+++++>+>+>+++
>++>++>++++>++++++>+>+++++>++++>+>+>+>+++++>+++++>+>+++>+>+++>++>++>++++>++++++>+>+++++>++>+++>+>+++
+>++++++>+>++++>+++++>++>+++>+>++++>+++++>++>++++>+>++++>++++++>++>+++++>++++>++>++++>++++>+>+>+>+++
++>+>+>+>++++++>++>++>++>+++++>+++++>+>+>+>+++>++>++>++>++++>++++++>++>++>++>++++++>+>+>+>+++>+++>++
+>++>++>++>++>++>++>+++++>++>++>++>++++++>+>++++>+>+>+++++>+>+>+>++++++>+++>+++++>+>+>+>++++++>++>++
>++++++>+>++++++>+>++++++>++>++>++>+++++>++>++>++>++++++>++++++>+>+++++>++>++>+++>+>+++>+>++++>+++++
+>++>++>+++++>+>+>+++>++>++>++++>++++++>+>+++++>++++>+>+>+>+++++>+++++>+>+++>+>+++>++>++>++++>++++++
>+>+++++>++>+++>+>++++>++++++>+++>+>++++>+++++>++>++++>+>+++++>++++>++++++>++++++>++>+++++>++++>++>+
+++>++>++>++>+++++>++>++>++>++++++>+>++++>+>+>+++++>+>+>+>++++++>+>+>+>+++++>+++++>++>++>++>+++>+>+>
+>++++>++++++>+>+>+>++++++>++>++>++>++>++>++++++>+>+>++++++>++>++>++>+++++>++>++>++>++++++>++++++>+>
+++++>+>++++>++>++++>++++++>+>++++++>+>+++++>+++>+++>+++>+++++>+>+++>+++>+++>+++>+++>+++>+++>+++>++>
++++>++++++>+>+++++++>+>+>++++++[<]>[[>]>[>]>[>]+[[>+<-]<]+[<]<[<]>[[>]>[>]>[>]<+[[>+<-]<]+++[<]<[<]
>-]>]>[>]>[-[<+>-]>]<<[<]>[[[>]>+<<[<]>-]>[>]+>-[-[-[-[-[-[-<->>>[>>>]++>>>+>>>+[<<<]>]<[->>>[>>>]++
>>>++>>>++[<<<]]>]<[->>>[>>>]++>>>++>>>+[<<<]]>]<[->>>[>>>]+>>>++>>>++[<<<]]>]<[->>>[>>>]+>>>++>>>+[
<<<]]>]<[->>>[>>>]+>>>+>>>++[<<<]]>]<[->>>[>>>]+>>>+>>>+[<<<]]<[<]>]++
%
<+[<+>>[[>+>+<<-]>[<+>-]>-[-[->[>+>+<<-]>[<+>-]>[<+>-[<->[-]]]<[-<->>>[>>>]<<<[[>>>+<<<-]<<<]>>>+++<
<<+++<<<---<<<[<<<]>->>[>>>]+[>>>]>]<<]]>]<<<[<<<]>[<<+>+>-]<<[>>+<<-]>[->>>[[>+>+<<-]>[<+>-]>-[<+>-
[<->-]<[-<-->>>[>>>]<<<[[>>>+<<<-]<<<]>>>+++<<<<<<[<<<]>->>[>>>]+[>>>]<<]>]>]<<<[<<<]]>[<<+>+>-]<<[>
>+<<-]>[->>>[[>+>+<<-]>[<+>-]+>-[<->[-]]<[-<-<<<[<<<]>->>[>>>]>>>[[<<<+>>>-]>>>]<<<<<]>>]<<<[<<<]]>[
>-<-]>]>[+++[>++++++++<-]>.>>]

Source of source

Congratulations on winning! :)

@Arjun Thanks but the Legrange answer was first and has the same score. It should win, instead.

@EngineerToast I mean it doesn't matter to me, it is CW so no +15 :P

Lenguage, 100%
5.71728886e+3431 null bytes. The full number can be found in this snippet:

571728886299524079667110831585172705903242988869730233666941239930957383634990884017758011673661456375420014789453910279412516365039911616569776194653994845706814330810597741840830026333447578878492702908613882908168867637282596648914407902821648635054942485156519086239517305702705783520430327882724649323623993252952774346675694385891810563667798834846369950692136274353903969878343229031870459050270140433402333183995076273934316316041923055208568854697194015046079301420468901769118098230767460924846552476679293134684448847449288151944932525087248192275095934337598653981534386220451824875829915842538357082913137430485883178947004702124084633123544060730650995512745030590989195409454379726020068090543485377485846396271958108709617635354477293970464272097575501779386668756938340200794894015824708091428944573831257244094409870775301993104432870895478408037450837230273086589639225269690034191664788952560282035550980217998364096267637012870557015775372943770232826937792678659741977391285036126978266614181473074907458591514305961253806814023933864985407267169604856107931116888268748039451683353551414447462928850923445503652021793168648510513597305336955173718471931736313986020652567023366257316037210037318158858503724736280981391398280363850853361932459586164155418666917331478035204211067642357524068995687396230593421768310516964395591974018305173396770508740001527520092344197005623355537596657473766544801370212627256410732664011822421191103127619073582845123484719578718376300070162355969718786766544705666866547241576008751585319953584072266931915765118041170749844694686800072822536450477293767227280278303598479313816303539184630996668979230004925749414158627159671600379023203894575932729998748035419783450180418397923824642227478374530825875117414862969170359605774864660165183532258493867754625154388052741695648070594472531159793952847078816841601345611759202959380748999978577549942317774738570775404426481919733186968468431270431605972498637946956126022229614797087117225823565342748501153741450722494697466495557622414355168111360033562039346636733121121610857454876606487443794811222591756267144914006412918432311781300777103610374114091997695742108877002082862282098075681749979978446425489037395541763956873201738020809689085082333652677837122632903083224964125736624491672540404024051399430701347505739704581760444853708889328730053965944499104791856210999740898398825918657619888095865548102735913913094386735714696418726741576678447905375266819534780270705492733528843064273668310355948806085914998909078430123434842644353766593108209757731578915664389676321477765937156616387196395610946243206146663560610797140874906254178018061181083047209661789909286724851898477573800702633601175620396600949134122178276685812142120568127180096273903971758009993201718908993673764199386800398143178502530082660500014722964981864977851706298981882062478994083243364559882663594491418634537443259947411981605363306172530522346606185828881879282631498937150281652951729913616393089658674346663853707461126940124422764766614384500640200165833857590144741546981402879612572412230319659934882344598744566237876680653747327784600034796624136727679072247471775907417517609655422229860544695004718249668190489544232936202367307609329582839156431588444789676252562273585535627566417124298941319814273113830010077536882402273792934052604658425046299684558311449368519016440435219777519127752414574327366464226160312027143

@ETHproductions fixed it. I think I win

Would this output 5.71728886e+3431 null bytes or something else?

@ETHproductions Yeah I guess.

Made CW because I may not be around to remove this :P

@Christopher You should include the precise amount of bytes so that this can be decoded.  There is currently no way to tell what this does.

@WheatWizard view revisions

It would also be nice if you included the Brainfuck program that this compiles into.

@SuperJedi224 So infinity score :D.

@Christopher I don't think the original program should count as an anagram of itself, but I reread the OP and the OP seems to be allowing it.

@SuperJedi224 Yeah it is unclear. But X/0 = infinity

Why isn't the score X/X = 100% ?

Unary and Lenguage use different binary encodings of Brainfuck programs. It's unlikely the quine would work in both Unary and Lenguage.

Jelly, 33.333...%
”ṘṘ

Try it online!
Community wiki because I did not write this. If you like this solution, or want an explanation, see Dennis's original post here.

Microscript II, score 1/1814399=5.5e-7
"qp1h"qp1h

"qph1"qph1 is also a quine.
Microscript II, score 5/119750399=4.2e-8
"qp12h"qp12h

"qp21h"qp21h, "qph12"qph12, "qph21"qph21, "qp1h2"qp1h2 and  "qp2h1"qp2h1 are also quines.
I'm sure someone can come up with a much higher score than either of these, but this is still the only answer with at least one quine that isn't the original program (which, IMO, shouldn't be counted).

V, 16.666...%
2i2i

Try it online!
There are 6 possible anagrams of this code:
2i2i
22ii
i22i
i2i2
ii22
2ii2

And one of them is a quine.

I'm not sure the original program should count as an anagram of itself, but the OP seems to be allowing it.