Chat:World/2022-03-30

From CG community
Jump to navigation Jump to search

jacek: :upside_down:

TimothyAlexisVass: Meaning of life = * ?

PatrickMcGinnisII: Life is what you make of it

TimothyAlexisVass: bs

TimothyAlexisVass: bananasauce?

PatrickMcGinnisII: That's what Douglas Adams was saying... google it

drnobody: 42

drnobody: Answer to the ultimate question...

PatrickMcGinnisII: Why do I have the desire to make some tea

drnobody: *looks around for towel*

**PatrickMcGinnisII laughs

drnobody: *finds book with "Don't Panic" written in a calming font on the cover...*

PatrickMcGinnisII: was deepthought a GA or a NN?

**PatrickMcGinnisII lost his mind years ago

Default avatar.png Synergyforge: My stupid pathfinding function doesn't work! :rage::rage::rage:

PatrickMcGinnisII: working on the new optim?

Uljahn: guess it's the Labyrinth puzzle

drnobody: you know, I don't know ... I would imagine an NN

LimitMax: hi hi world

PatrickMcGinnisII: drnobody either way I feel the wait time

Default avatar.png Synergyforge: wait maybe it is working... :thinking:

drnobody: heheh

Default avatar.png LinhT.Nguyen: haro how arr yu

derjack: :upside_down:

PatrickMcGinnisII: Finally: https://www.codingame.com/replay/616481223

derjack: :tada:

Uljahn: why not to start cutting (5, 17)?

PatrickMcGinnisII: it's not perfected, and doesn't save trees - just houses (if able)

Uljahn: ah, indeed

PatrickMcGinnisII: it's kinda like the coid cut algoithms

PatrickMcGinnisII: er COIF

Default avatar.png Luca_Crivellari_Balice: porco dio

derjack: :no_mouth:

Default avatar.png tantheman: dick

Default avatar.png PauliV: haha

Default avatar.png tantheman: schmogel

Default avatar.png PauliV: schmeagle

Default avatar.png PauliV: schmeagz

Default avatar.png tantheman: buy schmeagle coin guys

Default avatar.png PauliV: become millionaire today

Default avatar.png tantheman: :point_right_tone2::ok_hand:

VizGhar: where is 5DNL when we need him... Automaton2000 get them

Automaton2000: so i could try to find an answer by googling

derjack: nyoro~n

Uljahn: mods can't ban offline users, it's one of xmpp restrictions :(

derjack: what a nice idea... :thinking:

Default avatar.png tantheman: paul vogelberg

Tryst: take :taco:

antiwonto: [auto] aww, there are no tacos to take

Wontonimo: does someone need banning?

Cdude: the quest map os to big

Uljahn: what's the resolution of your device?

Uljahn: can't you zoom out?

Cdude: is on my mobile the quest map and the other ting too

Uljahn: use desktop mode on mobile

derjack: codingame isnt good for mobile

Cdude: ok

Cdude: but is a website

Uljahn: not just a regular website but a coding platform

derjack: clash of code webstie

Cdude: ok

Default avatar.png PainEXE: Im beating the boss but its not putting me in the next league

Default avatar.png PainEXE: do I just have to wait in the arena for a while?

eulerscheZahl: oh, a new optim. when did that happen?

eulerscheZahl: should have checked the forum instead of bothering you. 6 days ago

MrAnderson: @PainEXE you need to rank higher than the boss after all of the rounds are done. Beating the boss is a good indicator that you are close, but beating him one time isn't enough.

Default avatar.png coddednight: hi guys

MrAnderson: Well, sometimes beating him once is enough, but the criteria is your final rank.

Default avatar.png coddednight: ok can someone help me

Uljahn: it depends on your problem

Default avatar.png coddednight: i need help with java

Default avatar.png ukwolfy: don't we all

Uljahn: do you have the slightest idea how little that narrows the problem down?

Default avatar.png empties: example: http://chat.codingame.com/pastebin/8ee3541b-3e96-4206-a5d5-e75a4cd4666a

Default avatar.png empties: example: http://chat.codingame.com/pastebin/006c6272-4ea7-410f-b8b2-3084fdfb1599

Default avatar.png empties: HAHAHAHHAHAHA

-.-'

eulerscheZahl: too much boilerplate for a question, just get straight to the point

VizGhar: So... I wrote a bot, that always looses in UTTT :D

VizGhar: funny to look at, but I can't make him do opossite

Default avatar.png empties: love it!

Default avatar.png empties: where can I see your bot?

Default avatar.png empties: lol

VizGhar: I obviously havent posted it :D

Default avatar.png empties: great, still patent pending, I suppose

NewCoder09: hey

antiwonto: [auto] Hey NewCoder09, here is a :taco: for loggin in today while it is quiet. You now have 2 tacos

Default avatar.png Synergyforge: gimme a taco, immediately!

Default avatar.png Synergyforge: No? Oh. :(

NewCoder09: you have to say something when the chat is really quite

Default avatar.png Hafizur046: *quiet

Default avatar.png Synergyforge: I was thinkin' it, just not sayin' it. :)

visva: wassss up

Wontonimo: anyone working on mad pod racing and would like a hand?

Wontonimo: or any other multi for that matter

Wontonimo: nope

Default avatar.png coddednight: does anyone know how to do mad pod racing in java

AdemDj12: :taco: ademdj12

AdemDj12: i am waiting to tackle mars lander 3

.[-.-].: Hi peeps!

Default avatar.png ScifiSpirit: Hi

.[-.-].: Any way I can check what the threshold is to get into top 2% of the bot programming category?

.[-.-].: Trying to do the achievment .D

Default avatar.png ScifiSpirit: I think the games say how many people have bots there, take 2%, then you get a number, try to look at their score?

Default avatar.png ScifiSpirit: Unless they say that outright, but i assume you have looked.

Default avatar.png ScifiSpirit: Also i'm assuming it's per game, but those formulas used are actually published here somewhere.

Default avatar.png ScifiSpirit: And you can track your own progress in your profile.

Wontonimo: hey coddednight , yeah I can help

Wontonimo: if you want to get into the top 2%, focus on getting a high rank in 1 or 2 bot games instead of low rank in many

Wontonimo: you need about 6,200cp in bot programming specifically ScifiSpirit

EToTheIPi: :taco:

EToTheIPi: :taco:

EToTheIPi: :taco:

antiwonto: [auto] ':taco:' was defined as ' A currency to some, sustenance for others '

antiwonto: [auto] ':taco:' was defined as ' A currency to some, sustenance for others '

Default avatar.png ScifiSpirit: Or try to get high rank in every bot game, you might be better in one of them :)

antiwonto: [auto] ':taco:' was defined as ' A currency to some, sustenance for others '

EToTheIPi: :taco::taco:

EToTheIPi: :taco:

EToTheIPi: :taco:

antiwonto: [auto] ':taco:' was defined as ' A currency to some, sustenance for others '

antiwonto: [auto] ':taco:' was defined as ' A currency to some, sustenance for others '

Wontonimo: key EToTheIPi, you have been kicked for spamming

Default avatar.png Synergyforge: Oof

Wontonimo: you are welcome to come back in about 5 min if you behave

Lambert_W_Function: :taco: tuesday

Lambert_W_Function: oh wait its wednesday

Wontonimo: .[-.-]. you need about 6200cp in bot programming to reach 2%

Default avatar.png Synergyforge: I can't even get my stupid maze code to work. It works on two of the tests. :(

Default avatar.png ScifiSpirit: I have 3426, so i'm pretty far :)

Default avatar.png ThePurpleOne1: why is there no one in the event

Default avatar.png ScifiSpirit: It's alright though, i'm not very competitive person :)

Wontonimo: what event ThePurpleOne1 ?

Wontonimo: which maze code ScifiSpirit ?

Wontonimo: The Labyrinth ?

Default avatar.png ScifiSpirit: I wasn't the one talking about maze code.

Wontonimo: oh, sorry

Default avatar.png ThePurpleOne1: the python shortest code

Default avatar.png ScifiSpirit: :D

Lambert_W_Function: ok

Wontonimo: Synergyforge, (the other S... name), how's the maze thing

Default avatar.png Synergyforge: Other S name? :O

Default avatar.png ScifiSpirit: Synergyforge, he was talking about me, ScifiSpirit :)

Default avatar.png Synergyforge: I got tests 1 and 3 working. :(

Default avatar.png Synergyforge: I see. :)

Default avatar.png ScifiSpirit: See, s + tab turns into my name :)

Default avatar.png ScifiSpirit: Because of my 'c' ;)

Default avatar.png ScifiSpirit: Which puzzle are you doing?

Wontonimo: did you implement A* search Synergyforge ?

eulerscheZahl: that's not how tab completion works. depends on the users already active when you log in and such.

Default avatar.png Synergyforge: Been messing with this dumb labyrinth one for two days

Default avatar.png ScifiSpirit: Oh. I thought it was alphabetical.

eulerscheZahl: i get Synergyforge on s[tab]

Wontonimo: keep at it. it's difficult

Default avatar.png ScifiSpirit: I see.

Default avatar.png ScifiSpirit: The Labyrinth?

Wontonimo: yes

Default avatar.png ScifiSpirit: It says a breath first search would work too. I just looked at it.

Wontonimo: do you know how to implement BFS or A* ?

Default avatar.png ScifiSpirit: But i think i'm going to implement A* first before i'm going to attempt that one, since i'm already doing it, and i've kind of done it already in another language.

eulerscheZahl: within codingame A* is usually overkill, as maps are small enough

Default avatar.png ScifiSpirit: Hmmh.

Wontonimo: Synergyforge , are you implementing A* or BFS ?

eulerscheZahl: "breath first search" you forgot a letter

Default avatar.png ScifiSpirit: Well, i'm going to do A* anyway for projects outside Codingame, so i can just use it as a "library" then.

Default avatar.png ScifiSpirit: Right :D Not breathing :D

Default avatar.png ScifiSpirit: But don't forget to breathe while doing breadths ;)

eulerscheZahl: so far i never forgot to breath, lucky me

Default avatar.png ScifiSpirit: :D

.[-.-].: Thanks Wontonimo :)

Wontonimo: A* is the same as floodfill, except do a sort on math.sqrt(dx*dx + dy*dy) before picking the next element to expand

Wontonimo: but like eulerscheZahl said, these maps are so small a floodfill will also work just fine

eulerscheZahl: and c# has no built-in priority queue :(

eulerscheZahl: i noticed that years ago and still hate whoever made that decision

Wontonimo: .[-.-]. , would you like some help getting to Silver in Mad Pod Racing ? It will gather about 2000 points for you

eulerscheZahl: oh, you would do that for me Wontonimo? sure, go ahead

Wontonimo: you are currently in bronze using Kotlin in position 68,000 overall. I can help you get to at least 25,000 overall

eulerscheZahl: i don't even remember the Kotlin part. what do i have to do?

Wontonimo: no, i'm talking to the other guy who's name is .[-.-].

eulerscheZahl: oh, that's a nickname

Wontonimo: yeah ... difficult to type

Wontonimo: :taco: eulerscheZahl

antiwonto: [auto] Wontonimo has awarded eulerscheZahl 10 tacos. eulerscheZahl now has 38 taco. Wontonimo now has 28 taco

eulerscheZahl: :taco: Wontonimo

antiwonto: [auto] eulerscheZahl has awarded Wontonimo 10 tacos. Wontonimo now has 38 taco. eulerscheZahl now has 39 taco

Default avatar.png ScifiSpirit: :)

Default avatar.png ScifiSpirit: Aren't you already in like gold league or something?

Westicles: I have made the greatest clash ever

Default avatar.png ScifiSpirit: Or actually, probably legend leagure.

eulerscheZahl: there's no legend league without me

Wontonimo: Euler is uber league, above legend

Default avatar.png ScifiSpirit: Thought so :D

eulerscheZahl: so, what's the fuzz about that clash?

Westicles: Touching Balls?

antiwonto: [auto] Westicles be respectful and watch your language https://www.codingame.com/playgrounds/40701/help-center/code-of-conduct

Default avatar.png ScifiSpirit: lol

eulerscheZahl: touching

eulerscheZahl: balls?

antiwonto: [auto] eulerscheZahl be respectful and watch your language https://www.codingame.com/playgrounds/40701/help-center/code-of-conduct

eulerscheZahl: but i'm a sports enthusiast

eulerscheZahl: fine, i'll say soccer spheres

Westicles: that's nuts

Wontonimo: i guess antiwonto is really specific about geometry and food

Default avatar.png ScifiSpirit: :D

Westicles: :taco: Automaton2000

antiwonto: [auto] sorry Westicles but you can only award tacos once per day

Automaton2000: i would just have to get to the next league

fabio-dev: :heart_eyes: Automaton2000

Automaton2000: i thought that would be useful

Default avatar.png ScifiSpirit: Is it possible to make Automaton2000 say :taco: <nick>? :D

Automaton2000: i don't think you can use it in other ways

Wontonimo: I suspect nicknames are filtered out of its vocabulary

Default avatar.png ScifiSpirit: What would the chances be anyway...heh.

Default avatar.png ScifiSpirit: take taco

antiwonto: [auto] aww, there are no tacos to take

Wontonimo: gtg , later

Default avatar.png ScifiSpirit: :wave:

jacek: :upside_down:

antiwonto: [auto] ':upside_down:' was defined as ' ɥǝllo '

jacek: :taco: Automaton2000

antiwonto: [auto] jacek has awarded Automaton2000 10 tacos. Automaton2000 now has 51 taco. jacek now has 39 taco

Automaton2000: i guess there is a way to go

Automaton2000: is the best way to be sure

Westicles: shakedown Automaton2000

antiwonto: [auto] Using your superior Intelligence of 6 you shake 10 :taco:s off of Automaton2000. 9 fall on the floor, 1 got crushed, and you lost 1

Westicles: take taco

Automaton2000: and why do you need to focus on a single line

antiwonto: [auto] Westicles has taken 5 :taco:s off the floor and now has 14. There are 4 left

Automaton2000: because i dont understand how to use them

eulerscheZahl: take taco

antiwonto: [auto] eulerscheZahl has taken 2 :taco:s off the floor and now has 41. There are 2 left

eulerscheZahl: eat taco

antiwonto: [auto] eulerscheZahl has eaten 10 :taco: and your Dexterity is now 1. You have 31 left

Westicles: take taco

antiwonto: [auto] Westicles has taken 2 :taco:s off the floor and now has 16. There are 0 left

Default avatar.png Synergyforge: And here I've been typing people's names. :grimacing::sweat_smile:

MACKEYTH: C++ question: I'm looking for a method that will return System time as a millisecond-resolution primitive value representing units since start of epoch.

MACKEYTH: Kinda in the weeds with the documentation. Seems like everything returns a string or a specialized time object.

MACKEYTH: Something equivalent to System.currentTimeMillis() from Java

MACKEYTH: would be ideal.

MACKEYTH: Trying to minimize performance/memory load for controlling timed loops.

Default avatar.png Synergyforge: ctime library doesn't fill that need?

Westicles: I think people use chrono mostly

Default avatar.png ScifiSpirit: ctime's clock() is pretty much the smallest overhead that i know of

MACKEYTH: I figured it would be someting from ctime or chrono

Default avatar.png ScifiSpirit: But that doesn't mean that it's a good idea to time things with it with repeated clock() calls.

Ayza: pretty sure this should help https://stackoverflow.com/questions/19555121/how-to-get-current-timestamp-in-milliseconds-since-1970-just-the-way-java-gets

Ayza: it uses chrono

Default avatar.png ScifiSpirit: If that's what you mean. All system time calls have overhead, and are definitely not millisecond-resolution, since the operating system scheduler rarely even reaches such resolution

Default avatar.png ScifiSpirit: But for controlling timed loops, there really isn't anything else.

Default avatar.png ScifiSpirit: For main loops and events and such i guess either of chrono or clock is fine.

Default avatar.png ScifiSpirit: I once investigated the fluctuations in timing of the scheduler, and i think i once came close to 100ms pause in my testing process.

Default avatar.png ScifiSpirit: Scheduler tries to maintain 10ms slices, but apparently can reach 10 times longer, or maybe even more.

Default avatar.png ScifiSpirit: At least in Windows.

Default avatar.png ScifiSpirit: Probably was in Windows 10 that i tested.

MACKEYTH: It seems like all the methods I've found so far return an object that contains a count of system-specific time units plus methods for translating that into s/ms,etc.

Default avatar.png ScifiSpirit: Oh, right. Clock indeed returns a system specific value, which you convert with TICKS_PER_SEC macro, if i remember correctly.

MACKEYTH: If that's how it has to be I can deal, but I was hoping to avoid the performance hit of creating a object and calling its translation method(s).

Default avatar.png ScifiSpirit: Oh no, it was CLOCKS_PER_SEC.

Default avatar.png ScifiSpirit: Does it have to be cross-platform?

Notgoodatcoding5: Hello, how are you guys?

MACKEYTH: Hiya! Good, trying to learn some c++

Default avatar.png ScifiSpirit: Hello.

Notgoodatcoding5: Oh fun!

MACKEYTH: So, C++ programmers: what is your preferred method of exiting a sim loop based time elapsed?

MACKEYTH: Have been happy to discover that C++ shares a lot of language syntax w/Java

MACKEYTH: switch, for, for each, and if are identical.

Default avatar.png ScifiSpirit: clock() is what i've been using because i like the simplicity.

MACKEYTH: C++ doesn't seem to like storing arrays in containers, though, which is a bit disappointing

Default avatar.png ScifiSpirit: Yeah, that can be a bit... clumsy.

MACKEYTH: Buuut, it does let you store primitives in containers, which is a good thing.

Default avatar.png ScifiSpirit: But you can use something else rather than raw arrays.

Default avatar.png ScifiSpirit: Care to paste an example?

MACKEYTH: I hate not being to store primitives in Java collections objects.

Default avatar.png PainEXE: Am I allowed to promote my puzzle here? or nah

MACKEYTH: I was experimenting last night with trying to make a vector of int[], but c++ wasn't having it. Kept spitting out incredibly verbose compiler errors.

MACKEYTH: Finally went with vectors of vectors

Default avatar.png ScifiSpirit: PainEXE: CodinGame puzzle? I'm pretty sure you are allowed to promote stuff on CodinGame.

Default avatar.png PainEXE: K

Default avatar.png PainEXE: https://www.codingame.com/contribute/view/11533e190b55b63be956c0a928a28afdbe6fe Can someone gimme some feedback on this?

MACKEYTH: Doesn't seem to be a way to create/pass array literals, either, which I do all them time in Java.

Default avatar.png ScifiSpirit: MACKEYTH: yeah, that's usually the solution. Arrays are just pointers in C++ just like in C, but if you use the array object, that is another story.

Default avatar.png ScifiSpirit: Same with literals, you can use objects instead, and then use initializer lists.

MACKEYTH: Doesn't seem like c++ is cool with triangular multidimensional arrays, either.

Default avatar.png ScifiSpirit: I guess the old stuff that C++ inherits from C is what surprises someone learning it.

Default avatar.png ScifiSpirit: Same thing with those, they are pointers, or multidimensional pointers.

Default avatar.png ScifiSpirit: In C++, you basically have 2 languages in one.

Default avatar.png ScifiSpirit: C and C++.

Default avatar.png ScifiSpirit: Although not the entirety of C.

MACKEYTH: Java's array functionality seems to be a lot more robust than c++

CoolandonRS: Is there any way to just get a blank project to test in? I want to make a challenge but need to make my solution, and would rather do it in codingame itself if possible

Default avatar.png ScifiSpirit: Yes, C and C++ stuff doesn't mesh together as nicely as it does in some other languages.

Default avatar.png ScifiSpirit: However, most of the time i haven't really had much problems.

Default avatar.png ScifiSpirit: It can be done, just requires some knowledge.

Default avatar.png ScifiSpirit: You can for example wrap the arrays (or pointers rather) in smart pointer objects.

Default avatar.png ScifiSpirit: When using dynamic memory though.

Default avatar.png Synergyforge: I'm not cut out for this. :( Guess I'll just go flip burgers.

Default avatar.png ScifiSpirit: It's not always easy.

Default avatar.png ScifiSpirit: But you don't really even need the raw arrays in C++ anymore i think.

Default avatar.png ScifiSpirit: Or often. Sometimes maybe.

Default avatar.png ScifiSpirit: Although if the native types is exactly what you like about C++, well, it comes with its own problems :D

MACKEYTH: Wait, yikes, c++ will let you just keep writing past the end of a pointer array? That seems really dangerous.

Westicles: PainEXE, there are bunches of clashes like this where eval solves it

Default avatar.png ScifiSpirit: MACKEYTH: yes, there is no memory protections in C++, it's like C.

Default avatar.png ScifiSpirit: It's right down there on the metal.

MACKEYTH: Oh, I can already sense that's going to bite me in the butt. I manage to produce array index out of bounds errors in Java all the time.

Default avatar.png ScifiSpirit: Heh. Yep, and what's worse, it doesn't tell you about those bugs. Silent crashes, or worse, no crashes.

Default avatar.png ScifiSpirit: And then long time of bug hunting :)

Default avatar.png ScifiSpirit: However, debugger helps a lot with that.

Default avatar.png ScifiSpirit: However, some container objects do also have bounds checked indexing functions.

MACKEYTH: Does it at least set off limits the memory the array is declared to use?

Default avatar.png ScifiSpirit: C++ is like this combination of really old and modern kind of programming, however, you get to choose which you use. Everything is possible there, you just have to constrain yourself according to your wishes.

Default avatar.png Synergyforge: Some of us don't have that kind of willpower. :D

Default avatar.png ScifiSpirit: MACKEYTH: What do you mean?

MACKEYTH: So if I create a pointer array like int myarr[10];, there will be 10 int-sized continguous blocks of memory that c++ won't allocate to any other variables?

Default avatar.png ScifiSpirit: MACKEYTH: yes, that's right.

MACKEYTH: Until myarr falls out of scope, presumeably.

Default avatar.png ScifiSpirit: Synergyforge: heh, perhaps, but there are many languages out there suitable for those persons as well i think :)

Default avatar.png ScifiSpirit: Yes, until it falls out of scope, then the memory is usable again. Everything in C++ is allocated on stack, except objects like vector and such use dynamic memory from the heap.

Default avatar.png ScifiSpirit: Well, that is not entirely true. A more accurate way to put it is that the vector object itself is allocated on the stack, but the storage that the object uses to store things inserted into it use dynamic memory.

MACKEYTH: Hm, does that mean you can create a vector that allocates space for pointer arrays? And instead of trying add arrays to the vecotr, you add pointers?

Default avatar.png ScifiSpirit: C++ also has manual memory management is you want to use it, but i would recommend not to, and you can put the vector object on the heap if you want to.

Default avatar.png ScifiSpirit: if you want to use that*

Default avatar.png ScifiSpirit: Yes, that is also possible.

Default avatar.png ScifiSpirit: And that's how it works for plain arrays.

Default avatar.png ScifiSpirit: However, if you use plain arrays, you will almost inevitably enter the manual memory management area.

Default avatar.png ScifiSpirit: Because if you want 100 arrays, you probably aren't going to declare each of those manually.

MACKEYTH: Cool to know, but now I'm so terrified of plain arrays that I never want to used them.

Default avatar.png ScifiSpirit: Not to mention the memory usage.

Default avatar.png ScifiSpirit: Heh.

Default avatar.png ScifiSpirit: Yeah, like, i do encourage you to learn everything, but also i encourage to keep the C and C++ sides somewhat separated.

Default avatar.png ScifiSpirit: I use a lot of primitives, there's nothing wrong with those, but i avoid plain arrays in C++ these days.

Default avatar.png ScifiSpirit: If i wanted to use only C-like stuff, than i would likely use C instead of C++.

Default avatar.png ScifiSpirit: The whole point of C++ is objects.

Default avatar.png ScifiSpirit: But int, float etc. play nice with everything.

Default avatar.png ScifiSpirit: You can't go wrong with any primitive, except pointers and arrays.

Default avatar.png ScifiSpirit: Although, there is one additional trap in C++ stuff.

Default avatar.png ScifiSpirit: Or maybe several actually :P

Default avatar.png ScifiSpirit: You should be aware that the modern iterators actually do use pointers underneath, and offer pretty much direct interface to the pointer.

MACKEYTH: That seems wise. You'd almost have to check your array indices for inboundness every time you access the array to avoid accidentally garbaging up your program in devilish to identify ways.

Default avatar.png Justin_Lowry: i cant remember how we get to the cert tests

Default avatar.png ScifiSpirit: So what that means, is that the same kind of pointer errors are possible with iterators, going out of bounds, accessing memory that is no longer there, etc.

Default avatar.png Justin_Lowry: how do u?

Default avatar.png Justin_Lowry: nvm figured it out

MACKEYTH: Justin_Lowry from your home page, IIRC

Default avatar.png ScifiSpirit: Another trap is using "new". You are probably quite accustomed to using that in Java?

MACKEYTH: Not 100% on what c++ iterators are yet

Default avatar.png ScifiSpirit: The latest and probably best advice in modern C++: "don't use new" :)

MACKEYTH: ScifiSpirit very much so

Default avatar.png ScifiSpirit: new is pretty much the last thing in C++ left, which can lead to memory leaks.

MACKEYTH: IDK new /was/ a keyword in c++

Default avatar.png ScifiSpirit: If you don't use "new" or "malloc", you pretty much can't have a memory leak, i think.

MACKEYTH: How do array objects compare with vectors?

Default avatar.png ScifiSpirit: And another advantage is that you now have a fully automatic memory management in a language that uses manual memory management. So not bad.

Default avatar.png ScifiSpirit: Array objects try to mimic the plain arrays, whereas Vectors are dynamically resizable.

Default avatar.png ScifiSpirit: So Array objects don't resize, just like plain arrays.

MACKEYTH: A little reading suggests that that the read/write performance of container arrays is about the same as pointer arrays

MACKEYTH: While being much more memory safe

Default avatar.png ScifiSpirit: Right, but there's the object overhead.

Default avatar.png ScifiSpirit: Memory safety probably depends on how it is used though :)

MACKEYTH: So they take up more space and take longer to create?

Default avatar.png ScifiSpirit: I'd assume so.

Default avatar.png ScifiSpirit: But probably not by much.

Default avatar.png ScifiSpirit: You can check the memory usage with the "sizeof" operator.

Default avatar.png ScifiSpirit: array<int ,10> a; cout << sizeof(a) << '\n';

MACKEYTH: Hm, using the []operator to read/write to/from a container array out of bounds seems to fail silently

Default avatar.png ScifiSpirit: Yes, use the bounds checked "at()" method instead for that.

Default avatar.png ScifiSpirit: I think that is most handy for debugging versions, but i would not use it in production code probably.

Default avatar.png ScifiSpirit: Or maybe i would, depends of course on the performance impact.

Default avatar.png ScifiSpirit: I've barely ever used it, because i have learned how to code safely even in C, so memory errors don't bite me all that often.

MACKEYTH: No, wait, just tested. It does the same thing as a pointer array?

Default avatar.png ScifiSpirit: Yes.

MACKEYTH: container arrays don't do bounds checking?

Default avatar.png ScifiSpirit: Normally they don't, unless you use "at()".

Default avatar.png ScifiSpirit: That's where the performance comes from in C++.

Default avatar.png ScifiSpirit: C++ doesn't do anything extra.

Default avatar.png ScifiSpirit: But the option for safety is there.

Default avatar.png ScifiSpirit: It's just not a toggle option for the compiler or anything.

MACKEYTH: Sigh, so I'm back to using pointer arrays with manual bounds checking.

MACKEYTH: At least container arrays will tell you how big they're /supposed/ to be

Default avatar.png ScifiSpirit: Usually you are probably going to use them in loops, and they require a condition anyway, so if you can make it trivial and obvious, that's enough for bounds checking usually.

Default avatar.png ScifiSpirit: Or if you use "for(int i : myvector)", compiler does it for you, and it's safe.

MACKEYTH: Ok, so at() is safe with container arrays, []operator is dangerous

Default avatar.png ScifiSpirit: Yep.

Default avatar.png ScifiSpirit: Use operator in tight loops which you can guarantee are going to be safe anyway.

Default avatar.png ScifiSpirit: Like the range-for (which is the "for(int i : myvector)" syntax.

MACKEYTH: And bonus, you can foreach over container arrays.

Default avatar.png ScifiSpirit: Yes.

Default avatar.png ScifiSpirit: Iterators also make it pretty easy to judge the safety of a for-loop.

Default avatar.png ScifiSpirit: So no "int myarray[20]; for(int i=0; i<20; i++){}" and then requiring changing both pieces of code when you make the array declaration smaller :D

Default avatar.png ScifiSpirit: Although C isn't quite that error prone either, in C you would likely use the "sizeof" operator to make it safer.

MACKEYTH: Are there any other common c++ pointer/memory pitfialls beginners should be aware of?

Default avatar.png ScifiSpirit: Iterators is probably one, you can go out of bounds with it just as easily.

MACKEYTH: I'm assuming the []operator is dangerous for all containers?

Default avatar.png ScifiSpirit: Yes.

Default avatar.png ScifiSpirit: Another pitfall is that since C++ doesn't have garbage collection, doing multiple dynamic allocations with "new" in the same function call can lead to memory leaks despite using "safe" smart pointers.

MACKEYTH: But not strings, apparently. :) Looks like oob indices wrap around instead of walking onto adjacent memory.

Default avatar.png ScifiSpirit: So that's why avoiding new basically also avoids memory leaks.

Default avatar.png ScifiSpirit: Really?

Default avatar.png ScifiSpirit: That's surprising. I'll try, i thought i saw them going OB also.

MACKEYTH: Looks like negative indices will walk out of strings, though.

Default avatar.png ScifiSpirit: Went out of bounds with positive indices for me at least.

Default avatar.png ScifiSpirit: With this code:

Default avatar.png ScifiSpirit: string s("mystring"); for(int i=0; i<20; i++){cout << s[i];}; cout << endl;

Default avatar.png ScifiSpirit: This however:

Default avatar.png ScifiSpirit: string s("mystring"); for(int i=0; i<20; i++){cout << s.at(i);}; cout << endl;

MACKEYTH: for me, string s="test string"; for(int i=0;i<20;i++) cerr<<s[i]; cerr<<endl; produced

MACKEYTH: test string test string test string test string test string test string test string test string test string test string test string test string test string test string test string test string test string test string test string test string

Default avatar.png ScifiSpirit: i get this:

Default avatar.png ScifiSpirit: mystringterminate called after throwing an instance of 'std::out_of_range'

 what():  basic_string::at: __n (which is 8) >= this->size() (which is 8)

Default avatar.png ScifiSpirit: Which is nice, i actually used to get silent exceptions before.

MACKEYTH: Which is way more than 20 chars. 😕

Default avatar.png ScifiSpirit: I'll try that.

MACKEYTH: And seems to produce " " for s[s.length()]

Default avatar.png ScifiSpirit: That's weird. For me it printed just one "test string" and then garbage.

Default avatar.png ScifiSpirit: Are you use you didn't have another loop or something there?

Default avatar.png ScifiSpirit: Seems like it printed the entire string rather than the letters.

MACKEYTH: Don't think so...

MACKEYTH: http://chat.codingame.com/pastebin/ed2174b7-caf2-46bf-939c-81dd3c7da9cc

Default avatar.png ScifiSpirit: Well, that's not the same code.

MACKEYTH: D'oh. I see it.

MACKEYTH: Fixing

MACKEYTH: Yeah, you're right. Yields trash starting with s[s.length()]

MACKEYTH: <facepalm>

MACKEYTH: The CG IDE gives excessively long compiler error messages. To the point that they get clipped. Any remedy for that?

Default avatar.png ScifiSpirit: If you ever find yourself needing to use dynamic memory directly, "make_shared" or "make_unique" helps a lot. That way, you don't need to use "new" directly, which guarantees there will not be any memory leaks.

Default avatar.png ScifiSpirit: Yeah, i've noticed the same thing with CG IDE. Unfortunately it's not their fault, C++ has really long compiler error messages especially when templates are involved.

MACKEYTH: I wasn't planning to learn dynamic memory use, just on principle.

Default avatar.png ScifiSpirit: Only remedy is to run them on your machine i guess, so you get the whole message.

Default avatar.png ScifiSpirit: Or perhaps run with less code, if the long error message is caused by multiple lines (as it usually is).

MACKEYTH: C++ error messages are noticeably worse than Java ones.

MACKEYTH: Longer and less legible.

Default avatar.png ScifiSpirit: Yeah, i believe that even without seeing Java error messages :D

Default avatar.png Synergyforge: Moral of the story: Don't use C++. :)

MACKEYTH: But ah craves tha speeeed!

Default avatar.png ScifiSpirit: :D

Westicles: that's why we need fortran, it is as fast as c++

MACKEYTH: Java chews up sooo much time doing garbage collection.

Default avatar.png ScifiSpirit: I've been quite happy with C++ actually :)

Default avatar.png ScifiSpirit: But yes, i have also shot myself in the foot in C++ (but who hasn't ;) )

Default avatar.png ScifiSpirit: You'll learn eventually ;) :D

MACKEYTH: Especially when creating lots of objects for a MCTS

Default avatar.png ScifiSpirit: But if we get easier and safer language with same speed, and same library support and same interoperability with C, i might switch.

Default avatar.png ScifiSpirit: But all of that is already too much to ask.

Default avatar.png ScifiSpirit: We will never get such language.

Westicles: rust?

Westicles: oh, no interop with c

Default avatar.png ScifiSpirit: I've done Rust already, it's even more complicated, though safer. But not quite as simple interoperability with C as C++ has i think.

MACKEYTH: I bounced off Rust the last time I messed with it. Less in common with Java.

Default avatar.png ScifiSpirit: I don't think any languages even attempt C interoperability anymore.

Default avatar.png ScifiSpirit: It's all about bindings these days.

MACKEYTH: And I've made next to no progress with Haskell. Thinking functionally is hard.

Default avatar.png ScifiSpirit: Yeah, same here, though not Haskell, but others.

Default avatar.png ScifiSpirit: I'm stuck with C++ ;)

MACKEYTH: Does CG have any third party c++ libraries?

jacek: :no_mouth:

Default avatar.png ScifiSpirit: https://www.codingame.com/playgrounds/40701/help-center/languages-versions

Westicles: no, but you can get to gmp if you are desperate

Default avatar.png ScifiSpirit: Libraries: ‑lm, ‑lpthread, ‑ldl, ‑lcrypt

MACKEYTH: No idea what those are, but it's nice they're there. :)

Default avatar.png ScifiSpirit: Linux standard libraries. Math, pthreads...

MACKEYTH: Also, thought CG didn't support multi-threading?

Default avatar.png ScifiSpirit: I guess not exactly what you meant by third party libraries.

Default avatar.png ScifiSpirit: I'm not sure if you can run on multiple cores.

Westicles: you can dig around the file system and see if what you need is there, and use it like this

Westicles: https://www.codingame.com/contribute/view/57289ec74b1437929376813753dcee321467

Default avatar.png ScifiSpirit: You can use multithreading, but it's another matter if they run parallel.

MACKEYTH: Ah, so we have full access to the disadvantages of multithreading, but none of the advantages? CG hard mode unlocked ;)

Default avatar.png ScifiSpirit: lol

Default avatar.png ScifiSpirit: I don't know, you may get 2 cores or something.

Default avatar.png ScifiSpirit: There is probably a way to tell somehow.

jacek: its 1-core, you can do multithreading but it will do no good

dannyward630: I just got 92% on python3 cert test

jacek: :tada:

MACKEYTH: 'Gratz!

dannyward630: I've been practicing for 3 yeaers

dannyward630: years, i mean

Westicles: since you were 9yo?

Default avatar.png Synergyforge: How much did you google tho? :D

FrancoRoura: Congrats

MACKEYTH: I passed the last test in the Java cert with a very ugly brute force solution

jacek: :rage:

MACKEYTH: Ok, assume you allocate an object with a named var declaration, then add pointers to that object to containers or higher scope vars. Does c++ still delete the object when the original declaration goes out of scope?

antiwonto: [auto] Hey MACKEYTH, here is a :taco: for loggin in today while it is quiet. You now have 4 tacos

ImAmCoder: this is kind of hard for me i'm new

MACKEYTH: Do you have any prior programming experience?

MACKEYTH: ImAmCoder the best place to start is the quest map on your home page. You can also work on Easy puzzles under Activities->Practice

MACKEYTH: Anything in particular you're having trouble with?

a-Rye: Just finished streaming the creation of my first playground: https://www.codingame.com/playgrounds/64843/beginner-python-concepts/hello-world

antiwonto: [auto] Hey a-Rye, here is a :taco: for loggin in today while it is quiet. You now have 1 tacos

a-Rye: Working on adding the "run" functionality, but this is a decent place to start for anyone interested in learning basic Python

Wontonimo: you can made the code blocks runnable. as of right now they are just text

a-Rye: That's what I'm trying to figure out now. Is it that Json part at https://tech.io/playgrounds/408/tech-io-documentation/coding-exercise ?

Default avatar.png lwyen: lancer

Default avatar.png Adamimoka: Hi :)

XXGojo_satoruXX: -.-

Wontonimo: idk a-Rye , i've never tried. just seen it done

a-Rye: I'll keep at it and make sure to stream it when I figure it out. So far, that last video should help others create their own playgrounds. It's such a cool tool and feature!

ASM_MOV_INT: is there no way to get a count of items in a list in python?

Mortis_666: list.count

ASM_MOV_INT: that gives an error

ASM_MOV_INT: ??

ASM_MOV_INT: <built-in method count of list object at 0x7f1da6d05840>

Westicles: lmgtfy ASM_MOV_INT length of list in python

antiwonto: [auto] hey ASM_MOV_INT let me google that for you https://letmegooglethat.com/?q=length+of+list+in+python

ASM_MOV_INT: i've already googled rofl

ASM_MOV_INT: it should work, correct? that's why I'm asking, maybe i'm missing something

ASM_MOV_INT: s = input().split(' ')

ASM_MOV_INT: s.count

ASM_MOV_INT: gives an error

Mortis_666: o u mean get the size of the list?

ASM_MOV_INT: yes, for example if it parses into 4 items in the list, i want 4

Mortis_666: if u want to get the size use len(list)

ASM_MOV_INT: oh len()? rofl

ASM_MOV_INT: omg ty

Mortis_666: yes

ASM_MOV_INT: I'm still a newb to python, and it's been a few weeks since codingame(ing)

ASM_MOV_INT: rofl

Default avatar.png ScifiSpirit: MACKEYTH: yes, C++ deletes objects that go out of scope that still have pointers pointing to them in scope. Basically, all built-in functionality in C++ follows behavior of C, and the automated functionality is built into the C++ portion of the standard library.

Default avatar.png ScifiSpirit: that's called a dangling pointer, often caused by returning a pointer to object allocated in a function

Default avatar.png ScifiSpirit: Lots of things have automated counterparts, for example for this case, there is shared_ptr and unique_ptr, former does reference counting

Default avatar.png ScifiSpirit: I'm going to sleep now, have fun :wave:

UZUHAMA: Helo world

BobLob: 250 OK?

BobLob: Not SMTP? I sleep too.

3ataja: any solution for back pain

3ataja: other than walking

Default avatar.png Makblackaa: winou habibi

Wontonimo: have it surgically removed. it's not needed.

Wontonimo: like tonsils

MACKEYTH: Yoga, tylenol... Salonpas pads work pretty well.

Wontonimo: stretch to touch your toes. works wonders for me

Wontonimo: slowly ... no jerking

Wontonimo: also weed helps, or so i hear

Wontonimo: i mean, if you are into getting new addictions

3ataja: @Wontonimo I prefer your first solution, other solutions require getting off my laptop

3ataja: @MACKYTH thanks, will actually try the other two

Wontonimo: huntdown taco

antiwonto: [auto] Cant find anyone with enough tacos

Wontonimo: figures

a-Rye: I figured it out Wontonimo, streaming the process now!

Wontonimo: you may want to try the .__name__ for type like so print(type(a).__name__)

Westicles: go tell it on the stream

Wontonimo: i don't have a twitch account

Wontonimo: nice stream btw

a-Rye: Thanks! And I'm still watching this chat as well, all good!

Wontonimo: print(multipy(a,b))

Default avatar.png Synergyforge: http://chat.codingame.com/pastebin/7324727d-5115-41ef-adb7-3c9fafe45ccf

antiwonto: [auto] Hey Synergyforge, here is a :taco: for loggin in today while it is quiet. You now have 1 tacos

Default avatar.png Synergyforge: Dangit. It converted to pastebin, but I was asking a question about Python conditionals.

Default avatar.png Synergyforge: oh and I typed it a bit wrong in the first line... Basically, can I check that two separate characters are present in a char string?

Default avatar.png Synergyforge: if var1 in chars and var2 in chars.... can I rewrite this to only mention chars once?

KerbalNo15: Not that I know of