- Write a program that counts down from 10 (and can either end at 0|1) -- your choice
- Prints one number per line
- Can optionally accept a command-line argument
- No looping constructs are allowed, such a
for
andwhile
- Make it as short as possible, but still readable
- Please reply with your own solutions, include the programming language
-
- Include instructions on how to compile && run
Last active
April 21, 2023 02:47
-
-
Save jftuga/2a21954af56af19f89b0c627384b53da to your computer and use it in GitHub Desktop.
Code Golf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> // compile & run: gcc -Wall countdown.c -o countdown && ./countdown | |
int n = 10; int main(int argc, char *argv[]) { printf("%d\n", n) && --n && main(n, NULL); } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys # run: python3 countdown.py 10 | |
def main(n:int): sys.stdout.write(f"{n}\n") and n-1 and main(n-1) | |
main(int(sys.argv[1])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# run ./countdown.sh 10 | |
echo $1 && (($1-1)) && $0 $(($1-1)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment