-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTOP_ProblemSolving.html
More file actions
112 lines (83 loc) · 4.08 KB
/
TOP_ProblemSolving.html
File metadata and controls
112 lines (83 loc) · 4.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Problem Solving</title>
</head>
<body>
<p>
<a href="https://www.theodinproject.com/paths/foundations/courses/foundations/lessons/problem-solving"> <!--Link to module-->
Problem Solving <!--Name of module-->
</a>
</p>
<p> The work produced here is a product of learning done through the embedded link</p> <!--Disclaimer-->
<!--Sandbox div objects below-->
<script>
/* Notes and sample scripts */
// Problem solving is the core of what a developer does
// Def: writing original programs that perform a particular set of task
// and meet all stated constraints. - V. Anton Spraul (Think like a programmer)
// Best way to build this skill is producing a lot of programs
// PRACTICE!
// Steps in problem solving
// explain psuedo code and its use
// Break down problems into subproblems
// Explain
// Understand the problem, write it down in plain english, draw diagrams, etc - so that it makes sense
// Plan
// What steps are or goals are you going to need to solve?
// Is there a UI? what does it look like? functionality? Sketch it!
// What inputs are needed? will the user enter data or will you draw it from another source?
// What is the desired output? what do you want to present?
// What are the steps that need to be taken to get the desired output from the given inputs.
//Psuedo Code
// write the recipe for building the algorithm
// Take the time to slow down and work out the logic of your algorithm in plain language
// Once the logic is sorted out, moving to code and finding the appropriate functions and interactions will be smoother
// Divide & Conquer
// Pick the small and simple subproblems and build from there.
// Simple means you already know the answer (or are close), after that simple
// means the problem is independent of others being solved
// Its ok to not know all the steps, building an incomplete algo is fine
// this will make bridging the steps that are unknown easier
//connect the dots to arrive at the big solution
// Don't start with the big problem!
// Example - FizzBuzz
// Explain
// write a program that prints number from 1 to the input value
// for multiples of 3 print 'fizz' instead of the number
// for multiples of 5 print 'buzz' instead of the number
// for multiples of both print 'fizzbuzz' instead of the number
// Plan
// interface? Command line program
// input? user input from command line
// output? desired output is:
// list of numbers from 1 to input
// numbers divis by 3, replace with fizz
// numbers divis by 5, replace with buzz
// numbers divis by both, replace with fizzbuzz
// Pseudo Code
// user inputs a number
// loop from 1 to entered number
// if current num is divis by 3 then print 'Fizz'
// if current num is divis by 5 then print 'Buzz'
// if current num is visis by both then print 'FizzBuzz'
// otherwise print current number
// Divide & Conquer
/*
let answer = parseInt(prompt('Please enter your FizzBuzz number'));
for (let i = 1; i <= answer; i++) {
if (i % 3 ===0 && i % 5 === 0) { // must come first otherwise program will check valid for a single # and move on.
console.log('FizzBuzz');
} else if (i % 5 === 0) {
console.log('Buzz');
} else if (i % 3 === 0){
console.log('Fizz');
} else {
console.log(i);
}
}
*/
</script>
</body>
</html>