#dev-general
1 messages · Page 365 of 1
now when i ask questions on that site, they dont get answers cause they are too hard
lol
I'm mad
oml wtf
okay, you guys remember how I said material likes to change my editor?
guess what I see now
tf is this? Eclipse?
lmao
lol
doesn't clip use that theme?
🥲
it fucking deleted the custom theme I had
that's why
mother fucker
oh no!
lol
now I gotta write up the changelog for Krypton 0.14 🥲
I made sendActionBar, sendPlayerListHeaderAndFooter, showTitle, clearTitle and resetTitle work
added some documentation for data class constructor params with @param
switched to superior Kotlin DSL
also switched the config format to HOCON instead of TOML
also just used my brain and realised that KryptonServer can be an object
so yes, the server is now a singleton 🥲
ew
well, the backend of the server anyway
dw, there's no singletons in the actual API
actually, does having it be a singleton mean I still get control over when it's instantiated?
no
right, back to a class then lol
oh btw, probably asked this 100 times before, but I should definitely swap out using the manifest's main class for a main attribute in plugin.conf right?
screw it, it's done lol
also, is it just me or is use one of the most useful extensions to I/O streams there is
return JarFile(file).use { jar ->
val entry = jar.getJarEntry("plugin.conf")
?: throw FileNotFoundException("Plugin's JAR does not contain a plugin.conf!")
jar.getInputStream(entry).use {
HOCON.decodeFromConfig(ConfigFactory.parseReader(InputStreamReader(it)))
}
}
```vs```kotlin
val jar = JarFile(file)
val entry = jar.getJarEntry("plugin.conf")
?: throw FileNotFoundException("Plugin's JAR does not contain a plugin.conf!")
val stream = jar.getInputStream(entry)
try {
return HOCON.decodeFromConfig(ConfigFactory.parseReader(InputStreamReader(stream)))
} finally {
jar.close()
stream.close()
}
it's literally try with resources
that's what I mean
but use is so much better than try-with-resources
so much more idiomatic
xD
also, I do love some of the hackery in this project
like avoiding using ticking to send keep alive packets by using an SES
lol
I'm still actually thinking about how I'd even do ticking
since I've made a vow that a "primary thread" will never exist in Krypton
well, when Krypton gets into release anyway
that will not exist
questionable
as someone said the other day use creates arrow code
try with resources doesnt
what exactly are you going to do in place of having a primary thread o.o
die
distribute the load across many coroutines
if I can
yeah ik
I could split up the world into sections and have each section be processed concurrently
but that might get expensive at scale
that's a lot of threads

which you can kinda just throw around
i was thinking
tfw that's literally what aether does
what if instead of having a primary thread
yeah that's what Yugi said
you have a primary thread pool
there will be a pool for handling ticking
remember though, this won't be a thread pool
Kotlin will handle the thread pool internally
I'll be using a coroutine dispatcher 😎
why dont we have a stateless game that can be represented as a pure function
oh wait that's game of life
ez
?
split sections dynamically based on how many tiles are in use
add a new coroutine and rebalance after a threshold is passed
okay you lost me with the words dynamically and rebalance xD
lol
you don't need many coroutines for a small automata
I'm talking about Minecraft
oh yeah, because the game of life and Minecraft are the same thing
Mojang has entered the room
theyre close enough
/s
lol
Hey, how can I make material: change every seconds with DeluxeMenu please ?
anyways same point applies
you don't want or need 50 coroutines for a single loaded chunk
but thats hard
but I do want more than just a single thread ticking an entire world
it's just how they're going to stay at least somewhat in sync with each other that worries me
noooooooooooooooooooooooooooooooooooooooooooooo
yeah
i need to fix this now
Site down :/
yeah sorry
nginx good
Caddy good NGINX bad
off brand nginx
nah the proxy isnt the problem
does NGINX have extremely easy configuration? automatic HTTPS?
what
it's like 2 lines for https
eh, you need to make a redirect setup
which is like 4 lines
- the 4 lines you need for HTTPS
😦
🤷♂️
Not trying to demotivate
single-threaded ticking means Krypton's just gonna turn into vanilla though
Not true
which literally makes it pointless
no it doesn't
nginx runs on a single thread
Pretty much every game runs like this
ticking should be sync tho
what makes Minecraft bad then?
single thread does not = bad
shit spaghetti code with no optimizations
^
true, it's how you use that thread
aka coroutines
okay, so maybe Krypton can have a single thread for ticking
and all that stuff
though I want more stuff to be done reactively
as in?
it'd be nice to not have ticks at all
e.g. chunk loading checking, like checking whether you've crossed a chunk border, should be done reactively
or should it
position packets are sent more often than ticks run I think
also, how would I even tick?
I know Glowstone uses an SES
and vanilla just uses a while (this.running)
while true {
tick ()
^
I need a way for that to halt though
System.exit
won't that keep ticking until it shuts down the main thread though?
while (isTicking())
It closes your application bard
while running {tick()}
okay that does literally nothing
Also do have some logic to make sure your application doesnt over tick
and in isTicking() it can do tick()
watchdog
No
You dont need to shutdown the server
Just make sure you have a cap
And send warnings if it goes under
also, if I'm using while true, how am I gonna make it run every 20 seconds?
Before ticking get time
#816184747024711693 message
all for free 👀
after ticking, get time
Check deviated time
Compare with thresh holds
If < normal tick time
put thread to sleep till that time
krypton is supposed to be a super fancy speedy efficient concurrent engine right
else
maybe Glowstone's method of using a single thread SES and scheduling to run every 50ms wasn't so bad
put to sleep?
how about going all the way and finding a way to use GPU to tick 😎
No
We simply dont want the thread to do anything in that interval
actually, Netty can still answer people's calls
ayyyy
Yes
why not just while (tick())
private fun tick(): Boolean {
if (!running) return false
sleepThreadStuff
return true
}
ez
minimal downtime
ticking whilst isTicking makes 0 sense
since if isTicking returns false then we're not ticking anymore
but that will only be updated if we're not ticking
then tick()
you could use a shutdown hook
for System.exit use a shutdown hook
and you could stop the ticking
while (someBoolean) is better
no ivan
whats so bad about this 😫
game loops are a thing
well no i mean for if a thread has nothing to do
All the threads responsibilities will be inside the loop
maybe some build off others
const val TICK_EVERY = 50
var lastTickTime = System.currentTimeMillis()
fun start() {
// do magic
while (true) {
if (System.currentTimeMillis() - lastTickTime < TICK_EVERY) return
// do tick
}
}
```right?
if you want a thread to not do anything you dont want to use while(true)
just as an example
actually continue
wow did dkim just provide some useful information for once?
bardy has 3 now
wtf is this?
😳
why not schedule the tick for every 50 ms?
bardy and dkim switched braincell numbers
I was thinking of doing what Glowstone does and using a single threaded SES
everything is going to boil down to while (someBoolean) eventually whether any fancy library you use
or something similar
const val TICK_EVERY = 50
var lastTickTime = System.currentTimeMillis()
var running = true
fun start() {
// do magic
while (running) {
if (System.currentTimeMillis() - lastTickTime < TICK_EVERY) continue
// do tick
}
}
const val TICK_INTERVAL = 1000/20
...
while (true) {
val tickStartEpoch = System.currentTimeMillis()
tick()
val tickEndEpoch = System.currentTimeMillis()
val deviatedTime = tickEndEpoch - tickStartEpoch
if (deviatedTime < TICK_INTERVAL) {
Thread.sleep(TICK_INTERVAL - deviatedTime)
}
}
Something like this ig
beautiful
why 1000/20
Thread.wait()?
for clarity
1 second = thousand milli*seconds
1_000/20 ftw
20 ticks must happen in 1 second
I mean why don't we make it 60 ticks <o/
1000 ticks ftw /s
unlikely
i wouldn't want to use that server 😅
Can you imagine, you'd be able to do 1000 cps!
!!!
!!!
not bad
!!!
lmao xD
Next Up: Nuke Bridge
can Kotlin actually interpret 1000 / 20 as a compile-time constant?
I never knew that lol
because it seems to have issues with things
Could also do val tickTime = measureTimeMillis(::tick)
true
that'll call tick won't it?
Yes bard
what?
I mean Krypton 0.15 lol
oh version
is it possible to make like someVar = "a" also run like another method like variableChanged()? or do i need to make a custom setter
the version I'm about to release is 0.14
how
@oblique heath https://paste.bristermitten.me/zuzynuhyqi.hs Did that mountain problem and ended up with this
not the cleanest thing in the world but it makes sense
i think
var idk = 5
set(value) {
callListeners()
field = value
}
inputs <- replicateM 8 (getLine >>= (\x ->
return (read x :: Int)))
``` @old wyvern any idea how i could clean this up?
tried return . read :: Int already, doesn't work
hmm thinking
oo ty, i'll take a look at it
oh btw, is Sender's hasPermission function calling an event a violation of SRP?
it fires a PermissionCheckEvent
ok lmk if you have any questions
quite a few monads there so
well 2
maybe 1
does <- act like #get() for the IO
Wait why is the answer infinitely recursive?
the forever?
yes
cuz it's a clash problem
uh?
so the way it works is
Clash problems dont require that I think
each time the loop runs, the output "shoots" the mountain
Anyone wanna play some coc?
lowering it's height by 1
wait theres a singleplayer??
yeah like practice mode
Never seen that, rip
the singleplayer challenges are more sophisticated
^
it's actually just syntax sugar for >>= which is more like whenComplete or thenAccept in Future terms but yeah
ooo gotcha
Noone joining? :sad:
comin frost
so this line
fromMaybe (-1) $ elemIndex max inputs
i get what elemIndex max inputs does, it gets the index of the largest input
but what is fromMaybe, and the (-1)
pretty much Optional#getOrElse
-1 being the default value if max isn't in inputs
Except it always will be
is it required
It's optional#orElse, what a noob for not knowing this
Oh whoops soz
I think so -- elemIndex returns a Maybe Int so we need to turn that into an Int somehow
ah i see
also for
putStrLn $ show index
the show turns the int into a string, i take it?
yeah it's like toString kinda
plss 666
Ah yeah that works too
Only if the value implements the Show type class though afaik
;o
i'm getting
/tmp/Answer.hs:24:21: error:
Variable not in scope: fromMaybe :: Integer -> t0 -> t
|
24 | let index = fromMaybe (-1) $ elemIndex max inputs
| ^^^^^^^^^
/tmp/Answer.hs:24:38: error:
Variable not in scope: elemIndex :: Int -> [Int] -> t0
|
24 | let index = fromMaybe (-1) $ elemIndex max inputs
| ^^^^^^^^^
/tmp/Answer.hs:27:20: error:
• Ambiguous type variable ‘a0’ arising from a use of ‘show’
prevents the constraint ‘(Show a0)’ from being solved.
Probable fix: use a type annotation to specify what ‘a0’ should be.
These potential instances exist:
instance Show HandlePosn -- Defined in ‘GHC.IO.Handle’
instance Show BufferMode -- Defined in ‘GHC.IO.Handle.Types’
instance Show Handle -- Defined in ‘GHC.IO.Handle.Types’
...plus 27 others
...plus 12 instances involving out-of-scope types
(use -fprint-potential-instances to see them all)
• In the second argument of ‘($)’, namely ‘show index’
In a stmt of a 'do' block: putStrLn $ show index
In the second argument of ‘($)’, namely
‘do inputs <- replicateM 8
$ do input_line <- getLine
let ...
....
let max = maximum inputs
let index = fromMaybe (- 1) $ elemIndex max inputs
putStrLn $ show index’
|
27 | putStrLn $ show index
| ^^^^^^^^^^
with this:
forever $ do
inputs <- replicateM 8 $ do
input_line <- getLine
let mountainh = read input_line :: Int
return (mountainh)
let max = maximum inputs
let index = fromMaybe (-1) $ elemIndex max inputs
putStrLn $ show index
Did you do the imports?
all the imports are there
import System.IO
import Control.Monad
oh wait
🥲
thank you
I broke kotlin in COC
sadge
@old wyvern You coming or?
That one was bugged
oh
@prisma wave
import System.IO
import Control.Monad
import Data.List
import Data.Maybe
main :: IO ()
main = do
hSetBuffering stdout NoBuffering -- DO NOT REMOVE
forever solve
solve :: IO ()
solve = do
inputs <- replicateM 5 $ getLine >>= return . read
let max = maximum inputs :: Int
let index = fromMaybe (-1) $ elemIndex max inputs
print index
This should work
what's return . read
Its not a casting, the compiler just needs a type hint at some point in the function, it can infer the rest that use the same type
composition
it returns a function which first applied read and then return on any given argument
return . read so takes an argument (because read takes a single argument) applys read to it, then applies return to it
wait so the . does the same thing as $ would?
Well no, $ is just a change in precedence
man
what even
that looks odd
lol
In git production, I should be developing on a different branch to master right?
Its the bind operator
then merge when its "ready"
Basically a way to compose functions while using monads
no no
not a let binding
Basically you are mapping the value contained in the monad to create another monadic value
d; CompletableFuture#thenApply
<U> CompletionStage<U> thenApply(Function fn)```
Returns a new CompletionStage that, when this stage completes normally, is executed with this stage's result as the argument to the supplied function.
This method is analogous to Optional.map and Stream.map.
See the CompletionStage documentation for rules covering exceptional completion.
the new CompletionStage
fn - the function to use to compute the value of the returned CompletionStage
something like this
Barry really hates me
except you actually have to wrap it in the function yourself
@@Deprecated(since="9", forRemoval=true)
public interface ClassDoc
extends ProgramElementDoc, Type```
ClassDoc has 5 super interfaces, 2 extensions, 21 methods, and 1 sub interfaces.
The declarations in this package have been superseded by those in the package jdk.javadoc.doclet. For more information, see the Migration Guide in the documentation for that package.
Represents a java class or interface and provides access to information about the class, the class's comment and tags, and the members of the class. A ClassDoc only exists if it was processed in this run of javadoc. References to classes which may or may not have been processed in this run are referred to using Type (which can be converted to ClassDoc, if possible).
😦
@static zealot @oblique heath
I can't join rn lmao. I was just wondering
eeeh

d) coc
wait what?
g) bungee jumping with a rope
h) bungee jumping without a rope
I added support for Krypton to LuckPerms, but lucko wouldn't merge it because Krypton isn't popular enough 😔
so I'm maintaining it in my own fork, like he suggested
ah I see
and providing a download for it on the CI
I'm to lazy to open the link
If the rope wasn't tied around my feet, but around something else instead
your CoC
Your testicles
No
someone here actually test that LuckPerms JAR out btw, I wanna see if it works for you guys lol
your incredibly long and misshapen nose
all this time I've been the only one doing the testing
he was actually really nice about it, and he said it was really cool
ok now I can play @old wyvern wanna play?
Bardy, I'll set up a sub server tommorrow
I mean of course he wouldn't merge it, it's not a popular enough of a platform to be his responsibility loll
he just said it's not worth the maintenance required to maintain it
maintenance required to maintain it
that first sentence in his response made me smile
When the maintenance requires maintenance
oh no
I mean, I offered to maintain it myself, which is what I'm doing, he just said that he didn't want it in the main repo because the platform's not popular enough
tl;dr no one uses it because it sucks
Shut me up yourself bitch
Screenshot, save, show in a year when it's finished and it possibly goes places
this should be a helpchat emoji: https://cdn.discordapp.com/emojis/807237707906416682.png
No. I'll sue Funnycube if he steals my art
lol
it was my 5 minutes in photoshop
Oh right. So what would the type of inputs be? [IO Read]?
for BM
lol
Yeah I didn't make it
top copy a half, reverse it
and then add 1 more tier
the 3rd tear
💩
@old wyvern is either afk or extremely focused on finishing the CoC
[Int]
we literally don't care
Wot
so guys down for another game of COC?
back
Yea
Type hint can be at anypoint
Oh what
as long as it uses the sam type
That's crazy
isnt it the same in f#?
Composition, I know Yugi already explained this but I want to too.
return . read is the same as ```hs
\x -> return $ read x
I don't think F# has type hints in the same way
`\x?
lambda
I see
challenge: type a but replace a with ` (with the code block thing)
```
lol
it doesn't have code block
starttt
\ `
val a = "a".replace("a", "`")
🙂
Alright
I'll do next
Holy god is questions
for reading an int you'd just do ```fs
System.Console.ReadLine() |> int
No type hints needed
oh btw, @old wyvern, you know how for ticking, you said I should use Thread.sleep?
since this is a coroutine, shouldn't I use delay instead?
C#'s fault
to much fucking text
Ruddy interop
true 😔
Ez fix is fs let readLine = System.Console.ReadLine
so it would just end up as ```kotlin
while (true) {
val tickTime = measureTimeMillis(::tick)
if (tickTime < TICK_INTERVAL) delay(TICK_INTERVAL - tickTime)
}
I think I got some of it but this shit to much text
for me to read
it will
well not until we die
oh wait I'm blocked lmao and he uses BetterDiscord
so he can't see my messages
lmao
🙄
phew
i believe in you
i gtg lol
if all else fails i will let you borrow a length of rope
wait
its just a greedy algorithm i think, but i have to go rn
it's just math
yeah math
🥲
I got the height. just not the other thing
its unfinished
dewit
i couldnt figure out how to power a fucking int in kotlin
sat there for like 5 minutes
:/
just plug it in, idiot
Int.pow
or double*
Int.pow was not working on coc
Well I give up
oh btw, is it wise to use the default dispatcher instead of the IO dispatcher for ticking to avoid the IO dispatcher getting overcrowded?
and also because ticking isn't generally IO
Yugi
as the name suggests the IO dispatcher is only for IO
you never answered me
Seems like coroutine abuse now
.
guys let's have an unofficial rule for this next CoC
we'll have to use recursion
no thanks Ivan
😦
ez
nah, just coroutines good threads bad
Just because you have a hammer in your toolbox doesnt mean you should go hitting everything with it
actually that is the dumbest circlejerk I have heard ever I swear
🤣
^
hi
hello
you got yourself recursivity ivan
oh btw, @old wyvern, is it worth storing the next tick time so I can do what vanilla does and compare it to see if the server is running behind?
long nextTickTime = Util.getMillis() - this.nextTickTime;
if (nextTickTime > 2000L && this.nextTickTime - lastOverloadWarning >= 15000L) {
long nextTickTimeTicks = nextTickTime / 50L;
LOGGER.warn("Can't keep up! Is the server overloaded? Running {}ms or {} ticks behind", nextTickTime, nextTickTimeTicks);
this.nextTickTime += nextTickTimeTicks * 50L;
lastOverloadWarning = this.nextTickTime;
}
```like this
recursive magic for the win
I mean, a bit less whacky than that, but you get the idea
though i don't see how it's faster in this case
please don't bully my I was in a rush and idk what I did
i wont be able to finish
I didn't xD
also something confuses me
at first i put everything in man
🙂
main*
and it said it was too inefficient
how does moving this to a function make it run faster
idk
but yeah It would've been pretty easy to make it recursive
just remove the while
and move the check in the function
You can calculate that with just start time and interval
how?
starttime + interval ?
>>= (\x -> return (read x :: Int)) 😦
example?
sorry, I'm not quite with it today I guess
I want the if statement
if haskell is so good why can't it infer that i want read to be an Int
I can't figure out how that addition applies to the context
Actually im even more confused on what you actually want to do\
You want to find out if you're running behind on ticks right?
yes
example from vanilla
can anyone explain why this most recent CoC considers a nested while + for loop in the main inefficinent, but is okay with recursion or a while loop + helper function
i don't see why the latter two would be faster
huh?
That is pretty much checkign with the elapsedTime we used in the earlier loop
i got an error saying "this code is to inneficient" when i first solved it
probably because it timed out
right but why ;-;
idk
all i did was move stuff into a function
and i made it recursive too i guess but blitz literally has what i had originally, just with a function
very weird
recursive solutions are the best anyway
i can't agree more
If you do another one after that I'll join it, won't be able to for like 10 minutes
alrighty
we probably will
not like any of us have anything better to do
@old wyvern @jovial warren ?
is this supposed to happen
yes
i like it
it's a feature
fine
trust me
bm transcends reality
what monads do to a guy
that'd actually be a genius image to use as a profile pic
as long as I get to use Python for anything other than shortest then I'll play lol
fingers crossed it's reverse
python for shortest is cheating
reverse? does that mean you want to take the longest or something lol
no
it means you have to figure out what to do
shall we start?
based on the output
oh isee
unless anyone else is joining
ez pezy
I join when you finish lmao
okey
wait did you guys start a new COC?
link?
nice
ah darn
how tf you finish that in 1:40
jazz hands
oh fuck this
I can't even see what the question is so 🤷♀️
25%
I'm going to die here
yeah I'm not awake enough for these today
poor efe
it is
Kotlin: Is the only way to loop thru the digits of a number by converting it to a char array?
Or just get the size
no
test
And increment index
1234
you can use substring and loop for the length like frosty said ye
@static zealot what is this new avatar
do you not like it?
😫
omg parseint doesn't take a char wtf
I cant even tell what that is
you're looking for Character.digit
The level thing?
@cinder flare char+""
Level 69 Exp: 666, 664
it didn't want to give me 6x 6
yugi how to get indexed values of list
wdym?
haskal losing PepeLaugh
[1, 2, 4] => [(0, 1), (1, 2), (2, 4)]
wouldve solved this by now if i was in a good language
D:
Do you just need to map with an index or something?
Data.Sequence.mapWithIndex
forEachIndexed 🙂
#3 baby
did it
les go
oh I got 4?
new game?
how did I get 4 when I joined at minute 10
Another haskell requests to join
not done yet
haskell shall not lose
there's still 4 playing yugi
efe got a 0% score lmao
Johnny did it in Clojure? what a madman
which subject?
linear algebra 🥲
🥲
because you're last of the people who got 100% lol
I have like 2 weeks to my mid terms now I think
haskell?
No!
blasphemy
What was the question btw?
it was a weird question
Another really long one?
nah
I spent 90% of the time just trying to understand the question
minimum possible value of subtracting 9 from each digit of n
o.o
"Create the smallest number from the input by either subtracting each digit from 9 or not"
123 => min [823, 163, 126]
This or something similar was the way it was phrased
yes
var x = StringBuilder()
N.forEach {
var n = it.toString().toInt()
if (9-n<n) n = 9-n
x.append(n)
}```
1 more dude
unfortunately
Forgot you can forEach a number
that's Blitz' solution
did sensei leave?
it's over in a min anyway
anything wrong with this?
aight
no I was showing it off as an example of brilliance and how fucking dumb I am lol
it's cause you used C# lmao
that was BM's
😬
I used TypeScript lol
ewwww
Imperative bad
join sensei
THATS more like it
haskell has won this time
i got no idea
it's redeemed itself
😌
what was the question this time
reverse the alphabets
o.O
i feel i am doing this very poorly
that's cursed
Shhhh
I'm dumb, I thought 'a' was 65 lol
lol
maths already going great here
my answer is absolutely cursed
would be nicer with some MONADS
219 - charCode
☝️
no magic values here
Monads solve everything
Share code Nicole
That's smart
haskell definitely cleanest tho
Didn't even think about the char code
Throw em onto your torn shoes? Fixed.
Throw em onto your purse? Fixed, more money.
Hotel? Trivago
chaotic good
what in the fuck you can't do indexOf on a char array
can someone send me a link to the clash report
you can
ugh you guys started 2 of them
honestly not even that complicated
aw i cant view the code
those are both the reports
we need hasklash in here
pretty much identical to python except the lambda
!!!
!!!
not even waiting for others smh
no this is the same one
Petition to add hasklash
just submit something funny
I'll be off now anyway, you people have fun
adios
ciao
solid 7th bois
could be worse
how many fastest have we had in a row now
oop
let me guess. x is looping thru the chars of the word and ord() gets the ascii value of the chars and it does ascii(x) - ascii(char) + ascii(a) and then converts that to a char and maps it?
idk
yes
let me convert
wonderful
I think I just need to become more familiar with stuff
what does reverse do?
word.map {
('z'.toInt() - it.toInt() + 'a'.toInt()).toChar()
}
reverses the string. finish to start
gives you input and output, you need to figure out the question
I mean the reverse mode lmao
that sounds painful
like 10 options
like reverse engineering
and you have to know
what it does
to figure out
what it does
and then code it
oh god
is that a SNAKE
petition to give me it's invite link
This one is confusing
this one was a lot easier than i thought when i first saw it
mine bugged out on 2nd to last test
mhm
wtf yeah what's up with the second to last
and now I'm 3rd because of it
check yer casting
xXd
my casting?
or was that not a requirement?
i did no casting
all the tests worked
wait blitz i think you checked the tongue correctly
but of course it only gives 71
just submitted it with my debug lines but who cares
@static zealot ur last 2 tests would have failed
^
oh really?
gotta cast to int
go view my debug code if you dare
I missed it then
I'm perpetually 4th place
there's only one snake per line right?
yes
yeah
snek
then wtf is up with the last two
haskell division makes me want to die
I thought it was the perfect language!
almost perfect
i can see why they did it tbf
that whole language is a minefield
fromIntegral (length happyCount)
fromIntegral converts an Int to a "Float"
because you can only do truncating division on ints
Share code
no?
System.`in` in kotlin is cursed
what would I cast
yeah that's what I didn't do either
fun main(args : Array<String>) {
val input = Scanner(System.`in`)
val n = input.nextInt()
if (input.hasNextLine()) {
input.nextLine()
}
var counter = 0
for (i in 0 until n) {
val snake = input.nextLine()
if (snake.startsWith(">-") || snake.endsWith("-<")) {
counter++
}
}
println(((counter / n) * 100).toString() + "%")
}```
also for some reason it doesn't let me do println(int + "%")
shame
you didn't truncate the percentage
yeah you gotta toString it