From 1336450cccb640c1c925519c4e68d00aff8c62bc Mon Sep 17 00:00:00 2001 From: mrugesh mohapatra Date: Mon, 11 Jun 2018 19:55:04 +0530 Subject: [PATCH] chore: add patch to gitignore (#7) --- .gitignore | 3 +- last-4commits.patch | 342 -------------------------------------------- 2 files changed, 2 insertions(+), 343 deletions(-) delete mode 100644 last-4commits.patch diff --git a/.gitignore b/.gitignore index c1b093a726..7c9c6a9d59 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ dist unpacked/ *.log -*.tgz \ No newline at end of file +*.tgz +*.patch diff --git a/last-4commits.patch b/last-4commits.patch deleted file mode 100644 index 820371c6f5..0000000000 --- a/last-4commits.patch +++ /dev/null @@ -1,342 +0,0 @@ -From 39cb13380b898752cc54cabc3e97372126447252 Mon Sep 17 00:00:00 2001 -From: Vimal Raghubir -Date: Sun, 10 Jun 2018 19:45:18 -0400 -Subject: [PATCH 1/4] fix: added new test and fixed incorrect variable (#17471) - -* Added new test and fixed incorrect variable - -* Fix: Incorrect sentences and descriptions - -* Update es6.json ---- - .../es6.json | 22 +++++++++++-------- - 1 file changed, 13 insertions(+), 9 deletions(-) - -diff --git a/seed/challenges/02-javascript-algorithms-and-data-structures/es6.json b/seed/challenges/02-javascript-algorithms-and-data-structures/es6.json -index 941222890..5d45abf56 100644 ---- a/seed/challenges/02-javascript-algorithms-and-data-structures/es6.json -+++ b/seed/challenges/02-javascript-algorithms-and-data-structures/es6.json -@@ -127,22 +127,26 @@ - "let is not the only new way to declare variables. In ES6, you can also declare variables using the const keyword.", - "const has all the awesome features that let has, with the added bonus that variables declared using const are read-only. They are a constant value, which means that once a variable is assigned with const, it cannot be reassigned.", - "
\"use strict\"
const FAV_PET = \"Cats\";
FAV_PET = \"Dogs\"; // returns error
", -- "As you can see, trying to reassign a variable declared with const will throw an error. You should always name variables you don't want to reassign using the const keyword. This helps when you accidentally attempt to reassign a variable that is meant to stay constant. A common practice is to name your constants in all upper-cases and with an underscore to separate words (e.g. EXAMPLE_VARIABLE).", -+ "As you can see, trying to reassign a variable declared with const will throw an error. You should always name variables you don't want to reassign using the const keyword. This helps when you accidentally attempt to reassign a variable that is meant to stay constant. A common practice when naming constants is to use all uppercase letters, with words separated by an underscore.", - "
", -- "Change the code so that all variables are declared using let or const. Use let when you want the variable to change, and const when you want the variable to remain constant. Also, rename variables declared with const to conform to common practices, meaning constants should be in all caps" -+ "Change the code so that all variables are declared using let or const. Use let when you want the variable to change, and const when you want the variable to remain constant. Also, rename variables declared with const to conform to common practices, meaning constants should be in all caps." - ], - "tests": [ - { -- "text": "var does not exist in code.", -- "testString": "getUserInput => assert(!getUserInput('index').match(/var/g),'var does not exist in code.');" -+ "text": "var does not exist in your code.", -+ "testString": "getUserInput => assert(!getUserInput('index').match(/var/g),'var does not exist in your code.');" -+ }, -+ { -+ "text": "SENTENCE should be a constant variable declared with const.", -+ "testString": "getUserInput => assert(getUserInput('index').match(/(const SENTENCE)/g), 'SENTENCE should be a constant variable declared with const.');" - }, - { -- "text": "SENTENCE should be a constant variable (by using const).", -- "testString": "getUserInput => assert(getUserInput('index').match(/(const SENTENCE)/g), 'SENTENCE should be a constant variable (by using const).');" -+ "text": "i should be declared with let.", -+ "testString": "getUserInput => assert(getUserInput('index').match(/(let i)/g), 'i should be declared with let.');" - }, - { -- "text": "i should be a variable only defined within the for loop scope (by usinglet).", -- "testString": "getUserInput => assert(getUserInput('index').match(/(let i)/g), 'i should be a variable only defined within the for loop scope (by usinglet).');" -+ "text": "console.log should be changed to print the SENTENCE variable.", -+ "testString": "getUserInput => assert(getUserInput('index').match(/console.log/(/s*?SENTENCE/s*?/)/s*?;/g), 'console.log should be adjusted to print the variable SENTENCE.');" - } - ], - "releasedOn": "Feb 17, 2017", -@@ -161,7 +165,7 @@ - "", - " var sentence = str + \" is cool!\";", - " for(var i = 0; i < str.length; i+=2) {", -- " console.log(str);", -+ " console.log(sentence);", - " }", - "", - " // change code above this line", --- -2.17.1 - - -From b6f963bb9805d3fc3bd3724fffc0751f905f2620 Mon Sep 17 00:00:00 2001 -From: bogadodiegoh -Date: Sun, 10 Jun 2018 20:46:46 -0300 -Subject: [PATCH 2/4] fix(seed): updated basic javascript URLs for hints - (#17445) - -* Updated json file with right url values - -* Updated url links after review - -* Updated another broken url link after review ---- - .../basic-javascript.json | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -diff --git a/seed/challenges/02-javascript-algorithms-and-data-structures/basic-javascript.json b/seed/challenges/02-javascript-algorithms-and-data-structures/basic-javascript.json -index edce769e2..0a2a90a22 100644 ---- a/seed/challenges/02-javascript-algorithms-and-data-structures/basic-javascript.json -+++ b/seed/challenges/02-javascript-algorithms-and-data-structures/basic-javascript.json -@@ -6757,9 +6757,9 @@ - "If prop is \"tracks\" but the album doesn't have a \"tracks\" property, create an empty array before adding the new value to the album's corresponding property.", - "If prop is \"tracks\" and value isn't empty (\"\"), push the value onto the end of the album's existing tracks array.", - "If value is empty (\"\"), delete the given prop property from the album.", -- "Hints
Use bracket notation when accessing object properties with variables.", -+ "Hints
Use bracket notation when accessing object properties with variables.", - "Push is an array method you can read about on Mozilla Developer Network.", -- "You may refer back to Manipulating Complex Objects Introducing JavaScript Object Notation (JSON) for a refresher." -+ "You may refer back to Manipulating Complex Objects Introducing JavaScript Object Notation (JSON) for a refresher." - ], - "releasedOn": "January 1, 2016", - "solutions": [ -@@ -6807,7 +6807,7 @@ - "Si la propiedad prop es \"tracks\" y value no está en blanco, empuja (push) el valor value al final del vector tracks.", - "Si el valor value está en blanco, elimina esa prop.", - "Siempre retorna el objeto collection entero.", -- "Nota
No olvides usar notación corchete cuando accedes a propiedades de objetos con variables." -+ "Nota
No olvides usar notación corchete cuando accedes a propiedades de objetos con variables." - ] - } - }, --- -2.17.1 - - -From 8f4e8bb3dd918bd3872db71c52a41f3061445cc5 Mon Sep 17 00:00:00 2001 -From: Jarek Wojciechowski -Date: Sun, 10 Jun 2018 20:02:32 -0400 -Subject: [PATCH 3/4] fix(challenges): add info about ReactDOM.render in an - early react challenge (#17186) (#17473) - ---- - seed/challenges/03-front-end-libraries/react.json | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/seed/challenges/03-front-end-libraries/react.json b/seed/challenges/03-front-end-libraries/react.json -index 6b5e529ad..998106189 100644 ---- a/seed/challenges/03-front-end-libraries/react.json -+++ b/seed/challenges/03-front-end-libraries/react.json -@@ -22,6 +22,7 @@ - "React uses a syntax extension of JavaScript called JSX that allows you to write HTML directly within JavaScript. This has several benefits. It lets you use the full programmatic power of JavaScript within HTML, and helps to keep your code readable. For the most part, JSX is similar to the HTML that you have already learned, however there are a few key differences that will be covered throughout these challenges.", - "For instance, because JSX is a syntactic extension of JavaScript, you can actually write JavaScript directly within JSX. To do this, you simply include the code you want to be treated as JavaScript within curly braces: { 'this is treated as JavaScript code' }. Keep this in mind, since it's used in several future challenges.", - "However, because JSX is not valid JavaScript, JSX code must be compiled into JavaScript. The transpiler Babel is a popular tool for this process. For your convenience, it's already added behind the scenes for these challenges. If you happen to write syntactically invalid JSX, you will see the first test in these challenges fail.", -+ "It's worth noting that under the hood the challenges are calling ReactDOM.render(JSX, document.getElementById('root')). This function call is what places your JSX into React's own lightweight representation of the DOM. React then uses snapshots of its own DOM to optimize updating only specific parts of the actual DOM.", - "
", - "Instructions: The current code uses JSX to assign a div element to the constant JSX. Replace the div with an h1 element and add the text Hello JSX! inside it." - ], -@@ -3673,4 +3674,4 @@ - "react": true - } - ] --} -\ No newline at end of file -+} --- -2.17.1 - - -From 5ba9c1d5c07152a60e926161f21bf5204a43ff66 Mon Sep 17 00:00:00 2001 -From: Bhanu Pratap Singh Rathore -Date: Mon, 11 Jun 2018 05:33:55 +0530 -Subject: [PATCH 4/4] feat(interview-prep): Porting Rosetta problems (#17480) - -* feat(interview-prep): Porting Rosetta problems - -* Changes done - -* Update rosetta-code.json - -* Update rosetta-code.json ---- - .../rosetta-code.json | 169 ++++++++++++++++++ - 1 file changed, 169 insertions(+) - -diff --git a/seed/challenges/08-coding-interview-prep/rosetta-code.json b/seed/challenges/08-coding-interview-prep/rosetta-code.json -index fd929119d..692b37816 100644 ---- a/seed/challenges/08-coding-interview-prep/rosetta-code.json -+++ b/seed/challenges/08-coding-interview-prep/rosetta-code.json -@@ -3954,6 +3954,175 @@ - } - } - }, -+ { -+ "title": "Generator/Exponential", -+ "description": ["A generator is an executable entity (like a function or procedure) that contains code that yields a sequence of values, one at a time, so that each time you call the generator, the next value in the sequence is provided.", "Generators are often built on top of coroutines or objects so that the internal state of the object is handled “naturally”.", "Generators are often used in situations where a sequence is potentially infinite, and where it is possible to construct the next value of the sequence with only minimal state.", "Write a function that uses generators to generate squares and cubes. Create a new generator that filters all cubes from the generator of squares.", "The function should return the \\( n^{th} \\) value of the filtered generator.", "For example for \\(n=7\\), the function should return 81 as the sequence would be 4,9,16,25,36,49,81. Here 64 is filtered out, as it is a cube."], -+ "solutions": ["function exponentialGenerator(n){\n function* PowersGenerator(m) {\n \tvar n=0;\n \twhile(1) {\n \t\tyield Math.pow(n, m);\n \t\tn += 1;\n \t}\n }\n\n function* FilteredGenerator(g, f){\n \tvar value = g.next().value;\n \tvar filter = f.next().value;\n \twhile(1) {\n \t\tif( value < filter ) {\n \t\t\tyield value;\n \t\t\tvalue = g.next().value;\n \t\t} else if ( value > filter ) {\n \t\t\tfilter = f.next().value;\n \t\t} else {\n \t\t\tvalue = g.next().value;\n \t\t\tfilter = f.next().value;\n \t\t}\n \t}\n }\n\n var squares = PowersGenerator(2);\n var cubes = PowersGenerator(3);\n\n var filtered = FilteredGenerator(squares, cubes);\n\n var curr=0;\n for(var i=0;iexponentialGenerator should be a function.'", -+ "testString": "assert(typeof exponentialGenerator=='function','exponentialGenerator should be a function.');" -+ }, { -+ "text": "'exponentialGenerator() should return a number.'", -+ "testString": "assert(typeof exponentialGenerator(10)=='number','exponentialGenerator() should return a number.');" -+ }, { -+ "text": "'exponentialGenerator(10) should return 144.'", -+ "testString": "assert.equal(exponentialGenerator(10),144,'exponentialGenerator(10) should return 144.');" -+ }, { -+ "text": "'exponentialGenerator(12) should return 196.'", -+ "testString": "assert.equal(exponentialGenerator(12),196,'exponentialGenerator(12) should return 196.');" -+ }, { -+ "text": "'exponentialGenerator(14) should return 256.'", -+ "testString": "assert.equal(exponentialGenerator(14),256,'exponentialGenerator(14) should return 256.');" -+ }, { -+ "text": "'exponentialGenerator(20) should return 484.'", -+ "testString": "assert.equal(exponentialGenerator(20),484,'exponentialGenerator(20) should return 484.');" -+ }, { -+ "text": "'exponentialGenerator(25) should return 784.'", -+ "testString": "assert.equal(exponentialGenerator(25),784,'exponentialGenerator(25) should return 784.');" -+ }], -+ "id": "5a23c84252665b21eecc7e7b", -+ "challengeType": 5, -+ "releasedOn": "June 7, 2018", -+ "files": { -+ "indexjs": { -+ "key": "indexjs", -+ "ext": "js", -+ "name": "index", -+ "contents": ["function exponentialGenerator (n) {", " // Good luck!", "}"], -+ "head": [], -+ "tail": [] -+ } -+ } -+ }, -+ { -+ "title": "Gray code", -+ "description": ["Gray code is a form of binary encoding where transitions between consecutive numbers differ by only one bit.", "This is a useful encoding for reducing hardware data hazards with values that change rapidly and/or connect to slower hardware as inputs. ", "It is also useful for generating inputs for Karnaugh maps in order from left to right or top to bottom. ", "Create a function to encode a number to and decode a number from Gray code. The function should will have 2 parameters. ", "The first would be a boolean. The function should encode for true and decode for false. The second parameter would be the number to be encoded/decoded.", "Display the normal binary representations, Gray code representations, and decoded Gray code values for all 5-bit binary numbers (0-31 inclusive, leading 0's not necessary).", "There are many possible Gray codes. The following encodes what is called \"binary reflected Gray code.\"
Encoding (MSB is bit 0, b is binary, g is Gray code): ", "
if b[i-1] = 1
g[i] = not b[i]
else
g[i] = b[i]
", "
Or:
g = b xor (b logically right shifted 1 time)
Decoding (MSB is bit 0, b is binary, g is Gray code):
", "b[0] = g[0]
for other bits:
b[i] = g[i] xor b[i-1]
"], -+ "solutions": ["function gray(enc, number){\n if(enc){\n return number ^ (number >> 1);\n }else{\n let n = number;\n\n while (number >>= 1) {\n n ^= number;\n }\n return n;\n }\n}\n"], -+ "tests": [{ -+ "text": "'gray should be a function.'", -+ "testString": "assert(typeof gray=='function','gray should be a function.');" -+ }, { -+ "text": "'gray(true,177) should return a number.'", -+ "testString": "assert(typeof gray(true,177)=='number','gray(true,177) should return a number.');" -+ }, { -+ "text": "'gray(true,177) should return 233.'", -+ "testString": "assert.equal(gray(true,177),233,'gray(true,177) should return 233.');" -+ }, { -+ "text": "'gray(true,425) should return 381.'", -+ "testString": "assert.equal(gray(true,425),381,'gray(true,425) should return 381.');" -+ }, { -+ "text": "'gray(true,870) should return 725.'", -+ "testString": "assert.equal(gray(true,870),725,'gray(true,870) should return 725.');" -+ }, { -+ "text": "'gray(false,233) should return 177.'", -+ "testString": "assert.equal(gray(false,233),177,'gray(false,233) should return 177.');" -+ }, { -+ "text": "'gray(false,381) should return 425.'", -+ "testString": "assert.equal(gray(false,381),425,'gray(false,381) should return 425.');" -+ }, { -+ "text": "'gray(false,725) should return 870.'", -+ "testString": "assert.equal(gray(false,725),870,'gray(false,725) should return 870.');" -+ }], -+ "id": "5a23c84252665b21eecc7e80", -+ "challengeType": 5, -+ "releasedOn": "June 7, 2018", -+ "files": { -+ "indexjs": { -+ "key": "indexjs", -+ "ext": "js", -+ "name": "index", -+ "contents": ["function gray(enc, number) {", " // Good luck!", "}"], -+ "head": [], -+ "tail": [] -+ } -+ } -+ }, -+ { -+ "title": "Greatest common divisor", -+ "description": ["Write a function that returns the greatest common divisor of two integers."], -+ "solutions": ["function gcd(a, b) {\n return b==0 ? Math.abs(a):gcd(b, a % b);\n}\n"], -+ "tests": [{ -+ "text": "'gcd should be a function.'", -+ "testString": "assert(typeof gcd=='function','gcd should be a function.');" -+ }, { -+ "text": "'gcd(24,36) should return a number.'", -+ "testString": "assert(typeof gcd(24,36)=='number','gcd(24,36) should return a number.');" -+ }, { -+ "text": "'gcd(24,36) should return 12.'", -+ "testString": "assert.equal(gcd(24,36),12,'gcd(24,36) should return 12.');" -+ }, { -+ "text": "'gcd(30,48) should return 6.'", -+ "testString": "assert.equal(gcd(30,48),6,'gcd(30,48) should return 6.');" -+ }, { -+ "text": "'gcd(10,15) should return 5.'", -+ "testString": "assert.equal(gcd(10,15),5,'gcd(10,15) should return 5.');" -+ }, { -+ "text": "'gcd(100,25) should return 25.'", -+ "testString": "assert.equal(gcd(100,25),25,'gcd(100,25) should return 25.');" -+ }, { -+ "text": "'gcd(13,250) should return 1.'", -+ "testString": "assert.equal(gcd(13,250),1,'gcd(13,250) should return 1.');" -+ }, { -+ "text": "'gcd(1300,250) should return 50.'", -+ "testString": "assert.equal(gcd(1300,250),50,'gcd(1300,250) should return 50.');" -+ }], -+ "id": "5a23c84252665b21eecc7e82", -+ "challengeType": 5, -+ "releasedOn": "June 7, 2018", -+ "files": { -+ "indexjs": { -+ "key": "indexjs", -+ "ext": "js", -+ "name": "index", -+ "contents": ["function gcd(a, b) {", " // Good luck!", "}"], -+ "head": [], -+ "tail": [] -+ } -+ } -+ }, -+ { -+ "title": "Greatest subsequential sum", -+ "description": ["Given a sequence of integers, find a continuous subsequence which maximizes the sum of its elements, that is, the elements of no other single subsequence add up to a value larger than this one.", "An empty subsequence is considered to have the sum of \\( 0 \\); thus if all elements are negative, the result must be the empty sequence."], -+ "solutions": ["function maximumSubsequence(population) {\n function sumValues(arr) {\n var result = 0;\n for (var i = 0, len = arr.length; i < len; i++) {\n result += arr[i];\n }\n return result;\n }\n var greatest;\n var maxValue = 0;\n var subsequence = [];\n\n for (var i = 0, len = population.length; i < len; i++) {\n for (var j = i; j <= len; j++) {\n var subsequence = population.slice(i, j);\n var value = sumValues(subsequence);\n if (value > maxValue) {\n maxValue = value;\n greatest = subsequence;\n };\n }\n }\n\n return greatest;\n}\n\n\n"], -+ "tests": [{ -+ "text": "'maximumSubsequence should be a function.'", -+ "testString": "assert(typeof maximumSubsequence=='function','maximumSubsequence should be a function.');" -+ }, { -+ "text": "'maximumSubsequence('+JSON.stringify(tests[0])+') should return an array.'", -+ "testString": "assert(Array.isArray(maximumSubsequence(tests[0])),'maximumSubsequence('+JSON.stringify(tests[0])+') should return an array.');" -+ }, { -+ "text": "'maximumSubsequence('+JSON.stringify(tests[0])+') should return '+JSON.stringify(results[0])+'.'", -+ "testString": "assert.deepEqual(maximumSubsequence(tests[0]),results[0],'maximumSubsequence('+JSON.stringify(tests[0])+') should return '+JSON.stringify(results[0])+'.');" -+ }, { -+ "text": "'maximumSubsequence('+JSON.stringify(tests[1])+') should return '+JSON.stringify(results[1])+'.'", -+ "testString": "assert.deepEqual(maximumSubsequence(tests[1]),results[1],'maximumSubsequence('+JSON.stringify(tests[1])+') should return '+JSON.stringify(results[1])+'.');" -+ }, { -+ "text": "'maximumSubsequence('+JSON.stringify(tests[2])+') should return '+JSON.stringify(results[2])+'.'", -+ "testString": "assert.deepEqual(maximumSubsequence(tests[2]),results[2],'maximumSubsequence('+JSON.stringify(tests[2])+') should return '+JSON.stringify(results[2])+'.');" -+ }, { -+ "text": "'maximumSubsequence('+JSON.stringify(tests[3])+') should return '+JSON.stringify(results[3])+'.'", -+ "testString": "assert.deepEqual(maximumSubsequence(tests[3]),results[3],'maximumSubsequence('+JSON.stringify(tests[3])+') should return '+JSON.stringify(results[3])+'.');" -+ }, { -+ "text": "'maximumSubsequence('+JSON.stringify(tests[4])+') should return '+JSON.stringify(results[4])+'.'", -+ "testString": "assert.deepEqual(maximumSubsequence(tests[4]),results[4],'maximumSubsequence('+JSON.stringify(tests[4])+') should return '+JSON.stringify(results[4])+'.');" -+ }, { -+ "text": "'maximumSubsequence('+JSON.stringify(tests[5])+') should return '+JSON.stringify(results[5])+'.'", -+ "testString": "assert.deepEqual(maximumSubsequence(tests[5]),results[5],'maximumSubsequence('+JSON.stringify(tests[5])+') should return '+JSON.stringify(results[5])+'.');" -+ }], -+ "id": "5a23c84252665b21eecc7e84", -+ "challengeType": 5, -+ "releasedOn": "June 7, 2018", -+ "files": { -+ "indexjs": { -+ "key": "indexjs", -+ "ext": "js", -+ "name": "index", -+ "contents": ["function maximumSubsequence (population) {", " // Good luck!", "}"], -+ "head": [], -+ "tail": ["let tests=[ [1,2,-1,3,10,-10],", " [0, 8, 10, -2, -4, -1, -5, -3],", " [9, 9, -10, 1],", " [7, 1, -5, -3, -8, 1],", " [-3, 6, -1, 4, -4, -6],", " [-1, -2, 3, 5, 6, -2, -1, 4, -4, 2, -1]]", "let results=[ [ 1, 2, -1, 3, 10 ],", " [ 0, 8, 10 ],", " [ 9, 9 ],", " [ 7, 1 ],", " [ 6, -1, 4 ],", " [ 3, 5, 6, -2, -1, 4 ] ]"] -+ } -+ } -+ }, - { - "title": "Hailstone sequence", - "description": [ --- -2.17.1 -