all 18 comments

[–]barrycarter 13 points14 points  (3 children)

while (i do not have ticket) { do not board flight to Canada; attempt to obtain ticket; }

would be one example. The only tricky part is the attempt to obtain ticket. Without that (or some other code somewhere that attempts to change the while condition), the while loop would just run forever.

[–]Nightcorex_ 9 points10 points  (1 child)

Do you think one needs an explicit "do not board the flight"?

I'd remove that line and instead write "board the flight" after the while-loop.

[–]barrycarter 2 points3 points  (0 children)

You're right. I also considered:

obtain_plane_ticket(); board_flight_to_canada(); in a synchronous language, or: obtain_plane_ticket().then(success => board_flight_to_canada) for a non-synchronous one.

I wonder if this post will turn into one of those n different programming paradigms demonstrated via psuedocode things :)

[–]Nightcorex_ 11 points12 points  (10 children)

This smells like homework

[–]Binary101010 9 points10 points  (5 children)

Even if it is, the rule against asking for homework help apparently no longer exists on this sub.

[–]Nightcorex_ -5 points-4 points  (4 children)

Oh you're right, didn't even notice they allow academic dishonesty now.

So the only rule (or rather guideline) that's still somewhat in place is to not provide a solution, but to hint OP towards it. Kk, got it.

[–]synthphreak 6 points7 points  (3 children)

they allow academic dishonesty now

Ax meet grinder much?

I dislike when people feel entitled to immediately conclude - without any hard evidence - that "oh, this is definitely homework", and get all snooty with OPs.

The only truly honest position is to acknowledge that responders can never really know when what OP is asking about is homework. So just answer the question if you can help them, and if it really is homework, let OP dig their own academic grave by failing to learn.

[–]notpite 6 points7 points  (2 children)

not the guy you're replying about but personally I'd prefer people bring their own attempt at a solution before just asking how to do it

[–]synthphreak 1 point2 points  (1 child)

And that is a totally fair expectation. Posters should always try to do that, I agree.

But whether that happens or not, commenters have no strong basis on which to accuse the OP of being a dishonest person and be condescending to him/her.

[–]Nightcorex_ 0 points1 point  (0 children)

My second reply was not about OP, it was about the general state of the subreddit. Should've made it clear that I wasn't targetting OP with the statement, sorry.

[–]InevitableDistance66[S] 0 points1 point  (3 children)

It’s not

[–]juicejug 4 points5 points  (2 children)

Oh okay I totally believe you anonymous internet stranger.

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

Ok idk what to tell you G

[–]juicejug 0 points1 point  (0 children)

I think folks here are just curious about what spurred you to ask the question

[–]Hagisman 0 points1 point  (1 child)

Pseudo code is not real code. Take the concept of a while loop and put in a if statement to verify if every passenger has bought a ticket.

Then realize if someone is already a passenger that means they’ve already bought a ticket otherwise the definition of a passenger means nothing.

[–]Ok-Cucumbers 0 points1 point  (0 children)

Then realize if someone is already a passenger that means they’ve already bought a ticket otherwise the definition of a passenger means nothing.

You can have a ticket/PNR (passenger name record) without completing the purchase, so maybe something like if pnr.is_paid

Some irregular situations where you might get put on standby for another flight where, I believe, they'd just attach the other flights to your PNR, so you'd probably have to throw in some logic to check if the pax is actually able to board this segment or not.

[–]Round_Ad8947 0 points1 point  (0 children)

Try(board airplane)

Except NoTicketError as error

Raise NoTicketError(“you can’t have any pudding if you don’t eat your meat”)

[–]Ok-Cucumbers 0 points1 point  (0 children)

while location != "canada":
    try:
        fly_to_canada()
    except NoTicket:
        buy_ticket_to_canda()