thread for computer programming ppl

FAO anyone who uses Spring or Spring Boot, you’re gonna want to update to the latest version of Spring asap. There’s a poc going around with the potential to get as bad as log4shell, although currently only known to be exploitable on Java 9+ running in Tomcat

1 Like
2 Likes

What is that in and why does it work?

I think it’s Python. It “works” because the probability of choosing any given element of the array is the same as correctly choosing the user’s input.

3 Likes

Ah I see, it doesn’t give a value it’s picked, just gives you a result. Right

1 Like

Disappointed in myself for laughing at this.

5 Likes

I see it that essentially the chance of winning rock/paper/scissors is totally randomly, assuming you’re not cheating in some way. So to replicate a game in code you just read in the user input, pretend to take it into my account, and then randomly generate the result.

3 Likes

3 Likes

Also I still recall one of the first times I Googled Regex I found something along the lines of:

“If you try to solve a problem with Regex you’ll have two problems to solve.”

That said I’ve used it loads in Notepad++'s find and replace to help solve stuff in work. Just takes me 10 mins if refresher and trial and error first :joy:

1 Like

Yeah, it’s because I was thinking it was somehow actually playing and meant to be giving the user a result based on that, whoops!

1 Like

Yeah, luckily I don’t use it much. In fact the last time was possibly in IIS, when there was a helpful section to test input/outputs immediately.

1 Like

Just refactored out the unnecessary steps: the random selection of item and the logic to compare items. And replaced with random selection of result. Unless there was a requirement to see what your opponent chose it’s the same game.

IMO a good illustration of how TDD can often lead to simpler design and consequently lower cost of maintenance and change

2 Likes

I think the point is that there is no difference in outcome to the user whether the script is “choosing” rock, paper or scissors or just generating the random message of won, lost or draw (from which you can derive what they “chose”).

2 Likes

That is not the point

3 Likes

Having said what i said above, if i delivered that program without having asked whether the client wanted to know what the opponent had chosen, i would only have done half my job.

1 Like

Just to reiterate a third time for you and @the_ravens: I understand how it works and what it’s doing :grinning:

But

Yeah it actually is. What confused me was I assumed it was actually a full implementation of the game because otherwise its merely an illustration of odds which isn’t that amazing really.

1 Like

So, what you’re saying is that for you to consider it to be a full implementation of the game it should be displaying the opponent’s choice?

Why not also some logic to keep track of the player’s previous guesses and attempt to factor in that as a human they are unlikely to be truly random?

1 Like

should have mentioned this at requirements capture stage :wink:

2 Likes

Nah I think you are both still missing the point I’m afraid :slight_smile:

All it is saying is that when boiled down to it’s core, the computer is generating a random choice of 3. You can add as many layers on top of that to give the illusion of actually playing a game like you would face to face with a human, but ultimately the outcome is the same. The whole point is that it isn’t using the user input at all.

It’s not the most fascinating point in all fairness.

2 Likes

What would actually be cool is if you built it as some sort of machine learning thing which chose its response based on your previous choices, as there is some game theory around rock, paper, scissors believe it or not

2 Likes