Reformat
This commit is contained in:
@@ -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) {
|
function almostIncreasingSequence(sequence) {
|
||||||
let decreaseCounter=0;
|
let decreaseCounter = 0;
|
||||||
for (elements in sequence){
|
for (elements in sequence){
|
||||||
if (sequence[elements] > sequence[parseInt(elements)+1]) {
|
if (sequence[elements] > sequence[parseInt(elements) + 1]) {
|
||||||
decreaseCounter++;
|
decreaseCounter++;
|
||||||
if (decreaseCounter > 1) {
|
if (decreaseCounter > 1) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return true;
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Test */
|
/* Test */
|
||||||
console.log("[1,3,2,1]" + " -> " + almostIncreasingSequence([1,3,2,1]));
|
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] -> " + ${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] -> " + ${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]));
|
console.log(`[1,3,2,4,5,6,8,2] -> " + ${almostIncreasingSequence([1,3,2,4,5,6,8,2])}`);
|
@@ -1,20 +1,19 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
|
||||||
<title>Oppgave X</title>
|
<title>Oppgave X</title>
|
||||||
<link rel="stylesheet" href="../../../../resources/css/main.css">
|
<link rel="stylesheet" href="../../../../resources/css/main.css" />
|
||||||
<script async src="./script.js"></script>
|
<script async src="./script.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
<h1>Oppgave X</h1>
|
||||||
<h1>Oppgave X</h1>
|
|
||||||
|
<div class="center">
|
||||||
|
|
||||||
<div class="center">
|
</div>
|
||||||
|
|
||||||
</div>
|
</body>
|
||||||
|
</html>
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
|
@@ -15,42 +15,42 @@ jsonData['tasks'] = []
|
|||||||
numberOfTasks = int(input('Number of tasks: '))
|
numberOfTasks = int(input('Number of tasks: '))
|
||||||
|
|
||||||
for i in range(0, numberOfTasks):
|
for i in range(0, numberOfTasks):
|
||||||
#Define variables
|
#Define variables
|
||||||
realTaskNumber = i+1
|
realTaskNumber = i+1
|
||||||
dirPath = './oppgaver/oppgave' + str(realTaskNumber) + '/'
|
dirPath = './oppgaver/oppgave' + str(realTaskNumber) + '/'
|
||||||
htmlPath = dirPath + 'oppgave.html'
|
htmlPath = dirPath + 'oppgave.html'
|
||||||
jsPath = dirPath + 'oppgave.js'
|
jsPath = dirPath + 'oppgave.js'
|
||||||
|
|
||||||
#Make html file
|
#Make html file
|
||||||
with open('./task-template/oppgave.html', 'r') as file:
|
with open('./task-template/oppgave.html', 'r') as file:
|
||||||
data = file.read()
|
data = file.read()
|
||||||
data = data.replace("taskNumber", str(realTaskNumber))
|
data = data.replace("taskNumber", str(realTaskNumber))
|
||||||
os.makedirs(dirPath)
|
os.makedirs(dirPath)
|
||||||
with open(htmlPath, 'w') as file:
|
with open(htmlPath, 'w') as file:
|
||||||
file.write(data)
|
file.write(data)
|
||||||
|
|
||||||
#Make js file
|
#Make js file
|
||||||
with open(jsPath, 'w') as file:
|
with open(jsPath, 'w') as file:
|
||||||
file.write('')
|
file.write('')
|
||||||
|
|
||||||
#Add to JSON
|
#Add to JSON
|
||||||
jsonData['tasks'].append({
|
jsonData['tasks'].append({
|
||||||
'name': 'Oppgave ' + str(realTaskNumber),
|
'name': 'Oppgave ' + str(realTaskNumber),
|
||||||
'path': str(htmlPath)
|
'path': str(htmlPath)
|
||||||
})
|
})
|
||||||
|
|
||||||
jsVariable = "const tasks = " + json.dumps(jsonData)
|
jsVariable = "const tasks = " + json.dumps(jsonData)
|
||||||
|
|
||||||
#Update JSON
|
#Update JSON
|
||||||
with open(jsonPath, 'w') as file:
|
with open(jsonPath, 'w') as file:
|
||||||
file.write(jsVariable)
|
file.write(jsVariable)
|
||||||
|
|
||||||
#Delete the template
|
#Delete the template
|
||||||
deleteBool = input('Delete the template? (yes/No): ')
|
deleteBool = input('Delete the template? (yes/No): ')
|
||||||
if deleteBool == "yes":
|
if deleteBool == "yes":
|
||||||
rmtree('./task-template', ignore_errors=True)
|
rmtree('./task-template', ignore_errors=True)
|
||||||
|
|
||||||
#Delete itself
|
#Delete itself
|
||||||
deleteBool = input('Delete the program? (yes/No): ')
|
deleteBool = input('Delete the program? (yes/No): ')
|
||||||
if deleteBool == "yes":
|
if deleteBool == "yes":
|
||||||
os.remove(argv[0])
|
os.remove(argv[0])
|
@@ -1,21 +1,19 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
|
||||||
<title>Test</title>
|
<title>Test</title>
|
||||||
<link rel="stylesheet" href="./resources/css/main.css">
|
<link rel="stylesheet" href="./resources/css/main.css" />
|
||||||
<script src="./resources/js/tasksJSON.js"></script>
|
<script src="./resources/js/tasksJSON.js"></script>
|
||||||
<script async src="./resources/js/linkConnector.js"></script>
|
<script async src="./resources/js/linkConnector.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<h1>Test</h1>
|
<h1>Test</h1>
|
||||||
|
|
||||||
<div class="center">
|
<div class="center">
|
||||||
<div class="textboxGrid"></div>
|
<div class="textboxGrid"></div>
|
||||||
</div>
|
</div>
|
||||||
|
</body>
|
||||||
</body>
|
</html>
|
||||||
</html>
|
|
||||||
|
@@ -1,20 +1,18 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
|
||||||
<title>Oppgave taskNumber</title>
|
<title>Oppgave taskNumber</title>
|
||||||
<link rel="stylesheet" href="../../resources/css/main.css">
|
<link rel="stylesheet" href="../../resources/css/main.css" />
|
||||||
<script async src="./script.js"></script>
|
<script async src="./script.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<h1>Oppgave taskNumber</h1>
|
<h1>Oppgave taskNumber</h1>
|
||||||
|
|
||||||
<div class="center">
|
<div class="center">
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
</body>
|
||||||
</body>
|
</html>
|
||||||
</html>
|
|
||||||
|
Reference in New Issue
Block a user