Last active
August 29, 2015 13:57
-
-
Save joshuakfarrar/9862728 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
royalflush:bytewiser sent1nel$ node bytewiser.js current | |
Array Buffers | |
royalflush:bytewiser sent1nel$ node bytewiser.js run exercises/array_buffers/solution/solution.js | |
{"0":24557,"1":132,"BYTES_PER_ELEMENT":2,"buffer":{"0":237,"1":95,"2":132,"3":0,"byteLength":4},"length":2,"byteOffset":0,"byteLength":4} | |
royalflush:bytewiser sent1nel$ node bytewiser.js verify exercises/array_buffers/solution/solution.js | |
Your submission results compared to the expected: | |
ACTUAL EXPECTED | |
──────────────────────────────────────────────────────────────────────────────── | |
"{\"0\":24557,\"1\":132,\"BYTES_PER_ELEMENT\":2,\"buffer\":{\"0\":237,\"1\":95,\"2\":132,\"3\":0,\"byteLength\":4},\"length\":2,\"byteOffset\":0,\"byteLength\":4}" == "{\"0\":24557,\"1\":132,\"BYTES_PER_ELEMENT\":2,\"buffer\":{\"0\":237,\"1\":95,\"2\":132,\"3\":0,\"byteLength\":4},\"length\":2,\"byteOffset\":0,\"byteLength\":4}" | |
"" == "" | |
──────────────────────────────────────────────────────────────────────────────── | |
✓ Submission results match expected | |
# PASS | |
Your solution to Array Buffers passed! | |
Here's the official solution is if you want to compare notes: | |
──────────────────────────────────────────────────────────────────────────────── | |
var num = +process.argv[2] | |
var ui32 = new Uint32Array(1) | |
ui32[0] = num | |
var ui16 = new Uint16Array(ui32.buffer) | |
console.log(JSON.stringify(ui16)) | |
──────────────────────────────────────────────────────────────────────────────── | |
You've finished all the challenges! Hooray! |
This file contains hidden or 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
var exercise = require('workshopper-exercise')() | |
, filecheck = require('workshopper-exercise/filecheck') | |
, execute = require('workshopper-exercise/execute') | |
, comparestdout = require('workshopper-exercise/comparestdout') | |
// checks that the submission file actually exists | |
exercise = filecheck(exercise) | |
// execute the solution and submission in parallel with spawn() | |
exercise = execute(exercise) | |
// compare stdout of solution and submission | |
exercise = comparestdout(exercise) | |
exercise.addSetup(function (mode, callback) { | |
// generate a random number between min and max | |
function getRandomInt(min, max) { | |
return Math.floor(Math.random() * (max - min) + min) | |
} | |
var number = getRandomInt(1000000, 9999999) | |
// supply the file as an arg to the 'execute' processor for both | |
// solution and submission spawn() | |
// using unshift here because wrappedexec needs to use additional | |
// args to do its magic | |
this.submissionArgs.unshift(number) | |
this.solutionArgs.unshift(number) | |
callback(null) | |
}) | |
module.exports = exercise |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment