Skip to content

Instantly share code, notes, and snippets.

@SansPapyrus683
Last active August 1, 2023 10:54
Show Gist options
  • Save SansPapyrus683/a86692b06eef09fb000c7098db9fd111 to your computer and use it in GitHub Desktop.
Save SansPapyrus683/a86692b06eef09fb000c7098db9fd111 to your computer and use it in GitHub Desktop.
code conventions to satisfy dustin

general code stuff

  • comments
    • inline comments should be two spaces after the line of code
    • if a single comment takes over two lines, use a multiline comment
  • sols should have nearly the same structure, same names, etc. to avoid confusion
  • avoid global variables
  • for the brace languages, always use braces & space em out like: for (int i = 0; i < 2; i++) {
    • an if-else should be like this:
      if (x == 1)  {
          System.out.println("bruh");
      } else {
          System.out.println("ok");
      }
  • other stuff in the usaco guide (spaces between ops, tabs, etc.)
  • use actually good variable names

c++

  • naming
    • variables and functions in snake_case
    • class & struct names in PascalCase
  • preferably, use ifstream & ofstream over freopen
  • NO MACROS

java

  • naming
    • variables & functions in camelCase
    • class & struct names in PascalCase, same as c++
  • for usaco problems, class name should be same as the input file name (irrelevant for ones that use stdin)
  • use Kattio or BufferedReader

python

  • naming same as c++
  • when printing only a single line, use print with the file argument
  • use with instead of setting sys.stdin and sys.stdout
@envyaims
Copy link

cursed

@SansPapyrus683
Copy link
Author

blocked

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment