Skip to content

Commit 437b493

Browse files
committed
Moves hotPotatoRedux to bonus
1 parent 73e120c commit 437b493

File tree

1 file changed

+24
-20
lines changed

1 file changed

+24
-20
lines changed

algo-time-complexity-review.js

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -119,26 +119,8 @@ function tournament(players){
119119
}
120120

121121

122-
/////////// Prompt 10 ///////////
123-
/////////// time complexity:
124-
function tournamentRedux(players){
125-
var results;
126-
if (players.length < 3){
127-
return players[0];
128-
} else {
129-
for (i = 0; i < players.length; i = i + 3){
130-
results.push(hotPotato([players[i], players[i+1], players[i+2]]));
131-
//assume hotPotato is a function where
132-
//the three players at a time must play hot potato for 5 minutes.
133-
//the player in the room holding the potato is the winner
134-
//and gets returned from the function
135-
}
136-
return tournament(results);
137-
}
138-
}
139-
140122

141-
/////////// Prompt 11 ///////////
123+
/////////// Prompt 10 ///////////
142124
/////////// time complexity:
143125
function allPasswords(allowedChars, maxLength){
144126
var results = [];
@@ -159,7 +141,7 @@ function allPasswords(allowedChars, maxLength){
159141
}
160142

161143

162-
/////////// Prompt 12 ///////////
144+
/////////// Prompt 11 ///////////
163145
/////////// time complexity:
164146
function findColor(quadTree, coordinates){
165147
//a quad tree is a tree where each node has 4 children
@@ -206,6 +188,28 @@ function findColor(quadTree, coordinates){
206188

207189

208190

191+
/////////// Bonus! ///////////
192+
/////////// time complexity:
193+
//this will require some math to determine
194+
195+
function tournamentRedux(players){
196+
var results;
197+
if (players.length < 3){
198+
return players[0];
199+
} else {
200+
for (i = 0; i < players.length; i = i + 3){
201+
results.push(hotPotato([players[i], players[i+1], players[i+2]]));
202+
//assume hotPotato is a function where
203+
//the three players at a time must play hot potato for 5 minutes.
204+
//the player in the room holding the potato is the winner
205+
//and gets returned from the function
206+
}
207+
return tournament(results);
208+
}
209+
}
210+
211+
212+
209213

210214

211215

0 commit comments

Comments
 (0)