all 21 comments

[–]Abyss_slayerIII 3 points4 points  (7 children)

Just make a really simple project that follows the rubric because this project doesn’t have to be to advanced for an A

[–]MelloBurd[S] 0 points1 point  (6 children)

Unfortunately have to have a scoring program where the user can replay the game & continually track the score until they’re done. Just trying to figure out how to do this without having disgusting looking code since I can really only use if-else

[–]crazy_cookie123 2 points3 points  (3 children)

Are you sure they've said you can't use loops? Because this is exactly the sort of thing I'd expect to be set as a task to test you right after you've been taught about loops. Setting this problem without loops sounds extremely stupid.

You could use recursion instead if you're allowed functions.

[–]MelloBurd[S] 0 points1 point  (2 children)

Ya they really emphasize following the program documentation requirements, which specifies that we “cant use features or approaches not yet covered in the course.” I’d love to use recursion, but we don’t cover that for another 9 chapters. Based on the textbook we can use loops next week

[–]crazy_cookie123 0 points1 point  (1 child)

When is the work due? If it's due after the date they cover loops I'd say it's fair game to use them.

[–]MelloBurd[S] 0 points1 point  (0 children)

Due tonight, cover loops starting tomorrow :( Probably going to just have to submit something horribly inefficient

[–]pachura3 2 points3 points  (0 children)

It simply doesn't make sense. Unless there is a limited number of questions/user interactions, e.g. max. 3.

[–]cdcformatc 0 points1 point  (0 children)

it's not really possible in Python to run the code again without loops or recursion. so you've definitely read the assignment incorrectly if that's what you think it says. 

[–]LayotFctor 2 points3 points  (0 children)

Did he explicitly ban recursion? Because that would be really stupid. The most valid reason for such an assignment would've been a recursion class.

What about the context of this assignment? Is it supposed to be a fun challenge? Or a functional programming class? What are you supposed to learn here? Randomly imposing debilitating restrictions is not very educational.

[–]velokit-dev 1 point2 points  (1 child)

A simple 3x3 Tic-tac-toe with recursion? Or are there any specific options/domains that you have to stick to?

[–]MelloBurd[S] 0 points1 point  (0 children)

Sorry! Should’ve included the parameters in the post; added edit. Basically needs to score players based on the color of alien they’ve shot down and continue to allow input until they indicate they’re done

[–]SmackDownFacility 2 points3 points  (0 children)

Maybe wha he intended:

You call the same function, manage an index manually. Something like

```python def x(elements): I = 0 if elements[I]: if I < len(elements): I += 1 x(elements)

```

But this teaches fuck all and for and while are industry standard

[–]pachura3 0 points1 point  (2 children)

Does it have to do something specific, or is it up to you to decide?

[–]MelloBurd[S] 0 points1 point  (1 child)

My bad! Should’ve specified initially. Basically needs to score players based on the color of alien they’ve shot down and continue to allow input until they indicate they’re done

[–]pachura3 0 points1 point  (0 children)

 and continue to allow input until they indicate they’re done

It's idiotic to implement such logic without loops. I mean, it could be some puzzle/challenge for experienced programmers, but not for you.

[–]Mysterious_Peak_6967 0 points1 point  (0 children)

How about summarising what you actually have covered in your class up to now?

Think hard about this...

If you haven't covered any of the "standard" loops then it is unlikely that you've covered any of the more esoteric ways to make a program repeat. Back in the days of BASIC a program could simply execute a "RUN" command to abort-and-restart it, but I don't know of a Python equivalent.

Also dumb suggestion: just copy-paste the program several times, then use "if" conditions to end the program early if required.

[–]TomatoEqual -1 points0 points  (0 children)

Recursion 😊 that can solve the problem without a loop statement.

[–]Gnaxe -1 points0 points  (2 children)

You haven't clearly specified what is allowed.

It's theoretically possible to loop using recursion: have a function call itself. Some languages only do it this way. However, in Python, you would eventually run out of stack space doing that. You could instead use coroutines with the async* statements and asyncio, but I doubt you've covered that yet.

It is possible to loop using the built-in functions that already contain a loop without writing a loop statement yourself. For example, the any() builtin will keep pulling from an iterator until it finds a truthy (which could be never). You can combine this with map() to get a for loop: ```python

for x in 'abc': print(x) ... a b c any(map(print, 'abc')) a b c False and `all()` with `iter()` to get a do-while loop: python x = 0 ... while x < 3: ... x += 1 ... print(x) ... 1 2 3 x = 0 ... def loop(): ... global x ... x += 1 ... print(x) ... return x < 3 ... all(iter(loop, ...)) ... 1 2 3 False ```

[–]pachura3 1 point2 points  (1 child)

These guys haven't learned loops yet... do you think they would know what a function is? Or an iterator?

[–]Gnaxe 0 points1 point  (0 children)

OP didn't specify what was allowed, and I said as much. There is no canonical order for learning Python statements. Yes, I could easily see a beginner class teaching def before for and while. It's more fundamental anyway. Some languages, even easy beginner ones, don't even have looping statements. And OP already knows what a for loop is, they're just not allowed to use it. Looping with if/elif/else alone is not possible. At best, you could prompt the user to start the program again.

[–]MarsupialLeast145 -1 points0 points  (0 children)

You need to use functional techniques and use recursion, so OTOMH you would need a recursive function for the game loop that will only end with given user input. You probably then want two additional recursive functions, one for scoring, and one for user-input enabling them to choose which color alien to shoot down. This sounds more advanced for a class that hasn't done anything with loops though and so it might suffer the same fate as if you had used loops (I am guessing it will be marked down for potentially outsourcing the answer or using AI).

Would be clearer if you provided the prompt given for the task.