#development

1 messages · Page 194 of 1

quartz kindle
#

how about instead of a ladder

#

a tournament with groups and shit

frosty gale
#

now you have LLMs as well so the bots can trash talk

quartz kindle
#

lmao

crystal wigeon
#

Lmao

#

fr I could do that

#

And make the bot more engaging kekcry

#

but I need to train the bot for my game context

#

and I have no idea how to do that

crystal wigeon
#

But again they feel the bot is not balanced / not good enough yet

#

Sadly that’s the price I have to pay for leaving too many bugs for prolonged period

#

Anyway playerbase rn is slowly depleting and I see no hope

#

So I’d rather give to some game dev who can maybe make few sensible changes and revive it

#

Or I just quit

quartz kindle
#

tough position

crystal wigeon
#

Yeah any balancing change I make is seen as nerf and people quit

#

I can’t change the mentality frfr

#

Now that i think about it there was no reason for me to make it exponential buff. It was balanced as it but since nobody was using it and they kept complaining I killed that skill I made this dumb change

quartz kindle
#

sometimes if a change is needed for the health of the ecosystem, a sacrifice is unavoidable

#

you will lose players, but you will have a chance of getting new, more satisfied players

crystal wigeon
#

Not if it kills off the entire playerbase

#

It’s more like the players physiology is weak. They think 400k damage is normal and when I balance it out they start spamming that I killed the game myself lol just cause they don’t wanna try something new or balanced

#

All the trolling takes a mental toll ngl

#

I wanna get this over with fr

quartz kindle
#

you dont need to engage with them

#

game devs and game companies rarely interact with players

#

they just post updates and go home

crystal wigeon
#

But at the same time it has also prevented by bot from growth

quartz kindle
#

then look at metrics

#

not what peoplesay

crystal wigeon
#

Yeah I’m looking at metrics too

#

the metrics are what people say here in this case

quartz kindle
#

thats not good for your mental

crystal wigeon
#

Cause these guys are the ones engaging with new players

#

And then they drive them away ish

quartz kindle
#

if they are so invested in the game, then why not ask them to balance it for you

#

or make a voting system

crystal wigeon
#

I did that’s where the exponential buff came

quartz kindle
#

well

#

now they see what happened to the game

#

so they can rethink as well

crystal wigeon
#

Welp not entirely but I just thought of it based on some suggestions that’s all

#

Now if I change it. They’ll say it got too nerfed

#

Schrödinger cat

#

Anyways

#

idk why I’m also struggling to get like new players too tho

#

Bot hasn’t grown at all

#

Despite doing all the auctions on topgg

#

Welp

#

Ig it’s just not good enough

frosty gale
#

sometimes throwing more money isnt the solution

#

there are a bunch of factors that correlate to player count

crystal wigeon
#

Mhm

#

I agree if the game isn’t good enough it’s hard to attract new players

frosty gale
#

mostly boils down to how appealing your bot/page/ad/etc is to the player looking at it

#

the average person looking at your ads is probably just browsing for something completely unrelated and random so you really have to attract their attention

#

and also use the right tags ofc

crystal wigeon
#

mmm

frosty gale
#

but thats only one part of the problem, the second is actually getting the person looking at the ad to actually get and use the bot

#

im not an advertising or business expert but i would take a step back and look at what you can improve and ask yourself would you play/get this bot

#

ask for your players opinions as well, polls, suggestions, etc

#

they are the ones playing after all

green kestrel
#

what can you do to make the bot different

#

there are so many clones of idlerpg

#

and they all follow the same tropes of card collecting, anime characters, etc etc

#

what did you do to make it different, make note of that and make that the thing you emphasise on ad campaigns and on your bots page

#

on my bots webpage I explicitly call out how all these bots are the same in my FAQ and that my bot isn't anything like them

#

you have to stand out

#

I'm sure you already do, because if people wanted more idlerpg and more epic RPG they'd just play those bots, they're playing yours so it means you have something unique

slim dirge
#

Finding a niche concept gives you an edge, for sure.

green kestrel
#

most people probably already have one and aren't telling anyone that needs to know

lament rock
#

My bots aren't like the others. Mine are shitty and break down for no reason. Give money so I can totally fix that and make the bot usable :)

inner heart
#

@green kestrel

deft wolf
#

What

inner heart
#

@deft wolf can you come to vc

deft wolf
#

No, I can't

inner heart
#

@deft wolf bro i sumbited my bot to topgg but that time my bot offlined

#

i cant start my bot

#

saying like this

#

@deft wolf

#

can you help me

deft wolf
#

No

inner heart
#

plz help

harsh nova
# inner heart \

No clue how pterodactyl works but it sounds like some other service is running that can't run concurrently with the discord bot

green kestrel
#

it's not made for that it's made to host game server instances

#

just use a plain vps

#

and the fact it's called "my first bot" perhaps means it isn't ready for prime time yet, you didn't even give the project a proper name

frosty gale
#

honestly if people are happy over them currently and making money id just keep the change

#

but introduce more subtle changes that balance the game out more later on

#

cash cow per se

green kestrel
#

yeah don't remove your bread and butter feature

#

have you considered making the really big buffs premium feature? LUL

#

(this for hoax)

frosty gale
#

from the sounds of it at the moment he doesnt have the people to spare to make these changes that upset the user base that is actually paying you

#

tough spot really

green kestrel
#

premium feature: massively op enemies that need huge buffs, huge buffs in the premium

#

hmm, wait, you need multiple people to maintain a bot????

#

first I heard of it

frosty gale
green kestrel
#

at least, when it comes to source, I've never trusted anyone but myself

green kestrel
#

I would recommend it for dpp too if it was bundled with it

frosty gale
#

not a bad idea actually

#

i would of course do it around docker

#

basically the standard for container apps anyways

green kestrel
#

yeah

frosty gale
#

since i do security i can probably also harden it pretty well as well

green kestrel
#

I think people are using pterodactyl because cheap Minecraft hosting is readily available and that's what they all use, part of the problem is removing that interia

#

if they have to self host your bot platform it won't ever replace ptero

#

someone would have to offer it at the same price point as the cheap Minecraft boxes

#

most people using it aren't in the position to self host it

frosty gale
#

yeah thats what i thought

#

youd mostly be marketing it to panel hosts

#

cheap ones at that usually

#

i also see the pterodactyl containers for bots usually fail quite quickly and come up with some error

#

and the average developer using this likely wont know how to fix the issues

#

ill think about it

#

its definitely a promising project to add to a portfolio

#

and i could design it pretty well given ive been in the exact position like 5-6 years prior using pterodactyl for a bot without knowing what im doing

green kestrel
#

I tried to use pterodactyl to self host a Minecraft server

#

I hate the thing

#

it tried to take over my entire server

inner heart
#

Bro thats a free host

green kestrel
#

it doesn't work if you do other things on the server too

green kestrel
inner heart
#

I dont have money

green kestrel
#

running a bot costs money

inner heart
#

Ooo

#

But bro that host giving 24/7 support

#

The bot running in that host properly but i submited here my bot gone to offline

deft wolf
#

Then contact their support

inner heart
#

@green kestrel

green kestrel
#

I'm sure that they really really give good 24/7 service for free LUL

#

contact them, they'll fix it for sure

slim dirge
#

If it is, they have a Discord support server linked from their website. You can open tickets there for help. I opened one recently for perms issues and they sorted it kittyokay

inner heart
#

Ooo you using opticserver i see thank u bro

surreal sage
#

How can I properly merge a pr so that:

#

doesn't appear

surreal sage
#

aint forcing

slim dirge
#

Try git pull origin dev if you're using cmd line. Then git push.

wind copper
#

Can anyone help me in this stuff

lyric mountain
#

you were probably locked out of verification for that app for some reason

wind copper
lyric mountain
#

what is your app about?

#

is it a bot or a game?

#

and did you get it from some template?

wind copper
lyric mountain
#

and the other 2 questions?

quartz kindle
#

i dont think theres anything wrong

#

just scroll down and fill out the forms normally

quartz kindle
lyric mountain
#

ah lmao, I misread this as a "your app EMBEDDED cannot be verified"

quartz kindle
#

embededededded

lyric mountain
#

that's just discord verification, and they dont get your personal data either way

quartz kindle
#

embededashion

lyric mountain
#

eh, yk they already have any and all data they might want about you right?

quartz kindle
#

they already know

#

they just dont care for 90% of the cases

#

speaking of which, i still need to do my taxes

#

says the guy with a rainbow clown cartoon cat profile picture

crystal wigeon
#

The Linux backdoor made news lol

wind copper
#

What should I do now

quartz kindle
#

fill out the forms

#

you can ignore that warning

coral phoenix
#

wild

crystal wigeon
#

I think there was a similar exploit for su

past field
#

is it possible to attach photos to command?

lyric mountain
#

you'll need to verify your identity through stripe, so you'll need to either do it yourself or get someone older than 16 to do it for you

#

then there'll be the technical data about your bot, such as infrastructure and data collection policy, hope you paid attention during development else you'll struggle on this part

slim dirge
# wind copper

Congrats on getting to 100 servers! kittyhype definitely an achievement that you should be proud of! kittyokay

pale vessel
#

god bless bro

eternal osprey
#

my bot is still verified but not used lmao, anyone know what to do with it?

#

I am thinking about rebuilding the bot to a crypto bot

frosty gale
slim dirge
#

That's the million $ question, coming up with an idea that'll attract lots of users

eternal osprey
eternal osprey
frosty gale
#

why does discord need ID again when verifying a bot

quartz kindle
#

you guys ever heard of a DOW attack?

#

denial of wallet

#

xD

slim dirge
#

I think (though correct me if I'm wrong) that they're wondering, if their bot undergoes a complete revamp and becomes a bot that does something totally different to what it was originally verified on, if top.gg needs to reverify it. kittythink

lament rock
# frosty gale why does discord need ID again when verifying a bot

It likely comes down to data privacy and insurance. Bots are hosted on their platform and they're trying to allow bots to have deep integration with it. So much so that users probably wont think too much on the fact that an app is operated by a third party. If their data was being collected by this third party and they're exposed online, then Discord could get in big trouble. This way, they have collateral and can hold malicious actors responsible beyond banning their account and can get authorities involved.

#

My bot got denied verification because it retains user's data until the user requests a deletion. (just user IDs)

sharp geyser
quartz kindle
#

and still got verified

#

im guessing verification got much stricter with time

lament rock
#

yeah

lament rock
#

exactly that

#

Hey papiophidian,
 
Unfortunately, after looking it over, I have decided to deny your verification request. This is due to the duration in which you retain discord data. Do not fret, though! We will reconsider this verdict if you implement stronger data disposal processes and reapply for verification!
 
Furthermore, if you require additional assistance while using the Discord app, you can easily contact our Customer Experience team at any time. You can reach them at https://dis.gd/contact.
 
I'll go ahead and close this case as solved, but please reply to this ticket if you have any other queries, and I'll be pleased to assist you.
 
Cheers,
Davis
Hey Davis,

I had a question regarding the specifics of what I'm storing since I only store user IDs. Having to delete user's settings and economy data unless the user explicitly wants me to might suck for if they wanna keep that. How long do you suggest I should even retain this info for?
Hello papiophidian,
 
Thanks for writing back!
 
As much as we want to, due to our policy, we cannot provide precise information regarding your inquiry. We encourage developers to refer to the provided documentation and articles. Kindly check our Developer Policies and Terms of Service, which might help address your concerns.
 
Here are some more details on the topic: https://discord.com/developers/docs/policy#don’t-do-anything-illegal-harmful-or-otherwise-not-cool
 
Thanks for understanding!
 
Cheers,
Davis
quartz kindle
#

and eventually they get it lol

lament rock
#

I thought about lying but I dont want to

#

I guess it could help for people who abandoned and forgot my bot

#

would be a lot of data just left in the database unless they request deletion

#

but how I see that is a problem for me to solve if it comes to that

eternal osprey
#

Technically it ain’t an id no more 🤷🏽

#

That way you only store the generated part but can still benefit from the perks of having a user id

wheat mesa
#

The point of a hashing function is that it's one-way only

#

If he needed those IDs without the actual known user, he wouldn't have a way to get it

past field
#

I wanted to create an egg hunt around my server that will have the post randomly post eggs around certain channels, once a player finds it,they reply to it with the 🥚 emoji and they will get 1 point. the bot then announce the amount of points a player has and hides another egg. this loops until the score to win is reached, the bot announces the winner in the channel the command was invoked and then it deletes all the egg emojis that it put.. can someone look over this code and tell me what I could change on it?

#

even though i'm sure this is stupid.

wind copper
#

Oh already done

wind copper
wind copper
#

Lol 😂

#

I verified last night

modern sable
quartz kindle
#

economy bots according to discord:
didnt access your account in 30 days? gg you lost all your money

lyric mountain
#

your ultra rare one-of-a-kind item? too bad, where were you for the last 30 days?

radiant kraken
#

just make a game at this point

eternal osprey
#

yeah

#

an encoding type of system where we store a sort of 'hash'. I didn't really mean an actual cryptographic hash function.

#

but even then, it would be possible if he would store the private keys

#

that way the data is confidential and the id is only released and read ocne it's needed after solving the hash

lyric mountain
#

you simply store a hash of the password (because you shouldn't store plain text pass) and use that to encrypt whatever data you want to

#

you dont "solve" the hash, you decrypt the data

eternal osprey
#

we solve a hash using a private key

lyric mountain
#

that's pretty wrong in the technical sense

eternal osprey
#

thats what they refer to as decrypting a hash using a function and private key

grim aspen
#

could be an older term

eternal osprey
#

forgot from who it was

grim aspen
#

figured

#

usually the older books are outdated

lyric mountain
#

IT study material shouldn't even be books anyway

#

unless it's a language documentation

#

and even then it's iffy

eternal osprey
#

I don't study IT though

lyric mountain
#

java bible for example gets a new release every so often

grim aspen
#

computer science?

eternal osprey
lyric mountain
eternal osprey
#

To be fair i barely did anything that has to do with coding or something

#

in these past 3 years i only did theory after theory

lyric mountain
#

that's code-related

eternal osprey
#

Majority where math classes

#

i don't see that closely related to code

lyric mountain
#

it is, you dont need to build houses to learn architecture

grim aspen
#

math is used in coding

eternal osprey
#

yeah i know it is

#

but many of the things i am kearning rn will be useless in the future

#

like 80% of my courses

lyric mountain
#

if you stay in the IT area it'll help understand things you search for

#

like how I should've paid attention to matrix classes

radiant kraken
#

why

eternal osprey
lyric mountain
#

because I need to do matrix stuff for game dev

eternal osprey
#

Especially when creating games

radiant kraken
#

ah

#

like physics?

lyric mountain
#

tho godot is helping a lot tbh

eternal osprey
#

probably movement

lyric mountain
eternal osprey
#

do you use it a lot for collision physics as well?

#

Idk how it's done in practice, i know the theory tho

lyric mountain
#

kinda, as my collision hitboxes aren't axis-aligned rectangles

#

but I can use point-inside method for detecting hits

#

nonetheless I'm using godot now, so I dont need to do it myself anymore

eternal osprey
radiant kraken
#

thanks!

lyric mountain
eternal osprey
#

no jk, it's good that you use something to do it for you. The calculations are hella hard

lyric mountain
#

so I could migrate my tcg to discord activities

lyric mountain
#

the ship game is nearly ported fully, just need to finish the first boss and implement the other player ships

#

the source code is public I believe, spacebreach on my repo

#

nvm it was private, now it's public

radiant kraken
#

damn godot is a bit slow

lyric mountain
#

that's my vps probably

#

tho it does get faster on subsequent loads

radiant kraken
#

me after pressing play

lyric mountain
#

lmao

#

ah that's the music loading probably

#

I didnt make loading screens yet

radiant kraken
#

rewrite your game in vanilla js mmLol

lyric mountain
#

💀

#

ok just checked it myself, that delay ain't normal

radiant kraken
#

oh btw

#

the game loaded

#

but it's like 10 fps

lyric mountain
#

lemme check vps htop

#

odd, nothing unusual

#

I'll restart nginx

eternal osprey
#

the game looks awesome

#

though are you sure your matrix calculations are correct?

lyric mountain
#

well, I'll need to look up what's the fps issue

#

game was working normally yesterday

eternal osprey
#

I am shooting while standing still and my bullet curves heavy to the left each time

lyric mountain
#

on a side note, how tf did someone reach 38k score

radiant kraken
#

i did inspect element /s

lyric mountain
#

if it's curving something is wrong

eternal osprey
#

i think there is, the hitboxes are also not entirely accurate i think. i hit that mf like 5 times on the sides

radiant kraken
#

does your game lag?

eternal osprey
#

the game is really cool tho

eternal osprey
radiant kraken
#

oh i thought it's just my browser lol

lyric mountain
#

I'll try reuploading it, perhaps it solves the issue

#

the game was supposed to run 60 fps, as it was earlier

eternal osprey
#

@lyric mountain are you using projection matrices for the hitboxes and checking whether 2 points align on the same coordinates? If yes i suggest increasing the width, so the x, of the numerator.

#

cuz i keep hitting that ship but it aint dying

#

i can literally see my bullet go in his sides.

lyric mountain
#

the lag might cause collisions to be skipped

#

if it's physics processing lag, that is

radiant kraken
#

do you have the game as a standalone application?

#

maybe it being in the browser could cause some of the lag issue

lyric mountain
radiant kraken
#

my laptop cant run visual studio topggSob

lyric mountain
#

uploading the binaries again, I'll clear cf cache just in case too

past field
lyric mountain
#

well, it's lagging less but still subpar

lyric mountain
past field
lyric mountain
lyric mountain
past field
lyric mountain
#

I'm on mobile for a while so I can't check, but how are you checking if it's the winning point?

lyric mountain
#

Put some console.log or message before those resolves to see whether it's reaching them

wheat mesa
lyric mountain
#

That's out of my reach on godot

wheat mesa
#

They’re easy to implement and will give you a massive increase in performance compared to the naive O(n^2) attempt

#

Oh

#

That’s fine then

#

Thought you were still working on your engine of sorts

lyric mountain
#

Also the lag is happening because slow resource streaming probably, as the lag disappears when I host locally

#

I need to find a way to fix that

lyric mountain
surreal sage
#

💀

#

for a 65% keyboard

#

💀

lyric mountain
#

Oh lmao I just noticed

#

I can host the game on gh pages

lyric mountain
#

Aight, found some possible fixes, I'll try in a moment

quartz mortar
surreal sage
#

1 in 150 though

quartz mortar
#

The max i paid for a 65% is like 120€..

green kestrel
#

is that an April fools

#

id never buy anything other than a full size with numeric keypad

past field
past field
# past field

where i put the check for required points to win… should that be AFTER the end of round collector? or does it matter?

spark pebble
#

Am I tripping or did I wake up to FUCKED up embeds?

#

Why is this shit on 2 lines? I swear it never used to be.

lyric mountain
#

every feature is broken every once in a while

spark pebble
#

I hope it's a feature and not an update

spark flint
#

it was announced today KEKW

sharp geyser
#

Unless they are late with the joke

timber hatch
#

if anyone is able to help that would be great. firstly, it's worth noting this is only happening in production and was not happening in testing. but upon authentication, it doesn't return the session until the user gone onto another page and refreshed. (NextJS + AuthJS (formerly Next Auth)

the component you're looking at:
[redacted]

my _app.js (i've seen some people say this might be the issue?)
[redacted]

my next auth callback
[redacted]

humble gyro
#

yo that site looks sick

timber hatch
#

thank you my man, would be great it it was functional too :(

humble gyro
#

hahaha yea

#

i haven't used authjs

#

how do you manage your sessions?

#

for next-auth you could set it to jwt and avoid needing any backend session tracking

timber hatch
#

lemme take a look

#

my first time using both nextjs and authjs (formerly next auth) so still ropey

humble gyro
#

yea fair

timber hatch
#

pog fixed with refetchOnWindowFocus={true} on the sessionprovider

silver jackal
#

Onebump on top

timber hatch
#

sorry about him

silver jackal
frosty gale
#

and if you use the argument that you can mess it up and leave a vulnerability you can do the same by using authy

#

even moreso id say because youre putting in less care overall

past field
lyric mountain
past field
#
// Wait for a user to find the egg or timeout
                const collected = await new Promise(resolve => {
                    collector.on('collect', async (reply) => {
                        // If a winner is already found, do nothing
                        if (winner) return;
#

idk what’s wrong with it then lol

#

i don’t get one

quartz kindle
#
  1. you're trying to reinvent the wheel, discord.js already has a built in method to do exactly that
past field
#

tim man i’m sorry 😭😭😭😭😭

quartz kindle
#

or reactions

quartz kindle
lyric mountain
#

@radiant kraken quick question, what browser did u use to run the game?

#

some people are saying edge runs fine while chrome has heavy performance issues on it

past field
wheat mesa
#

holy moly webdev is awful, just had to make this duct tape solution for something I'm trying to do ```js
window.onload = () => {
const element = document.getElementById("term-user-input");
element.addEventListener('keydown', event => {
if (event.key == "Backspace" && element.innerText.trim() == ">") {
event.preventDefault();
}
})
}

open cedar
#

Hi

proven lantern
#

is there a built-in function in JS that will only filter out undefined items in an array?

lyric mountain
#

dont think so, but you can always prototype it

proven lantern
#

if i did that i would overwrite the functionality for filter() with no params. it would filter out undefined by default. i would probably need to copy over the original filter() code just to modify it. i never modify the prototypes

lament rock
#

0 is a falsy value

#

I wouldnt overwrite it unless you arent using any third party libs

#

You can always make your own prototype

#

Array.prototype.filterUndefined = function(callback) { return this.filter((i, ind, arr) => i !== undefined && callback ? callback(i, ind, arr) : !!i) }

proven lantern
#
Array.prototype.__originalFilter = Array.prototype.__originalFilter ?? Array.prototype.filter;
Array.prototype.filter = (callbackFn, thisArg) => {
    if (callbackFn === undefined) {
        return Array.prototype.__originalFilter(a => a === undefined, thisArg)
    }
    return Array.prototype.__originalFilter(callbackFn, thisArg)
}```
humble gyro
lament rock
#

Libs may expect the original behavior. Overwriting isnt good

humble gyro
#
function notNull<T>(value: T | null | undefined): value is T {
  return value !== undefined || value !== null;
}
#

my favourite way to do this

#
const values: (number | null)[] = [1, 2, null, 4, 5];
const filteredValues: number[] = values.filter(notNull);
sharp geyser
humble gyro
#

sorry i already had a security article made about me this month

humble gyro
sharp geyser
humble gyro
#

sadge

radiant kraken
sharp geyser
#

We don’t speak about it

radiant kraken
#

🤨

proven lantern
#

Imagine a function that accepts a list of numbers and returns two lists of numbers, where the sum of the numbers in the two lists are as close as possible. is it possible to write that function so it's 100% accurate without checking every combination?

#

i have this unit test that compares everything i write against the brute force method and i keep failing

#

this is my attempt not using brute force

// return two lists of numbers, where the sum of the numbers in the two lists are as close as possible
function splitNumbersEvenly(numbers) {

    // sort the number list input
    numbers.sort((a, b) => a - b);

    // initialize two list arrays
    const list1 = [];
    const list2 = [];

    // add numbers alternately to list1 and list2
    let i;
    for (i = 0; i <= numbers.length - 4; i += 4) {
        // add the first and last numbers to list1
        list1.push(numbers[i]);
        list1.push(numbers[numbers.length - i - 1]);

        // add the second and second-to-last numbers to list2
        list2.push(numbers[i + 1]);
        list2.push(numbers[numbers.length - i - 2]);
    }

    // add the remaining numbers
    for (let j = i; j < numbers.length; j += 2) {
        list1.push(numbers[numbers.length - j]);
        list2.push(numbers[numbers.length - j + 1]);
    }

    // return the balanced lists
    return [list1, list2];
}

module.exports = splitNumbersEvenly;
timber hatch
#

bit of a weird use case but was wondering if anyone could help...

  • my users make a request from nextjs frontend to nextjs backend with some params.
  • the backend makes a request to /pdf-template which is on the fronend (with the params)
  • the pdf template is updated with the params
  • puppeteer turns it into a pdf and returns to client

my issue is when i have "I'm under attack" mode enabled on cloudflare. The puppeteer request gets captcha. I tried changing the configuration rules to: ip src add !== vercel deployment ip but that did not work.

any tips?

quartz kindle
#

in any case, you can probably access it internally using localhost:port/pdf-template

timber hatch
#

it's "technically" public but will redirect to root if the header we set in backend isn't there. and since users will never know what that header is then

quartz kindle
#

as you add the numbers to the arrays, keep track each array's total score

#

on every number, check how that number would affect each score, and add to the lowest scored array

#

at the end you can walk through the arrays just a little to even out any large score discrepancy

#

or even just walk through the numbers backwards, from highest to lowest

proven lantern
#

mmkay, i'll give that a try. thanks!

#
// return two lists of numbers, where the sum of the numbers in the two lists are as close as possible
function splitNumbersEvenly(numbers) {

    // sort the number list input
    numbers.sort((a, b) => a - b);

    // initialize two list arrays
    const list1 = [];
    const list2 = [];

    const numbersCopy = [...numbers];

    // iterate over the numbersCopy array while it has elements pop
    // the first and last elements and push them to list1 and list2
    // respectively
    while (numbersCopy.length) {
        const listOneAverage = list1.reduce((acc, curr) => acc + curr, 0) / list1.length;
        const listTwoAverage = list2.reduce((acc, curr) => acc + curr, 0) / list2.length;

        // if the average of list1 is greater than the average of list2 then push the highest number
        if (listOneAverage > listTwoAverage) {
            list1.push(numbersCopy.shift());
            list2.push(numbersCopy.pop());
        } else {
            list2.push(numbersCopy.shift());
            list1.push(numbersCopy.pop());
        }
    }

    // return the balanced lists
    return [list1, list2];
}

module.exports = splitNumbersEvenly;```
#

the brute force is still finding better lists that are closer

#

AI came up with this magic

function splitNumbersEvenlyOptimized(numbers) {
    const totalNumbers = numbers.length;
    const halfTotal = totalNumbers / 2;

    let minDifference = Infinity;
    let result;

    // Iterate over all possible bitmasks for the first list
    for (let bitmask = 0; bitmask < (1 << totalNumbers); bitmask++) {
        if (countSetBits(bitmask) !== halfTotal) continue; // Skip if the number of set bits is not halfTotal

        const list1 = [];
        const list2 = [];
        let sum1 = 0;
        let sum2 = 0;

        // Distribute numbers based on the bitmask
        for (let i = 0; i < totalNumbers; i++) {
            if (bitmask & (1 << i)) {
                list1.push(numbers[i]);
                sum1 += numbers[i];
            } else {
                list2.push(numbers[i]);
                sum2 += numbers[i];
            }
        }

        // Calculate the difference in sums
        const difference = Math.abs(sum1 - sum2);

        // Update the result if the current difference is smaller than the minimum difference
        if (difference < minDifference) {
            minDifference = difference;
            result = [list1, list2];
        }
    }

    return result;
}

// Function to count the number of set bits in a number
function countSetBits(num) {
    let count = 0;
    while (num) {
        count += num & 1;
        num >>= 1;
    }
    return count;
}

module.exports = splitNumbersEvenlyOptimized;```
quartz kindle
quartz kindle
#

can you show your brute force version as well? im in the mood for some benchmarking :^)

proven lantern
# quartz kindle huh interesting, at first glance its very hard to understand what it is actually...

here's the brute force

function splitNumbersEvenlyBruteForce(numbers) {
    const totalNumbers = numbers.length;

    // Generate all possible combinations of indices for the first list
    const combinations = generateCombinations(totalNumbers);

    let minDifference = Infinity;
    let result;

    // Iterate over each combination and calculate the difference in sums
    for (const combination of combinations) {
        const list1 = [];
        const list2 = [];
        let sum1 = 0;
        let sum2 = 0;

        // Split numbers into two lists based on the current combination
        for (let i = 0; i < totalNumbers; i++) {
            if (combination.includes(i)) {
                list1.push(numbers[i]);
                sum1 += numbers[i];
            } else {
                list2.push(numbers[i]);
                sum2 += numbers[i];
            }
        }

        // Calculate the difference in sums
        const difference = Math.abs(sum1 - sum2);

        // Update the result if the current difference is smaller than the minimum difference
        if (difference < minDifference) {
            minDifference = difference;
            result = [list1, list2];
        }
    }

    return result;
}

// Function to generate all combinations of indices for the first list
function generateCombinations(totalNumbers) {
    const combinations = [];
    const halfTotal = totalNumbers / 2;

    // Recursively generate combinations
    function generate(current, remaining, start) {
        if (current.length === halfTotal) {
            combinations.push(current.slice());
            return;
        }

        for (let i = start; i < remaining.length; i++) {
            current.push(remaining[i]);
            generate(current, remaining, i + 1);
            current.pop();
        }
    }

    generate([], Array.from({ length: totalNumbers }, (_, i) => i), 0);
    return combinations;
}

module.exports = splitNumbersEvenlyBruteForce;
#

the optimized one is twice as fast for me

quartz kindle
proven lantern
# quartz kindle can you also paste your test function so i can copy it
test('test', () => {

    let bruteForceTimeAccumulator = 0;
    let optimizedTimeAccumulator = 0;

    // run 100 times with random numbers
    for (let i = 0; i < 100; i++) {
        // log the iteration number
        console.log(`iteration: ${i}`);

        // random even number between 4 and 24
        const randomEven = Math.floor(Math.random() * 11) * 2 + 4;

        // function to generate a random number between 800 and 1600
        const randomNumberFn = () => Math.floor(Math.random() * 800) + 800;
        const numbers = Array.from({length: randomEven}, randomNumberFn);

        // see how long it takes to run the optimized method
        const startOptimized = new Date().getTime();
        const [list1, list2] = splitNumbersEvenlyOptimized(numbers);
        const endOptimized = new Date().getTime();
        optimizedTimeAccumulator += endOptimized - startOptimized;

        // see how long it takes to run the brute force method
        const startBruteForce = new Date().getTime();
        const [list1BruteForce, list2BruteForce] = splitNumbersEvenlyBruteForce(numbers);
        const endBruteForce = new Date().getTime();
        bruteForceTimeAccumulator += endBruteForce - startBruteForce;

        // difference between the sum of the numbers in the two lists
        const sum1 = list1.reduce((acc, val) => acc + val, 0);
        const sum2 = list2.reduce((acc, val) => acc + val, 0);
        const difference = Math.abs(sum1 - sum2);

        const sum1BruteForce = list1BruteForce.reduce((acc, val) => acc + val, 0);
        const sum2BruteForce = list2BruteForce.reduce((acc, val) => acc + val, 0);
        const differenceBruteForce = Math.abs(sum1BruteForce - sum2BruteForce);

        expect(difference === differenceBruteForce).toBeTruthy();
    }

    // avg time in ms
    console.log(`optimized avg: ${optimizedTimeAccumulator / 100}`);
    console.log(`brute force avg: ${bruteForceTimeAccumulator / 100}`);
});```
quartz kindle
#

the initial array is always even?

proven lantern
#

so like a 5v5 game. it will alway be even

timber hatch
#

does anyone here use resend for emails?

quartz kindle
proven lantern
quartz kindle
#

lmfao

#

99 iterations of array4 takes 1ms

#

99 iterations of array16 takes 380ms

#

array18 takes 1800ms

#

array 20 takes 8000+ms

#

array24 took 162194ms

#

lmao

quartz kindle
proven lantern
#

12v12 would be the biggest

quartz kindle
#

alright

proven lantern
#

24 total numbers

quartz kindle
#

the AI version is indeed faster, but still horribly slow

#

200ms at 16
3600ms at 20

#

24 still running lmao

proven lantern
quartz kindle
#

87000ms for the 24

#

99 iterations

quartz kindle
proven lantern
quartz kindle
surreal sage
#

I ran sudo ip addr add public.ip.here.123/255.255.255.0 dev enp2s0 on my ubuntu 22.04 server

#

for some reason, all connections outside the local network (192.168.*.*) are timing out

#

ip addr show enp2s0

#

blurred/24 = public ip/24

quartz kindle
#

but i think the bruce forcing can be optimized

proven lantern
#

I'm still confused by what the ai did to optimize the brute force code.

#

I guess the ai code is still brute force, but doing some bitwise trickery

proven lantern
#

Leet code would put an annoying problem like that on their website.

vagrant coral
#

I vote pokemon hq but not sending vote success message

warm surge
#

because it’s probably webhook issues

vagrant coral
#

Thank you sir. 8)

warm surge
#

Your welcome

charred nest
#

hey yall i need a stupid easy developer-oriented question for my work for verifying developers TT_pog

#

nothing too difficult, something that a developer of any experience should be able to get correctly

radiant kraken
#

can you give an example?

radiant kraken
#

idk fizz buzz

#

never wrote a fizz buzz code before mmLol

sharp geyser
#

It’s simple

sharp geyser
radiant kraken
#

i see, thanks!

sharp geyser
#

actually I can make this better by not doing an addition of x

#

cause iircyou can set where it starts in range

#

but im too lazy

#

:D

radiant kraken
#

mhm

sharp geyser
#

fixed

#

but yea thats how you do fizz buzz

#

its relatively easy

radiant kraken
sharp geyser
#

fibonacci is s omething even I don't know how to do tbh

quartz kindle
#

1 second for a single function call is ridiculous

#

honestly i would just go with a naive version and not care about teams being slightly uneven

#

lmao

#

i didnt try the leetcode versions yet, they will likely be faster

past field
#

@quartz kindle you are a genius!!!!

#

ok the game runs exactly how I wanted it to!!!

#

the only issue is when invoking the command i get "application did not respond" but the command does run like it's supposed to, and I don't get any errors in my terminal

#

when i use the command, it sends a message to the channel letting people know the game started.. I'm guessing that response is not within the 3 seconds.. so I changed it to an ephemeral and it worked fine - no error.. but I wanted the response to the command to be a channel message that everyone sees so that they know the game has started

past field
quartz kindle
# past field

the main problem is that you're receiving an interaction and responding with a normal message, not with an interaction reply

past field
#

ohhhhhh

quartz kindle
#

you could simply change the first response The Easter egg hunt game has started! to interaction.reply()

#

also, a suggestion

#

save the egg messages in an array

quartz kindle
#

so you can directly delete them afterwards, without needing to fetch messages

#
eggs.push(await randomChannel.send("🥚"))

Promise.all(eggs.map(egg => egg.delete()))
quartz kindle
past field
#

ok i’m gonna try this

wheat mesa
#

“Wanna make a bit with me” = “I’ll tell you what to do and you make the bot for me” lol

deft wolf
#

And you are gonna pay for hosting

real rose
#

how dare we delete him

past field
past field
quartz kindle
quartz kindle
past field
#

ok one more question

#

nvm

#

ignore me

quartz kindle
#

what a great question

past field
#

thanks for your answer to it, just learned a lot from it

real rose
#

i enjoy those types of questions

past field
#

😂

real rose
#

require the least amount of effort to respond to

past field
#

im surprised yall have not blocked me yet LOL

quartz kindle
#

which is a big plus

real rose
#

dub

quartz kindle
#

inb4 battleless arrives

past field
#

and it’s hard right now but i’m learning a lot and making progress

#

thank you guys fr for being so patient with me

#

i know @deft wolf got tired of me 😂😂

eternal osprey
#

hey, does anyone have a clear overview of all discord markup features?

#

like # test

#
  • test
#

hey

#

etc

eternal osprey
#

arigato

shell tundra
hidden gorge
#

Hey does anyone know why it says Expired when it shouldnt be?

<script>
    // Set the target date in Eastern Standard Time (Friday, March 5th, 2024)
    const targetDate = new Date('March 5, 2024 12:00:00 EST').getTime();

    // Update the countdown every second
    const countdown = document.getElementById('countdown');
    const timer = setInterval(function () {
        const now = new Date().getTime();
        const distance = targetDate - now;

        // Calculate days, hours, minutes, and seconds
        const days = Math.floor(distance / (1000 * 60 * 60 * 24));
        const hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
        const minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
        const seconds = Math.floor((distance % (1000 * 60)) / 1000);

        // Display the countdown
        if (distance > 0) {
            countdown.innerHTML = `Expires in: ${days}d ${hours}h ${minutes}m ${seconds}s`;
        } else {
            clearInterval(timer);
            countdown.innerHTML = 'EXPIRED';
        }
    }, 1000);
</script>
spark flint
#

because its cool

quartz kindle
lyric mountain
#

your subscription will has been expired

hidden gorge
#

OH WAIT

quartz kindle
#

lmao

hidden gorge
#

I'm stupid

hidden gorge
wheat mesa
#

Wait until this guy finds out about operator overloading existing in every modern sane language other than Java

#

(It’s an awesome feature that they should honestly support in java)

past field
#

nvm i got it

eternal osprey
#

in a message component collector, is it possible to retrieve input from 2 different embeds?

const collector = message.createMessageComponentCollector({
     componentType: ComponentType.Button,
   });

right now i have hit the max of 5 components, but i need 5 more..
Or is it not doable?

craggy pine
#

You can create another row of buttons if you wanted it on a single embed.

eternal osprey
#

i have hit 5 rows already

#

which is the component max iirc

deft wolf
#

Holy

craggy pine
#

Wait, so you haver 25 buttons?

eternal osprey
#

no

craggy pine
#

or 20 whatever the limit is

eternal osprey
#

Wait i might actually be really stupid rn

#

i tried to categorize them in diff rows lmao

#

but that's not needed

#

each row holds like max 2/3 buttons

craggy pine
#

let row = new ActionRowBuilder()
let row2 = new ActionRowBuilder()

add 5 buttons to row 2?

#

Then components: [row, row2]

eternal osprey
#

miyuka i know, i was having a brainfog moment

#

what i did is categrize each button section into a new actionrow

craggy pine
#

I see i see

eternal osprey
#

but that's not needed, so i saved space by filling each row

wooden ember
#

just wondering;
I have trash internet, I was testing a few things on a web page I was making but if I show it to my mates over the internet it loads like ass because even lowrez images tank m,y 0.8Mb/s upload. I had the idea I can just upload the image to discord and link it from there to save on my bandwidth. However it still loads sorta slow, is that still my internet also having bad download? Or is that cuz it downloads the image from discord to the web server and then gets reuploaded to the client?

quartz kindle
#

as well as free webhosting services in general like github pages

wooden ember
#

yeah but I'm testing this one thing and I will forget about all this in the morning

#

just an idle curiosity really

#

this is literally it.

#

was messing with transparency effects

#

thats just a b/w baground image but with an orange background colour on top of it that is opaque

#

originally I was wondering if it would mean I would save on file size but thats dumb cuz an orange and white image will use the same space as a black and white image does(probably)

quartz kindle
#

and generally, colorful images also cost more space than simple images, with less colors and less complexity

#

other than that is depends on image format, encoding and compression

frosty gale
#

unless you need some other data to figure out which pixel is transparent and which isnt

frosty gale
#

so they can still be compressed no problem no?

quartz kindle
#

1 extra byte needed for transparency

wooden ember
#

well exept for the bytes for the line in the css file I guess

quartz kindle
#

that would probably help saving bytes yes

#

if your imageis pure black and white, you can also use a format that uses indexed colors

#

for example PNG8

#

idk if webp also does that by default

wooden ember
#

I have no idea its just a png I found on the internet

quartz kindle
#

png8 basically has a maximum of 256 different colors and uses an index table to lookup colors

#

so instead of being 3 bytes per pixel, is just 1 byte per pixel

wooden ember
#

one of the few tiling pcb traces images I could find that was hard to see if it was tiled but also interesting

quartz kindle
#

it can be further reduced

wooden ember
#

ooo nice

quartz kindle
#

if you have a color index with only 2 colors, technically each pixel can use only 1 bit

#

but idk if png can be slimmed down that far

#

The standard allows indexed color PNGs to have 1, 2, 4 or 8 bits per pixel

wooden ember
#

I know nothing about image formats other than jpg is for printing and png is usually for digital stuff

#

and gif is for the funny moving images

quartz kindle
#

jpg is a "lossy" format, which means it doesnt store all pixels, but only key pixels

#

and reconstructs the image by guessing the missing pixels from its neighbours

wooden ember
#

it also sucks around curves

quartz kindle
#

png is lossless, which means all pixels are saved

wooden ember
#

yeah

quartz kindle
#

then you have bit depth, aka how many bits per pixel

#

jpg is usually 24 bits, aka 3 bytes per pixel

#

png has variable depth, which can go as low as 1 bit per pixel, for pure black and white images

#

webp has both modes, lossy and lossless

#

lossy webp is similar do jpg, but with a lot of improvements

#

lossless webp is similar to png, but also with a lot of improvements

wooden ember
#

interesting

timber hatch
#

recently updated my bot to start using hybrid sharding which means i've opted for vanilla requests.

can anyone tell me what i'm doing wrong here? i'm getting status 400

    async function updateTopGGStats() {
        if (client.cluster.id !== (client.cluster.count - 1)) return;
        const guildAmount = await client.utils.getServerCount().catch((e) => console.error(e));
        await fetch(`https://top.gg/api/bots/${client.user.id}/stats`, {
            method: "POST",
            headers: { "Authorization": `${client.config.topgg}`, },
            body: {
                "server_count": guildAmount,
                "shard_count": client.cluster.info.TOTAL_SHARDS
            }
        }).then((r) => {console.log(r.status, r.body); client.logger.dbl(`TOP-GG-UPDATER Updated the Stats`)}).catch((e) => console.error(e))
    }
quartz kindle
sharp geyser
#

Hey tim

quartz kindle
#

strigify

quartz kindle
proven lantern
# quartz kindle honestly i would just go with a naive version and not care about teams being sli...

i've been going back and forth on this. another thing i need to worry about is memory usage. i'm running the code on 128MB lambdas and it takes about 450MB to use the brute force method with 24 numbers. the optimized version barley uses any memory so it's actually possible to use that. and lambdas are pretty cheep. it would cost about $0.0000021 each time i run that function(if it "only" takes a second)

quartz kindle
#

1000ms of "cpu time" is not a small amount

proven lantern
#

let me see

quartz kindle
#

idk about AWS, but like cloudflare workers limit instances to 10ms of cpu time per request

quartz kindle
proven lantern
#

Duration is calculated from the time your code begins executing until it returns or otherwise terminates, rounded up to the nearest 1 ms*. The price depends on the amount of memory you allocate to your function. In the AWS Lambda resource model, you choose the amount of memory you want for your function, and are allocated proportional CPU power and other resources. An increase in memory size triggers an equivalent increase in CPU available to your function. To learn more, see the Function Configuration documentation.

#

i wonder what this means and are allocated proportional CPU power and other resources

quartz kindle
proven lantern
#

it seems like a lambda that is running idle would cost as much as a lambda running at 100% cpu usage

#

but that doesnt make sense

quartz kindle
#

they dont run at idle

#

once the request is done, the instance is shut down / sleeps

proven lantern
quartz kindle
#

ah no, that doesnt count as cpu time

#

idk lambdas, but cf workers are limited by time as well

#

30 seconds per request

eternal osprey
#

hey, a designing dilemma here again!
Is this okayish looking?

proven lantern
proven lantern
eternal osprey
#

it's an animated background

sharp geyser
#

It’s a star

eternal osprey
#

i added stars in

#

hollon

sharp geyser
#

Also if it’s animated

#

Make a gif

proven lantern
#

trickery

sharp geyser
#

💀

#

Can’t ask for opinions on something you aren’t showing fully

eternal osprey
proven lantern
#

that star doesn't look like the others

sharp geyser
#

Looks fine but that border shadow is a little much

eternal osprey
sharp geyser
eternal osprey
#

that's a bug

#

but tbh, a comet sounds good

sharp geyser
#

I was helping you out

eternal osprey
#

thank youu!!

sharp geyser
#

But nah it looks fine

eternal osprey
#

What do you guys think of the black form? Does it match with the dark purple?

eternal osprey
sharp geyser
#

Are you making this for @quartz kindle 2034 astrology api

eternal osprey
#

No, it's a discord bot i am trying to create a site for.

sharp geyser
#

I know I was kidding

sharp geyser
#

An api Tim has been saying he’ll make since 2020 or before hand

eternal osprey
#

relatable

#

got so many unfinished projects

past field
#

ok so when storing messages in an array to be deleted at the end of a game.. is it possible to set it to delete any message that contains a specific emoji?

#

i’ve been trying to do that and it isn’t deleting the messages

sharp geyser
#

Or if you have them in an array

#

See if they contain the emote

past field
#

i may not have done it correctly then

sharp geyser
#

Hard to say without knowing how you’re currently doing it

past field
#

let me get it

#

so long story short, i created an egg hunt game that sends eggs around the server, and @analog patrol gave me the idea to have the eggs stored in an array so that it’ll be deleted after the game, but there’s another message that tells the users who found the egg when it’s found.. i tried to also have that in the array to be deleted and now it won’t delete, so i added the egg emojis to that message so that the bot will save every message containing the egg emoji and delete it afterwards

#

idk if that makes sense

analog patrol
#

I did? lol

quartz kindle
#

wrong tim lmao

analog patrol
#

figured heh

past field
#

oh 💀💀💀💀💀

#

not me thinking you changed your pic 💀

proven lantern
quartz kindle
# proven lantern can i see your code for this?
function splitNumbersEvenlyOptimized3(numbers) {
    const totalNumbers = numbers.length;
    const halfTotal = totalNumbers / 2;

    let minDifference = Infinity;
    let result = Array(halfTotal);

    // Iterate over all possible bitmasks for the first list
    for (let bitmask = 0; bitmask < (1 << totalNumbers); bitmask++) {
        if (countSetBits(bitmask) !== halfTotal) continue; // Skip if the number of set bits is not halfTotal

        let sum1 = 0;
        let sum2 = 0;

        // Distribute numbers based on the bitmask
        for (let i = 0; i < totalNumbers; i++) {
            const x = numbers[i];
            if (bitmask & (1 << i)) {
                sum1 += x;
            } else {
                sum2 += x;
            }
        }

        // Calculate the difference in sums
        const difference = Math.abs(sum1 - sum2);

        // Update the result if the current difference is smaller than the minimum difference
        if (difference < minDifference) {
            minDifference = difference;
            for (let i = 0, n = 0; i < totalNumbers; i++) {
                if (bitmask & (1 << i)) {
                    result[n++] = numbers[i];
                }
            }
        }
    }

    return [result, numbers.filter(x => !result.includes(x))];
}

// Function to count the number of set bits in a number
function countSetBits(num) {
    let count = 0;
    while (num) {
        count += num & 1;
        num >>= 1;
    }
    return count;
}
proven lantern
#

the countSetBits and bitmask < (1 << totalNumbers); part mostly

quartz kindle
#

it took me a while to understand it as well

#

basically

proven lantern
#

if (bitmask & (1 << i)) {

quartz kindle
#

its using bits to iterate over combinations

#

ie

#

0b00001111 = check items 4 5 6 7 from the array

proven lantern
#

oh, that's a good way to iterate through all the combinations

quartz kindle
#

ye

proven lantern
#

very tricky

quartz kindle
#

then it increments the number

#

and checks if the bits do have the right number of items set

#

if not, skip that number

proven lantern
#

0001 -> 0010

#

and it doesn't need to store all the combinations, it just keeps the lowest until it's tried everything

quartz kindle
#

ye

#

actually

#

there is one more optimization i can add

proven lantern
#

exit out if it's 0 difference?

quartz kindle
#

an early termination if the number is within 1 of perfect average

#

ye

proven lantern
#

not a bad optimization

quartz kindle
#

let me test

proven lantern
#

countSetBits(bitmask) !== halfTotal so this is making sure half the bits are 0 and half are 1 right?

quartz kindle
#

with

#

lmao

proven lantern
#

is that with random numbers?

quartz kindle
#

ye

proven lantern
#

maybe it got lucky

quartz kindle
#

im having some weird results

#

let me double check

quartz kindle
proven lantern
#

oh same numbers in both lists error right?

#

numbers.filter(x => !result.includes(x))

quartz kindle
#

yup

#

new code (even better)

#
function splitNumbersEvenlyOptimized3(numbers) {
    const totalNumbers = numbers.length;
    const halfTotal = totalNumbers / 2;

    let minDifference = Infinity;
    let result = 0;

    // Iterate over all possible bitmasks for the first list
    for (let bitmask = 0; bitmask < (1 << totalNumbers); bitmask++) {
        if (countSetBits(bitmask) !== halfTotal) continue; // Skip if the number of set bits is not halfTotal

        let sum1 = 0;
        let sum2 = 0;

        // Distribute numbers based on the bitmask
        for (let i = 0; i < totalNumbers; i++) {
            const x = numbers[i];
            if (bitmask & (1 << i)) {
                sum1 += x;
            } else {
                sum2 += x;
            }
        }

        // Calculate the difference in sums
        const difference = Math.abs(sum1 - sum2);

        // Update the result if the current difference is smaller than the minimum difference
        if (difference < minDifference) {
            minDifference = difference;
            result = bitmask;
            if(difference < 2) {
                break;
            }
        }
    }

    const r1 = [];
    const r2 = [];
    for (let i = 0; i < totalNumbers; i++) {
        const x = numbers[i];
        if (result & (1 << i)) {
            r1.push(x);
        } else {
            r2.push(x);
        }
    }

    return [r1, r2];
}

// Function to count the number of set bits in a number
function countSetBits(num) {
    let count = 0;
    while (num) {
        count += num & 1;
        num >>= 1;
    }
    return count;
}
proven lantern
#

that's super fast

quartz kindle
#

which means

#

this problem actually has multiple solutions, not only one

#

there are multiple arangements of numbers that have the same result

#

let me prove this

proven lantern
#
    break;
  }

lol

quartz kindle
#

or not

#

im confused now

proven lantern
#

i did 100 iterations and it always matched

quartz kindle
#

there we go

#

check this out

#

2140 combinations where the difference between sums is less than 2

proven lantern
#

i wonder how many are 0

sharp geyser
#

What the hell are you guys doing

quartz kindle
#

some cant have 0

#

if all mmrs combined are uneven, it cant be 0

#

so basically

#

we managed to improve performance by over 2000x

#

lmao

#

since you only need 1 combination, not all of them

proven lantern
#

that should be worth it

quartz kindle
#

problem solved xDDDD

proven lantern
#

i want to see if i can find a combo that breaks it

#

i haven't found one yet

quartz kindle
#

run a test case with thousands of randomized inputs

quartz kindle
#

from an array of mmrs, split them into two teams as evenly as possible

sharp geyser
#

Is this for a discord bot

quartz kindle
#

well

#

the bulk of them is literally the same numbers

#

just in different orders and/or groups

sharp geyser
#

If this is all for a discord bot then wow

#

Didn’t think people would take it this seriously to implement mmr

quartz kindle
proven lantern
sharp geyser
#

Meh

#

Debatable

#

If it’s hidden mmr then it’s bogus and shouldn’t be implemented

quartz kindle
#

if it were me i would just go with a naive function

sharp geyser
#

Nothing I hate more than games implementing hidden mmr

#

Also mmr isn’t really needed if a rank system is in place, just match people based off rank

proven lantern
proven lantern
quartz kindle
#

so either 1 or 0

#

1 if total is uneven, 0 if total is even

#

even total cannot have a diff of 1

#

liekwise uneven cannot have a diff of 0

proven lantern
#

oh yeah, so should it check for difference === 2 instead of difference < 2?

sharp geyser
#

Truth be told who cares about new players

proven lantern
#

oh wait

#

that's 1

quartz kindle
#

you always need to check for both, even and uneven

sharp geyser
#

It’s not a competitive game if you hand hold people

#

You won’t be able to stop smurfing by any means

#

So mmr is a toxic system

proven lantern
sharp geyser
#

It harms new players than it does help

sharp geyser
#

You’d match people based off rank

proven lantern
sharp geyser
#

mmr is a system to "stop" smurfs from ruining the game for new players by ranking them up to get them back into their appropriate elo. Usually by measuring based off how good they do in a match

#

Which is a toxic system

#

Because what if a new player just happens to get some lucky wins and now they are facing people in the top 500 leaderboard (exaggerated example but point still stands)

#

Doing a rank based system is better off than mmr which is controlled solely based off match performance

proven lantern
sharp geyser
#

Fair enough just don’t implement it poorly then

#

Cause it can and will create a toxic game play

#

Just look at riot games

quartz kindle
#

mmr is just elo, nothing more nothing less

sharp geyser
#

Their mmr is hidden and it creates a toxic environment for new players who happen to just be good enough at the game to excel in their rank but not good enough at higher ranks

quartz kindle
#

the whole rank system was placed on top of it to make it more appealing

#

but under the hood its the same elo as it always was

sharp geyser
#

Yet they are forced into gold lobby’s while still being at silver skill level

quartz kindle
#

they just tweak how hard it scales every now and then

sharp geyser
#

I think hidden mmr is the dumbest thing (a lot of games hide their mmr)

#

I also think the rank system in a lot of games are shit too

proven lantern
#

and devs dont want to deal with it

sharp geyser
#

Okay but I assume this is a discord bot

#

You can’t really cheat

quartz kindle
#

you can win trade

#

:^)

proven lantern
#

it's up to the discord admins to stop cheaters

sharp geyser
quartz kindle
sharp geyser
#

It’ll stop you from having multiple accounts

quartz kindle
#

vpns, multiple accounts, friends, paypal

proven lantern
#

social engineering

sharp geyser
#

Time to bribe the admins

#

Either way good luck

#

Hopefully your ranking system won’t be as bad as others

proven lantern
wheat mesa
#

chess ranking is actually a pretty decent system

#

Most matches are pretty evenly matched when you have two players about 1000 elo playing each other

#

At low elos it's a little more unbalanced because it's often just chaos but still

proven lantern
#

why does this fail once the list is 32 numbers long? shouldn't it fail at 34?

proven lantern
#

i switched to bigint. i switched back

radiant kraken
#

JavaScript tends to act weird with bitshifting large numbers

frosty gale
#

bigints are cursed

#

you should only use if absolutely necessary for example cryptography since you need massive prime numbers

#

64 bit ints should suffice for 99% of purposes anyways

quartz kindle
#

since it uses signed ints, at 32 bit it becomes negative numbers
however, there is a way to do bitwise with math, this way you can trick js into doing bitwise operations correctly until its safe integer limit of 53 bits

raw lagoon
#

How much do you earn per month for having a bot with premium functions (cost 10 euros)?

quartz kindle
raw lagoon
#

For example the MEE6 bot?

quartz kindle
#

you can estimate that around 1 every 1000-2000 users will pay for premium

#

if you have a million users, thats 500-1000 paying users

frosty gale
#

at this rate mee6 wouldn't be a fair comparison since it's basically a business at this point and discord bots are one aspect of it

raw lagoon
quartz kindle
#

pretty much

#

before taxes that is

#

mee6 is probably bigger than that tho

unreal lotus
#

In what ways do you keep your bots online/running?

quartz kindle
unreal lotus
deft wolf
#

I pay 5 euros for more than my bot needs, so you can easily find a nice VPS for 3 euros

deft wolf
#

No, monthly

quartz kindle
#

there are some providers that offer free tiers, for example google, amazon, and oracle

unreal lotus
quartz kindle
#

google has a free forever 1gb ram vps

#

but they charge you for network usage if you use more than 1gb or internet per month

#

amazon gives you free trial for 12 months

deft wolf
quartz kindle
deft wolf
#

And I still have over 8GB of free ram

unreal lotus
unreal lotus
quartz kindle
#

for example

#

i've seen some large bots, like 150k guilds

#

that use 40-50gb of ram

unreal lotus
#

what for bots are that?

quartz kindle
#

so it depends on how efficient your bot is

unreal lotus
#

do you guys now what the largest bot is?

quartz kindle
#

it used to be rhythm, but idk now

#

here

unreal lotus
#

thx

unreal lotus
#

i cant find it

#

this:?

#

(i know its in dutch because i'm from belgium)

quartz kindle
unreal lotus
quartz kindle
#

when you create an instance, it has to be of type e2-micro, and it has to be in one of those 3 regions

#

otherwise its not free

unreal lotus
#

so is it free in belgium ore not?

quartz kindle
#

not where you are from

unreal lotus
#

ow

#

euh...

quartz kindle
#

for example

unreal lotus
#

Oh k thx man for youre help

lyric mountain
#

I think it's worth noting that you'll have to get used to command line interface

#

there's no panel or one-click setup or anything, all done from terminal

quartz kindle
lyric mountain
#

lul

wheat mesa
#

Just install libxz, it’s basically Remote Desktop anyways ;^)

past field
pale vessel
#

except that only one guy could access ur desktop and it's not u

past field
#

sorry i meant to upload this last night and fell asleep.. lol

inner heart
#

anyone know how to fix this

#

@unkempt ocean

#

@rare mist

spark flint
#

read the error ☠️

#

no need to ping random people

inner heart
#

ok

unkempt ocean
inner heart
#

sorry

#

sorry

wheat mesa
#

You can always use that 😉

wheat mesa
#

Yeah

#

It was made for the purpose of researching the exploit

#

Not actually to infect computers

quartz kindle
#

you need to install it

grim aspen
#

do npm install discord.js

#

in console

frosty gale
#

are there any more discord libraries for js now

#

or is it still the same discord.js and eris landscape

radiant kraken
quartz kindle
#

experienced devs maybe

#

but normal devs are pretty much still hogging discord.js

#

havent seen any mention of eris or others in a long time

radiant kraken
#

go libless topggSunglasses

quartz kindle
#

is it still libless if you make your own code into a lib?

#

:^)

harsh nova
#

If I was going libless I'd probably switch to a new language

radiant kraken
#

like Rus-

quartz kindle
#

i havent touched any discord code ever since i moved to tiny-discord + webhook slash commands only

#

it feels like you finally get peace of mind

#

no need to worry about scaling or updates

#

new discord features can be added directly to the code, without needing any lib update

#

bot will pretty much never exceed 100-150mb ram usage, no matter how big it gets

quartz kindle