diff --git a/html/tasks/extra/task1/script.js b/html/tasks/extra/task1/script.js index 38d225f..aabba11 100644 --- a/html/tasks/extra/task1/script.js +++ b/html/tasks/extra/task1/script.js @@ -5,20 +5,20 @@ eller så må vi ta vekk det andre, men vi står fortsatt alltid igjen med ett a */ function almostIncreasingSequence(sequence) { - let decreaseCounter=0; - for (elements in sequence){ - if (sequence[elements] > sequence[parseInt(elements)+1]) { - decreaseCounter++; - if (decreaseCounter > 1) { - return false; - } - } + let decreaseCounter = 0; + for (elements in sequence){ + if (sequence[elements] > sequence[parseInt(elements) + 1]) { + decreaseCounter++; + if (decreaseCounter > 1) { + return false; + } } - return true; + } + return true; } /* Test */ -console.log("[1,3,2,1]" + " -> " + almostIncreasingSequence([1,3,2,1])); -console.log("[1,3,2]" + " -> " + almostIncreasingSequence([1,3,2])); -console.log("[1,3,2,4,5,6,8]" + " -> " + almostIncreasingSequence([1,3,2,4,5,6,8])); -console.log("[1,3,2,4,5,6,8,2]" + " -> " + almostIncreasingSequence([1,3,2,4,5,6,8,2])); \ No newline at end of file +console.log(`[1,3,2,1] -> ${almostIncreasingSequence([1,3,2,1])}`); +console.log(`[1,3,2] -> " + ${almostIncreasingSequence([1,3,2])}`); +console.log(`[1,3,2,4,5,6,8] -> " + ${almostIncreasingSequence([1,3,2,4,5,6,8])}`); +console.log(`[1,3,2,4,5,6,8,2] -> " + ${almostIncreasingSequence([1,3,2,4,5,6,8,2])}`); \ No newline at end of file diff --git a/html/tasks/template/OppgaveMal/oppgave.html b/html/tasks/template/OppgaveMal/oppgave.html index 1e08c79..60367c8 100755 --- a/html/tasks/template/OppgaveMal/oppgave.html +++ b/html/tasks/template/OppgaveMal/oppgave.html @@ -1,20 +1,19 @@ - - - - - Oppgave X - - - - - -

Oppgave X

+ + + + + Oppgave X + + + + +

Oppgave X

+ +
-
- -
- - - \ No newline at end of file +
+ + + diff --git a/test-template-generator/generate.py b/test-template-generator/generate.py index 76b14ca..1a0c0fc 100644 --- a/test-template-generator/generate.py +++ b/test-template-generator/generate.py @@ -15,42 +15,42 @@ jsonData['tasks'] = [] numberOfTasks = int(input('Number of tasks: ')) for i in range(0, numberOfTasks): - #Define variables - realTaskNumber = i+1 - dirPath = './oppgaver/oppgave' + str(realTaskNumber) + '/' - htmlPath = dirPath + 'oppgave.html' - jsPath = dirPath + 'oppgave.js' + #Define variables + realTaskNumber = i+1 + dirPath = './oppgaver/oppgave' + str(realTaskNumber) + '/' + htmlPath = dirPath + 'oppgave.html' + jsPath = dirPath + 'oppgave.js' - #Make html file - with open('./task-template/oppgave.html', 'r') as file: - data = file.read() - data = data.replace("taskNumber", str(realTaskNumber)) - os.makedirs(dirPath) - with open(htmlPath, 'w') as file: - file.write(data) - - #Make js file - with open(jsPath, 'w') as file: - file.write('') + #Make html file + with open('./task-template/oppgave.html', 'r') as file: + data = file.read() + data = data.replace("taskNumber", str(realTaskNumber)) + os.makedirs(dirPath) + with open(htmlPath, 'w') as file: + file.write(data) + + #Make js file + with open(jsPath, 'w') as file: + file.write('') - #Add to JSON - jsonData['tasks'].append({ - 'name': 'Oppgave ' + str(realTaskNumber), - 'path': str(htmlPath) + #Add to JSON + jsonData['tasks'].append({ + 'name': 'Oppgave ' + str(realTaskNumber), + 'path': str(htmlPath) }) jsVariable = "const tasks = " + json.dumps(jsonData) #Update JSON with open(jsonPath, 'w') as file: - file.write(jsVariable) + file.write(jsVariable) #Delete the template deleteBool = input('Delete the template? (yes/No): ') if deleteBool == "yes": - rmtree('./task-template', ignore_errors=True) + rmtree('./task-template', ignore_errors=True) #Delete itself deleteBool = input('Delete the program? (yes/No): ') if deleteBool == "yes": - os.remove(argv[0]) \ No newline at end of file + os.remove(argv[0]) \ No newline at end of file diff --git a/test-template-generator/index.html b/test-template-generator/index.html index 040759f..b882bbe 100644 --- a/test-template-generator/index.html +++ b/test-template-generator/index.html @@ -1,21 +1,19 @@ - - - - + + + + Test - + - - - + +

Test

-
+
- - - \ No newline at end of file + + diff --git a/test-template-generator/task-template/oppgave.html b/test-template-generator/task-template/oppgave.html index d0dc9c3..466686a 100644 --- a/test-template-generator/task-template/oppgave.html +++ b/test-template-generator/task-template/oppgave.html @@ -1,20 +1,18 @@ - - - - + + + + Oppgave taskNumber - + - - - + +

Oppgave taskNumber

- - - \ No newline at end of file + +