think of the strings as base-26 integers <@UC44J50...
# getting-started
s
think of the strings as base-26 integers @Egor
a
except
"ab" in "a".."z"
but if
a=0
,
z=25
and
ab=27
it won't work
s
“ab” isn’t in “a”..”z” though
a
yes it is...
s
where in the range of strings from “a” to “z” is “ab”? list them out and find it
a
lol
don't get a job in a library 😛
s
if it is then i’m not understanding how this works in the slightest lol
a
think alphabetical order
s
No, Campbell is correct.
a
"ab" comes after "a", but before "z"
s
"ab" !in 'a'..'z'
on the other hand,
"ab" in "aa".."az"
s
exactly
d
Interesting.
a
you guys are pretty lazy not just trying it before speaking https://pl.kotl.in/ryuzUMeG4
s
like, is
0xAB in 0xA..0xF
?
d
I knew it!
😁 1
a
hey,
'a'
is not the same as
"a"
@Shawn
s
that’s true, are we not on the same page?
a
go back to the start of the thread
s
oh, that’s interesting
s
I see.
s
I’m on my phone, I’d try it if I could lol
a
to be fair, took me a while to notice the chars in
"ab" !in 'a'..'z'
s
wait, is
”ba” in “a”..”z”
?
a
yes
s
take
the first n chars in the initial string (n being the length of the longest string in the range), convert to base 26, and compare that in the range
is how I see it calculating
a
what it is doing is
a in b..c
is
a.compareTo(b) >= 0 && a.compareTo(c) <= 0
e.g.
"ba"
is alphabetically after
"a"
but alphabetically before
"z"
s
alphabetically, yes
i’m thinking about how strings are compared in the first place
a
one character at a time left to right, if they are the same up until their lengths differ, the shorter one comes before the longer one
you don't have to read all the characters
"a" is always before "b <plus millions of chars>" no matter what those chars are
so converting to base26 number etc is not the way
s
but it works :)
think about it, alan. if you had to write your own
compareTo
impl for strings and emulate that behavior, how would you do it?
because
take
and conversion to base26 would be my method
b
note that things gets funny with unicode
"é" in "a".."z" => false (but not for a librarian)
a
@serebit "if you had to write your own
compareTo
impl for strings and emulate that behavior" I said how https://kotlinlang.slack.com/archives/C0B8MA7FA/p1546819682237400?thread_ts=1546817918.220500&amp;cid=C0B8MA7FA
I also showed right at the start of the thread that base 26 idea does not work. https://kotlinlang.slack.com/archives/C0B8MA7FA/p1546818291220700?thread_ts=1546817918.220500&amp;cid=C0B8MA7FA