26
\$\begingroup\$

Your task

Given a string, output the range of ASCII values.

Example

Let's say we have the string Hello.

We get the ASCII values:

  • H = 72
  • e = 101
  • l = 108
  • l = 108
  • o = 111

Now, we get the range (max - min):

  • 111 - 72 = 39

Our answer is 39.

Test cases

Input Output
Hello, World! 82
aaaaa 0
Code Golf 79
Stack Exchange 88
ASCII 18

Scoring

For scoring, we will get the range of ASCII/Unicode values of your program source code, and add that to the length of your code in bytes.

For example, with the program abc, the score would be:

  • 3 (the length of the program) + 2 (the ASCII range of the program) = 5

You can use this TIO link to get your score.

Clarifications

  • There will be no non-ASCII characters in the input (but your program source code may contain non-ASCII characters)
  • There will be no newline characters in the input (but your program source code may include newlines)
  • Lowest score wins
asked Nov 28, 2022 at 17:30
\$\endgroup\$
13
  • 1
    \$\begingroup\$ What if our language uses a different code page e.g. Jelly's code page instead of ASCII/Unicode? I'd suggest using the range of code points + length \$\endgroup\$ Commented Nov 28, 2022 at 17:34
  • 1
    \$\begingroup\$ What about languages for which the basic coding unit is not a character? For instance, machine code (basic units = raw bytes) or Nibbles (basic units = raw 4-bit nibbles). Should we score using the range of values of the basic unit, or the range of values of bytes in the code, or the range of Unicode values if the code was interpreted as if it was a string (but I imagine this might not always be parseable...)? \$\endgroup\$ Commented Nov 28, 2022 at 18:59
  • 3
    \$\begingroup\$ @JeppeStigNielsen - don't forget the range of the characters of your code, though: in this case it seems to be a whopping 9069: not very competitive! \$\endgroup\$ Commented Nov 29, 2022 at 10:54
  • 1
    \$\begingroup\$ @Deadcode yes it is. I'll add comments below the answers that don't support this. \$\endgroup\$ Commented Mar 10, 2023 at 17:53
  • 1
    \$\begingroup\$ @ShaunBebbington yeah, that's fine \$\endgroup\$ Commented Jun 4, 2023 at 18:57

58 Answers 58

1
2
9
\$\begingroup\$

MATL, score 37 (length 7, range 30)

X>GX<ZP

Try it online! Or verify all test cases and source code.

X> % Implicit input. Maximum
G % Push input again
X< % Minimum
ZP % Distance (of code points). Implicit display
answered Nov 28, 2022 at 19:48
\$\endgroup\$
8
\$\begingroup\$

C (clang), 79 bytes + 28 = (削除) 145 138 129 112 111 (削除ここまで) 107

-7 score thanks to @Digital Trauma
(削除) -9 (削除ここまで) -10 score thanks to @jdt

A,B;D(*C)??<*C<A?A=*C:*C>B?B=*C:0;*++C?D(C):0;??>C(*C)??<A=B=*C;D(C);*C=B-A;??>

Try it online!

Explanation

??< and ??> are trigraphs for { and } respectively

A,B; // A will track the minimum, B will track the maximum
D(*C){ // D() will traverse C updating the values of A and B
 *C<A? // if current character < A
 A=*C // update A with it's value
 :*C>B? // else if current character > B
 B=*C // update B with it's value
 :0; // else, do nothing
 *++C? // if we're not at the end of the string
 D(C) // call D recursively with the next character
 :0; // else, do nothing
} // end D()
C(*C){ // C() takes the string, which is also where we'll store the output
 A=B=*C; // initialize A and B with the first character in C
 D(C); // call D
 *C=B-A; // store the range (max - min) in the out argument
} // end C()
answered Nov 28, 2022 at 19:42
\$\endgroup\$
6
  • 1
    \$\begingroup\$ You can reduce the overall score to 138 if you use trigraphs: ... \$\endgroup\$ Commented Nov 28, 2022 at 20:23
  • \$\begingroup\$ tio.run/… \$\endgroup\$ Commented Nov 28, 2022 at 20:23
  • \$\begingroup\$ @DigitalTrauma nice one, braces are really expensive \$\endgroup\$ Commented Nov 28, 2022 at 20:24
  • 1
    \$\begingroup\$ score: 111 \$\endgroup\$ Commented Nov 30, 2022 at 17:29
  • \$\begingroup\$ @jdt that's interesting, I didn't know you could do that \$\endgroup\$ Commented Nov 30, 2022 at 22:11
6
\$\begingroup\$

Bash + GNU utilities, 52 bytes + 92 range = 144

od -An -w1 -td1 -v|sort -n|sed -n '1p;$p'|dc -e??r-p

Try it online!

answered Nov 28, 2022 at 20:24
\$\endgroup\$
4
\$\begingroup\$

Pip, 13 bytes + 39 = 52

a:A^aMXaADMNa

Try It Online!

Explanation

A straight code-golf solution to the challenge might look like this:

A*:a;Ma-Na
 a First command-line argument
A* Get ASCII value of each character
 : and assign that list of integers back to a
 ; Statement separator
 Na Minimum of a
 a- Subtract that from each element in a
 M and take the maximum of the resulting list

This gets a score of 65. The a for getting the command-line argument and A for taking ASCII values are both necessary, so to improve the score we'll need to look at the characters with ASCII values less than A.

The smallest character is *, which we can get rid of by splitting the string into a list of characters with ^ and passing that list to A directly:

A*:a
 ->
a:A^a

The next-smallest character is -, which we can get rid of by using the absolute difference operator AD instead. Then we have to rearrange a bit more to avoid needing a space; we'll use the old MX and MN operators for max and min instead of the newer M and N.

Ma-Na
 ->
MXaADMNa

(We could also keep using M, but since it also requires a semicolon to parse correctly, the score is the same if we replace it with MX which doesn't need the semicolon.)

answered Nov 28, 2022 at 19:18
\$\endgroup\$
4
\$\begingroup\$

Octave, score 56 (length 6, range 50)

@range

Try it online!

answered Nov 28, 2022 at 19:54
\$\endgroup\$
4
\$\begingroup\$

Terse, 7 bytes + 6769 = 6776

找没最手样找到

Try it here

Could be worse.

找    Char codes
 没    Maximum, after
 最手   Squaring and then square root (identity)
  样  Subtract
   找到 Minimum
answered Nov 28, 2022 at 23:15
\$\endgroup\$
4
  • \$\begingroup\$ what kind of wretched 残体字 programming language is this ?? \$\endgroup\$ Commented Dec 19, 2022 at 5:12
  • \$\begingroup\$ @RAREKpopManifesto let's say I did not have readability in mind when I designed the stuff \$\endgroup\$ Commented Jan 1, 2023 at 20:29
  • \$\begingroup\$ that's not my point - i could read simplified. the question was about why use a character set invented by CCP instead of one that has existed since 嬴政 統一六國 文字 ? \$\endgroup\$ Commented Jan 2, 2023 at 19:13
  • \$\begingroup\$ Unfortunately this program can't handle strings of length 1, for which it should return \0ドル\$. \$\endgroup\$ Commented Mar 10, 2023 at 17:54
4
\$\begingroup\$

Alumin, (削除) 36 (削除ここまで) 19 bytes + (削除) 22 (削除ここまで) 20 = (削除) 58 (削除ここまで) 39

idiqdhhhwrvsruripkc

Try it online!

Both the right language for the job(削除) , and horribly inefficient at it! (削除ここまで) Turns out, I'm just an inefficient thinker!

Explanation

idiqdhhhwrvsruripkc
 explanation | stack
id take input, duplicate | MAX MIN
 iq ip while input > 0 | MAX MIN in
 d duplicate | MAX MIN in in
 hhhw grab top 3 | MAX [ MIN in in ]
 r reverse stack | MAX [ in in MIN ]
 v get lesser of two | MAX [ in MIN' ]
 s ungrab | MAX in MIN'
 r reverse stack | MIN' in MAX
 u get greater of two | MIN' MAX'
 r reverse stack | MAX' MIN'
 (this gives us a better score than using `y` to swap 2)
 loop finishes | MAX MIN -1
 k discard eof | MAX MIN
 c subtract | MAX-MIN

Explanation (Old)

hqidrlhcwrspkrklhhgwfufsykrlhcwfvfsc
h push 1 (to start loop)
 q p input loop
 id take input, duplicate
 r reverse stack
 lhc stack length - 1
 wrs reverse that many elements off the stack
 this has the effect of pushing two copies of the input
 krk pop trailing EOF twice
 lhhg stack length / 2
 w grab that many elements into a new stack
 fuf fold over maximum
 sykr place on bottom stack, remove initial 1
 lhc stack length - 1
 w grab that many elements as before
 fvf fold over minimum
 sc push and subtract
answered Nov 29, 2022 at 21:27
\$\endgroup\$
3
\$\begingroup\$

Husk, 11 bytes + 63 = 74

ASz>o;FYOmc

Try it online!

ASz>o;FYOmc
 m # map over input
 c # getting character values
 O # and sort into ascending order;
 z # now, zip together
 > # getting differences
 S # the sorted list itself
 # and
 o; # the single-element list of
 F # fold over the sorted list
 Y # getting pairwise maxima
A # finally, get the average
 # of the resulting single-element list.
answered Nov 29, 2022 at 8:37
\$\endgroup\$
3
\$\begingroup\$

Nibbles, (削除) 9 (削除ここまで) 12 bytes + (削除) 56 (削除ここまで) (削除) 49 (削除ここまで) 38 = 50

;*;-;o;/;\;`<@@o;/_$;`$$

This corresponds to the Nibbles program with nibbles:

6 a 6 9 6 e 6 a 6 b 6 e 4 d 4 e 6 a 5 3 6 d 7 3

Which, paired-up into bytes, gives

6a 69 6e 6a 6b 6e 4d 4e 6a 53 6d 73

which can be read-out as a string (with the same ASCII values)

jinjknMNjSms

with ASCII range 115 (73) - 77 (4d) = 38.


How? We start from a straightforward code-golf solution to the question: -o/\;`<$$o/ (5.5 bytes, 11 nibbles):

-o/\;`<$@o/
- # subtract
 o # character value of
 / # fold over
 \ # reverse of
 ; # (save)
 `< # sorted
 @ # input
 $ # returning left element each time
 # (so the fold returns the first element)
 # from
 o # character value of
 / # fold over
 # (implicit) saved sorted input
 # (implicit) returning left element each time

The nibbles are slightly re-arranged in the final program, since the 2-nibble 'sort' function ( `<) wraps around its argument (here $). Thus, the paired-up nibbles from this are:

-o /\ ;` @< $o / # program code (in final order)
9e ab 6e 4d 3e a # nibbles

We can reduce the range of bytes by inserting 'save' operators (;, nibble 6) to shift high-valued nibbles into the least-significant-nibble position of each byte.
This doesn't affect the output, but we need to override the final implicit variable to account for the saved (but ignored) values. Hence:

;- ;o ;/ ;\ ;` @< $o ;/ ;$ # program code (in final order), with final variable changed to ;$
69 6e 6a 6b 6e 4d 3e 6a 63 # nibbles

Modifying both folds (so returning right element @ instead of left element $) avoids the lowest byte 3e, but unfortunately outputs a negated value.
So we multiply (and save: ;*) the negated value by its own sign (also saved: ;`$): this corrects the output, introducing a new highest byte of 73, but the overall score is still reduced.

enter image description here

answered Nov 28, 2022 at 21:00
\$\endgroup\$
2
  • \$\begingroup\$ @TheThonnu - The actual program corresponds to the nibbles in the .nbb file. The string that you've calculated from is just a human-readable form (which uses one character for every nibble of the program). The bytes of the program that you've scored were hex values 69 6a 6c 3e 38 34 6a 4a 34, giving the all-ASCII string ijl>84jJ4 with range 56. \$\endgroup\$ Commented Nov 29, 2022 at 7:48
  • \$\begingroup\$ @TheThonnu here is an example of using the raw bytes of the (now updated) program directly. Obviously, the program is unintelligible for a human like this (since the characters represent pairs of nibbles that are smashed-together), but this is what it looks like if interpreted as characters... \$\endgroup\$ Commented Nov 29, 2022 at 7:55
3
\$\begingroup\$

Julia, 22 bytes + 80 = 102

+s=-(-(extrema(s)...))

Attempt This Online!

answered Nov 29, 2022 at 14:00
\$\endgroup\$
3
\$\begingroup\$

Java 8, score: 134 (54 bytes)

s->s.chars().max().orElse(0)-s.chars().min().orElse(0)

Try it online (also contains code to extract the lambda function from the code-block and calculate its score: (max_codepoint - min_codepoint) + length).

Not too much too improve unfortunately.

  • We could change the x to \u0078, but unfortunately the next highest codepoint then becomes u which isn't too much lower than x, so the +5 in byte-count is higher than the -3 in codepoint, giving a +2 in score instead of decrease: Try it online.
  • Using a regular for-loop requires both {} and a space, so the difference of the max-min codepoints would widen on both ends. And in addition it's longer anyway: Try it online.

Explanation:

s-> // Method with String parameter and integer return-type
 s.chars() // Convert the String to an IntStream of codepoint integers
 .max() // Get the maximum of these codepoints
 .orElse(0) // Convert the OptionalInt to an int
 // (`.orElse(0)` is 1 byte shorter than `.getAsInt()`)
 - // And subtract
 s.chars().min().orElse(0)
 // The same to get the minimum codepoint
answered Nov 29, 2022 at 14:44
\$\endgroup\$
3
\$\begingroup\$

Excel, score = (削除) 103 (削除ここまで) 94 (length 46, range 48)

-9 score thanks to Engineer Toast

=LET(A,CODE(RIGHT(A1,ROW(A:A))),MAX(A)-MIN(A))

enter image description here

answered Nov 28, 2022 at 21:36
\$\endgroup\$
1
  • 2
    \$\begingroup\$ Same range but shorter length (46) by abusing CODE() which will convert only the first character of a multi-character string: =LET(A,CODE(RIGHT(A1,ROW(A:A))),MAX(A)-MIN(A)) \$\endgroup\$ Commented Nov 29, 2022 at 14:58
3
\$\begingroup\$

K (ngn/k), (削除) 12 bytes + 86 = 98 (削除ここまで) 13 bytes + 56 = 69

h/t @isaacg

+/1_-':@/1<:\

Try it online!

answered Nov 30, 2022 at 2:22
\$\endgroup\$
3
\$\begingroup\$

MATL, 3 bytes + 32 = 35

Sds

Explanation

Sds
S % Sort implicit input
 d % Difference between adjacent elements
 s % Sum the values

Try it online!

answered Mar 10, 2023 at 19:44
\$\endgroup\$
2
\$\begingroup\$

Jelly, 5 bytes + 149 = 154

I think this is about as good as it's going to get in Jelly due to the distance between O (unavoidable as it's the only way to get the ordinals of the input string) and the large ordinals of Unicode characters representing the bytes for mapping and getting maximums and minimums, index into a list etc.

OÞOIS

A monadic Link that accepts a list of characters and yields the range size as an integer.

Try it online!

How?

OÞOIS - Link: list of characters (ordinal)
 Þ - sort by: (222)
O - ordinal value (79)
 O - ordinal values (79)
 I - forward differences (73)
 S - sum (83)
 ----
 222
 -ひく 73
 ====
 149
answered Nov 28, 2022 at 18:13
\$\endgroup\$
7
  • \$\begingroup\$ Yeah, the golflangs with custom codepages are probably going to struggle on this challenge... \$\endgroup\$ Commented Nov 28, 2022 at 18:13
  • \$\begingroup\$ @TheThonnu strictly speaking the code is bytes (the Unicode characters are just an abstraction for ease of reading), but I think this may still be best using that measure too (with a score of \5ドル + 63 = 68\$). \$\endgroup\$ Commented Nov 28, 2022 at 18:18
  • \$\begingroup\$ Would it help if you used literal UTF-8 bytes and ran with fu or eu? \$\endgroup\$ Commented Nov 28, 2022 at 19:58
  • 2
    \$\begingroup\$ No, I mean take the literal indices in the Jelly codepage and interpret it as a UTF-8 byte sequence, then run with Jelly's fu/eu flags. I thought it might be a lower score. (In other words, use the indices in the Jelly codepage, and have the program use those indices as UTF-8 byte sequence.) \$\endgroup\$ Commented Nov 29, 2022 at 1:46
  • 1
    \$\begingroup\$ Sorry, I had it backwards lol. Yes, what i meant is running without the u flag. Try it online! \$\endgroup\$ Commented Nov 29, 2022 at 22:11
2
\$\begingroup\$

R, 29 bytes + 77 = 106

\(a)diff(range(utf8ToInt(a)))

Attempt This Online!

Seems that most golfy approach has also the lowest score, since we need to use utf8ToInt() and it has the range of 77 by itself.

answered Nov 29, 2022 at 7:28
\$\endgroup\$
2
\$\begingroup\$

JavaScript (Node.js), 42 bytes + 80 = 122

s=>Math.max(...b=Buffer(s))-Math.min(...b)

Try it online!

answered Nov 29, 2022 at 9:51
\$\endgroup\$
2
\$\begingroup\$

Ly, 8 bytes + 70 = 78

ia0I-s>l

Try it online!

I found a shorter program, but the character range of the code was big enough that it had a higher total score.

ia - read STDIN onto stack as codepoints, sort the stack
 0I - copy the bottom of the stack to the top
 - - subtract to get the range
 s>l - save result, switch to clean stack, load result
answered Nov 29, 2022 at 10:43
\$\endgroup\$
2
\$\begingroup\$

Raku, 25 bytes

ASCII range: 88 Length: 25 Total score: 113

[-] @_.ords.minmax[*-1,0]

Try it online!

answered Nov 29, 2022 at 13:34
\$\endgroup\$
5
  • 1
    \$\begingroup\$ Note the custom scoring criteria - you need to add ASCII range of your code to the score \$\endgroup\$ Commented Nov 29, 2022 at 14:01
  • \$\begingroup\$ @KirillL. Got it, thanks. \$\endgroup\$ Commented Nov 29, 2022 at 14:07
  • 1
    \$\begingroup\$ By our site consensus, you can't take input from a variable (@_ in this case). You can take input from a function: {[-] .ords.minmax[*-1,0]} for a score of 118. You can also use a full program: put [-] get.ords.minmax[*-1,0] which is also 118 score. \$\endgroup\$ Commented Nov 29, 2022 at 21:58
  • \$\begingroup\$ @Steffan Thanks for your input. Is it acceptable with some like this? \$\endgroup\$ Commented Nov 30, 2022 at 14:42
  • \$\begingroup\$ Sorry, no, because you're still taking input from a variable ($_). \$\endgroup\$ Commented Nov 30, 2022 at 17:10
2
\$\begingroup\$

J, score 70 (16 bytes, range 54)

[:+/2-/\a.I.]\:]

Try it online!

  • ] \: ]: Pass the input (using the identity function ]) on both sides of \: to sort it in descending order.
  • a. I.: For each character of the sorted input, find its index in the "alphabet"; at least on TIO's setup, this contains all of ISO-8859-1 in order, which includes ASCII. Thus, this produces the ASCII values of the characters, while keeping the highest used character lower than the straightforward method of 3 u: would.
    (I. would also take the following index if a character is not found, but that never happens; it was chosen over i. to reduce the highest used character.)
  • 2-/\: For each length-2 subarray (from the 2 and \), subtract the second value from the first (- /).
  • [: +/: Take the sum (+ /) of the values, using [: to do so monadically.
answered Nov 29, 2022 at 9:57
\$\endgroup\$
2
\$\begingroup\$

Charcoal -v, 35 bytes, score 61

castminusordceilceil[q]ordminmin[q]

Try it online! Abusing Charcoal's verbose parser again. In order for it to recognise q as a variable name I can't follow it with a letter, so the next nearest suitable characters are the list delimiters. I've also used ceil instead of max to avoid using an x; this costs 2 bytes but overall saves 1 from my score. Normally the program would be written like this:

Print(Cast(Minus(Ordinal(Maximum(q)), Ordinal(Minimum(q)))));

The best I could do in succinct Charcoal was a score of 10135:

⭆ψ−c/o⌈θc/o⌊θ

Try it online! Link is to verbose version of code. Explanation: The limiting factors here are the Greek letter θ needed for the two occurrences of the input variable (the only other input method uses S which has a ridiculously high Unicode code point of 65531) and the used to stringify the result (again, I would have had far too high a code point).

 ψ Predefined string null character
⭆ Map over characters and join
 θ Input string
 ⌈ Maximium
 c/o Ordinal
 − Minus
 θ Input string
 ⌊ Minimum
 c/o Ordinal
 Implicitly print

If using bytes from Charcoal's code page was allowed, its score would "only" be 210:

SαI−c/o⌈αc/o⌊α

Try it online! Link is to verbose version of code. Explanation: The limiting factors here are that (Minimum) is byte index 25 while α (variable a) is byte index 225, although I did reduce my score by 14 by taking the input into α rather than the default input of θ (variable q, byte index 241).

S Input as a string
 α Store in variable `a`
 α Input string
 ⌈ Maximum
 c/o Ordinal
 − Subtract
 α Input string
 ⌊ Minimum
 c/o Ordinal
 I Cast to string
 Implicitly print
answered Nov 28, 2022 at 19:02
\$\endgroup\$
2
\$\begingroup\$

Pyth, 8 bytes + 34 = 42

+F.+CDCM

Try it online!

  • CM: Map to ASCII value

  • CD: Sort (equivalent to S)

  • .+: Deltas (Differences between consecutive elements, all nonegative because of sort)

  • +F: Sum (equivalent to s)

Using .+ is golfier than h and e, and also stays within the established ASCII value range.

answered Nov 29, 2022 at 20:55
\$\endgroup\$
2
  • \$\begingroup\$ Using deltas is a neat trick. K doesn’t have a handy sort so it ends up longer. f:+/1_-':@/1<:\. \$\endgroup\$ Commented Nov 30, 2022 at 2:43
  • \$\begingroup\$ Ah, but it lowers the score! Thanks. \$\endgroup\$ Commented Nov 30, 2022 at 5:08
2
\$\begingroup\$

Burlesque, 12 bytes + 52 = 64

)**J>]\/<].-

Try it online!

)** # Map to char code
J # Duplicate
>] # Maximum
\/ # Swap
<] # Minimum
.- # Difference
answered Nov 30, 2022 at 0:22
\$\endgroup\$
2
\$\begingroup\$

C# (Visual C# Interactive Compiler), 98 score (18 bytes)

ASCII range: 80
Length: 18
Total score: 98

s=>s.Max()-s.Min()

Try it online!

  • -27 score thanks to Kevin Cruijssen for the tip to use C# Interactive

C# (Visual C# Compiler), 125 score (36 bytes)

ASCII range: 89
Length: 36
Total score: 125

s=>s.Max()-s.Min()

If we're going traditional through the compiler then we have to include an extra 18 bytes for using System.Linq;

Try it online!

answered Nov 29, 2022 at 17:24
\$\endgroup\$
2
  • \$\begingroup\$ 98 score (18 length + 80 max-min) by using the Visual C# Interactive Compiler as language, so you won't need the Using: try it online. \$\endgroup\$ Commented Nov 29, 2022 at 17:42
  • \$\begingroup\$ @KevinCruijssen Ah good tip, it's been a while so a little rusty on some of the tips and tricks! \$\endgroup\$ Commented Nov 30, 2022 at 8:55
2
\$\begingroup\$

Vyxal, 6 bytes + 67 = score 73

C:G$g-

Try it Online!

answered Nov 28, 2022 at 19:56
\$\endgroup\$
2
  • \$\begingroup\$ Why the additional f? It seems like the older 6 byte version both meets all test cases and has a lower score \$\endgroup\$ Commented Apr 3, 2023 at 15:08
  • \$\begingroup\$ @emirps it only works because of an update made a couple days ago that make G and g on numbers be a no-op instead of erroring. Thanks \$\endgroup\$ Commented Apr 4, 2023 at 0:35
2
\$\begingroup\$

Wolfram Language (Mathematica), 31 bytes + 85 = 116

ToCharacterCode@s//Max@#-Min@#&

Try it online!

answered Apr 6, 2023 at 0:14
\$\endgroup\$
1
  • \$\begingroup\$ This challenge has its own scoring criterion (not code-golf) so your score is 116 \$\endgroup\$ Commented Apr 6, 2023 at 5:56
2
\$\begingroup\$

Thunno 2 GB, 2 + 24 = 26

G_

Try it online!

Port of lyxal's Vyxal answer.

Explanation

G_ # Implicit input
 # Convert to codepoints
G # Maximum codepoint
 _ # Subtract each input codepoint
 # Find the maximum
 # Implicit output
answered Jul 20, 2023 at 8:43
\$\endgroup\$
1
\$\begingroup\$

Sequences, score = 73 + 4.12 = 77.12

(Sequences uses the 96 printable ASCII characters as its codepage, so the byte count of this program is \5ドル\log_{256}(96) \approx 4.12\$)

`vMm-

Explanation

`vMm- # Implicit input as a string
`v # Get the ASCII values of the input string in a list
 M # Get the maximum value of that list
 m # Get the minimum value of that list
 - # And subtract to find the range
 # (implicit output)
answered Nov 28, 2022 at 17:30
\$\endgroup\$
1
\$\begingroup\$

Python, 39 + 80 = 119

print(ord(max(s:=input()))-ord(min(s)))

Attempt This Online!

answered Nov 28, 2022 at 18:21
\$\endgroup\$
1
\$\begingroup\$

Ruby, 26 bytes + 80 = 106

-2 bytes thanks to Steffan

->s{y=s.bytes;y.max-y.min}

Attempt This Online!

answered Nov 28, 2022 at 18:46
\$\endgroup\$
2
  • \$\begingroup\$ Same ASCII range, two bytes shorter: ->s{y=s.bytes;y.max-y.min} \$\endgroup\$ Commented Nov 28, 2022 at 19:53
  • \$\begingroup\$ @Steffan Cool, thanks. \$\endgroup\$ Commented Nov 28, 2022 at 20:06
1
2

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.