728 x 90 Ad
The vision of the sudoku api challenge is to have a place for sudoku solvers (programmers with their programs) come and compete. I will provide ten puzzles a day, available at say 12:05 AM. Nine of the puzzles will be the same across the board, and the tenth will be random. This is to help keep the playing field level (how come HE always gets the easy puzzles!?), and fair. Stats will be forthcoming, as will a way to have something besides your email address appear. You are actually welcome to use a phony email address for the contest.

To participate in the sudoku api challenge, you just have to go through the following simple steps:
  1. Register for an apichallenge.com account using a link as below. You will need to swap in your own values. You will have to register just once

  2. http://apichallenge.com/api/spack/register?email=$email&password=$password&password_verify=$password&iagree=iagree[&outserial=dumb|json|storable|xml|yaml]

    You can specify any of the above outserials, and just need to parse accordingly. All the links below accept the optional outserial. For default, json, the registration response looks something like

    {"status":"ok","data":{"auth":"442bde2ce2a6af1348b9f10613d4e676b23e5216bdda7ed92300ada0936954b603fb35b66114bcef8073abda4380495d1c6357ef61ef0a7b03adc19fdb5213c2","user_id":137}}

    Which deserializes to
    $ref = {
        data => {
            auth => '442bde2ce2a6af1348b9f10613d4e676b23e5216bdda7ed92300ada0936954b603fb35b66114bcef8073abda4380495d1c6357ef61ef0a7b03adc19fdb5213c2',
            user_id => 137
        },
        status => 'ok'
    };
    
    I have recently been playing with C, which isn't quite as parse friendly as say perl. Consequently I made the dumb outserial, which looks like

    auth=e08da9298a9c232b5e03097d5e55cb29d923ac9ba58c1bf9964028c7501b4af24d5b1e9b79d67e34a4d92acf72d2c7599b0c657c10de11f147c6da7b9723d6c40770cf6f535621def463e5399bb83ba7;
    
    Or more generally,

    $key=$value;
    
    where the ; is there for each key/value pair, including the last one. I hope to shortly make my C code available, at least the dumb parser, and my libcurl tie ins.

  3. Login.

  4. http://apichallenge.com/api/spack/login?email=$email&password=$password

    For json, the login response should look like

    {"status":"ok","data":{"auth":"442bde2ce2a6af1348b9f10613d4e6767a4e79941e78d61c15797916c482f212093ea0fe67cac0808e1fb83fcac5b9f16f9de932bdb3e5150edf0857fd667efb"}}

    Which deserializes to
    $ref = {
        data => {
            auth => '442bde2ce2a6af1348b9f10613d4e6767a4e79941e78d61c15797916c482f212093ea0fe67cac0808e1fb83fcac5b9f16f9de932bdb3e5150edf0857fd667efb'
        },
        status => 'ok'
    };
    
    For the record, the auth expires, so you will need to regenerate it at least daily.

  5. You will repeat the next two steps, ten times per day. Using the auth, request a puzzle.

  6. http://apichallenge.com/api/sudokuapi/gen?auth=$auth

    For json, the puzzle should look like

    {"status":"ok","data":{"puzzle_id":1,"number":1,"start_time":1165991800.8489,"puzzle":"..9.8.......25.1..8....3.6....3..4.9.21......9.......3.3549.........79.1...13...6"}}
    which deserializes to
    $ref = {
        data => {
            number     => 1,
            puzzle     => '..9.8.......25.1..8....3.6....3..4.9.21......9.......3.3549.........79.1...13...6',
            puzzle_id  => 1,
            start_time => '1165991800.8489'
        },
        status => 'ok'
    };
    
  7. Grab the puzzle_id and the puzzle, solve the puzzle and post it back.

  8. http://apichallenge.com/api/sudokuapi/submit?auth=$auth&puzzle_id=$puzzle_id&answer=$answer[&reported_elapsed=$reported_elapsed]

    Which the first time, gave me a response of

    {"status":"ok","data":{"elapsed_time":81.631720000000}}

    Which deserializes to
    $ref = {
        data => {
            elapsed_time => '81.631720000000'
        },
        status => 'ok'
    };
    
    The reported_elapsed is optional. I will use it as a latency check. You should start your timings as soon as you get the puzzle response back (yes, before you parse it), and just before you submit your answer.

    It is looking like the network overhead is likely, say thirty times more than the time to solve the puzzle. To help test your latency, I added a ping method. You would authenticate as above, then start the ping

    http://apichallenge.com/api/sudokuapi/ping?auth=$auth

    Which just gave me a response of

    {"status":"ok","data":{"ping_id":18,"start_time":1195111557.33704,"user_id":25},"elapsed":0.022838830947876}

    Which deserializes to
    $ref = {
        data => {
            ping_id => 18,
        },
        elapsed => 0.022838830947876,
        status => ok,
    };
    
    Just grab the ping_id, and hit back with

    http://apichallenge.com/api/sudokuapi/ping?auth=$auth&ping_id=$ping_id

    Which just gave me a response of

    {"status":"ok","data":{"user_id":25,"elapsed":235.473090000000},"elapsed":0.00563883781433105}

    Which shows that I had a ping time of 235 seconds. Guess that shows how fast I can type :)

    You may only submit one answer per puzzle. On the second submit you'd get something like

    {"status":"error","error":"already submitted an answer (1)"}

    $ref = {
        error => 'already submitted an answer (1)',
        status => 'error'
    };
    
    The (1) means I got the puzzle right :)

    Puzzles are cron'd to be created nightly at midnight mountain time.
    Standings for the current day are here
Questions or comments? Please email me.

a spackshop production
sudoku solver
Sudoku Sudoku Web-Ring Community
Forum
« Previous - Next » -Join-