Guild icon
DDraceNetwork
Development / developer
Development discussion. Logged to https://ddnet.tw/irclogs/ Connected with DDNet's IRC channel, Matrix room and GitHub repositories — IRC: #ddnet on Quakenet | Matrix: #ddnet-developer:matrix.org GitHub: https://github.com/ddnet
Between 2020-12-05 00:00:00Z and 2020-12-06 00:00:00Z
Avatar
god damn it. today was very possible to get in the top100 😦
Avatar
[quakenet] ChillerDragon BOT 2020-12-05 08:14:40Z
flex
Avatar
i dont get the second part
09:21
the meaning
09:21
tee_thinking
09:22
ahhh
09:25
done
09:26
i think i got a pretty solution
09:31
09:31
monkalaugh
Avatar
Avatar
Ryozuki
i dont get the second part
I did just sum from lowest to highest - sum all given ids
Avatar
read full msgs bro
10:36
i already did it
Avatar
Yeah but you iterate and sort, pah :d
Avatar
Is set a hash set in nim?
13:44
I just replaced F and B with 0 and 1 respectively to get binary and than used a standard lib function to convert to a number
Avatar
@timakro yes, but I didn't use the regular hash sets (https://nim-lang.org/docs/sets.html) but instead the more efficient bit sets: https://nim-lang.org/docs/system.html#system-module-sets
14:39
thus also limited to int16
Avatar
on codewars there was "count number of vowels a-e-i-o-u in string" and I was able to remove all branches happy int getCount(const std::string& inputStr){ int num_vowels = 0; for (auto i : inputStr){ num_vowels += (0x208222 >> (i & 0x9F)) & 0x1; } return num_vowels; }
Avatar
@ReD looks like undefined behavior. did you mean (0x208222 >> (i & 0x1f)) & 0x1?
15:57
(which probably also represents what your code will compile to)
16:00
indeed, they compile to the same assembly: https://godbolt.org/z/865Kez
int getCount(const std::string& inputStr){ int num_vowels = 0; for (auto i : inputStr){ num_vowels += (0x208222 >> (i & 0x9F)) & 0x1; } return num_vowels; } int getCount2(const std::string& inputStr){ int num_vowels = 0; for (auto i : inputStr){ num_vowels += (0x208222 >> (i & 0x1F)) & 0x1; } return num_vowels; }
16:02
these are the characters you count: >>> "".join([chr(i) for i in range(128) if (0x208222 >> (i & 0x1F)) & 0x1]) '\x01\x05\t\x0f\x15!%)/5AEIOUaeiou' (edited)
Avatar
the inputStr only contains lower case numbers and space, so I only considered that range
Avatar
lowercase letters? ah okay
Avatar
if it was whole range I would need to think about something else 😄
Avatar
nice optimization then 😉
Avatar
thanks I will think about the "all characters challenge" 😉
Avatar
How did you find the 2 constants (0x208222, 0x9F)?
Avatar
curious aswell
16:46
some math stuff?
16:46
xD
Avatar
binary I think
Avatar
ok let's explain :D we start with character i &ing 0x9F is just subtracting 96 because 0x9f = 1001'1111, and &ing this removes the 64 and 32 bit (which adds to 96) it's useful because 'a' == 97, so it's just one off 0x208222 is 1000001000001000100010 in binary which has 5 binary digits at positions : 1, 5, 9, 14 and 21 this corresponds to the position of vowels after 96 : 'a' = 97 + 0 == 96 + 1 'e' = 97 + 4 == 96 + 5 'i' = 97 + 8 == 96 + 9 'o' = 97 + 14 == 96 + 14 'u' = 97 + 20 == 96 + 21 so if after rightshifting 0x208222 by (i - 96) the last bit is 1 ,it must be a vowel (edited)
16:47
nice
Avatar
@heinrich5991 and 0x9F and 0x1F compile into the same binaries because if a character was greater than 128 (96 + 32) than 0x208222 >> 32 results in 0, which has no 1 at the last bit . it doesn't matter for this string range, but this could lead to undefined behavior (ISO 9899:2011 6.5.7 Bitwise shift operators) which is avoidable, so you are correct that I should use 0x1F instead of 0x9F 😄 (edited)
Avatar
just had this happen to two ppl on korean ddnet server. dk why
Avatar
@nils send me their map and savecode (or name) in DM
Avatar
i have one question
Avatar
how the f u guzs are hosting server
23:10
servers*
Avatar
we rent a vps and run our servers on them
Avatar
ough
Exported 53 message(s)