Cody

# Problem 1385. Perimeter

Solution 1743106

Submitted on 5 Mar 2019 by Martin C.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Pass
xy=[0,0; 1,0; 1,1; 0,1; 0,0]; err=(abs(perimeter1(xy)-4)/(4))*100; assert(err<.1)

d = 1 0 0 1 -1 0 0 -1 n = 1 1 1 1 L = 4

2   Pass
t=[0:pi/100:2*pi,0]'; xy=[cos(t),sin(t)]; err=(abs(perimeter1(xy)-2*pi)/(2*pi))*100; assert(err<.1)

d = -0.0005 0.0314 -0.0015 0.0314 -0.0025 0.0313 -0.0034 0.0312 -0.0044 0.0311 -0.0054 0.0309 -0.0064 0.0308 -0.0073 0.0305 -0.0083 0.0303 -0.0092 0.0300 -0.0102 0.0297 -0.0111 0.0294 -0.0120 0.0290 -0.0129 0.0286 -0.0138 0.0282 -0.0147 0.0278 -0.0156 0.0273 -0.0164 0.0268 -0.0172 0.0263 -0.0181 0.0257 -0.0189 0.0251 -0.0196 0.0245 -0.0204 0.0239 -0.0211 0.0232 -0.0219 0.0226 -0.0226 0.0219 -0.0232 0.0211 -0.0239 0.0204 -0.0245 0.0196 -0.0251 0.0189 -0.0257 0.0181 -0.0263 0.0172 -0.0268 0.0164 -0.0273 0.0156 -0.0278 0.0147 -0.0282 0.0138 -0.0286 0.0129 -0.0290 0.0120 -0.0294 0.0111 -0.0297 0.0102 -0.0300 0.0092 -0.0303 0.0083 -0.0305 0.0073 -0.0308 0.0064 -0.0309 0.0054 -0.0311 0.0044 -0.0312 0.0034 -0.0313 0.0025 -0.0314 0.0015 -0.0314 0.0005 -0.0314 -0.0005 -0.0314 -0.0015 -0.0313 -0.0025 -0.0312 -0.0034 -0.0311 -0.0044 -0.0309 -0.0054 -0.0308 -0.0064 -0.0305 -0.0073 -0.0303 -0.0083 -0.0300 -0.0092 -0.0297 -0.0102 -0.0294 -0.0111 -0.0290 -0.0120 -0.0286 -0.0129 -0.0282 -0.0138 -0.0278 -0.0147 -0.0273 -0.0156 -0.0268 -0.0164 -0.0263 -0.0172 -0.0257 -0.0181 -0.0251 -0.0189 -0.0245 -0.0196 -0.0239 -0.0204 -0.0232 -0.0211 -0.0226 -0.0219 -0.0219 -0.0226 -0.0211 -0.0232 -0.0204 -0.0239 -0.0196 -0.0245 -0.0189 -0.0251 -0.0181 -0.0257 -0.0172 -0.0263 -0.0164 -0.0268 -0.0156 -0.0273 -0.0147 -0.0278 -0.0138 -0.0282 -0.0129 -0.0286 -0.0120 -0.0290 -0.0111 -0.0294 -0.0102 -0.0297 -0.0092 -0.0300 -0.0083 -0.0303 -0.0073 -0.0305 -0.0064 -0.0308 -0.0054 -0.0309 -0.0044 -0.0311 -0.0034 -0.0312 -0.0025 -0.0313 -0.0015 -0.0314 -0.0005 -0.0314 0.0005 -0.0314 0.0015 -0.0314 0.0025 -0.0313 0.0034 -0.0312 0.0044 -0.0311 0.0054 -0.0309 0.0064 -0.0308 0.0073 -0.0305 0.0083 -0.0303 0.0092 -0.0300 0.0102 -0.0297 0.0111 -0.0294 0.0120 -0.0290 0.0129 -0.0286 0.0138 -0.0282 0.0147 -0.0278 0.0156 -0.0273 0.0164 -0.0268 0.0172 -0.0263 0.0181 -0.0257 0.0189 -0.0251 0.0196 -0.0245 0.0204 -0.0239 0.0211 -0.0232 0.0219 -0.0226 0.0226 -0.0219 0.0232 -0.0211 0.0239 -0.0204 0.0245 -0.0196 0.0251 -0.0189 0.0257 -0.0181 0.0263 -0.0172 0.0268 -0.0164 0.0273 -0.0156 0.0278 -0.0147 0.0282 -0.0138 0.0286 -0.0129 0.0290 -0.0120 0.0294 -0.0111 0.0297 -0.0102 0.0300 -0.0092 0.0303 -0.0083 0.0305 -0.0073 0.0308 -0.0064 0.0309 -0.0054 0.0311 -0.0044 0.0312 -0.0034 0.0313 -0.0025 0.0314 -0.0015 0.0314 -0.0005 0.0314 0.0005 0.0314 0.0015 0.0313 0.0025 0.0312 0.0034 0.0311 0.0044 0.0309 0.0054 0.0308 0.0064 0.0305 0.0073 0.0303 0.0083 0.0300 0.0092 0.0297 0.0102 0.0294 0.0111 0.0290 0.0120 0.0286 0.0129 0.0282 0.0138 0.0278 0.0147 0.0273 0.0156 0.0268 0.0164 0.0263 0.0172 0.0257 0.0181 0.0251 0.0189 0.0245 0.0196 0.0239 0.0204 0.0232 0.0211 0.0226 0.0219 0.0219 0.0226 0.0211 0.0232 0.0204 0.0239 0.0196 0.0245 0.0189 0.0251 0.0181 0.0257 0.0172 0.0263 0.0164 0.0268 0.0156 0.0273 0.0147 0.0278 0.0138 0.0282 0.0129 0.0286 0.0120 0.0290 0.0111 0.0294 0.0102 0.0297 0.0092 0.0300 0.0083 0.0303 0.0073 0.0305 0.0064 0.0308 0.0054 0.0309 0.0044 0.0311 0.0034 0.0312 0.0025 0.0313 0.0015 0.0314 0.0005 0.0314 0 0.0000 n = Columns 1 through 18 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 Columns 19 through 36 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 Columns 37 through 54 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 Columns 55 through 72 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 Columns 73 through 90 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 Columns 91 through 108 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 Columns 109 through 126 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 Columns 127 through 144 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 Columns 145 through 162 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 Columns 163 through 180 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 Columns 181 through 198 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 Columns 199 through 201 0.0314 0.0314 0.0000 L = 6.2829

3   Pass
t=[0:pi/100:pi,0]'; xy=[cos(t),sin(t)]; err=(abs(perimeter1(xy)-(pi+2))/(2+pi))*100; assert(err<.1)

d = -0.0005 0.0314 -0.0015 0.0314 -0.0025 0.0313 -0.0034 0.0312 -0.0044 0.0311 -0.0054 0.0309 -0.0064 0.0308 -0.0073 0.0305 -0.0083 0.0303 -0.0092 0.0300 -0.0102 0.0297 -0.0111 0.0294 -0.0120 0.0290 -0.0129 0.0286 -0.0138 0.0282 -0.0147 0.0278 -0.0156 0.0273 -0.0164 0.0268 -0.0172 0.0263 -0.0181 0.0257 -0.0189 0.0251 -0.0196 0.0245 -0.0204 0.0239 -0.0211 0.0232 -0.0219 0.0226 -0.0226 0.0219 -0.0232 0.0211 -0.0239 0.0204 -0.0245 0.0196 -0.0251 0.0189 -0.0257 0.0181 -0.0263 0.0172 -0.0268 0.0164 -0.0273 0.0156 -0.0278 0.0147 -0.0282 0.0138 -0.0286 0.0129 -0.0290 0.0120 -0.0294 0.0111 -0.0297 0.0102 -0.0300 0.0092 -0.0303 0.0083 -0.0305 0.0073 -0.0308 0.0064 -0.0309 0.0054 -0.0311 0.0044 -0.0312 0.0034 -0.0313 0.0025 -0.0314 0.0015 -0.0314 0.0005 -0.0314 -0.0005 -0.0314 -0.0015 -0.0313 -0.0025 -0.0312 -0.0034 -0.0311 -0.0044 -0.0309 -0.0054 -0.0308 -0.0064 -0.0305 -0.0073 -0.0303 -0.0083 -0.0300 -0.0092 -0.0297 -0.0102 -0.0294 -0.0111 -0.0290 -0.0120 -0.0286 -0.0129 -0.0282 -0.0138 -0.0278 -0.0147 -0.0273 -0.0156 -0.0268 -0.0164 -0.0263 -0.0172 -0.0257 -0.0181 -0.0251 -0.0189 -0.0245 -0.0196 -0.0239 -0.0204 -0.0232 -0.0211 -0.0226 -0.0219 -0.0219 -0.0226 -0.0211 -0.0232 -0.0204 -0.0239 -0.0196 -0.0245 -0.0189 -0.0251 -0.0181 -0.0257 -0.0172 -0.0263 -0.0164 -0.0268 -0.0156 -0.0273 -0.0147 -0.0278 -0.0138 -0.0282 -0.0129 -0.0286 -0.0120 -0.0290 -0.0111 -0.0294 -0.0102 -0.0297 -0.0092 -0.0300 -0.0083 -0.0303 -0.0073 -0.0305 -0.0064 -0.0308 -0.0054 -0.0309 -0.0044 -0.0311 -0.0034 -0.0312 -0.0025 -0.0313 -0.0015 -0.0314 -0.0005 -0.0314 2.0000 -0.0000 n = Columns 1 through 18 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 Columns 19 through 36 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 Columns 37 through 54 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 Columns 55 through 72 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 Columns 73 through 90 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 Columns 91 through 101 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 0.0314 2.0000 L = 5.1415

4   Pass
side=rand; x=side*[-1 -0.5 0.5 1 0.5 -0.5 -1]; y=side*sqrt(3)*[0 -0.5 -0.5 0 0.5 0.5 0]; xy=[x',y']; err=(abs(perimeter1(xy)-(6*side))/(6*side))*100; assert(err<.1)

d = 0.3200 -0.5543 0.6400 0 0.3200 0.5543 -0.3200 0.5543 -0.6400 0 -0.3200 -0.5543 n = 0.6400 0.6400 0.6400 0.6400 0.6400 0.6400 L = 3.8402