Commit f13da498 authored by Brady James Garvin's avatar Brady James Garvin
Browse files

Initial commit.

parents
# Disable line-ending conversions for this repository.
* -text
# dependencies
/node_modules
# testing
/coverage
# production
/build
# environments
.env.local
.env.development.local
.env.test.local
.env.production.local
# logs
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# misc
*~
.DS_Store
[submodule "eslint-config"]
path = eslint-config
url = git@git.unl.edu:csce-310/eslint-config.git
# Tests-Only Starter Code
A minimal project to be used as starter code for Homework 1 in the 250 section
of the CSCE 310 course at UNL.
# Quick Start
Recursively clone this repository and `cd` into the root folder:
```
$ git clone --recursive git@git.unl.edu:csce-310/2021-fall-homework-1.git
$ cd 2021-fall-homework-1
```
(If you forget `--recursive` when cloning, you can `cd` into your clone and run
`git submodule update --init --recursive` instead.)
Install dependencies:
```
$ npm install
```
# Instructions
See <https://canvas.unl.edu/courses/114253/assignments/1083209>.
Subproject commit 24df42fb655d234b83c93b0fb24d012e4d9ecb58
{
"folders": [
{
"path": "."
}
],
"settings": {
"files.eol": "LF",
"files.exclude": {
"**/node_modules": true
},
"files.trimFinalNewlines": true,
"files.trimTrailingWhitespace": true
}
}
# dependencies
/node_modules
# testing
/coverage
# production
/build
# environments
.env.local
.env.development.local
.env.test.local
.env.production.local
# logs
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# misc
*~
.DS_Store
This diff is collapsed.
{
"name": "@unlsoft/homework-1-implementation",
"version": "1.0.0",
"description": "A minimal project to be used as starter code for Homework 1.",
"type": "module",
"private": true,
"license": "UNLICENSED",
"scripts": {
"lint:js": "eslint --max-warnings 0 ./src",
"lint": "run-s --continue-on-error lint:**",
"test-once:hasIncreasingDigits": "node --experimental-vm-modules node_modules/jest/bin/jest.js --coverage -t 'hasIncreasingDigits'",
"test-once:takeReverseLexicographicalPermutations": "node --experimental-vm-modules node_modules/jest/bin/jest.js --coverage -t 'takeReverseLexicographicalPermutations'",
"test-once": "node --experimental-vm-modules node_modules/jest/bin/jest.js --coverage",
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js --watchAll --coverage"
},
"dependencies": {
"npm-run-all": "^4.1.5"
},
"devDependencies": {
"@unlsoft/eslint-config": "file:../eslint-config",
"eslint": "^7.30.0",
"jest": "^27.0.6",
"jest-environment-node": "^27.0.6"
},
"eslintConfig": {
"extends": "@unlsoft"
},
"jest": {
"clearMocks": true,
"collectCoverageFrom": [
"src/**/*.js",
"!src/testing/**/*.js"
],
"resetMocks": false,
"restoreMocks": false,
"testEnvironment": "./src/testing/failFast.js",
"transform": {}
},
"//": [
"See https://github.com/facebook/jest/issues/9430 for information on Jest+ES6."
]
}
export function hasIncreasingDigits(nonnegativeBigInteger) {
// INSTRUCTIONS: Complete this JavaScript function so that it takes a
// nonnegative JavaScript `BigInt` called `nonnegativeBigInteger`, returns
// `true` if the base-10 digits of `nonnegativeBigInteger` are weakly
// monotonically increasing, and returns `false` otherwise. For example, the
// result of `hasIncreasingDigits(1123n)` should be `true` because 1 ≤ 1 ≤ 2 ≤
// 3, but the result of `hasIncreasingDigits(2311)` should be `false` because
// 3 > 1.
//
// Any method for checking this condition is acceptable. If you want to write
// especially efficient code, consider taking inspiration from Exercise D on
// `while` loops in the JavaScript practice repository.
//
// You may also find the following article useful when writing code to
// manipulate `BigInt`s in JavaScript:
//
// * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt
//
// Be aware that you may get style errors from the linter if you use the
// constant `10n` directly in your code, because it will see `10n` as a "magic
// number", and complain that your code does not make it clear why you chose
// that value and not another. To resolve that issue, add this line of code
// above the function to give the value a meaningful name:
//
// ```
// const BASE = 10n;
// ```
//
// and then write the constant `BASE` everywhere in the function where you
// would use `10n`. Because the constant has a name, the linter will no
// longer see it as an arbitrary, undocumented choice.
}
This diff is collapsed.
export function takeReverseLexicographicalPermutations(list, count) {
const results = [];
// INSTRUCTIONS: Read the natural-language description of an algorithm to
// generate permutations in lexicographic order at https://is.gd/uGhGFr.
// Determine how you would change the algorithm to give the permutations in
// reverse lexicographic order instead and how you would change it to limit
// the number of permutations generated to a certain number.
//
// Based on the description and your changes, complete this JavaScript
// function so that it returns the first `count` permutations (or as many as
// possible if that many permutations do not exist) of `list` in reverse
// lexicographic order. For example, the result of
// `takeReverseLexicographicalPermutations([6, 5, 4], 3)` should be this list
// of lists:
//
// ```
// [
// [6, 5, 4],
// [6, 4, 5],
// [5, 6, 4],
// ]
// ```
//
// To simplify your code, you may assume that `list` as given is always sorted
// in reverse order.
//
// You may also find the following articles useful when writing code to
// manipulate arrays in JavaScript:
//
// * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array
// * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/push
// * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice
// * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reverse
// * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice
//
// Because JavaScript stores array elements by reference, it can be dangerous
// to push an array directly onto `results` if you plan to modify that array
// later; any subsequent changes to the array would also affect the result
// that you pushed. To avoid this problem, write code like
//
// ```
// results.push([...anArray]);
// ```
//
// where the expression `[...anArray]` will make a copy of `anArray`.
return results;
}
This diff is collapsed.
import NodeEnvironment from 'jest-environment-node';
export default class FailFastEnvironment extends NodeEnvironment {
constructor(...rest) {
super(...rest);
this.failed = false;
}
async handleTestEvent(event, state) {
switch (event.name) {
case 'hook_failure':
case 'test_fn_failure':
this.failed = true;
break;
case 'test_start':
if (this.failed) {
event.test.mode = 'skip';
}
break;
default:
}
if (super.handleTestEvent !== undefined) {
await super.handleTestEvent(event, state);
}
}
}
*~
*.aux
*.toc
*.fdb_latexmk
*.fls
*.log
*.synctex.gz
This diff is collapsed.
{
"name": "@unlsoft/homework-1",
"version": "1.0.0",
"description": "A project skeleton to be used as starter code for Homework 1.",
"private": true,
"license": "UNLICENSED",
"scripts": {
"postinstall:eslint-config": "cd eslint-config && npm install",
"postinstall:app": "cd homework-1 && npm install",
"postinstall": "run-s postinstall:**",
"lint:app": "cd homework-1 && npm run lint",
"lint": "run-s --continue-on-error lint:**",
"test-once:hasIncreasingDigits": "cd homework-1 && npm run test-once:hasIncreasingDigits",
"test-once:takeReverseLexicographicalPermutations": "cd homework-1 && npm run test-once:takeReverseLexicographicalPermutations",
"test-once": "cd homework-1 && npm run test-once",
"test": "run-s test-once",
"start": "cd homework-1 && npm run start",
"build:app": "cd homework-1 && npm run build",
"build": "run-s build:**"
},
"devDependencies": {
"ghooks": "^2.0.4",
"npm-run-all": "^4.1.5"
},
"config": {
"ghooks": {
"pre-commit": "npm run lint"
}
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment