Skip to content

usrme/protohackers

Repository files navigation

protohackers

Protohackers server programming challenge answers.

Deployment

  • install 'flyctl';
  • authenticate;
  • navigate to the root of the repository;
  • allocate dedicated IPv4 address (costs $2/mo): flyctl ips allocate-v4 --app <app name>;
    • without this it is not possible to connect over just TCP, even if an IPv6 address is allocated;
    • here's a blog post over at Tigris that gives away $50 in credits;
    • more information about this requirement here and here;
  • deploy: flyctl deploy --dockerfile Dockerfile.<problem name> --ha=false;
    • see problem names under cmd/ directory and here;
  • find out currently allocated IP: flyctl ips list.

Important

Any uncommitted changes will also be deployed.

Testing

Locally

  • move to problem directory: pushd cmd/<problem name>/

  • run tests:

    go test -v
    === RUN   TestProblem
    --- PASS: TestProblem (0.00s)
    PASS
    ok      github.com/usrme/protohackers/cmd/<problem name>    3.138s
  • move back to the root of the repository: popd;

  • build image: docker build --tag <problem name> -f Dockerfile.<problem name> .;

  • run container: docker run -p 5000:5000 <problem name>;

  • pass command:

    $ echo "hello world" | nc -w1 localhost 5000
    hello world

Remotely

  • deploy;

  • pass command:

    $ echo "hello world" | nc -w1 <app name>.fly.dev 5000
    hello world

Note

For testing in the Protohackers page, use the IP from flyctl ips list and pass the port 5000

About

Protohackers server programming challenge answers

Topics

Resources

License

Stars

Watchers

Forks

Languages