text:
Counting unit squares circle passes through
Write a program or function that given an integer radius r returns the number of unit squares the circle with radius r centered at the origin passes through. If the circle passes exactly through a point on the grid that does not count as passing through the adjacent unit squares.
Here's an illustration for r = 5:

Illustration by Kival Ngaokrajang, found on OEIS
Examples:

0 → 0
  1 → 4
  4 → 28
  5 → 28
  49 → 388
  50 → 380
  325 → 2540
  5524 → 44180
  5525 → 44020

OEIS - A242118

@Luke I just went looking for this, but it seems to use a slightly different definition (at least it doesn't agree on N = 50).

On the other hand, your illustration is clearly taken from https://oeis.org/A242118/a242118_1.pdf (which you should probably cite...)

@MartinEnder The OEIS numbers are wrong, I have a draft in review as we speak.

The unit squares will have integer coordinates at their edges, yes?

@Dennis Yes, although I'm interested what made you think otherwise.

It seems implied, but the spec doesn't actually say it.

Can you explain how you arrived at the numbers for the case 50 and up, since they're different from the OEIS and what I'm getting?

@smls By counting in the bounding square. Make sure that you do not count squares where the circle only touches a corner. The numbers on OEIS are wrong, I have a correction in review right now.

@orlp: Got it now. May I suggest adding the test-case 5 -> 28, which also has squares where the circle only touches a corner, but is easier to visualize  / reason about than ones with large radii?

@smls Sure, but that's the illustration :)

I have a sudden urge to build domes in minecraft again...

4 → 28\n5 → 28 um...

@KritixiLithos Wait until you see 49/50 :)

Related with a solid circle.

Are you a fellow 3Blue1Brown viewer?

@nitro2k01 Yes :)

Python 2, 54 bytes
f=lambda r,x=0:r-x and-~((r*r-x*x)**.5%1>0)*4+f(r,x+1)

Try it online!
Less golfed (55 bytes) (TIO)
lambda r:8*r-4*sum((r*r-x*x)**.5%1==0for x in range(r))

This estimates the output as 8*r, then corrects for vertex crossings. The result is 8*r-g(r*r), where g(x) counts the number of ways to write x as a sum of two squares (except g(0)=0).
If the circle never went through any vertices, the number of cells touched would equal the number of edges crossed. The circle passes through 2*r vertical gridlines and 2*r horizontal gridlines, passing each one in both directions, for a total of 8*r.
But, each crossing at a vertex counts as two edge crossings while only entering one new cell. So, we compensate by subtracting the number of vertex crossings.
This includes the points on axes like (r,0) as well as Pythagorean triples like (4,3) for r=5.
We count for a single quadrant the points (x,y) with x>=0 and y>0 with x*x+y*y==n, then multiply by 4. We do this by counting the numer of sqrt(r*r-x*x) that are whole number for x in the interval [0,r).

Mathematica, 48 bytes
4Count[Range@#~Tuples~2,l_/;Norm[l-1]<#<Norm@l]&

Looks at the first quadrant and counts the number of grid cells for which the input falls between the norms of the cell's lower left and upper right corners (multiplying the result by 4, of course).

Another method is 8#-SquaresR[2,#^2]Sign@#& based on xnor's post

@miles Oh wow, I had no clue SquaresR exists. Feel free to post that yourself (or let xnor post it).

Python 2, 72 bytes
lambda n:sum(0<n*n-x*x-y*y<2*(x-~y)for x in range(n)for y in range(n))*4

Try it online!

Jelly, 21 13 12 11 bytes
R²ạ²Æ²SạḤ×4

Try it online!
How it works
R²ạ²Æ²SạḤ×4  Main link. Argument: r

R            Range; yield [1, 2, ..., r].
 ²           Square; yield [1², 2², ..., r²].
   ²         Square; yield r².
  ạ          Absolute difference; yield [r²-1², r²-2², ..., r²-r²].
    Æ²       Test if each of the differences is a perfect square.
      S      Sum, counting the number of perfect squares and thus the integer
             solutions of the equation x² + y² = r² with x > 0 and y ≥ 0.
        Ḥ    Un-halve; yield 2r.
       ạ     Subtract the result to the left from the result to the right.
         ×4  Multiply by 4.

Perl 6, 61 bytes
->\r{4*grep {my &n={[+] $_»²};n(1 X+$_)>r²>.&n},(^r X ^r)}

How it works
->\r{                                                    } # Lambda (accepts the radius).
                                                (^r X ^r)  # Pairs from (0,0) to (r-1,r-1),
                                                           #   representing the bottom-left
                                                           #   corners of all squares in
                                                           #   the top-right quadrant.
       grep {                                 }            # Filter the ones matching:
             my &n={[+] $_»²};                             #   Lambda to calculate the norm.
                              n(1 X+$_)>r²                 #   Top-right corner is outside,
                                          >.&n             #   and bottom-left is inside.
     4*                                                    # Return length of list times 4.

Haskell, 74 bytes
f n=sum[4|x<-[0..n],y<-[0..n],(1+n-x)^2+(1+n-y)^2>n^2,(n-x)^2+(n-y)^2<n^2]

Pretty straightforward, count the number of squares between (0,0) and (n,n) where the bottom left is inside the circle and the top right is outside the circle, then multiply by 4.

AWK, 90 bytes
{z=$1*$1
for(x=$1;x>=0;x--)for(y=0;y<=$1;y++){d=z-x*x-y*y
if(d>0&&d<2*(x+y)+2)c++}$0=4*c}1

Usage:
awk '{z=$1*$1
    for(x=$1;x>=0;x--)for(y=0;y<=$1;y++){d=z-x*x-y*y
    if(d>0&&d<2*(x+y)+2)c++}$0=4*c}1' <<< 5525

Just a simple search through quadrant 1 to find all boxes that will intersect the circle.  Symmetry allows for the multiply by 4. Could go from -$1 to $1, but that would take a more bytes and be less efficient. Obviously this is not the most time efficient of algorithms, but it only takes about 16 seconds to run the 5525 case on my machine.

Pyth, 29 bytes
Lsm*ddb*4lf}*QQrhyTym+1dT^UQ2

Try it!
Explanation
Lsm*ddb*4lf}*QQrhyTym+1dT^UQ2  # implicit input: Q
Lsm*ddb                        # define norm function
 s                             # sum
  m   b                        #     map each coordinate to
   *dd                         #                            its square
                         ^UQ2  # cartesian square of [0, 1, ..., Q - 1]
                               #     -> list of coordinates of all relevant grid points
          f                    # filter the list of coordinates T where:
           }*QQ                # square of Q is in
               r               #     the range [
                hyT            #         1 + norm(T),
                               #                  ^ coordinate of lower left corner
                   ym+1dT      #         norm(map({add 1}, T))
                               #              ^^^^^^^^^^^^^^^ coordinate of upper right corner
                               #     ) <- half-open range
         l                     # size of the filtered list
                               #     -> number of passed-through squares in the first quadrant
       *4                      # multiply by 4
                               # implicit print

Bash + Unix utilities, 127 bytes
c()(d=$[(n/r+$1)**2+(n%r+$1)**2-r*r];((d))&&echo -n $[d<0])
r=$1
bc<<<`for((n=0;n<r*r;n++));{ c 0;c 1;echo;}|egrep -c 01\|10`*4

Try it online!
Just go through all the points in the first quadrant, count them up, and multiply by 4.  It can be very slow, but it works.

Batch, 147 bytes
@set/an=0,r=%1*%1
@for /l %%i in (0,1,%1)do @for /l %%j in (0,1,%1)do @set/a"i=%%i,j=%%j,a=i*i+j*j-r,i+=1,j+=1,a&=r-i*i-j*j,n-=a>>31<<2
@echo %n%

Somewhat inspired by the AWK and Haskell answers.

Glad I can somewhat inspire someone :)

JavaScript (ES7), 76 bytes
n=>4*(G=k=>k<n?Math.ceil((n**2-k++**2)**0.5)-(0|(n**2-k**2)**0.5)+G(k):0)(0)

Can you perhaps shave off a couple of bytes by recursing from n down to 0?

@Neil I did try but couldn't see a way. Wanted to use just one function but still need to store both n radius and k iteration and all attempts came out same bytes

@Neil Ah I see what you are saying about k<n?... but I lose out on those bytes reordering at n**2-k++**2 because the operator precedence is wrong when going in reverse and subtraction is non-commutative so the left side always needs to have k-1 and needs parentheses. Unless you've found a way?

Ah, I overlooked the subtraction... maybe you can multiply the whole thing by -4 instead of 4 to work around that? (Although that might still eat up into your saving...)


text:
Enthusiastically Russianify a String
Many of you may have interacted with people from Russia on the internet at some point, and a subset of you may have noticed the slightly odd method they have of expressing themselves.
e.g. удали игру нуб)))
where the ))) are added for emphasis on the previous statement, I have been working on a theory that the ratio of )'s to the rest of the string is directly proportional to the amount of implied emphasis, however I oftentimes find it difficult to compute the ratio on the fly, as I am also trying to cope with a slew of abuse, so I would like the shortest possible code to help me calculate what the resulting string should be, for a value of enthusiasm between 0 and 500%, given the original, unenthusiastic string, this will aid my research greatly as I will not have to type out bulky scripts every time I wish to test my hypothesis.
So, the challenge:
write a full program or function, which, provided two arguments, a string of unknown length, and a number, in either integer format (between 0 and 500) or in decimal format (between 0 and 5, with 2 points of accuracy) will

return/display the original string, suffixed with a number of )'s
the number will be the calculated as a ratio of the input number to the string length.
so if the number 200, or 2.00 was provided, 200% of the string must be suffixed as )'s
the number of brackets rounded to in decimal situations does not matter.
script is required to support Printable ASCII characters.
only has to support one input number format, of your choice.

Examples:
"codegolf" 125      = codegolf))))))))))
"codegolf" 75       = codegolf))))))
"noob team omg" 0.5 = noob team omg))))))
"hi!" 4.99          = hi!)))))))))))))))

Example code (PowerShell) (with decimal input):
Function Get-RussianString ([string]$InputStr,[decimal]$Ratio){
    $StrLen = $InputStr.Length
    $SuffixCount = $StrLen * $Ratio
    $Suffix = [string]::New(")",$SuffixCount)
    return $InputStr + $Suffix
}

Get-RussianString "codegolf" 0.5
codegolf))))

This is code-golf so shortest code wins!

"the number of brackets rounded to in decimal situations does not matter" -- Does this mean the 4th test-case could also print 14 brackets instead of 15?

@smls yes, either the floor or ceiling of any decimal is acceptable.

I get a variation of two )s for the hi!,4.99 example. ")"*(LEN(S$)*N) produces 14 )s, ")"*LEN(S$)*N and ")"*LEN(S$*N) give 12.

I'm confused, do Russians really use ) for emphasis like an !? Is it some encoding issue?

@CaptainMan I believe it's more like smiley faces than !s, but they do type them as is, it's not super common, but it's quite iconic.

@CaptainMan No ) is reduced emoticon :). It is used very common between young people as far as I know.

) is not an emphasis, it is simply the smiley. As far as I know, it is harder to type : when using Russian keyboard layout, therefore they smile without eyes.

@Juris it's as hard to write : on Russian layout (ЙЦУКЕН) as it is to type ^ on QWERTY. But indeed, the ) is a reduced version of :). It's much easier to press and hold Shift-0 than to repeatedly alternate keys.

I think the appropriate word for "to make something Russian" is to Russify it, or Russianize it (I prefer the former).

Will you ever get 500 or 5.0 as input?

@EriktheOutgolfer I'm intrigued as to how it would make a difference to your code, but yes the range is inclusive for this challenge, primarily because I want the 0 case to be handled.

@ConnorLSW I did not just ask for my code, but for everybody's reference BTW.

Just by the way, the example should be удали игру нуб))) (instead of деинсталляция игра нуб)))).

Do you require the program to both accept the decimal and integer formats? I read the challenge that way, but your example only accepts decimals.

@Justin the example code is decimal only, but the input type is your own decision, only one is required.

Jelly, 7 bytes
ȮL×Ċ”)x

Try it online!
Uses the decimal format.
How?
ȮL×Ċ”)x - Main link: string, decimal
Ȯ       - print string
 L      - length(string)
  ×     - multiply by the decimal
   Ċ    - ceiling (since rounding method is flexible)
    ”)  - a ')' character
      x - repeated that many times
        - implicit print

@ConnorLSW I just noticed that this will print the required string as a full program, but that the specification states "return" - is this OK?

any standard accepted output format is fine

no worries - this is my first challenge so there's a few of these things that I missed, i've updated it in the question to be more clear - thanks for asking.

Perl 6, 21 bytes
{$^a~")"x$^b*$a.comb}

Common Lisp, 59 52 50
Parentheses? I am in.
(lambda(s n)(format()"~a~v@{)~}"s(*(length s)n)0))

Details
(lambda(s n)               ; two arguments (string and ratio)
  (format ()               ; format as string
          "~a~v@{)~}"      ; control string (see below)
          s                ; first argument (string)
          (* (length s) n) ; second argument (number of parens)
          0))              ; one more element, the value does not matter

Format control  string

~a : pretty print argument (here the given string)
~v@{...~} : iteration block, limited to V iteration, where V is taken as an argument, namely the (* ...) expression. The iteration is supposed to iterate over a list, but when you add the @ modifier, the list is the remaining list of arguments to the format function. There must be at least one element in the iterated list (otherwise we exit, disregarding V). That is why there is an additional argument to format (0).

Since no element in the list is consumed by the format, the loop is infinite but fortunately, it is also bounded by V, a.k.a. the number of parentheses to be printed.

Edit: thanks to Michael Vehrs for pointing out that there is no need to round the numerical argument (the question allows to truncate/round however we want, so the default behavior works here).

(())/10 not enough parentheses

Who thought this language is a good idea?

Scheme's format accepts a decimal argument to v. Maybe Common Lisp's does, too?

@MichaelVehrs Indeed, thanks a lot.

@coredump Actually, I should have said "Guile's format accepts ...", since standard Scheme format does not support ~r; and Guile's format follows the example of Common Lisp's.

JavaScript ES6, 38 31 30 bytes
s=>n=>s+')'.repeat(s.length*n)

f=s=>n=>s+')'.repeat(s.length*n)

console.log(f("hi!")(4.99))

Nice, I think that's the shortest possible. You can save a byte through currying: s=>n=>s+')'.repeat(s.length*n) (it would then be called like f("hi!")(4.99))

Python 2, 29 bytes
lambda s,p:s+len(s)*p/100*')'

s in the string, p is the percentage (integer).
Try it online!

Pyth, 8 bytes
*\)s*lpz

Online Test! Takes the excitement ratio first, then the string to be enthused about.
Explanation:
      pz  print out the enthused string
     l    ... and get its length
    *...Q multiply that by the ratio
   s      floor to get an integer, let's call this S
 \)       single-character string ")"
* ")" S   multiply that integer by the string, which gives a string of )s of length S.
          implicitly print that string of S )s.

05AB1E, 9 8 bytes
g*ï')×¹ì

Try it online!
g*       # Length, multiplied by emphasis.
  ï')×   # Covnerted to an integer, push that many parenthesis.
      ¹ì # Prepend original string.

Works for both integer and decimal, arguments order: f(String, Double)

-1 in the new version of 05AB1E, where the ï is done implicitly for × with float argument.

And here’s a 7-byter that works on both legacy and modern 05AB1E: sg*F')«.

Python, 30 bytes
lambda s,r:s+')'*int(len(s)*r)

Uses the decimal input.
Try it online!

PowerShell, 33 bytes
$a,$b=$args;$a+')'*($b*$a.Length)

Try it online!
Supports decimal format.

R, 62 46 42 bytes
Anonymous function that takes string a and decimal n, prints output to stdout.
pryr::f(cat(a,rep(")",n*nchar(a)),sep=""))

Perl 5, 29 bytes
sub{($_=pop).')'x(y///c*pop)}

(Number is first arg, string is second.)
Try it online!

Pyth, 9 bytes
*s*lpzE")

Takes two lines of input: string and ratio (decimal).
Try it on pyth.herokuapp.com
Explanation
A denotes a function's first argument, B its second argument.
*s*lpzE")
    pz     # print the input string
   lAA     # take the length of the printed string
      E    # read the next line of input (the emphasis ratio)
  *AAAB    # multiply the length by the ratio
 sAAAAA    # floor the result
*AAAAAA")  # repeat ")" n times
           # implicit print

TI-Basic, 33 bytes
Takes decimal input.
Prompt Str1,A
")
For(I,0,9
Ans+Ans
End
Str1+sub(Ans,1,AI

PostgreSQL, 102 bytes
create function q(text,int)returns text as $$select rpad($1,(100+$2)*length($1)/100,')')$$language sql

Details
Uses the integer input format.
This simply right-pads the input string with parens out to the target length.
create function q(text,int)
returns text as $$
    select rpad($1,             -- Pad the string input
        (100 + $2) *            -- to 100 + int input % ...
        length($1) / 100,       -- ...of the input string
        ')')                    -- with ) characters
$$ language sql

Called with
select q('codegolf', 125), q('codegolf', 75);
select q('noob team omg', 50), q('hi!', 499);

sB~, 17 bytes
i\,N?\;')'*(N*l(\

Explained:
i\,N    input a string and a number
?\;     print the string
')'*    also print ) multiplied by...
(N*l(\  the number times the string length.

Parentheses are closed automatically
Here's the output of the compiler, if you're interested:
 INPUT  S$ ,N? S$ ;")"*(N* LEN(  S$ ))

This version of the compiler was written on 1/27/2017 at 11:12 pm, which might have been a few minutes after this question was posted.
So here's a version which works on the oldest version of the compiler, written an hour earlier: iS$,N?S$;')'*(N*l(S$)) (22 bytes)

CJam, 9 bytes
l_,ld*')*

Try it online!
Input string on the first line, emphasis ratio in range 0 to 5 on the second.
Explanation
l    e# Read input string.
_,   e# Duplicate, get length.
ld   e# Read emphasis ratio.
*    e# Multiply by length.
')*  e# Get that many parentheses.

MATL, 11 10 8 bytes
yn*:"41h

This solution uses the decimal form of the second input
Try it online!
Explanation
        % Implicitly grab first input as a string
        % Implicitly grab the second input as a number
y       % Make a copy of the first input
n       % Compute the length of the string
*       % Multiply the decimal by the length to determine the # of )'s (N)
:       % Create the array [1...N]
"       % For each element in this array
  41    % Push 41 to the stack (ACSII for ")")
  h     % Horizontally concatenate this with the current string
        % Implicit end of for loop and display

Bash + coreutils, 45 bytes
echo $1`seq -s\) $[${#1}*$2/100+1]|tr -cd \)`

Try it online!
Integer input.

echo $1\jot -b ) -s '' $[${#1}*$2/100]`` 40 bytes :) try it out

Groovy, 27 bytes
Straightforward solution
{s,r->s+')'*(s.length()*r)}

Test program :
def f = {s,r->s+')'*(s.length()*r)}

println f("hi!", 4.99)
println f("noob team omg", 0.5)

Rebol, 39 bytes
func[a b][append/dup a")"b * length? a]

Clojure, 40 bytes
Quite boring solution :
#(reduce str %(repeat(*(count %)%2)")"))

Just reduces str function on a list of closing parentheses with a string as initial parameter.
See it online : https://ideone.com/5jEgWS
Not-so-boring solution (64 bytes) :
#(.replace(str(nth(iterate list(symbol %))(*(count %)%2)))"(""")

Converts input string to a symbol (to get rid of quotes) and repeatedly applies function list on it generating infinite sequence like this: (a (a) ((a)) (((a))) ... ). Takes nth element converts it to string and replaces all opening parentheses with nothing.
See it online : https://ideone.com/C8JmaU

#(.replaceAll(str(nth(iterate list %)(*(count %)%2)))"[(\"]""")
1 byte less (yay). I wanted to do comp but can't get it below 70 bytes.

You can change ")" to \) to save a byte.

SimpleTemplate, 92 bytes
Takes the string as the first parameter and the "ratio" as the second.
The ratio is between 0 and 5, with 2 decimal places.
{@echoargv.0}{@callstrlen intoL argv.0}{@set*Y argv.1,L}{@callstr_repeat intoO")",Y}{@echoO}

As you can see, it is non-optimal.
The 2 {echo} there could be reduced to 1.
Due to a bug in the compiler, this code can't be reduced much further.

Ungolfed:
{@echo argv.0}
{@call strlen into length argv.0}
{@set* ratio argv.1, length}
{@call str_repeat into parenthesis ")", ratio}
{@echo parenthesis}

If no bug existed, the code would look like this, 86 bytes:
{@callstrlen intoL argv.0}{@set*Y argv.1,L}{@callstr_repeat intoO")",Y}{@echoargv.0,O}

C# Interactive, 77 67 bytes
string r(string s,int p)=>s+new string(')',(int)(s.Length*p/100d));

C# interactive is sweet.

If you are using C# Interactive that needs to be in the header otherwise, in C#, you should include the using System; or fully qualify Math. Also, not sure if you can do it in interactive, but you could compile to a Func<string, Func<int, string>> to save bytes i.e. s=>p=>s+new...

Also you probably don't need the call to Math.Round just casting to an int should call Floor and the OP said either Floor or Ceiling is fine

International Phonetic Esoteric Language, 24 bytes
A reimplementation of the old answer into the new specification. Input is as a positive integer first, then the string.
ɪ{100}viħɖf0ɑ")"x1esøɒʕo

Explanation:
ɪ{100}viħɖf0ɑ")"x1esøɒʕo
ɪ                        (push input int)
 {100}                   (push 100)
      v                  (divide int//100)
       iħ                (push input str, push len)
         ɖ               (rotate top 3 clockwise)
          f              (multiply int//100 * len)
           0             (push 0)
            ɑ            (begin loop, from 0 to int//100 * len)
             ")"         (push ")")
                x        (concat)
                 1esø    (increment index)
                     ɒ   (end loop)
                      ʕ  (list to str)
                       o (print)

International Phonetic Esoteric Language, 18 bytes (WIP language) (OLD)
I discovered some bugs in my interpreter because of this challenge. Takes input as string then integer.
iɢ291tʃɪðθœ<)>ɲqɶo

No TIO interpreter yet, but is runnable by cloning the repository above, and calling python3 main.py "code here".
iɢ291tʃɪðθœ<)>ɲqɶo
i                  ; push string input
 ɢ                 ; peek, push string length
  291tʃ            ; push (1 + 9)^2
       ɪ           ; push number input
        ðθ         ; push [num / 100 * len]
          œ        ; start loop: pop, run ceil(n) times
           <)>     ; push string ")"
              ɲ    ; swap top 2 elements of the stack
               q   ; pop, pop, push concatenated strings
                ɶ  ; end loop
                 o ; output

Sample cases:
python3 main.py "iɢ291tʃɪðθœ<)>ɲqɶo"
codegolf
125
codegolf))))))))))

python3 main.py "iɢ291tʃɪðθœ<)>ɲqɶo"
iɢ291tʃɪðθœ<)>ɲqɶo
300
iɢ291tʃɪðθœ<)>ɲqɶo))))))))))))))))))))))))))))))))))))))))))))))))))))))

python3 main.py "iɢ291tʃɪðθœ<)>ɲqɶo"
less than 1.00
50
less than 1.00)))))))

Stax, 7 bytes
é┴eó¡µf

Run and debug it

GNU AWK, 59 bytes
{t=sprintf("%"n*length(s)"s","");gsub(/ /,")",t);print s t}

Accepts arguments on command line (using the decimal form) like so:
: | awk -v s="codegolf" -v n=0.75 -f russianify.awk

Yes, AWK requires something to be attached to stdin, even if that something is 0 bytes returned by the no-op shell builtin. You could also use echo | awk ..., or really anything that doesn't contain a newline.

Clojure, 68 bytes
An anonymous function that accepts decimal input.
(fn [s n] (print (str s (reduce str (repeat (* n (count s)) ")")))))

Literally the first Lisp program I've ever written! I'm already having fun.

Welcome to the world of Lisp! :P In Clojure, you can use the condensed form of anonymous functions #(...), and you can get rid of the print (since function returns should be acceptable). You can change reduce to apply for the str function, and you can change ")" to \), which does the same thing. So, the final code should be: #(str %(apply str(repeat(*(count %)%2)\))))).

Also, the current state of your code doesn't work, (#(...) "codegolf" 125) must add 125 percent of the length of "codegolf" instead of 125 times the length of "codegolf". So, the fixed program would be: #(str %(apply str(repeat(*(count %)%2 1/100)\)))), which is 49 bytes.

C++14, 43 bytes
As unnamed lambda modifying its input, assuming s is similar to std::string (has .append(int,char) and assuming p to be of floating point type:
[](auto&s,auto p){s.append(s.size()*p,41);}

Usage:
#include<string>
#include<iostream>

auto f=
[](auto&s,auto p){s.append(s.size()*p,41);}
;

int main() {
 std::string s = "abcdefghijk";
 f(s,0.75);
 std::cout << s << std::endl;
}

Haskell, 37 bytes
s!n=s++([1..div(n*length s)100]>>")")

Try it online! Usage: "codegolf" ! 125

A version that takes a decimal number: (41 bytes)
s!n=s++([1..n*toRational(length s)]>>")")

Try it online! Usage: "codegolf" ! 1.25

Jellyfish, 16 bytes
P
,$')
 *i
 #
EI

Takes input as decimal, then newline, then string.
Try it online!
Explanation
Let's start from the bottom.
I

A raw string read from STDIN.
#
I

The length of the string.
*i
#
I

Multiply it by a number read from STDIN (the number is read first, since i comes before I in the source).
$')
*i
#
I

Repeat the character ) that many times, rounding down.
,$')
 *i
 #
EI

Append to the original string (the , looks for arguments from the south and east, and E tells the southward seeker to turn east, where it finds the I).
P
,$')
 *i
 #
EI

Print the resulting string.

PHP, 50 bytes
<?=str_pad($s=$argv[1],strlen($s)*++$argv[2],")");

takes string and decimal number as command line arguments; cuts padding. Run with -r;
breakdown
<?=                     // print ...
str_pad(                    // pad
    $s=$argv[1],            // string=argument 1
    strlen($s)*++$argv[2],  // to string length*(1+argument 2)
    ")"                     // using ")" as padding string
);

Mathematica, 24 bytes
#<>Table[")",#2Tr[1^#]]&

Unnamed function taking a list of characters and a decimal number as input and returning a string. Tr[1^#] is a sneaky golfy way to calculate the length of a list, so #2Tr[1^#] computes the required number of parentheses. Table[")",...] produces a list of that many right parentheses (all decimals automatically rounded down, which is nice). Finally, #<> concatenates the input string to the parentheses, flattening the list produced by Table as it goes.

That's quite cheaty, taking the string as a list of characters, but returning as a multi-character string. For consistent IO formats you could replace <> with ~Join~ at a cost of 4 bytes

I'd be interested in a community judgment on this issue. If it's cheating, then of course I'll avoid this type of mismatch. But if it's just cheaty - well, it seems to me that cheaty is very much on topic for this site :)

The challenge specification is sufficiently vague: return/display the original string, suffixed with a number of )'s (though I'd be picky with original string). Many other challenges specifically state "I/O formats must be consistent". If it's not a default rule, I guess you're in the white-enough part of the gray area.

@LLlAMnYP community consensus applies for I/O methods, so I believe this is valid Mathematica

Ruby, 25 bytes
->(s,n){s+')'*(s.size*n)}

I'm using lambdas. The test program would be something like:
f=->(s,n){s+')'*(s.size*n)}
f.("codegolf", 1.5)        # => "codegolf))))))))))))"
f.("hi!", 4.99)            # => "hi!))))))))))))))"

SmileBASIC, 29 bytes
INPUT S$,N?S$;")"*(LEN(S$)*N)

since 3*4.99 = 14.97, only 14 or 15 would be acceptable as answers, the 29 bytes version should work fine though, sorry!

Gol><> (Golfish), 17 bytes
i:a=?v
R*Il~/Hr)`

Try it here.
The top line reads characters (i) until it finds a newline (ASCII 10, a), then goes down (v).
Then we discard one character (the newline) with ~, push the length of the stack (l), read a float (I), multiply the two, and repeatedly (R) push the character ")" that many times. Finally, reverse the stack (r), output it and halt (H).

Japt, 8 bytes
+')pUÊ*V

Try it

Thunno 2, 6 bytes
l×')×+

Try it online!
Takes the string, then the decimal.
Explanation
l×')×+  '# Implicit input
l        # Length of string input
 ×       # Multiply by the number
  ')×   '# Multiply by ")"
         # (implicit floor)
     +   # Append to the input
         # Implicit output

source: Stack Exchange

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

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

sort: votes


text:
Is this word Lexically Ordered?
Given an input string S, return truthy if all the letters in S are Lexically Ordered: their ASCII values need to be in either ascending or descending order. Return falsy in other cases.
Input

Input will be in the same case (all upper- or all lowercase). Your submission should be able to handle both.
Input will consist of ASCII in the range [A-Za-z] only
Input length will be at least 1, up to whatever maximum your language supports.
Input is a string - not a list of characters, not an array of ASCII-codepoints.

Output

Output should be true or false, or 0/1, or any other distinct true / false style output your language can provide.
All true cases need to have the same output, as well as all the false cases. No "False is 0, true is 1, 2, or 3".

Additional rules

Standard loopholes are forbidden
Answer must be a full program or a function, not a snippet or a REPL-entry.
code-golf, shortest answer in bytes wins.

Test cases
Truthy
"ABCDEF"
"ZYX"
"no"
"tree"   --> the multiple 'e's don't break the order
"q"

Falsy
"ABCDC"
"yes"
"deed"

Invalid
"Hello" --> invalid input - mixed case-, does not have to be handled
""      --> invalid input - length 0-, does not have to be handled
"\n
  "     --> invalid input - newline is not in range [A-Za-z]-, does not have to be handled

Can you clarify about the output: does the truthy value need be the same regardless of what input is given?

@BusinessCat I've added a clarification.

What if your language's implementation of a string is a list of characters? Many of the answers posted here are using such languages...

@theonlygusti If your language of choice treats strings as lists of characters, that's fine. If your language has a string type, input may not be given as a list.

If you really want distinct values for True and False you shouldn't say truthy or falsy. This implies that any values that evaluate to true or false are allowed.

@FlipTack You're right. What I mean is that it doesn't matter what value resembles TRUE or FALSE, as long as it is always the same value.

related: Find the Wavy Words!

Has any one got to deal well with all the invalid values? I found no one in a quick look

@PatrickBard No, they're marked invalid because those cases do not need to be handled. Submissions need not concern themselves with those inputs.

@steenbergh I see, I understood this different the first time I read. My mistake.

Can we output 0 for ordered, and 1 for not?

@cairdcoinheringaahing Yes you can, as long as it's consistent between all cases.

Some more test cases: deer, AAAAA, aabb (we can't infer direction from only first or last pair, order has to continue after a double letter).

@TobySpeight all truthy, and imo all covered by existing cases.

Sorry, I should have said that they are all truthy, and that I meant them as stress-tests for solutions that take unjustified short-cuts to pass the suite.

@TobySpeight do you have an example of a solution that does this? - I'm a little reluctant to change a question this old...

No, I spotted the problem before I posted my answer.

I can explain the invalid test cases in one sentence instead of including them: invalid inputs do not need to be handled.

05AB1E, 5 bytes
Â)¤{å

Try it online!
Explanation
Â)     # pair the input with it's reverse in a list
  ¤{   # get a copy of the reverse and sort it
    å  # check if the sorted copy is in the list of [input,reverse_input]

{Â¹å for 4, deleted my answer. Didn't notice the use of bifurcate, mine was too similar.

@carusocomputing: that would unfortunately only check if the input is in the reverse of the sorted input.

Or equal to the sorted input. aba => ['aab', 'baa'] => is in? => 0| aab => same => 1

@carusocomputing: The sorted input is ignored as it's below the reverse on the stack. You never pair them in a list.

Coulda sworn bifurcate wrapped output; nvm, ignore me.

Python 2, 53 44 40 39 bytes
lambda a:`sorted(a)`[2::5]in(a,a[::-1])

Try it online!

Nice, but it returns true for invalid values

@PatrickBard mixed case is an invalid input, does not have to be handled

Haskell, 33 bytes
(%)=scanl1
f s=s==max%s||s==min%s

Try it online!
Thanks to Ørjan Johansen for 1 byte with aliasing scanl1 infix.
Haskell is an interesting language to golf sorting-based challenges because it does not have a built-in sort, barring a lengthy import Data.List. This encourages finding a way to do the task by hand without explicitly sorting.
The code uses scanl1, which folds an operation over the list from left to right, keeping track of the intermediate results. So, scanl1 max has the effect of listing the cumulative maxima of the list, i.e. the maxima of progressively longer prefixes. For example, scanl1 max [3,1,2,5,4] == [3,3,3,5,5].
The same with min checks whether the list is decreasing. The code checks the two cases and combines them with ||.
Compare to other expressions:
(%)=scanl1;f s=s==max%s||s==min%s

f s=or[s==scanl1 q s|q<-[min,max]]
f s=s==scanl1 max s||s==scanl1 min s
f s=any(\q->scanl1 q s==s)[min,max]
f s=any((==s).(`scanl1`s))[min,max]
f s=elem s$(`scanl1`s)<$>[min,max]

Actually your version with || wins if you define (?)=scanl1.

Perl 6, 25 bytes
{[le] .comb or[ge] .comb}

How it works:

.comb splits the input into a sequence of characters.
le and ge are the "less or equal" and "greater or equal" string comparison operators.
[ ] around an infix operator, reduces ("folds") the argument list with that operator. (It's smart enough to return True if the input has only zero or one characters.)
or returns True if the expressions on either side of it is true.

JavaScript (ES6), 43 bytes
([...s],q=s+"")=>q==s.sort()|q==s.reverse()

Didn't know you could modify variables in the argument itself. Nice!

@Luke This is just a tricky use of default parameters: if you were to call the function with a second argument, q would be set to that value instead.

I actually meant the spread operator which (in this case) converts it into an array right away.

Oh, OK. Yeah, destructuring assignments are really handy too ;-)

Clever using the mutating .sort() to implicitly sort in the reverse check

MATL, 7 bytes
dZSuz2<

Try it online! Or verify all test cases.
d     % Implicitly input string. Push array of consecutive differences of code points
ZS    % Sign. Transforms each entry into 1, 0 or -1
u     % Unique
z     % Number of nonzeros
2<    % Is it less than 2? Implicit display

It returns true for all invalid cases

@PatrickBard As the directions say, none of those need to be handled.

Clojure, 47 bytes
#(let[c(map int %)a apply](or(a <= c)(a >= c)))

Couldn't figure out how to decide which operator to apply concisely. This is great.

Wait you can put builtin function names into variables in Clojure? Huh, that's cool. It does make the <= and >= look infix though, which is really weird.

(let[+ *](+ 2 3)) = 6 :D It works on any function but apparently not on macros: "Can't take value of a macro"

R, 48 50 61 bytes
As an unnamed function
function(s)sd(range(sign(diff(utf8ToInt(s)))))<1

Thanks to @guiseppe for a few extra bytes.
charToRaw takes s and splits into a raw vector. This is converted to integers and a diff applied.  sign makes the diffs a single unit.  range reduces the vector to it's minimum and maximum.  Then if the standard deviation sd is less than 1 it is TRUE
Try it online!

You can save 9 bytes using function(s,d=utf8ToInt(s))all(d==sort(d)) or function(s,d=utf8ToInt(s))!is.unsorted(d)

Or down to 34 bytes with !is.unsorted(utf8ToInt(scan(,'')))

@mnel unfortunately these do not handle the reverse sort eg cba and the last one would require a cat() to make it a full program

Save 5 bytes with function(s)all(!diff(order(utf8ToInt(s)),,2)) (works with the reverse sort too!)

@mnel sorry again, that fails for tree

[facepalm]. One final attempt, function(s)prod(sign(diff(unique(utf8ToInt(s))))) (outputs 1 for true, -1 for false), saves a byte.

@mnel apologies this fails on quite a number.  Try this 'abcddcba'

Let us continue this discussion in chat.

there's a beautiful 48 byte solution if you replace diff with sd and <2 with <1 for your second submission, so function(s)sd(range(sign(diff(utf8ToInt(s)))))<1

C (gcc), 70 bytes
o(s,a)char*s;{for(a=0;s[1];s++)a|=s[1]-*s&64|*s-s[1]&32;return a!=96;}

I was hoping to find a shorter solution based on a recursive function, but it didn't work out due to the output requirement. So here's an imperative approach. At least, C's operator precedence works nicely for the inner loop statement.
Try it online!

Jelly, 4 5 bytes
Ṣm0ẇ@

Try it online!
Originally was Ṣm0w at four bytes.
Explanation
Ṣm0ẇ@  Input: string S
Ṣ      Sort S
 m0    Concatenate sort(S) with reverse(sort(S))
   ẇ@  Sublist exists? Check if S is contained in the previous result

I was sure there was a four byter, but couldn't think of it!

...unfortunately the OP has clarified output is not truthy/falsy, but two distinct values. Four bytes still possible with ẇ though, I believe. Edit: ugh Ṣm0ẇ@.

@JonathanAllan Unfortunate since it did meet the original rule of using the true/false style of the language. Another form might be Ṣẇm0$. If the argument order wasn't different for w and ẇ...

Nice, but it returns true on invalid values

@PatrickBard Huh? '\n' and 'Hello' are perfectly valid values.

Mathematica, 33 bytes
0<=##||##>=0&@@ToCharacterCode@#&

Based on this tip. Unfortunately, I have to use ToCharacterCode instead of Characters, because <= and >= don't compare strings.

MATL, 8 bytes
tPvGSXma

Try it Online!
Explanation
        % Implicitly grab the input as a string
tP      % Create a copy that is reversed
v       % Vertically concatenate these
GS      % Grab the input again and sort it
Xm      % Check if each row of the normal and reversed matrix is equal to the sorted one
a       % Check if either row matched
        % Implicitly display the result

Nice, but it returns true for '\n' and 'Hello' :/

@PatrickBard The input will be all the same case and will only be [A-Za-z] as stated in the initial post. They are in the "invalid" section because they explicitly don't need to be handled.

PowerShell, 61 bytes
param($a)$a-in-join(($b=[char[]]$a)|sort),-join($b|sort -des)

Try it online!
Takes input $a, then checks whether it's -in a two-element array. The array is formed by taking $a, casting it as a char-array, storing that in $b for later, piping it to sort-object which sorts lexically. The other element is $b sorted in -descending order.

Perl, 35 bytes
Saved 4 bytes thanks to @Xcali directly, and 4 more indirectly.
31 bytes of code + -pF flag.
@b=reverse@a=sort@F;$_=/@a|@b/x

Try it online!
The code sorts the input, and checks if the inputs matches itself sorted (or in reverse order).

Slightly different method, but cuts it down to 38 bytes: Try it online!

@Xcali Very nice, thanks. We can then get rid of $"=$, and use /x modifier instead to save 5 more bytes.

Bash + coreutils, 59 bytes
f()(sed 's/\(.\)/\1\
/g'<<<$s|grep .|sort -c$1)
s=$1
f||f r

The input string is passed as an argument.
The output is returned in the exit code (0 for truthy, 1 for falsy, as usual), as allowed by PPCG I/O methods.

Brachylog, 5 bytes
I've tried to find a 4 bytes solution without success, so for now here's the most interesting 5 bytes solution I've found:
:No₎?

Try it online!
o, the ordering function, can take a parameter: 0 means ascending order, 1 means descending order. We set that parameter to an unbound variable N. Brachylog will try different values for N (only 0 or 1 are possible), try to unify the result with the input, and return whether any of those tries succeeded.

Seems to no longer work :( o?|o₁? works for an extra byte tho

Seems to work if you replace the colon with a semicolon. Another one-byte-longer variant would be o{|↔}?.

Racket, 93 bytes
(define(f s)(let([t(string->list s)])(or(equal?(sort t char<=?)t)(equal?(sort t char>=?)t))))

Try it online!
Ungolfed:
(define (lex-sorted? string)
  (let ([char-list (string->list string)])
    (or
     (equal? (sort char-list char<=?) char-list)
     (equal? (sort char-list char>=?) char-list))))

Using the sort then compare to original approach

Haskell, 54 50 bytes
t a=or[and(zipWith(<=)`f`tail$a)|f<-[(=<<),(<*>)]]

Usage example: t "defggh" -> True. Try it online!.
Maybe using sort like may other answers is shorter although it requires import Data.List. Here's a different approach:
For every function f from [(=<<),(<*>)], calculate and(zipWith(<=)`f`tail$a) and require any of the results to be True. The functions are
((=<<) (zipWith(<=)) tail) a
((<*>) (zipWith(<=)) tail) a

which both perform comparisons of neighbor elements of the input list a with <=, but one with the arguments flipped resulting in a >=. and checks if all comparisons are True.

PHP, 66 bytes
$a=$s=$r=str_split($argv[1]);sort($s);rsort($r);echo$s==$a|$r==$a;

takes input from command line argument. Run with -r.

Ruby, 44 bytes
->s{[s,s.reverse].include?s.chars.sort.join}

Try it online!

Jelly, 5 bytes
,Ue@Ṣ

Try it online!
How?
,Ue@Ṣ - Main link: string
,     - pair string with
 U    - reverse(string)
    Ṣ - sorted(string)
  e@  - exists in with reversed arguments

K (ngn/k), 19 bytes
{t:!#x;(t~<x)|t~>x}

Try it online!
A little bit lengthy. I have considered using inline assignment, but it seems to be on the same length as this one. Returns 0 for false and 1 for true.
Explanations:
{t:!#x;(t~<x)|t~>x}  Main function. Takes x as input
 t:                  Assign variable t to
   !                 Range between 0 to
    #x;              Length of x (exclusive)
       (  <x)        Ascended version of x
         ~           Matches (deep equal)
        t            Variable t
             |       Or
                >x   Descended version of x
               ~     Matches
              t      Variable t

Thunno 2, 5 bytes
r,sṠƇ

Attempt This Online!
Explanation
r,sṠƇ  # Implicit input
r,     # Pair the input with its reverse
  sṠ   # Sort the input
    Ƈ  # Is this in the list?
       # Implicit output

J-uby, 28 bytes
(:>>+(A|:==%:sort)&:any?)%:~

This is equivalent to the below Ruby code, with A equivalent to chars and :~ equivalent to reverse:
->s{[s,s.reverse].any?{_1.chars==_1.chars.sort}

Attempt This Online!

Arturo, 39 bytes
$->s[some?@[reverse<=split s]=>sorted?]

Try it!
$->s[                      ; a function taking an argument s
    some?@[...]=>sorted?   ; is at least one item in the list [...] sorted?
    split s                ; convert s from string to block of length-1 strings
    <=                     ; duplicate
    reverse                ; reverse; both stack items get trapped in the list
]                          ; end function

Nekomata + -e, 4 bytes
oᶜ↔=

Attempt This Online!
o       Sort
 ᶜ↔     Optionally reverse
   =    Check equality

GNU sed, 97 + 1(r flag) = 98 bytes
If the letters are ordered, the script returns 1, otherwise 0. In sed there are no data types.
s:$: zyxwvutsrqponmlkjihgfedcba:
s:(.*(.)(.).* ).*\2.*\3.*:\1abcdefghijklmnopqrstuvwxyz:i
//c0
c1

To check if all letters are arranged in ascending order, I do a table lookup of each pair of consecutive letters in a descending alphabet, that is I try to find a counter example. Note that // actually repeats the last regular expression match! (see lines 2 and 3)
Run example: the script can test multiple input words, one per line
me@LCARS:/PPCG$ echo -e "tree\nABCDC" | sed -rf word_ordered.sed
1
0

Pyth, 5 bytes
}Q_BS

A program that takes input of a "quoted string" and prints True or False as appropriate.
Test suite
How it works
}Q_BS   Program. Input: Q
}Q_BSQ  Implicit variable fill
 Q      Is Q
}       in
    SQ  Q sorted
   B    or
  _     Q sorted reversed?
        Implicitly print

You can save a byte (and become the shortest answer) by replacing }Q with /, which uses an implicit Q.

Scala, 47 bytes
def f(x:String)=x==x.sorted|x==x.sorted.reverse

Octave, 24 bytes
@(s)issorted(s,'either')

Try It Online!

JavaScript (ES6) 74 62 50 47 43 bytes
([...a],b=a+'')=>b==a.sort()|b==a.reverse()

After some golfing and bugfixing, this answer ended up being pretty much the same as ETHProduction's, so please check his answer out and give it a +1.

Fixed the bug..

You caught me, I posted the comment before editing...

I found the cause of the bug, and I now fixed it properly by arranging everything cleverly...

Bug is back... https://repl.it/FZrs/2

Well, this is pretty much @ETHProduction's answer now, so I added a notice. Please +1 his answer.

MATLAB / Octave, 38 bytes
@(x)any(all([x;flip(x)]'==sort(x)',1))

Online demo

CJam, 12 11 bytes
q_$_W%+\#)g

Try it online!
Explanation
q            Push the input
 _$          Duplicate and sort
   _W%       Duplicate and reverse
      +      Concatenate the sorted and the reversed strings
       \     Bring input to the top
        #    Find the index of the input in the other string; returns -1 if not found
         )   Increment
          g  Signum (coerces to 0 or 1)

Pushy, 7 bytes
ogoGo|#

Try it online!
Explanation:
      \ Implicit: Input on stack as charcodes
og    \ Check if the stack is sorted ascendingly (Push 0/1)
oG    \ Check if the stack is sorted descendingly (Push 0/1)
      \   - Note that this will work regardless of the first check, as input
      \     is guaranteed to be /[A-Za-z]+/
o|    \ Bitwise OR
#     \ Print the result

This does not return one distinct true-value.

@steenbergh No, but it satisfies our meta consensus on what counts as truthy or falsy - 1 and 2 are True in Pushy, whereas 0 is False.

If Pushy has a bitwise OR operator, that should work instead.

@FlipTack I thought it was clear in the challenge, but I've now made it more specific: TRUE must output the same value on all testcases. Same goes for FALSE.

@steenbergh The meta consensus is there for a reason and makes sense, but if you insist...

Swift 4, 70 bytes
var o=Array(readLine()!);var g=o.sorted();print(o==g||o==g.reversed())

Try it online!

Python 3.5+, 37 bytes
lambda a:sorted(a)in([*a],[*a][::-1])

8086 machine code, 68 61 48 46 45 39 bytes
00000000  b2 31 be 82 00 ac 9f 88  c3 ac 3c 0d 74 14 38 c3  |.1........<.t.8.|
00000010  74 f5 e3 03 b1 00 9f 77  05 9e 76 ea eb 03 9e 77  |t......w..v....w|
00000020  e5 4a b4 02 cd 21 c3                              |.J...!.|
00000027

Assembled from:
org 0x100
use16
    mov dl, 0x31
    mov si, 0x82
    lodsb
a:  lahf
b:  mov bl, al
    lodsb
    cmp al, 0x0d
    je y
    cmp bl, al
    je b
    jcxz @f
    mov cl, 0
    lahf
@@: ja @f
    sahf
    jbe a
    jmp n
@@: sahf
    ja a
n:  dec dx
y:  mov ah, 0x02
    int '!'
    ret

Is comparing [si] longer or shorter?

√ å ı ¥ ® Ï Ø ¿ , 3 bytes
Ißo

This is a stack-based language that uses cp-1252 encoding. Full description at the link in the title.
How it works
I   - Take input and convert to characters
 ß  - Is sorted?
  o - Output

Add++, 13 bytes
L,B#b+dbRB]Ae

Try it online! Based on @caird coinheringaahing's answer.
Explanation
L,            [arg]                   Lambda with no flags
  B#          [sorted(arg)]           Sort every item in stack
    b+        [sorted]                Reduce top item by addition (string join)
      d       [sorted sorted]         Duplicate
       bR     [sorted reversed]       Reverse top item
         B]   [[sorted reversed]]     Clear stack and add stack as single stack item (sorted + reversed)
           A  [[sorted reversed] arg] Add arguent
            e [result]                Top item is found in second top item (Python's "x in y")

Add++, 28 18 bytes
L,2]dbRAº=
L^,bU#

Try it online!

C, 68 bytes
This assumes the use of a character encoding such as ASCII where the letters are in ascending (or descending) order.
f(char*s){for(int a=3;*s&&a;++s)a&=s[1]<=*s|2*(s[1]>=*s);return!*s;}

We use variable a to store two flags - bit 0 is set if everything we've seen so far is consistent with an ascending sequence, and bit 1 if it's consistent with descending.  Before we've seen anything, both are true.
If both these flags become false before the end of string, we exit the loop before s points at the terminating NUL and so return false (0).
If we reach the end of string, then we return true (1).
Test program
#include <stdio.h>
#include <string.h>
int main(int argc, char **argv)
{
    for (int i = 1;  i < argc;  ++i)
        printf("  %s -> %d\n", argv[i], f(argv[i]));
}

C++ (gcc), 125 124 123 115 bytes
Very boring obvious solution.  We use GCC's internal header to save many includes.  Conveniently, std::ranges::is_sorted() accepts equal adjacent elements, so we don't need to pass a std::less_equal<>() to it.
#include<bits/stdc++.h>
int f(auto s){using namespace std::ranges;return is_sorted(s)|is_sorted(s|views::reverse);}

Demo program:
#include <cstdio>
#include <string>

int main(int argc, char **argv)
{
    for (int i = 1;  i < argc;  ++i)
        std::printf("  %s -> %d\n", argv[i], f(std::string{argv[i]}));
}

Vyxal, 2 bytes
ÞȮ

Try it Online!
Simple means is ordered?

Ruby, 39 bytes
Returns false for ordered and true for unordered.
->s{!(s+$/+s.reverse)[s.chars.sort*""]}

Attempt This Online!

K (ngn/k), 14 bytes
{^(<x;>x)?!#x}

Try it online!
Returns 0 for "truthy" inputs and 1 for "falsy" inputs.

!#x generate 0..len(x)
(<x;>x) create a two-length list containing the grade up and grade down of the input
(...)?... find the indices in the list; if the indices (as a whole) are not present, this returns 0N (the integer null). otherwise, the 0-based index of the matching element is returned (i.e. 0 or 1)
^ null - returns 1 if its input is null, and 0 otherwise

C++, 138 bytes
#import<algorithm>
using namespace std;f(string s){string u,t=s;sort(t.begin(),t.end());u=t;reverse(u.begin(),u.end());return s==t||s==u;}

Haskell, 46 bytes
import Data.List
f s=sort s`elem`[s,reverse s]

Try it online! Usage: f "somestring", returns True or False.
Not as interesting as nimi's approach, but some bytes shorter.
Given a string s, we check whether s sorted is euqal to the original or reversed string.

Pyth, 5 bytes
}SQ,_

Explanation:
}SQ,_
}SQ      Check if the sorted input is a member ...
   ,_QQ  ... of [reversed input, input]

Scala, 52 bytes
def p(s:String)=List(s,s.reverse).contains(s.sorted)

Clojure, 69 66 bytes
#(let[s(apply str(sort %))](or(= % s)(= %(apply str(reverse s)))))

-3 by inlining reversed.
My original try ended up being a longer version of the other Clojure answer, so I went the "sorted" route. Checks if the original string is equal to a sorted version of itself, or a reversed sorted string. Amazingly, (apply str (reverse s) ended up being shorter than using the built-in reverse string method.
(defn lex? [s]
  ; (apply str ...) basically just turns a list into a string
  (let [sorted (apply str (sort s))
        reversed (apply str (reverse sorted))]
    (or (= s sorted) (= s reversed))))

Wouldn't it be shorter if you remove r altogether and put the definition of r in the second equality check?

@Qwerp-Derp Thanks, I forgot to inline that in my golfed version.

TI-Basic, 66 + 78 = 144 bytes
Input Str1
For(I,1,length(Str1
inString(Str2,sub(Str1,I,1->L1(I
End
L1->L2
Ans->L3
SortA(L2
SortD(L3
L1=L2 or L1=L3

And in Str2 you must have this (+78 bytes):
`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz

Retina, 36 bytes
Byte count assumes ISO 8859-1 encoding.
$
¶$_¶$_
O^#`\G.
Or`.\G
(.+)\D*\b\1$

Try it online!

Pyke, 5 bytes
SD_]{

Try it here!
S     -   sorted(input)
   ]  -  [^, v]
 D    -    ^
  _   -   reverse(^)
    { - input in ^

PHP 7, 63 bytes
for($s=$argv[1];$s[++$i]&a;)${$s[$i-1]<=>$s[$i]}=1;echo!$${-1};

Röda, 75 bytes
f s{x=[split(s,sep="")];[s=[sort(x)]&""or s=[sort(x,cmp={|a,b|[a>b]})]&""]}

Try it online!
Alternative solution:
f s{x=[split(s,sep="")];[s in[[sort(x)]&"",[sort(x,cmp={|a,b|[a>b]})]&""]]}

Try it online!
It is possible that shorter solutions exist, but I couldn't find them now.

Why not s/"" instead of split?

@KritixiLithos The / operator was implemented after this challenge.

Alice, 15 bytes, non-competing
/o.zz./
@inssR\

Try it online!
Prints nothing (or rather an empty string) as the falsy value and Jabberwocky as the truthy value.
Explanation
/.../
@...\

This is a template for linear string-processing programs that operate entirely in Ordinal mode. However, the code in between is executed in a zig-zag pattern first from left to right and then right to left. Unfolding this part, the actual program we get looks like this:
i.szR.szno

And here is what that does:
i   Read all input as a string.
.s  Duplicate and sort it.
z   "Drop to substring". If the original contains the sorted version (which means
    they're equal) this results in the empty string, otherwise we get the original back.
R   Reverse the string.
.sz Do the same thing again.
    If either the original or the reversed original was sorted, we end up
    with an empty string (falsy), otherwise we get the reverse of the original
    (truthy, because it's non-empty).
n   Logical NOT. Turns non-empty strings into empty (falsy) strings and
    empty strings into "Jabberwocky".
o   Print the result.

Standard ML (MLton), 99 93 bytes
open Char
fun g(x::y::r)c=c(x,y)andalso g(y::r)c|g&c=1=1
(fn$ =>g$op<=orelse g$op>=)o explode

Try it online! The last line is an anonymous function. Example usage: ((fn$ =>g$op<=orelse g$op>=)o explode) "somestring". Returns true or false.
Ungolfed code:
open Char
fun g (x::y::r) c = c(x,y) andalso g (y::r) c
  | g     _     c = true
fun h s = g s op<= orelse g s op>=
val f = h o explode

APL NARS 30 19 chars
{(⊂⍵[⍋⍵])∊(⊂⍵),⊂⌽⍵}

{(⍵[⍋⍵]≡⍵[⍳⍴⍵])∨⍵[⍋⍵]≡⍵[⌽⍳⍴⍵]}
Copy the algo of 'Emigna' in APL...Test
  f¨'ABCDEF' 'ZYX' 'tree' 'q'
1 1 1 1
  f¨'ABCDC' 'yes' 'deed'
0 0 0

Couple of questions: 1) link to interpreter? and 2) bytecount? I get 66 bytes, not 30 chars...

@steenbergh the request origin of Nars Apl is here http://www.nars2000.org/ the char count is 30 characters; the bytes count would be here 69 bytes. Each character seems more than 2 bytes...In a different code page would be possibly 30 bytes; but the advantage to have Unicode seems to me > of win some codegolf competition

@steenbergh this seems to run https://tio.run/##SyzI0U2pTMzJT///P/1R24RqjUe9W6Mf9XYDqdhHnQshvM2PereABDQfdazAIt@zF6GkVgEEuMCkwqO@qUAz09UdnZxdXN3Uuf7/BwA

15: {⍵(⌽⍵)∊⍨⊂⍵[⍋⍵]}

q/kdb+, 20 bytes
Solution:
{x in(asc;desc)@\:x}

Examples:
q){x in(asc;desc)@\:x}"tree"
1b
q){x in(asc;desc)@\:x}"yes"
0b
q){x in(asc;desc)@\:x}"ABCDEF"
1b

Explanation:
{x in(asc;desc)@\:x} / the solution
{                  } / anonymous lambda function
                   x / implicit input
               @\:   / apply (@) each left (\:) to x
     (asc;desc)      / list of two functions, sort ascending and descending respectively
 x in                / is x in either sorted/unsorted list?

Notes:
Closest equivalent in K4 would be {x in x@(>:;<:)@\:x} for 20 bytes too...

APL (Dyalog Unicode), 9 bytesSBCS
∨/⍬∘⍋⍷⍒,⍋

Try it online!
∨/ Is it anywhere true that (lit. OR-reduction of)
⍬∘⍋ the indices (viz. those that would put the argument into its current order)
⍷ are found in (each position of)
⍒ the indices that would put the argument into descending order
, followed by
⍋ the indices that would put the argument into ascending order?

Retina, 26 bytes
O`.
V`
$
¶$+¶$+1¶
(.+)¶\1¶

Try it online!
I still haven't seen a Retina program anywhere making use of the history feature, so here it is.
Explanation
O`.

Sort the input
V`

Reverse it
$
¶$+¶$+1¶

Append at the end of the string a newline ¶, followed by the original input to the program $+, another newline, the result of the first stage $+1, and a final newline. What we get is "input sorted descending¶original input¶input sorted ascending¶"
(.+)¶\1¶

Count the pairs of consecutive identical lines. This can be either 0, if the input was unordered, or 1 if the input was ordered.

Tcl, 75 bytes
proc L s {expr {[set C [split $s ""]] in [list [lsort $C] [lsort -de $C]]}}

Try it online!

PowerShell, 49 bytes
param($a)$a-in(0,1|%{-join($a|% t*y|sort -d:$_)})

Try it online!

Google Sheets, 113 bytes
It assumes the input string is in A1.
=OR(MAP({1,0},LAMBDA(o,LEN(REDUCE(A1,SORT(CHAR(ROW(65:90)),1,o),LAMBDA(a,c,REGEXREPLACE(a,"(?i)^"&c&"+",))))=0)))

SmileBASIC, 91 89 84 bytes
DIM A[1]INPUT S$WHILE LEN(S$)>1PUSH A,ASC(POP(S$))-ASC(POP(S$))WEND?MIN(A)*MAX(A)==0

Makes an array of the differences between consecutive characters (and an extra 0), and checks if either the min or max is 0.

Uiua SBCS, 9 bytes
∊:⊏⊟⊃⍖⍏..

Try it!

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


text:
Letter Interpolate
This is a fairly simple challenge. Given a lower-case word, you must "interpolate" between letters. Here's some examples to hopefully clarify this:
Input: test
Output: tsrqponmlkjihefghijklmnopqrst
Between letters you must add, in alphabetical order, the letters between those two letters. So if you have ad, you must output abcd. If you are given da, you must output dcba.
If the letters are next to each other in the alphabet, nothing happens:
Input: hi
Output: hi
Assume the input contains a lower-case word consisting of ASCII letters only; no spaces, symbols, etc. The input is also never empty.
Lowest byte count wins; this is code-golf. If you have any questions please comment.

What is the output for too? tsrqpo, tsrqpoo, tsrqpooo, something else?

Duplicate? (numbers instead of characters).

I agree that it's a duplicate - converting between ASCII characters and numbers is a minor difference.

Unless McMastery clarifies on Jonathan's question and there is some significant difference regarding that

05AB1E, 4 bytes
ÇŸçJ

Try it online!
Honestly? I don't know why this works.
Ç    # Push characters as ASCII.
 Ÿ   # Supposed to be range from [a, .., b], apparently vectorizes on lists...
  çJ # Turn back into characters, join stack.

I've seen this use for Ÿ before. It's a pretty cool feature

It's mis-documented slightly, hence my surprise :P. Ÿ 24 = pop a,b    push [a, ..., b]


text:
Convert a logical expression to conjunctive normal form
Goal:
Write a complete program or function which takes a formula in propositional logic (henceforth referred to as a logical expression or expression) and outputs that formula in conjunctive normal form. There are two constants, ⊤ and ⊥ representing true and false, a unary operator ¬ representing negation, and binary operators ⇒, ⇔, ∧, and ∨ representing implication, equivalence, conjunction, and disjunction, respectively which obey all of the usual logical operations (DeMorgan's law, double negation elimination, etc.).
Conjunctive normal form is defined as follows:

Any atomic expression (including ⊤ and ⊥) is in conjunctive normal form.
The negation of any previously constructed expression is in conjunctive normal form.
The disjunction of any two previously constructed expressions is in conjunctive normal form.
The conjunction of any two previously constructed expressions is in conjunctive normal form.
Any other expression is not in conjunctive normal form.

Any logical expression can be converted (non-uniquely) into a logically equivalent expression in conjunctive normal form (see this algorithm). You do not need to use that particular algorithm.
Input:
You may take input in any convenient format; e.g., a symbolic logical expression (if your language supports it), a string, some other data structure. You do not need to use the same symbols for true, false, and the logical operators as I do here, but your choice should be consistent and you should explain your choices in your answer if it's not clear. You may not accept any other input or encode any additional information in your input format. You should have some way of expressing an arbitrary number of atomic expressions; e.g. integers, characters, strings, etc.
Output:
The formula in conjunctive normal form, again in any convenient format. It need not be in the same format as your input, but you should explain if there are any differences.
Test cases:
P ∧ (P ⇒ R) -> P ∧ R
P ⇔ (¬ P) -> ⊥
(¬ P) ∨ (Q ⇔ (P ∧ R)) -> ((¬ P) ∨ ((¬ Q) ∨ R)) ∧ ((¬ P) ∨ (Q ∨ (¬ R)))

Notes:

If the input expression is a tautology, ⊤ would be a valid output. Similarly, if the input expression is a contradiction, ⊥ would be a valid output.
Both your input and output formats should have a well-defined order of operations capable of expressing all possible logical expressions. You may need parentheses of some sort.
You may use any well-defined choice of infix, prefix, or postfix notation for the logical operations. If your choice differs from the standard (negation is prefix, the rest are infix), please explain that in your answer.
Conjunctive normal form is not unique in general (not even up to reordering). You need only to output a valid form.
However you represent atomic expressions, they must be distinct from the logical constants, operators, and grouping symbols (if you have them).
Built-ins which compute conjunctive normal form are allowed.
Standard loopholes are forbidden.
This is code-golf; shortest answer (in bytes) wins.

related

CNF isn't unique up to reordering: the equivalent expressions P and (P ∨ Q) ∧ (P ∨ (¬Q)) are both in conjunctive normal form.

Checking for tautology/contradiction is a second task unrelated to CNF transformation, so I would suggest to drop this requirement and put in into its own challenge.

@Laikoni Very true. I updated the question to say that those are possible outputs for tautologies and contradictions rather than required outputs.

Maxima, 4 bytes
pcnf

Try It Online!
You can use implies, eq, and, or   operators for implication, equivalence, conjunction, and disjunction respectively.

The online sample doesn't work anymore, but here's an example: First load(logic), then: pcnf((c and (a or b)) or (a and b)). The response is: (a or b or c) and (not a or b or c) and (not b or a or c) and (not c or a or b)

You're going to hate me....
Mathematica, 23 bytes
#~BooleanConvert~"CNF"&

The input will use True and False instead of ⊤ and ⊥, but otherwise will look very similar to the notation of the question: all of the characters ¬, ⇒, ⇔, ∧, and ∨ are recognized in Mathematica (when input with UTF-8 characters 00AC, F523, 29E6, 2227, and 2228, respectively), and parentheses act as you would expect.
By default, the output will use Mathematica's preferred symbols: for example, the last test case will output (! P || ! Q || R) && (! P || Q || ! R) instead of ((¬ P) ∨ ((¬ Q) ∨ R)) ∧ ((¬ P) ∨ (Q ∨ (¬ R))). However, changing the function to
TraditionalForm[#~BooleanConvert~"CNF"]&

will make the output look pretty and conforming to these usual symbols:

JavaScript (ES6), 127 bytes
f=(s,t='',p=s.match(/[A-Z]/),r=RegExp(p,'g'))=>p?'('+f(s.replace(r,1),t+'|'+p)+')&('+f(s.replace(r,0),t+'|!'+p)+')':eval(s)?1:0+t

I/O format is as follows (in order of precedence):

(: (
): )
⊤: 1
⊥: 0
¬: !
⇒: <=
⇔: ==
∧: &
∨: |

Examples:
P&(P<=R) -> ((1)&(0|P|!R))&((0|!P|R)&(0|!P|!R))
P==(!P) -> (0|P)&(0|!P)
(!P)|(Q==(P&R)) -> (((1)&(0|P|Q|!R))&((0|P|!Q|R)&(1)))&(((1)&(1))&((1)&(1)))

The function is trivially rewritten to produce disjunctive normal form:
f=(s,t='',p=s.match(/[A-Z]/),r=RegExp(p,'g'))=>p?'('f(s.replace(r,1),t+'&'+p)+')|('+f(s.replace(r,0),t+'&!'+p)+')':eval(s)?1+t:0

8 bytes could be saved from this version if I was allowed to assume the above precedence on output too, which would remove all the parentheses from the output examples:
P&(P<=R) -> ((1&P&R)|(0))|((0)|(0))
P==(!P) -> (0)|(0)
(!P)|(Q==(P&R)) -> (((1&P&Q&R)|(0))|((0)|(1&P&!Q&!R)))|(((1&!P&Q&R)|(1&!P&Q&!R))|((1&!P&!Q&R)|(1&!P&!Q&!R)))


text:
Automate your first grade counting exercise
CodeGolf Challenge
PWSSHHHH! You wake up in a cryogenics lab in the year 3000. Upon being escorted to the assignment office to receive your career chip, presumably that of a delivery boy, a probe detects that you are from the year 2000. Because of this, and a few stereotypes, you are assumed stupid compared to today's modern human and are forced to repeat gradeschool.
You enter your first grade classroom and the teacher is giving an assignment. She will say or write a number up to 50. If she writes the number on the board (for example: 25) then you have to say the numbers up to that number "one, two, three, ..., twenty-five". If she says the number out loud (for example: "six") then, on your tablet, you have to write the numbers up to that number "1, 2, 3, 4, 5, 6"
This becomes very tedious and you decide you will automate the process with your still functioning, yet archaic, 21st century programming knowledge.

Objective:
Your program should take an input. This input will either be a decimal number (1 thru 50) or a written-out number (one thru fifty).
•If the input is a decimal number, your output should count from one to said number, using written-out style. (e.g. thirty-two)
•If the input is a written-out number, your output should count from 1 to said number, using decimal style. (e.g. 32)

Rules:
Input and Output can be in any case of your choosing (so you can make a program that only accepts upper-case if desired).
Input decimal numbers do not have to be of a number type (e.g. int), they can be a input string containing numbers (25 vs "25"). Either are fine and you can chose which one you want your program to accept. (Your program does not need to accept both)
Written out style does NOT require a hyphen between compound words, but you can if desired.
Output values have to be separated in some form, any separator is fine 1,2,3 1 2 3 etc
You can not add extra libraries like num2words (python) etc (However system libraries are fine)
Even though the back-story says you are from the year 2000, you can use languages created after that date (lol)

This is code-golf, so the program with the shortest bytecount wins!

Are we allowed to use libraries like num2words in case of python.

@GurupadMamadapur thank you for asking, I am going to say no for the sake of this challenge, I think it takes too much fun out of it. Editing this into my post

Just to be clear: "either" doesn't mean we have to choose the format we prefer, right? an answer should be able to handle both kinds of inputs (numbers and words).

Related: http://codegolf.stackexchange.com/q/57053/21348

@AlbertRenshaw but what about builtins that do that? (Mathematica)

@coredump Either means you can pick one or the other or both. It doesn't have to be able to handle both kinds of inputs

@AdmBorkBork system libraries are fine, edited into post.

@Pavel those languages have an advantage I suppose, answers might  be kind of boring though, I'm really enjoying seeing the creative solutions in languages that don't support that. This answer is great imo: http://codegolf.stackexchange.com/a/108776/16513

@AlbertRenshaw Ok thanks

"Bite my shiny metal ass!" I won't count myself

I keep thinking the title is "your first (grade counting)" not "your (first grade) counting"

Perl 6, 119 113 bytes
{my \n=<① ⑳ ㉑ ㉟ ㊱ ㊿>.map:{|map *.uniname.words[2..*].join,$^a..$^b}
/\d/??n[^$_]!!1..1+first $_,n,:k}

Unicode database FTW!
Uses upper-case written-out numbers without hypen, e.g. TWENTYTWO.
Returns a list of strings, or a range of numbers. (Both use space as separator when printed with put.)

Very clever ahahaha! Love it

Python3, 276 271 269 243 237 235 232 217 bytes
Taking a cue from the @smls perl submission...
from unicodedata import*
o=[name(chr(k)).split(' ',2)[-1]for j in['①⑴','㉑㉠','㊱㋀']for k in range(ord(j[0]),ord(j[1]))]
i=input()
w=i in o
for i in range(w and o.index(i)+1or int(i)):print(w and i+1or o[i])

I suspect it might be golfed a little bit further.
It makes use of the system library unicodedata to look up names for numbers.  It requires upper case number names (separated by space: FORTY TWO) or decimal integers as input.
(This is my first code golf submission.)
(I also just noticed I was miscounting the length (encoding), so it's a few bytes less than previously thought. I've only updated the most recent byte count, though. Oops.)

Welcome to PPCG!

In advocacy: unicodedata is a system library that comes with the default installation, not an "extra" library that needs to be installed separately.

Welcome to the site! You can remove lots of spaces from your code.

I can lose another dozen bytes if I don't bother with the join, but I end up with output like ['ONE', 'TWO', 'THREE'].  While it technically fulfills the "any sort of separator" condition the prefix and suffix may be out of bounds. It doesn't quite feel like it adheres to the spirit of the challenge...

I am fine with a system library being used. I like this solution too

Welcome to PPCG. You can lose 3 bytes by putting the print inside a for loop and having newlines between each output. print() doesn't care if it is an integer or a string then.  Try it online!

Thanks @ElPedro. I worked from your advice before looking at your link and came to basically the same result.

I think you can import* instead of import name to save a couple of bytes

Common Lisp, 297 253 243 242 144 128
(lambda(s)(#1=dotimes(u(or(#1#(i 51)(if(equal(#2=format()"~R"i)s)(return i)))s))(#2#t"~[~:;, ~]~:[~R~;~D~]"u(stringp s)(1+ u))))

Details
(lambda (s)
  (dotimes                         ; iterate...
      (u                           ; for u from zero below ...
       (or                         ; if s is a string, then
        (dotimes (i 51)            ;   parse s by iterating from 0 to 50
          (if (equal               ;   until we find a match between
               (format nil "~R" i) ;   the English word(s) for i
               s)                  ;   and the given s
              (return i)))         ;   (exit loop)
        s))                        ; otherwise, use s, which is a number
    (format t                      ; for each U, print to standard output
            "~[~:;, ~]~:[~R~;~D~]" ; (see below for details)
            u                      ; ...
            (stringp s)            ; ... arguments to format
            (1+ u))))              ; ...

~[ 0 ~; 1 ~; ... ~:; else ~] is a switch, based on the next available argument's value, which jumps to the appropriate sub-control format. Here, I only have a case of "0" and for "else". This is used to insert a separator before each number except the first one, thanks to U starting from zero.
~:[ FALSE ~; TRUE ~] is a conditional format; here we output things differently whether the input s is a string or not.
~R write a number as a cardinal English number, whereas ~D simply prints the number.

Examples
CL-USER> (test "five")
1, 2, 3, 4, 5

CL-USER> (test 32)
one, two, three, four, five, six, seven, eight, nine, ten, eleven, twelve, thirteen, fourteen, fifteen, sixteen, seventeen, eighteen, nineteen, twenty, twenty-one, twenty-two, twenty-three, twenty-four, twenty-five, twenty-six, twenty-seven, twenty-eight, twenty-nine, thirty, thirty-one, thirty-two

From what I understand of the question, you have to be able to parse both styles, not just one, so your 55 byte solution might not be valid. "Your program does not need to accept both" is referring to 25 vs "25", the decimal as a number or as a string.

@TomDevs Thanks. This is definitely confusing. To be sure, if I define f so that "(f 2)" prints "one, two" and (f "two") prints "1, 2", does it look good to you?

Yep, I think that's right.

@TomDevs Thanks, I fixed it

I had a feeling Lisp  would be used for this challenge! Does it support other languages too, just curious?

@AlbertRenshaw No, only English; this feature might be already considered as bloat, but since it was already implemented in some Lisps, it was standardized.

JavaScript ES6, 559 526 381 368 364 358 332 327 315 bytes
a="one0two0three0four0five0six0seven0eight0nine0ten0eleven0twelve0thir10four10fif10six10seven10eigh10nine1".replace(/1/g,'teen').split(0),b="twenty0thirty0forty0fifty".split(0),c=(n,d=Array,e=b.forEach(i=>a=a.concat(i,a.slice(0,9).map(x=>i+x))))=>1/n?a.slice(0,n).join():d.from(d(a.indexOf(n)+1),(x,i)=>i+1).join();

Thanks to Kritixi Lithos for the idea of splitting the array and Arnauld for the 1/n trick.

a="one0two0three0four0five0six0seven0eight0nine0ten0eleven0twelve0thir10four10fif10six10seven10eigh10nine1".replace(/1/g,'teen').split(0),b="twenty0thirty0forty0fifty".split(0),c=(n,d=Array,e=b.forEach(i=>a=a.concat(i,a.slice(0,9).map(x=>i+x))))=>1/n?a.slice(0,n).join():d.from(d(a.indexOf(n)+1),(x,i)=>i+1).join();

console.log(c("twentyfive"));
console.log(c("fifty"));
console.log(c(50));

You can remove the var and you can change the array ['one,'two',..] to "one0two0three0...".split(0)

Redundant whitespace at null, Array(n).

You can replace !isNaN(n) by 1/n. This gives you NaN for a string (falsy), a non-zero float for a non-zero integer (truthy), or Infinity for 0 (also truthy).

Add 4 spaces infront of every code line

@sagiksp Yeah, must have messed something up when editing the post, should be fixed now :)

PHP - 397 372 349 344 329 bytes
Inspired by TomDevs's JS solution
Saved 25 bytes by replacing $a=[...] by $a=explode(...)
Saved another 23 bytes by switching back to an array without string delimiters and by storing teen in a variable, thanks to @user59178
Saved another 5 bytes by removing the (int) typecasting
Saved another 15 bytes by dropping $b, the $i in the for declarations, and the curly braces, thanks to @user59178 again
$a=[one,two,three,four,five,six,seven,eight,nine,ten,eleven,twelve,thir.$t=teen,four.$t,fif.$t,six.$t,seven.$t,eigh.$t,nine.$t];foreach([twenty,thirty,forty,fifty] as$c){$a[]=$c;for($i=0;$i<9;)$a[]=$c.'-'.$a[$i++];}if($argv[1]!=0)for($i=0;$i<$argv[1];)echo$a[$i++].' ';else for($i=1;$i<=array_search($argv[1],$a)+1;)echo$i++.' ';

Ungolfed :
$a =[one,two,three,four,five,six,seven,eight,nine,ten,eleven,twelve,thir.$t=teen,four.$t,fif.$t,six.$t,seven.$t,eigh.$t,nine.$t];
foreach ([twenty,thirty,forty,fifty] as $c){
    $a[] = $c;
    for ($i=0;$i<9;)
        $a[] = $c . '-' . $a[$i++];
}
if( $argv[1] !=0 )
    for ($i=0;$i<$argv[1];)
        echo $a[$i++] . ' ';
else
    for ($i=1;$i<=array_search($argv[1], $a)+1;)
        echo $i++ . ' ';

Try it for an input string or for an input number

When golfing you can use many strings directly without any quotes, including all the number you use. This causes a notice but that can be ignored. Additionally it's shorter (by 2 whole bytes) to store teen in a  variable rather than repeating it each time. As such it would become: $a=[one,two,three,four,five,six,seven,eight,nine,ten,eleven,twelve,thir.$t=teen,four.$t,fif.$t,six.$t,seven.$t,eigh.$t,nine.$t];

Hadn't thought of that, thanks ;)

You can save 7 more bytes by dropping $b and putting the second array directly into the foreach, 6 more bytes by dropping all the curly braces (though you need to put the $a=$c into the setup of the for loop) and 6 more bytes by post-incrementing $i when you use it rather than in the 'after' bit of the for loops.

Save six bytes (two per loop) by moving the post-increment from the for to the following line: for ($i=0;$i<9;)$a[]=$c.'-'.$a[$i++];

Ooops, sorry, just noticed that @user59178 suggested the same thing...

Wow, I didn't know I could omit the third parameter of a for, thanks !

Well, you were still missing some golfing tricks and I was pretty sure I could beat the 315 byte javascript answer so here's a 306 byte modification: $a=[one,two,three,four,five,six,seven,eight,nine,ten,eleven,twelve,thir.$t=teen,four.$t,fif.$t,six.$t,seven.$t,eigh.$t,nine.$t];foreach([twenty,thirty,forty,fifty]as$c)for($a[]=$c;$i<9;)$a[]=$c.'-'.$a[$i++?:0];if(0<$t=$argv[1])for(;$j<$t;)echo$a[$j++?:0].' ';else for(;$j++<=array_flip($a)[$t];)echo$j.' '; The main savings were from assigning $argv[1] to a 1 byte variable and switching to using un-initialised loop counters.

Well, it seems like removing the $a[] = $c; declaration causes bugs : https://eval.in/728469 (for a string input) and https://eval.in/728468 (for an int input).

You're right, I didn't test properly. Sorry. for($a[]=$c,$i=0;$i<9;)$a[]=$c.'-'.$a[$i++]; works.

Scheme, 161, 152, 149
(define (c x)(let((r(string->number x)))(let l((i 1))(let((n (format #f "~r" i)))(display(if r n i))(newline)(or(eq? r i)(equal? x n)(l (+ i 1)))))))

Uncompressed:
(define (count limit)
  (let ((numerical-limit (string->number limit)))
    (let l ((i 1))
      (let ((current-number (format #f "~r" i)))
        (display (if numerical-limit current-number i))
        (newline)
        (or (eq? numerical-limit i)
            (equal? limit current-number)
            (l (+ i 1)))))))

How do you convert from e.g. "four" to 4? I am not sure string->number does this, I checked quickly and it seems to be used to convert e.g. from string "4" to number 4.

@coredump That is correct. (string->number "four") returns #f.

Which Scheme are you running?

@coredump guile 2.0.9

Python 2, 503 499 494 490 479 bytes
-5 with thanks to @JonathanAllan
l='one two three four five six seven eight nine ten eleven twelve thir#four#fif#six#seven#eigh#nine#'.replace('#','teen ').split()
m='twenty','thirty','forty','fifty'
i,z,R=raw_input(),' ',range
try:n=int(i);p=(n/10)-2;o=(l+sum([[m[x]]+[m[x]+z+l[y]for y in R(9)]for x in R(p)],[])+[m[p]]+[m[p]+z+l[y]for y in R(n%10)],l[:n])[n<20]
except:j=i.split();o=map(str,R(1,(m.index(j[0])+2)*10+l.index(j[1])+2if z in i else l.index(i)+2if i in l else(m.index(i)+2)*10+1))
print','.join(o)

Try it online!
Input either a number or a space seperated spelling of a number.
Slightly less golfed and more readable version:
l='one two three four five six seven eight nine ten eleven twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen'.split()
m='twenty','thirty','forty','fifty'
i=raw_input()
try:
 n=int(i)
 if n<20:
  o=l[0:n]
 else:
  o=l
  for x in range((n/10)-2):
   o+=[m[x]]+[m[x]+' '+l[y]for y in' '*9]
  p=m[(n/10)-2]
  o+=[p]+[p+' '+l[y]for y in' '*n%10]
except:
 if' 'in i:
  t=i.split()
  s=((m.index(t[0])+2)*10)+l.index(t[1])+2
 else:
  s=l.index(i)+2 if i in l else((m.index(i)+2)*10)+1
 r=range(1,s)
 o=map(str,r)
print','.join(o)

6 byte save with l="one two three four five six seven eight nine ten eleven twelve thir#four#fif#six#seven#eigh#nin#".replace("#","teen ").split()

...oops 5, missed the e from nineteen.

Is there a reason you need to use Python 2, without it the print would be longer, but the raw_input could just be input? (Same question for your other answer)

@nedla2004 - No reason other than that I haven't got round to installing Python 3 on my latest laptop yet :-)

Python 2, 262 bytes

x="one two three four five six seven eight nine ten eleven twelve thir#four#fif#six#seven#eigh#nine#".replace("#","teen ").split()
x+=[a+"ty"+b for a in"twen","thir","for","fif"for b in['']+x[:9]]
v=input()
for s in range(1,x.index(v)+2)if v>50else x[:v]:print s

repl.it
Input and output strings are lower case and concatenated*, so to test a string input enter, for example, "thirtyfive" at the prompt.
Builds the list of all the words (plus "fiftyone" to "fiftynine"), x, then tests if input is a word with the proxy v>50 (strings are greater than numbers in Python 2, and all the numbers in the valid input range from the specification are <=50) and prints the appropriate values by either slicing the list, x[:v], or building a range of integers, range(1,x.index(v)+2).
* Adding hyphenation on both costs 11 bytes, by replacing a+"ty"b with a+"ty"+'-'*(b>'')+b.

Wolfram Language, 92 bytes
If[NumberQ@#, Do[Print@IntegerName@i, {i, #}],
  Do[Print@i, {i, Interpreter["SemanticNumber"]@#}]] &

(I'm new to this, let me know if I did something wrong)

-10 bytes: Do[Print@If[#>0,i,,IntegerName@i],{i,If[#>0,#,,Interpreter["SemanticNumber"]@#]}]&

JavaScript (ES6), 261 bytes
Note: the string assigned to z is encoded with atob. In the encoded string there are 11 bytes that I can not post to this site, even if they are valid characters in a javascript string. So I used an hex escape in the form \xHH. Each one of these escapes is counted as 1 byte.
The original uncompressed string is the less golfed version.
x=>(z=btoa('ö\x89ÞöÜ(öØkyï_¢êý~+ÞöÈ±öÇ¯z\x7f^\x8a\x08möx§{Û^\x9f×¥z÷§öÜ\x1e\x96÷½¶\x18«÷×â\x7fß}z(!÷Ûpz\x7f}~\x8aý').split(9),o=(0+z.map((v,i)=>i<20?i<13?v:(v||z[i-10])+'teen':z.slice(0,10).map(d=>(z[i]||z[i-8]||z[i-18])+'ty'+d))).split`,`,p=o.indexOf(x),o.slice(1,-~x+p+!~p).map((x,i)=>~p?i+1:x))

Less golfed
x => (
  z = '9one9two9three9four9five9six9seven9eight9nine9ten9eleven9twelve9thir99fif999eigh99twen99for9'
      .split(9),
  o = (0 + // 0 + array to build a comma separated string
       z.map( (v, i) =>
         i < 20
         ? i < 13
           ? v // 1 to 13 are 'as is'
           : (v||z[i-10])+'teen' // compose for 14 to 19
         : z.slice(0,10).map(d=>(v||z[i-8]||z[i-18])+'ty'+d)) // 20s, 30s, 40s, 50s
      ).split`,`, // from comma separated to array again
  // o contains strings from one to fiftynine
  p = o.indexOf(x), // look for input
  o.slice(1, -~x+p+!~p).map((x,i) => ~p?i+1:x)
)

Test

F=
x=>(z=btoa('ö\x89ÞöÜ(öØkyï_¢êý~+ÞöÈ±öÇ¯z\x7f^\x8a\x08möx§{Û^\x9f×¥z÷§öÜ\x1e\x96÷½¶\x18«÷×â\x7fß}z(!÷Ûpz\x7f}~\x8aý').split(9),o=(0+z.map((v,i)=>i<20?i<13?v:(v||z[i-10])+'teen':z.slice(0,10).map(d=>(v||z[i-8]||z[i-18])+'ty'+d))).split`,`,p=o.indexOf(x),o.slice(1,-~x+p+!~p).map((x,i)=>~p?i+1:x))

function update() {
  var i=I.value
  O.textContent = F(i)
}

update()
<input id=I value=25 oninput='update()'>

ö\x89ÞöÜ(öØ... this stuff is great hahaa

Relevant to your top note: http://meta.stackoverflow.com/questions/342546/stackexchange-removes-certain-unicode-characters-from-code-blocks-causing-some

Python 2, 432 422 416 403 bytes
I'm sure this can be improved on.  At the very least if I can get away with hardcoding the value to be worked on and not needing a function I can save 20.  It needs a space to separate words in text input.  Saved 6 bytes thanks to JonathanAllan's comment on ElPedro's answer, 4 for rearranging maths.
def z(f):
 a,b,i,d="one two three four five six seven eight nine ten eleven twelve thir#four#fif#six#seven#eigh#nine#".replace("#","teen ").split()+[""],"twenty thirty forty fifty".split(),1,f>50
 if d:f=f.split();f=a.index(f[-1])+21+b.index(f[-2])*10 if len(f)>1 else b.index(f[-1])*10+20 if f[-1]in b else a.index(f[-1])+1
 while i<=f:s=i if d else a[i-1]if i<20 else b[i//10-2]+a[i%10-1];print s;i+=1

(NB: The actual version of this uses tabs to indent instead of spaces. QPaysTaxes added a single space because that wasn't rendering properly, to ensure that the given code compiles. It shouldn't change the byte count.)

@JonathanAllan's comment on ElPedro's answer works here too for -6

len(`f`)>2 can be ...`f`[2:] for another 3 I believe. (ignore the ... can't seem to get the backticks working properly)

In fact in python 2 you could go for f>50 for 6. (and another one by not using d)

@JonathanAllan that doesn't work for passing numbers as integers, which I currently do: TypeError: 'int' object has no attribute '__getitem__'. If I pass numeric input as a string, f[2:] gets closer but still fails when trated as a boolean (print f[2:] and True prints a blank line if len(f)<2, not True or False)

@JonathanAllan f>50 works, thank you.  Dropping d isn't so simple as I always put the end value of the loop into f so line 8 can't be changed to if f>50 as it will never be true.

With the backticks it makes sense

Off by one error for words less then "twenty" (a.index(f[-1])+1).

Upvoted but then noticed that for input of 22 it gives nineteen twentynineteen twentyone as the output.
Try it online!. I won't remove the upvote until you have had time to fix it.

@ElPedro that's bizarre, as it doesn't do that for 25, though I have seen that bug and it comes back quite easily so it might be a pasting error. I can't test on my phone but I  would guess that I end up with a[-1] and the solution is to add +[""]  to the definition of a for +5 bytes.

@ElPedro the fix was as I thought, plus another bugfix.  Saved a few by nesting ternaries

@JonathanAllan I think I introduced that one when trying to get a shorter defintion of d working.  Your fix implemented, thanks.  Byte count is still down because I could combine some lines

@Chris - Looks good!

@ElPedro and another -3, which I realised as I wrote the previous comment to you.

Is it just me or would this cause a syntax error because the contents of z aren't indented?

@QPaysTaxes if those lines aren't indented it's a formatting error when I uploaded the latest version and doesn't affect the byte count. They're indented by tabs in my source, which I can't fix on mobile. If the indent was 4 spaces the reason would be obvious, so I'm not sure what happened. I'll fix it later

Ah, alright. That makes sense. With your permission, I'll edit it to use a single space in front of the last three lines.

@QPaysTaxes thank you, that would be kind.

@ChrisH I didn't get your reply until just now. Edit suggested.

Python 3, 305 303 bytes
Converted to Python 3 after advice from @nedla2004. Now also has no space between written numbers on input or output e.g. enter twentytwo
l='one two three four five six seven eight nine ten eleven twelve thir#four#fif#six#seven#eigh#nine#'.replace('#','teen ').split()
m='twenty','thirty','forty','fifty'
i,R=input(),range
l+=sum([[m[x]]+[m[x]+l[y]for y in R(9)]for x in R(3)],[])
for x in R(1,l.index(i)+2)if i in l else l[:int(i)]:print(x)

Try it online 3!
Python 2, 327 320 313 308 bytes
l='one two three four five six seven eight nine ten eleven twelve thir#four#fif#six#seven#eigh#nine#'.replace('#','teen ').split()
m='twenty','thirty','forty'
i,R=raw_input(),range
l+=sum([[m[x]]+[m[x]+l[y]for y in R(9)]for x in R(3)],[])+['fifty']
for x in R(1,l.index(i)+2)if i in l else l[:int(i)]:print x

Try it online 2!
163 170 177 bytes shorter than my original answer so I am posting it as an alternative. This uses for on the two lists to build up a complete list of all of the string representations of the numbers then identifies the right one in the list and prints everything up to it either by value or by index. Outputs a new line for each value.

C++11, 484 480 477 bytes
#import<iostream>
#import<cstdlib>
#import<vector>
using namespace std;f(){int j,i=2;string s="teen";vector<string>v={"","one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve"};for(;i++<9;)v.push_back(v[i]+s);v[13]="thir"+s;v[15]="fif"+s;v[18]="eigh"+s;for(i=19;i++<50;){string n[4]={"twenty","thirty","forty","fifty"};v.push_back(n[i/10-2]+v[i%10]);}cin>>s;if(i=atoi(s.c_str()))for(j=0;j++<i;)cout<<v[j]<<" ";else while(v[i++]!=s)cout<<i<<" ";}

Text input in lower-case without hyphens.

Swift3, 402 bytes
let f=["one","two","three","four","five","six","seven","eight","nine"]
let g=["twenty","thirty","forty","fifty"]
let v=[f,["ten","eleven","twelve"],["thir","four","fif","six","seven","eigh","nine"].map{$0+"teen"},[g[0]],f.map{g[0]+$0},[g[1]],f.map{g[1]+$0},[g[2]],f.map{g[2]+$0},[g[3]]].flatMap{$0}
func c(s:String){if let i=Int(s){print(v.prefix(upTo:i))}else{for j in 1...v.index(of:s)!+1{print(j)}}}

Ungolfed:
let f = ["one","two","three","four","five","six","seven","eight","nine"]
let g = ["twenty","thirty","forty","fifty"]

let values = [f,["ten","eleven","twelve"],["thir","four","fif","six","seven","eigh","nine"].map{$0+"teen"},
              [g[0]], f.map{g[0]+$0},
              [g[1]], f.map{g[1]+$0},
              [g[2]], f.map{g[2]+$0},
              [g[3]]].flatMap{$0}

func count(s:String){
    if let i = Int(s) {
        print(values.prefix(upTo: i))
    } else {
        for j in 1...values.index(of: s)!+1{
            print(j)
        }
    }
}

count(s:"29")
count(s:"twentyeight")

Nothing special here, just using an array to back up the written-out numbers.
I originally thought this solution using this other way to calculate the values array:
let values = f + ["eleven","twelve"]
    + ["thir","four","fif","six","seven","eigh","nine"].map{$0+"teen"}
    + [g[0]] + f.map{g[0]+$0}
    + [g[1]] + f.map{g[1]+$0}
    + [g[2]] + f.map{g[2]+$0}
    + [g[3]]

Which could be golfed to:
let v=f+["eleven","twelve"]+["thir","four","fif","six","seven","eigh","nine"].map{$0+"teen"}+[g[0]]+f.map{g[0]+$0}+[g[1]]+f.map{g[1]+$0}+[g[2]]+.map{g[2]+$0}+[g[3]]

replacing the 3rd line in the golfed code
I could have scored 381 bytes, but, there is a compiler error that says: "expression was too complex to be solved in reasonable time", more info on the error can be found here

LOVE seeing swift in here, I'll have to check this out more when I get back

R, 452 430 424 bytes
o=c("","one","two","three","four","five","six","seven","eight","nine")
t=gsub(0,"teen",c("ten","eleven","twelve","thir0","four0","fif0","six0","seven0","eigh0","nine0"))
s=c("twenty","thirty","forty")
p=""
for(i in s){for(j in o){p=paste0(p,i,j," ")}}
as.data.frame(t(d<-1:50))
names(d)=c(o[-1],t,as.vector(strsplit(p," ")[[1]]),"fifty")
f=function(x){if(is.numeric(x)){names(d)[1:x]}else{matrix(d[1:d[x]],dimnames=NULL)}}

#> f(5)
#[1] "one"   "two"   "three" "four"  "five"

#> f('five')
#     [,1]
#[1,]    1
#[2,]    2
#[3,]    3
#[4,]    4
#[5,]    5

Places the numbers in a data.frame with written-out numbers as column names, making the translation between the two (and subsequent printing) pretty easy.
Main attempt at golfing was in creating the written-out numbers for 20-49, probably much more to golf here.
I made an attempt with as.matrix to print the data.frame with just the numbers, but am still left with a matrix header. Hopefully that's ok.
Ungolfed:
ones <- c("","one","two","three","four","five","six","seven","eight","nine")
teens <- c("ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen")
tens <- c("twenty","thirty","forty")

p=""
for(i in tens){
  for(j in ones){
    p=paste0(p, i, j," ")
  }
}

nums <- 1:50
as.data.frame(t(nums))
names(nums) <- c(ones[-1], teens, as.vector(strsplit(p, " ")[[1]]), "fifty")
f <- function(x){
  if(is.numeric(x)){
    names(nums)[1:x]
  } else {
    matrix(nums[1:nums[x]], dimnames = NULL)
  }
}

Slight improvement to 359 Bytes: o=c("","one","two","three","four","five","six","seven","eight","nine") ; v=c("ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"); w=c("twenty","thirty","forty"); a=data.frame(0:50, c(o,v, sapply(w[1:3],function(y) sapply(o,function(x) paste0(y,x))),"fifty")); b=which(a==i); a[if(b<52) 2:b else 2:(b-51),ifelse(b<52,2,1)]

@count looks like a big improvement! I can't seem to figure out where the function is, though, or where you'd take an argument.

PowerShell, 362 bytes
$z=0..50|%{("0twenty0thirty0forty0fifty"-split0)[+(($b="$_"[0])-gt49)*($_-gt19)*(+"$b"-1)]+($x=(("0one0two0three0four0five0six0seven0eight0nine0ten0eleven0twelve"-split0)+(-split'thir four fif six seven eigh nine'|%{$_+'teen'})))[($_%10)*($_-gt19)]+$x[$_*($_-le19)]}
if(($n=-split$args)[0][0]-in48..57){$z[$n[0]..$n[2]]}else{$z.IndexOf($n[0])..$z.IndexOf($n[2])}

Try it online! words input or numbers input
This is a right mess, and I'm not terribly happy with it, but here it is. Golfing suggestions welcome.
The first line sets $z to be an array of the full English words. You can see the -split0 for numbers 1 to 12, and the loop to construct all the teens, and then there's a bunch of logic to put everything together right. Try it online!
The second line starts with some logic. We take the input $args (as a string), -split it on whitespace, store it into $n for use later, take the first [0] word, and the first [0] character of that, and check if it is -in a range 48..57 (i.e., ASCII 0 to 9). So, we're checking if we have decimal input or English input. Try it online!
In the first case, we build a range based on the decimal inputs $n[0]..$n[2] and use that to index into $z[...]. In the other case, we find the .indexOf() the first word and the last word, and build just a numerical range from that. In either situation, we now have an array of objects on the pipeline (either strings or integers), and an implicit Write-Output at program completion gives us a newline between elements.

C, 342 331 bytes
char*x[]={"teen","one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve","thir","four","fif","twenty","thirty","fourty","fifty"};void main(int z,char**i){for(z=1;z<=atoi(i[3]);z++)printf("%s%s%s\n",z<16?x[z]:z<20?z^18?x[z-10]:"eigh":x[z/10+14],z>20&&z%10?"-":z>12&&z<20?*x:"",z>20&&z%10?x[z%10]:"");}

Try it online!

My favorite language :)

You actually don't need the 1 thru or one thru; all this codegolf requires is your third argument. The first two will always be "1 and thru" (or "one and thru")

@AlbertRenshaw Good call! Thanks :)

SAS, 179
%macro c(n);%let f=words.;%if%length(&n)>2%then%do;%do c=1%to 50;%if%qsysfunc(putn(&c,&f))=&n%then%let n=&c;%end;%let f=2.;%end;%do i=1%to &n;%put%sysfunc(putn(&i,&f));%end;%mend;

Output is written to the log separated by newlines. SAS has a built-in format for converting digits to words, which is a major advantage for this challenge, but annoyingly it lacks an informat for doing the reverse.