Selaa lähdekoodia

First attempt to parse content from codeforces

* Test to use request
* Test to parse
* Add content to README
Marcelo Fornet 6 vuotta sitten
vanhempi
commit
65a291d20e
10 muutettua tiedostoa jossa 2122 lisäystä ja 56 poistoa
  1. 9 2
      README.md
  2. 203 40
      package-lock.json
  3. 3 0
      package.json
  4. 2 10
      src/conn.ts
  5. 0 2
      src/core.ts
  6. 7 0
      src/extension.ts
  7. 1 1
      src/gwen.ts
  8. 85 0
      src/parsers/codeforces.ts
  9. 1757 0
      src/test/codeforces.html
  10. 55 1
      src/test/extension.test.ts

+ 9 - 2
README.md

@@ -1,9 +1,16 @@
-# acmhelper-vscode README
+# ACM HELPER - README
 
-This is the README for your extension "acmhelper-vscode". After writing up a brief description, we recommend including the following sections.
+**ACMHelper** is tool that allow users to solve problems from several online judges easily. This extension contains awesome features powered with Machine Learning.
 
 ## Features
 
+* Contest/Problem parsing
+* Running solution against testcases automatically
+* Add custom testcases easily
+* Smart veredict reporting (OK, WA, RTE, TLE, CE)
+* Stressing solution against brute using a generator (Useful to find corner cases)
+* Automatic generator creation from inputs/outputs structure
+
 Describe specific features of your extension including screenshots of your extension in action. Image paths are relative to this README file.
 
 For example if there is an image subfolder under your extension project workspace:

+ 203 - 40
package-lock.json

@@ -4,6 +4,22 @@
     "lockfileVersion": 1,
     "requires": true,
     "dependencies": {
+        "@types/concat-stream": {
+            "version": "1.6.0",
+            "resolved": "http://registry.npmjs.org/@types/concat-stream/-/concat-stream-1.6.0.tgz",
+            "integrity": "sha1-OU2+C7X+5Gs42JZzXoto7yOQ0A0=",
+            "requires": {
+                "@types/node": "*"
+            }
+        },
+        "@types/form-data": {
+            "version": "0.0.33",
+            "resolved": "http://registry.npmjs.org/@types/form-data/-/form-data-0.0.33.tgz",
+            "integrity": "sha1-yayFsqX9GENbjIXZ7LUObWyJP/g=",
+            "requires": {
+                "@types/node": "*"
+            }
+        },
         "@types/mocha": {
             "version": "2.2.48",
             "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-2.2.48.tgz",
@@ -13,8 +29,12 @@
         "@types/node": {
             "version": "8.10.39",
             "resolved": "https://registry.npmjs.org/@types/node/-/node-8.10.39.tgz",
-            "integrity": "sha512-rE7fktr02J8ybFf6eysife+WF+L4sAHWzw09DgdCebEu+qDwMvv4zl6Bc+825ttGZP73kCKxa3dhJOoGJ8+5mA==",
-            "dev": true
+            "integrity": "sha512-rE7fktr02J8ybFf6eysife+WF+L4sAHWzw09DgdCebEu+qDwMvv4zl6Bc+825ttGZP73kCKxa3dhJOoGJ8+5mA=="
+        },
+        "@types/qs": {
+            "version": "6.5.1",
+            "resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.5.1.tgz",
+            "integrity": "sha512-mNhVdZHdtKHMMxbqzNK3RzkBcN1cux3AvuCYGTvjEIQT2uheH3eCAyYsbMbh2Bq8nXkeOWs1kyDiF7geWRFQ4Q=="
         },
         "ajv": {
             "version": "6.6.2",
@@ -137,6 +157,11 @@
             "integrity": "sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0=",
             "dev": true
         },
+        "asap": {
+            "version": "2.0.6",
+            "resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz",
+            "integrity": "sha1-5QNHYR1+aQlDIIu9r+vLwvuGbUY="
+        },
         "asn1": {
             "version": "0.2.4",
             "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.4.tgz",
@@ -155,8 +180,7 @@
         "asynckit": {
             "version": "0.4.0",
             "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
-            "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=",
-            "dev": true
+            "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k="
         },
         "aws-sign2": {
             "version": "0.7.0",
@@ -170,6 +194,15 @@
             "integrity": "sha512-ReZxvNHIOv88FlT7rxcXIIC0fPt4KZqZbOlivyWtXLt8ESx84zd3kMC6iK5jVeS2qt+g7ftS7ye4fi06X5rtRQ==",
             "dev": true
         },
+        "axios": {
+            "version": "0.18.0",
+            "resolved": "http://registry.npmjs.org/axios/-/axios-0.18.0.tgz",
+            "integrity": "sha1-MtU+SFHv3AoRmTts0AB4nXDAUQI=",
+            "requires": {
+                "follow-redirects": "^1.3.0",
+                "is-buffer": "^1.1.5"
+            }
+        },
         "babel-code-frame": {
             "version": "6.26.0",
             "resolved": "https://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.26.0.tgz",
@@ -211,6 +244,14 @@
                 "tweetnacl": "^0.14.3"
             }
         },
+        "biskviit": {
+            "version": "1.0.1",
+            "resolved": "https://registry.npmjs.org/biskviit/-/biskviit-1.0.1.tgz",
+            "integrity": "sha1-A3oM1LcbnjMf2QoRIt4X3EnkIKc=",
+            "requires": {
+                "psl": "^1.1.7"
+            }
+        },
         "block-stream": {
             "version": "0.0.9",
             "resolved": "https://registry.npmjs.org/block-stream/-/block-stream-0.0.9.tgz",
@@ -251,8 +292,7 @@
         "buffer-from": {
             "version": "1.1.1",
             "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz",
-            "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==",
-            "dev": true
+            "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A=="
         },
         "builtin-modules": {
             "version": "1.1.1",
@@ -263,8 +303,7 @@
         "caseless": {
             "version": "0.12.0",
             "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz",
-            "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=",
-            "dev": true
+            "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw="
         },
         "chalk": {
             "version": "2.4.1",
@@ -345,7 +384,6 @@
             "version": "1.0.7",
             "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.7.tgz",
             "integrity": "sha512-brWl9y6vOB1xYPZcpZde3N9zDByXTosAeMDo4p1wzo6UMOX4vumB+TP1RZ76sfE6Md68Q0NJSrE/gbezd4Ul+w==",
-            "dev": true,
             "requires": {
                 "delayed-stream": "~1.0.0"
             }
@@ -362,6 +400,17 @@
             "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=",
             "dev": true
         },
+        "concat-stream": {
+            "version": "1.6.2",
+            "resolved": "http://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz",
+            "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==",
+            "requires": {
+                "buffer-from": "^1.0.0",
+                "inherits": "^2.0.3",
+                "readable-stream": "^2.2.2",
+                "typedarray": "^0.0.6"
+            }
+        },
         "convert-source-map": {
             "version": "1.6.0",
             "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.6.0.tgz",
@@ -374,8 +423,7 @@
         "core-util-is": {
             "version": "1.0.2",
             "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz",
-            "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=",
-            "dev": true
+            "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac="
         },
         "dashdash": {
             "version": "1.14.1",
@@ -390,7 +438,6 @@
             "version": "3.1.0",
             "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz",
             "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==",
-            "dev": true,
             "requires": {
                 "ms": "2.0.0"
             }
@@ -416,8 +463,7 @@
         "delayed-stream": {
             "version": "1.0.0",
             "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
-            "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=",
-            "dev": true
+            "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk="
         },
         "diff": {
             "version": "3.5.0",
@@ -425,6 +471,11 @@
             "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==",
             "dev": true
         },
+        "dom-parser": {
+            "version": "0.1.5",
+            "resolved": "https://registry.npmjs.org/dom-parser/-/dom-parser-0.1.5.tgz",
+            "integrity": "sha1-pPYBn5oxW3XXQoqqfMv1vYWeFvs="
+        },
         "duplexer": {
             "version": "0.1.1",
             "resolved": "http://registry.npmjs.org/duplexer/-/duplexer-0.1.1.tgz",
@@ -453,6 +504,14 @@
                 "safer-buffer": "^2.1.0"
             }
         },
+        "encoding": {
+            "version": "0.1.12",
+            "resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.12.tgz",
+            "integrity": "sha1-U4tm8+5izRq1HsMjgp0flIDHS+s=",
+            "requires": {
+                "iconv-lite": "~0.4.13"
+            }
+        },
         "end-of-stream": {
             "version": "1.4.1",
             "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.1.tgz",
@@ -537,6 +596,15 @@
                 "pend": "~1.2.0"
             }
         },
+        "fetch": {
+            "version": "1.1.0",
+            "resolved": "https://registry.npmjs.org/fetch/-/fetch-1.1.0.tgz",
+            "integrity": "sha1-CoJ58Gvjf58Ou1Z1YKMKSA2lmi4=",
+            "requires": {
+                "biskviit": "1.0.1",
+                "encoding": "0.1.12"
+            }
+        },
         "flush-write-stream": {
             "version": "1.0.3",
             "resolved": "https://registry.npmjs.org/flush-write-stream/-/flush-write-stream-1.0.3.tgz",
@@ -547,6 +615,14 @@
                 "readable-stream": "^2.0.4"
             }
         },
+        "follow-redirects": {
+            "version": "1.5.10",
+            "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.5.10.tgz",
+            "integrity": "sha512-0V5l4Cizzvqt5D44aTXbFZz+FtyXV1vrDN6qrelxtfYQKW0KO0W2T/hkE8xvGa/540LkZlkaUjO4ailYTFtHVQ==",
+            "requires": {
+                "debug": "=3.1.0"
+            }
+        },
         "forever-agent": {
             "version": "0.6.1",
             "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz",
@@ -557,7 +633,6 @@
             "version": "2.3.3",
             "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.3.tgz",
             "integrity": "sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ==",
-            "dev": true,
             "requires": {
                 "asynckit": "^0.4.0",
                 "combined-stream": "^1.0.6",
@@ -604,6 +679,11 @@
             "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==",
             "dev": true
         },
+        "get-port": {
+            "version": "3.2.0",
+            "resolved": "https://registry.npmjs.org/get-port/-/get-port-3.2.0.tgz",
+            "integrity": "sha1-3Xzn3hh8Bsi/NTeWrHHgmfCYDrw="
+        },
         "getpass": {
             "version": "0.1.7",
             "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz",
@@ -909,6 +989,41 @@
             "integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0=",
             "dev": true
         },
+        "http-basic": {
+            "version": "7.0.0",
+            "resolved": "https://registry.npmjs.org/http-basic/-/http-basic-7.0.0.tgz",
+            "integrity": "sha1-gvClBr6UJzLsje6+6A50bvVzbbo=",
+            "requires": {
+                "@types/concat-stream": "^1.6.0",
+                "@types/node": "^9.4.1",
+                "caseless": "~0.12.0",
+                "concat-stream": "^1.4.6",
+                "http-response-object": "^3.0.1",
+                "parse-cache-control": "^1.0.1"
+            },
+            "dependencies": {
+                "@types/node": {
+                    "version": "9.6.41",
+                    "resolved": "https://registry.npmjs.org/@types/node/-/node-9.6.41.tgz",
+                    "integrity": "sha512-sPZWEbFMz6qAy9SLY7jh5cgepmsiwqUUHjvEm8lpU6kug2hmmcyuTnwhoGw/GWpI5Npue4EqvsiQQI0eWjW/ZA=="
+                }
+            }
+        },
+        "http-response-object": {
+            "version": "3.0.1",
+            "resolved": "https://registry.npmjs.org/http-response-object/-/http-response-object-3.0.1.tgz",
+            "integrity": "sha512-6L0Fkd6TozA8kFSfh9Widst0wfza3U1Ex2RjJ6zNDK0vR1U1auUR6jY4Nn2Xl7CCy0ikFmxW1XcspVpb9RvwTg==",
+            "requires": {
+                "@types/node": "^9.3.0"
+            },
+            "dependencies": {
+                "@types/node": {
+                    "version": "9.6.41",
+                    "resolved": "https://registry.npmjs.org/@types/node/-/node-9.6.41.tgz",
+                    "integrity": "sha512-sPZWEbFMz6qAy9SLY7jh5cgepmsiwqUUHjvEm8lpU6kug2hmmcyuTnwhoGw/GWpI5Npue4EqvsiQQI0eWjW/ZA=="
+                }
+            }
+        },
         "http-signature": {
             "version": "1.2.0",
             "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz",
@@ -920,6 +1035,14 @@
                 "sshpk": "^1.7.0"
             }
         },
+        "iconv-lite": {
+            "version": "0.4.24",
+            "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz",
+            "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==",
+            "requires": {
+                "safer-buffer": ">= 2.1.2 < 3"
+            }
+        },
         "inflight": {
             "version": "1.0.6",
             "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
@@ -933,8 +1056,7 @@
         "inherits": {
             "version": "2.0.3",
             "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
-            "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=",
-            "dev": true
+            "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4="
         },
         "is": {
             "version": "3.3.0",
@@ -955,8 +1077,7 @@
         "is-buffer": {
             "version": "1.1.6",
             "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz",
-            "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==",
-            "dev": true
+            "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w=="
         },
         "is-extglob": {
             "version": "2.1.1",
@@ -1030,8 +1151,7 @@
         "isarray": {
             "version": "1.0.0",
             "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
-            "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=",
-            "dev": true
+            "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE="
         },
         "isstream": {
             "version": "0.1.2",
@@ -1130,14 +1250,12 @@
         "mime-db": {
             "version": "1.37.0",
             "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.37.0.tgz",
-            "integrity": "sha512-R3C4db6bgQhlIhPU48fUtdVmKnflq+hRdad7IyKhtFj06VPNVdk2RhiYL3UjQIlso8L+YxAtFkobT0VK+S/ybg==",
-            "dev": true
+            "integrity": "sha512-R3C4db6bgQhlIhPU48fUtdVmKnflq+hRdad7IyKhtFj06VPNVdk2RhiYL3UjQIlso8L+YxAtFkobT0VK+S/ybg=="
         },
         "mime-types": {
             "version": "2.1.21",
             "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.21.tgz",
             "integrity": "sha512-3iL6DbwpyLzjR3xHSFNFeb9Nz/M8WDkX33t1GFQnFOllWk8pOrh/LSrB5OXlnlW5P9LH73X6loW/eogc+F5lJg==",
-            "dev": true,
             "requires": {
                 "mime-db": "~1.37.0"
             }
@@ -1230,8 +1348,7 @@
         "ms": {
             "version": "2.0.0",
             "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
-            "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=",
-            "dev": true
+            "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
         },
         "multimatch": {
             "version": "2.1.0",
@@ -1315,6 +1432,11 @@
                 "readable-stream": "^2.0.1"
             }
         },
+        "parse-cache-control": {
+            "version": "1.0.1",
+            "resolved": "https://registry.npmjs.org/parse-cache-control/-/parse-cache-control-1.0.1.tgz",
+            "integrity": "sha1-juqz5U+laSD+Fro493+iGqzC104="
+        },
         "path-dirname": {
             "version": "1.0.2",
             "resolved": "https://registry.npmjs.org/path-dirname/-/path-dirname-1.0.2.tgz",
@@ -1370,14 +1492,20 @@
         "process-nextick-args": {
             "version": "2.0.0",
             "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz",
-            "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==",
-            "dev": true
+            "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw=="
+        },
+        "promise": {
+            "version": "8.0.2",
+            "resolved": "https://registry.npmjs.org/promise/-/promise-8.0.2.tgz",
+            "integrity": "sha512-EIyzM39FpVOMbqgzEHhxdrEhtOSDOtjMZQ0M6iVfCE+kWNgCkAyOdnuCWqfmflylftfadU6FkiMgHZA2kUzwRw==",
+            "requires": {
+                "asap": "~2.0.6"
+            }
         },
         "psl": {
             "version": "1.1.31",
             "resolved": "https://registry.npmjs.org/psl/-/psl-1.1.31.tgz",
-            "integrity": "sha512-/6pt4+C+T+wZUieKR620OpzN/LlnNKuWjy1iFLQ/UG35JqHlR/89MP1d96dUfkf6Dne3TuLQzOYEYshJ+Hx8mw==",
-            "dev": true
+            "integrity": "sha512-/6pt4+C+T+wZUieKR620OpzN/LlnNKuWjy1iFLQ/UG35JqHlR/89MP1d96dUfkf6Dne3TuLQzOYEYshJ+Hx8mw=="
         },
         "pump": {
             "version": "2.0.1",
@@ -1409,8 +1537,7 @@
         "qs": {
             "version": "6.5.2",
             "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz",
-            "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==",
-            "dev": true
+            "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA=="
         },
         "querystringify": {
             "version": "2.1.0",
@@ -1431,7 +1558,6 @@
             "version": "2.3.6",
             "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz",
             "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==",
-            "dev": true,
             "requires": {
                 "core-util-is": "~1.0.0",
                 "inherits": "~2.0.3",
@@ -1539,14 +1665,12 @@
         "safe-buffer": {
             "version": "5.1.2",
             "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
-            "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==",
-            "dev": true
+            "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g=="
         },
         "safer-buffer": {
             "version": "2.1.2",
             "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
-            "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==",
-            "dev": true
+            "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
         },
         "semver": {
             "version": "5.6.0",
@@ -1642,7 +1766,6 @@
             "version": "1.1.1",
             "resolved": "http://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
             "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==",
-            "dev": true,
             "requires": {
                 "safe-buffer": "~5.1.0"
             }
@@ -1662,6 +1785,24 @@
             "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=",
             "dev": true
         },
+        "sync-request": {
+            "version": "6.0.0",
+            "resolved": "https://registry.npmjs.org/sync-request/-/sync-request-6.0.0.tgz",
+            "integrity": "sha512-jGNIAlCi9iU4X3Dm4oQnNQshDD3h0/1A7r79LyqjbjUnj69sX6mShAXlhRXgImsfVKtTcnra1jfzabdZvp+Lmw==",
+            "requires": {
+                "http-response-object": "^3.0.1",
+                "sync-rpc": "^1.2.1",
+                "then-request": "^6.0.0"
+            }
+        },
+        "sync-rpc": {
+            "version": "1.3.4",
+            "resolved": "https://registry.npmjs.org/sync-rpc/-/sync-rpc-1.3.4.tgz",
+            "integrity": "sha512-Iug+t1ICVFenUcTnDu8WXFnT+k8IVoLKGh8VA3eXUtl2Rt9SjKX3YEv33OenABqpTPL9QEaHv1+CNn2LK8vMow==",
+            "requires": {
+                "get-port": "^3.1.0"
+            }
+        },
         "tar": {
             "version": "2.2.1",
             "resolved": "http://registry.npmjs.org/tar/-/tar-2.2.1.tgz",
@@ -1673,6 +1814,24 @@
                 "inherits": "2"
             }
         },
+        "then-request": {
+            "version": "6.0.0",
+            "resolved": "https://registry.npmjs.org/then-request/-/then-request-6.0.0.tgz",
+            "integrity": "sha512-xA+7uEMc+jsQIoyySJ93Ad08Kuqnik7u6jLS5hR91Z3smAoCfL3M8/MqMlobAa9gzBfO9pA88A/AntfepkkMJQ==",
+            "requires": {
+                "@types/concat-stream": "^1.6.0",
+                "@types/form-data": "0.0.33",
+                "@types/node": "^8.0.0",
+                "@types/qs": "^6.2.31",
+                "caseless": "~0.12.0",
+                "concat-stream": "^1.6.0",
+                "form-data": "^2.2.0",
+                "http-basic": "^7.0.0",
+                "http-response-object": "^3.0.1",
+                "promise": "^8.0.0",
+                "qs": "^6.4.0"
+            }
+        },
         "through": {
             "version": "2.3.8",
             "resolved": "http://registry.npmjs.org/through/-/through-2.3.8.tgz",
@@ -1786,6 +1945,11 @@
             "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=",
             "dev": true
         },
+        "typedarray": {
+            "version": "0.0.6",
+            "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz",
+            "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c="
+        },
         "typescript": {
             "version": "3.2.2",
             "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.2.2.tgz",
@@ -1830,8 +1994,7 @@
         "util-deprecate": {
             "version": "1.0.2",
             "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
-            "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=",
-            "dev": true
+            "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8="
         },
         "uuid": {
             "version": "3.3.2",

+ 3 - 0
package.json

@@ -69,5 +69,8 @@
         "tslint": "^5.8.0",
         "@types/node": "^8.10.25",
         "@types/mocha": "^2.2.42"
+    },
+    "dependencies": {
+        "sync-request": "^6.0.0"
     }
 }

+ 2 - 10
src/conn.ts

@@ -1,4 +1,5 @@
 import { SiteDescription, Contest, Problem } from "./types";
+import { CODEFORCES } from "./parsers/codeforces";
 
 /**
  * Register a new site creating an entry in this dictionary.
@@ -26,16 +27,7 @@ export const SITES: SiteDescription[] = [
         }
     ),
 
-    new SiteDescription(
-        "codeforces",
-        "codeforces.com",
-        contestId => {
-            return new Contest();
-        },
-        problemId => {
-            return new Problem();
-        },
-    ),
+    CODEFORCES,
 ];
 
 export function getSite(site: string): SiteDescription  {

+ 0 - 2
src/core.ts

@@ -206,8 +206,6 @@ export function testSolution(path: string){
     let testcasesId = testcasesName(path);
     testcasesId.sort(); // Proccess all testcases in sorted order
 
-    console.log("Test Solution at: ", testcasesId);
-
     let results = [];
     let fail = undefined;
 

+ 7 - 0
src/extension.ts

@@ -9,6 +9,7 @@ import { newContestFromId, testSolution, veredictName, stressSolution, upgradeAr
 import { Veredict } from './types';
 
 /**
+ * TODO: Add How to Use (in the README.) adding own template etc...
  * TODO: Allow custom checker easily
  * TODO: Add several checkers and try to infer which is the correct! [*]
  * TODO: Smart ID detection while parsing ContestId & ProblemId [*]
@@ -17,6 +18,12 @@ import { Veredict } from './types';
  * TODO: Implement parser for codeforces to test on real cases
  * TODO: Learn how to move static files from `src` to `out`.
  * TODO: Allow programming in other languages than c++
+ * TODO: Run testcases in sorted order
+ * TODO: How to use behind proxy
+ *
+ * TODO: When Runtime Error happens show as much output as possible and display the error in the console
+ * TODO: If a solution is run whith an open test, run that test first.
+ * TODO: Figure out something for interactive problems.
  *
  * [*] Machine Learning?
  */

+ 1 - 1
src/gwen.ts

@@ -1,3 +1,3 @@
 export function create(inputs: string[], outputs: string[]) {
-    return 'print("Hello world!")';
+    return 'import random\nprint(random.randint(1, 100))\n';
 }

+ 85 - 0
src/parsers/codeforces.ts

@@ -0,0 +1,85 @@
+import { SiteDescription, Contest, Problem } from "../types";
+
+// TODO: Use sync requests
+const request = require('sync-request');
+
+/**
+ * contestId: ${contest}
+ * http://codeforces.com/contest/${contest}/
+ *
+ * Example:
+ * http://codeforces.com/contest/1081/
+ */
+function parseContest(contestId: string | number) {
+    let problemsId: string[] = [];
+
+    let problems: Problem[] = [];
+
+    problemsId.forEach(problemId => {
+        let prob = parseProblem(`${contestId}-${problemId}`);
+        problems.push(prob);
+    });
+
+    return new Contest(problems);
+}
+
+/**
+ * problemId: ${contest}-${problem}
+ * http://codeforces.com/contest/${contest}/problem/${problem}
+ *
+ * Example:
+ * http://codeforces.com/contest/1081/problem/E
+ */
+function parseProblem(problemId: string) {
+    let data = problemId.split('-');
+    let contest = data[0];
+    let problem = data[1];
+
+    var res = request('GET', `http://codeforces.com/contest/${contest}/problem/${problem}`);
+
+    let html: string = res.getBody('utf8');
+    let pos = 0;
+
+    let inputs = [];
+    let outputs = [];
+
+    while (true){
+        pos = html.indexOf('<div class="title">Input</div>', pos);
+
+        if (pos === -1){
+            break;
+        }
+
+        let begin_pre = html.indexOf('<pre>', pos);
+        let end_pre = html.indexOf('</pre>', pos);
+
+        let inputTestcase = html.substring(begin_pre + 5, end_pre);
+
+        while (inputTestcase.indexOf('<br />') !== -1){
+            inputTestcase = inputTestcase.replace('<br />', '\n');
+        }
+
+        pos = html.indexOf('<div class="title">Output</div>', pos);
+
+        begin_pre = html.indexOf('<pre>', pos);
+        end_pre = html.indexOf('</pre>', pos);
+
+        let outputTestcase = html.substring(begin_pre + 5, end_pre);
+
+        while (outputTestcase.indexOf('<br />') !== -1){
+            outputTestcase = outputTestcase.replace('<br />', '\n');
+        }
+
+        inputs.push(inputTestcase);
+        outputs.push(outputTestcase);
+    }
+
+    return new Problem(problem, inputs, outputs);
+}
+
+export const CODEFORCES = new SiteDescription(
+        "codeforces",
+        "codeforces.com",
+        parseContest,
+        parseProblem,
+    );

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 1757 - 0
src/test/codeforces.html


+ 55 - 1
src/test/extension.test.ts

@@ -8,7 +8,7 @@ import * as assert from 'assert';
 import { dirname, join } from 'path';
 import { timedRun, testcasesName, testSolution, newArena, ATTIC, TESTCASES, upgradeArena, stressSolution, newProblemFromId, newContestFromId } from '../core';
 import { TestcaseResult, Veredict } from '../types';
-import { rmdirSync, existsSync, readdirSync, unlinkSync, openSync, writeSync, closeSync } from 'fs';
+import { rmdirSync, existsSync, readdirSync, unlinkSync, openSync, writeSync, closeSync, readSync } from 'fs';
 
 const SRC = join(dirname(dirname(dirname(__filename))), 'src', 'test');
 const ARENA = join(SRC, 'arena');
@@ -290,4 +290,58 @@ suite("Extension Tests", function () {
 
         recRmdir(path);
     });
+
+    // test("downloading", function(){
+    //     let request = require('sync-request');
+
+    //     console.log("Start downloading...");
+    //     var res = request('GET', 'http://codeforces.com/contest/1081/problem/E');
+    //     console.log("Downloaded...");
+    //     let html: string = res.getBody('utf8');
+
+    //     let fd = openSync("/home/marx/xxx.html", "w");
+    //     writeSync(fd, html);
+    //     closeSync(fd);
+    // });
+
+    function readFile(path: string){
+        let fd = openSync(path, "r");
+        let buffer = new Buffer(1 << 20);
+        readSync(fd, buffer, 0, 1 << 20, 0);
+        let answer = buffer.toString();
+        return answer;
+    }
+
+    test("parsing", function(){
+        let html: string = readFile(join(__dirname, "codeforces.html"));
+        let pos = 0;
+
+        while (true){
+            pos = html.indexOf('<div class="title">Input</div>', pos);
+
+            if (pos === -1){
+                break;
+            }
+
+            let begin_pre = html.indexOf('<pre>', pos);
+            let end_pre = html.indexOf('</pre>', pos);
+
+            let inputTestcase = html.substring(begin_pre + 5, end_pre);
+
+            while (inputTestcase.indexOf('<br />') !== -1){
+                inputTestcase = inputTestcase.replace('<br />', '\n');
+            }
+
+            pos = html.indexOf('<div class="title">Output</div>', pos);
+
+            begin_pre = html.indexOf('<pre>', pos);
+            end_pre = html.indexOf('</pre>', pos);
+
+            let outputTestcase = html.substring(begin_pre + 5, end_pre);
+
+            while (outputTestcase.indexOf('<br />') !== -1){
+                outputTestcase = outputTestcase.replace('<br />', '\n');
+            }
+        }
+    });
 });