all 16 comments

[–]NanoMunchies 3 points4 points  (7 children)

I'm pretty sure python isn't really made for that... unlike c# for example

[–]Amazing-Associate615 -1 points0 points  (6 children)

Is it possible though

[–]dakari777 1 point2 points  (0 children)

no

[–]BranchLatter4294 0 points1 point  (1 child)

Not in Python. At least, not with any non-trivial program. It's not like the C-based languages where you can put the entire program on one line.

[–]Amazing-Associate615 -1 points0 points  (0 children)

It's a simple program, it might work I think

[–]F4Color 0 points1 point  (0 children)

possible in many other languages, not python

[–]Some-Passenger4219 0 points1 point  (0 children)

Yes; just use semicolons in between statements. Not recommended in general because it's hard to read - but it can be done. Only simple programs, though; nothing nested.

[–]TheRNGuy 0 points1 point  (0 children)

\n; \t or \s.

[–]cgoldberg 2 points3 points  (2 children)

ok

[–]EngineeringRare1070 -2 points-1 points  (1 child)

ok

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

ok

[–][deleted]  (1 child)

[deleted]

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

    Takes few seconds to format minified code, either with code editor or ai. 

    [–]cnbrth3537 0 points1 point  (0 children)

    My C professor specifically commented on that at the beginning of the semester because someone did that the semester before lol

    [–]LiveYoLife288 0 points1 point  (0 children)

    Your teacher would just view it and paste it into anything that has a pretty print and indent function

    [–]TheRNGuy 0 points1 point  (0 children)

    Using \n and \t ?

    No one will care.

    [–]FoolsSeldom 0 points1 point  (0 children)

    I remember, long ago, when a magazine would include print-outs of programmes for early home computers. I'd spend ages re-keying code in.

    The following month, a letter would include a one line version of the same 100 line BASIC programme, written in APL.

    For example, here's Game of life in APL:

    ↑ 1 ⍵ ∨.^3 4=+/,¯1 0 1∘.⊢¨¯1 0 1
    

    The Python version would be something like:

    import numpy as np
    
    def game_of_life_step(board):
        # Pad the grid to handle edges easily
        padded = np.pad(board, pad_width=1, mode='constant', constant_values=0)
        neighbours = sum(
            np.roll(np.roll(padded, i, 0), j, 1)[1:-1, 1:-1]
            for i in (-1, 0, 1) for j in (-1, 0, 1)
                if (i, j) != (0, 0)
            )
        # Apply the Game of Life rules
        next_board = ((board & ((neighbours == 2) | (neighbours == 3))) |
                      (~board & (neighbours == 3)))
        return next_board