University of Arizona
TEST A CITY THAT IS VERY CLOSE TO BOTH RESOURCES
|The following will be the same for each update | |
|as long as the city center or resource don't move. | |
|distanceToFood = 5 | |
|distanceToWood = 5 | |
|newFood=round(((637-5) % 636) / 56) + 1 |city = City("CloseVille", Point(470, 470)) |
|= 12 |p1 = Point(470, 475) |
|newPallets=round(((637-5.0) % 636) / 158 ) + 1 |p2 = Point(470, 475) |
|= 5 | |
| | |
|food pallets population |self.assertEqual(4, city.getFoodToEat()) |
|initial: 4 0 10 |self.assertEqual(0, city.getPalletsOfWood()) |
| |self.assertEqual(12, city.getPopulation()) |
|Given these two points, the distance is 5.0 | |
| | |
|. (470, 470) The city | |
|. (470, 475) Source of food and wood |p1 = Point(470, 475) |
| |p2 = Point(470, 475) |
| | |
|add 12food 5pallets | |
|16 5 |city.update(p1, p2) |
|4 2 14 |self.assertEqual(4, city.getFoodToEat()) |
| |self.assertEqual(2, city.getPalletsOfWood()) |
| |self.assertEqual(14, city.getPopulation()) |
| | |
|add 12food 5pallets | |
|16 7 | |
|4 4 18 |city.update(p1, p2) |
| |self.assertEqual(4, city.getFoodToEat()) |
| |self.assertEqual(4, city.getPalletsOfWood()) |
| |self.assertEqual(18, city.getPopulation()) |
|add 12food 5pallets | |
|16 9 | |
|4 6 22 | |
| |city.update(p1, p2) |
| |self.assertEqual(4, city.getFoodToEat()) |
| |self.assertEqual(6, city.getPalletsOfWood()) |
| |self.assertEqual(22, city.getPopulation()) |
| | |
# place all reds to the left
spot = 0
start = spot
for i in range(len(self.list)):
if self.list[i] == 'red':
temp = self.list[spot]
self.list[spot] = self.list[i]
self.list[i] = temp
spot += 1
self.drawLines(start)
start = spot
# sort orange after all 'red' colors and before all other colors
for i in range(len(self.list)):
if self.list[i] == 'orange':
temp = self.list[spot]
self.list[spot] = self.list[i]
self.list[i] = temp
spot += 1
self.drawLines(start)
start = spot
'''
Compare sequential search to binary search by measuring how many seconds it takes
to search for every list element using both algorithms. The sequential search is done
by using Python's list method index(element) to return the index of element in a list.
The binary search is done with a function binarySearch(element, list)
Created on Nov 15, 2011
@author: mercer
'''
import datetime
import time
# Return the index of element in list or -1 if not found
def binarySearch(element, list):
left = 0
right = len(list)
mid = (left + right) // 2
while (left ................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related searches
- university of arizona salaries
- university of arizona salary list
- university of arizona salary 2018
- university of arizona financial
- university of arizona address tucson
- university of arizona admissions status
- university of arizona application 2020
- university of arizona arthritis center
- university of arizona rheumatology
- university of arizona body donation
- university of arizona employment
- university of arizona salary grades