twelve-of-code-official / challenges

All of the official challenges for Twelve of Code
GNU General Public License v3.0
0 stars 0 forks source link

Program March 2024, Challenge 2 #4

Open Mesure73L opened 8 months ago

Mesure73L commented 8 months ago

[!WARNING] Spoiler warning, we are talking about the specific challenges in this issue.

BeepBot99 commented 8 months ago

@Mesure73L I have an idea for this challenge about an API for statistics but you probably don't know the math so is that fine? It is about least square regression.

Mesure73L commented 8 months ago

We already had a plan for challenge 2

BeepBot99 commented 8 months ago

I know we did, and this follows that. It just uses math too. I will explain it step by step here, but first, you will need to have a basic understanding of what linear regression is.

Linear regression

If you are given a set of points (coordinates on a Cartesian plane, also known as ordered pairs), a linear regression line is the line of best fit through them. Least square regression is a method of finding a linear regression line such that the sum of the squares of the vertical distance from each point to the line is minimal. Linear regression can be used to predict linear patterns in a set of data. TL;DR: A linear regression line is a line of best fit for a set of points.

The challenge

All you will be given is the API, nothing else.

  1. When you call the API with an x coordinate, it returns a Y coordinate.
  2. You can do this as many times as you would like.
  3. Once you are done using the API, you will click a button.
  4. The button will send a message to the API to close off your access to the API. This will require each user to have a unique UUID.
  5. After you click the button, you will not be able to get Y coordinates from the API anymore.
  6. After you click the button, you will get your input.
  7. Your input will be an X coordinate.
  8. You will have to use linear regression to predict what the API would say. It must be accurate to 3 decimal places.
  9. If you did not get enough data from the API, you must change your seed and reset the challenge to continue.
  10. It will keep track of all your former seeds, so you can never go back to an old one.

Is that good?

BeepBot99 commented 8 months ago

Oh, and by the way, I know you don't think UUIDs are random enough without multiple, but I have evidence now. The chance of a specific person being hit by a meteorite in a given year is 1 in 17 billion. That is the same chance that if you generate 10 trillion UUIDs, two of them will be the same.

Mesure73L commented 8 months ago

Oh, and by the way, I know you don't think UUIDs are random enough without multiple, but I have evidence now. The chance of a specific person being hit by a meteorite in a given year is 1 in 17 billion. That is the same chance that if you generate 10 trillion UUIDs, two of them will be the same.

I do think they are random enough without multiple.

Mesure73L commented 8 months ago

All you will be given is the API, nothing else.

The challenge will still have to be explained.

Mesure73L commented 8 months ago
  • Once you are done using the API, you will click a button.

  • The button will send a message to the API to close off your access to the API. This will require each user to have a unique UUID.

  • After you click the button, you will not be able to get Y coordinates from the API anymore.

  • After you click the button, you will get your input.

  • If you did not get enough data from the API, you must change your seed and reset the challenge to continue.

  • It will keep track of all your former seeds, so you can never go back to an old one.

I do not think we should limit the access to the API.

Mesure73L commented 8 months ago

It's good other than that tho

BeepBot99 commented 8 months ago

All you will be given is the API, nothing else.

The challenge will still have to be explained.

Yeah ofc.

Mesure73L commented 8 months ago

I have this code to get the user's starting brand:

const startingBrand =
    finalBrandNames[
        Math.floor(smanRandom2024mar1.startingBrand * finalBrandNames.length)
    ];

It is returning undefined. How can I fix this?

Mesure73L commented 8 months ago

@BeepBot99

BeepBot99 commented 8 months ago

Please don't mention me in issues that I am subscribed to (every issue I have commented in). Please debug things on your own first. Don't ask me things like this that are simple. I believe that finalBrandNames doesn't exist in the global scope.

BeepBot99 commented 8 months ago

Also check that the index exists. Please don't ask for help with simple things like this. You're a person, you can do things.

Mesure73L commented 8 months ago

thanks for your positive help ig /s

Mesure73L commented 8 months ago

Can you send me the php code I need for sman and the logic for the answer checker? I am a bit stuck on what I need to do for it. Thanks!

BeepBot99 commented 8 months ago

The PHP code for sman is in https://github.com/twelve-of-code-official/website/issues/173. For the answer checker, you just need to run the same code that the user would run and the code that the API would run and check if you get the same answer. However, you should run the API's code in the JavaScript (client side) so that it doesn't have to wait for the API to respond.

BeepBot99 commented 8 months ago

If you are stuck, make the API. That is the most important part right now.

Mesure73L commented 8 months ago

This is my current plan (in order of what I'm planning on completing it in). Is this good, and is there anything missing? image

BeepBot99 commented 8 months ago

Ok, so that is mostly good, except I wouldn't hard code test seed. I would just make it 0 or something simple like that. Currently, 0 is not allowed as a seed, so you can't just enter 0 as your real seed.

Mesure73L commented 8 months ago

Ok, so that is mostly good, except I wouldn't hard code test seed. I would just make it 0 or something simple like that. Currently, 0 is not allowed as a seed, so you can't just enter 0 as your real seed.

We already discussed the seed and agreed on it being TEST_SEED.

BeepBot99 commented 8 months ago

No, I mean, instead of preprogramming every single possibility for test seed, just when the API gets sent it, it acts as if it were 0.

Mesure73L commented 8 months ago

It's not that many, i'll just hard code it.

BeepBot99 commented 8 months ago

No, please don't.

BeepBot99 commented 8 months ago

What do you mean it's not that many, it's 129.

Mesure73L commented 8 months ago

Do you even know what TEST_SEED is?

Mesure73L commented 8 months ago

Because it's a lot less than 129.

BeepBot99 commented 8 months ago

Yeah it will be like 5 right? Like an example? But still don't hardcode it just take a random subset please.

Mesure73L commented 8 months ago

No, TEST_SEED is made for you to use in any challenge where you need to input your seed so that you can use the example in your program. The example is the same for every person. TEST_SEED is for the very simple example that was given on the challenge for testing purposes. If TEST_SEED is not hardcoded, it will have to always give the same response as what was given in the challenge example. Final decision.

Mesure73L commented 8 months ago

I literally put that in the challenge HTML for that reason.

Mesure73L commented 8 months ago

oops didnt mean to do that

BeepBot99 commented 8 months ago

No, TEST_SEED is made for you to use in any challenge where you need to input your seed so that you can use the example in your program. The example is the same for every person. TEST_SEED is for the very simple example that was given on the challenge for testing purposes. If TEST_SEED is not hardcoded, it will have to always give the same response as what was given in the challenge example. Final decision.

Yeah, any seed always gives the same response 🤯.

BeepBot99 commented 8 months ago

I'm saying if TEST_SEED is entered as the seed in the API, then it should just act as if it were the seed 0 but with a limited dataset.

BeepBot99 commented 8 months ago

I'm not letting you hardcode every single possibility.

Mesure73L commented 8 months ago

If you want to do that for your challenges, go ahead. But for my challenges, I'm doing it this way because it's easier for me. You haven't listed any downsides yet. Plus I already did and it doesn't make the code worse at all.

Mesure73L commented 8 months ago

Yeah, any seed always gives the same response 🤯.

No, I mean the same response as is already on the challenge HTML.

Mesure73L commented 8 months ago

🤯

BeepBot99 commented 8 months ago

Ok so clearly you don't know what like the whole point of a RESTful API is.

Mesure73L commented 8 months ago

You can use whatever code you want in your challenge as long as it works as expected. Unlike you, I don't care about how the code was written, as long as it works correctly.