Cody

Solution 1374791

Submitted on 10 Dec 2017
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

This solution is outdated. To rescore this solution, sign in.

Test Suite

Test Status Code Input and Output
1   Pass
assessFunctionAbsence({'regexp','regexpi','regexprep','str2num'},'FileName','fivesteps.m') assert(isempty(regexp(fileread('fivesteps.m'),'assert'))); [~,~]=system('rm freepass*');

2   Pass
%lines=textread('fivesteps.m','%s'); %id=str2num(regexp(lines{end},'\d+','match','once')); %assert(~ismember(id,[3430216]),'Please submit a valid non-cheating solution and ask the problem author to manually evaluate it'); % [3931805,3397427,3430216]

3   Pass
% X,Y X<Y between 2 and 100 [x,y]=find(triu(ones(100),1)); z=[x y]; valid=all(z>1,2); assert(fivesteps(z(valid,:))==true);

4   Pass
% X,Y X<Y between 2 and 60 [x,y]=find(triu(ones(60),1)); z=[x y]; valid=all(z>1,2); assert(fivesteps(z(valid,:))==false);

5   Pass
% X,Y X<Y between 2 and 200 [x,y]=find(triu(ones(200),1)); z=[x y]; valid=all(z>1,2); assert(fivesteps(z(valid,:))==true);

6   Pass
% X,Y X<Y between 2 and 1680 [x,y]=find(triu(ones(1680),1)); z=[x y]; valid=all(z>1,2); assert(fivesteps(z(valid,:))==true);

7   Pass
% X,Y X<Y between 2 and 1700 [x,y]=find(triu(ones(1700),1)); z=[x y]; valid=all(z>1,2); assert(fivesteps(z(valid,:))==false);

8   Pass
% X,Y X<Y between 1 and 20 [x,y]=find(triu(ones(20),1)); z=[x y]; valid=all(z>=1,2); assert(fivesteps(z(valid,:))==false);

9   Pass
% X,Y X<Y between 1 and 30 [x,y]=find(triu(ones(30),1)); z=[x y]; valid=all(z>=1,2); assert(fivesteps(z(valid,:))==true);

10   Pass
% X,Y X<Y between 1 and 40 [x,y]=find(triu(ones(40),1)); z=[x y]; valid=all(z>=1,2); assert(fivesteps(z(valid,:))==false);

11   Pass
% X,Y X<Y between 3 and 5000 [x,y]=find(triu(ones(3000),1)); z=[x y]; valid=all(z>=3,2); assert(fivesteps(z(valid,:))==true);

12   Pass
% X,Y X<Y between 3 and 100 [x,y]=find(triu(ones(100),1)); z=[x y]; valid=all(z>=3,2); assert(fivesteps(z(valid,:))==false);

13   Pass
% X,Y X<Y even between 2 and 40 [x,y]=meshgrid(2:2:40); z=[x(:) y(:)]; valid=y>x; assert(fivesteps(z(valid,:))==false);

14   Pass
% X,Y X<Y odd between 1 and 1000 [x,y]=meshgrid(1:2:1000); z=[x(:) y(:)]; valid=y>x; assert(fivesteps(z(valid,:))==true);

15   Pass
% X,Y X<Y non-primes between 1 and 50 [x,y]=meshgrid(setdiff(1:50,primes(50))); z=[x(:) y(:)]; valid=y>x; assert(fivesteps(z(valid,:))==true);

16   Pass
% X,Y X<Y primes between 1 and 50 [x,y]=meshgrid(primes(50)); z=[x(:) y(:)]; valid=y>x; assert(fivesteps(z(valid,:))==false);

ans = 'Empty'

17   Pass
% X,Y X<Y between 3 and 100 [x,y]=find(triu(ones(randi([10,100])),1)); z=[x y]; valid=all(z>2,2); assert(fivesteps(z(valid,:))==false);

18   Pass
% X,Y X<Y between 1 and 100 [x,y]=find(triu(ones(randi([40,100])),1)); z=[x y]; valid=all(z>=1,2); assert(fivesteps(z(valid,:))==false);

19   Pass
% X,Y X<Y between 2 and 100 [x,y]=find(triu(ones(randi([62,100])),1)); z=[x y]; valid=all(z>1,2); assert(fivesteps(z(valid,:))==true);

20   Pass
% X,Y X<Y between 2 and 100 [x,y]=find(triu(ones(randi([10,61])),1)); z=[x y]; valid=all(z>1,2); assert(fivesteps(z(valid,:))==false);

21   Pass
% X,Y X<Y in 3 5 12 18 20 28 30 % Possible solutions after step 1: [3,20] [3,30] [5,18] [5,28] [18,30] [20,28] % Possible solutions after step 2: [3,30] [5,18] % Possible solutions after step 3: [5,18] % Possible solutions after step 4: [5,18] % Possible solutions after step 5: [5,18] [x,y]=meshgrid([3 5 12 18 20 28 30]); z=[x(:) y(:)]; valid=y>x; assert(fivesteps(z(valid,:))==true);

22   Pass
% X,Y X<Y in 3 5 12 15 28 30 % Possible solutions after step 1: [3,30] [5,28] % Possible solutions after step 2: [x,y]=meshgrid([3 5 12 15 28 30]); z=[x(:) y(:)]; valid=y>x; assert(fivesteps(z(valid,:))==false);

ans = 'Empty'

23   Pass
% X,Y X<Y in 2 4 6 8 12 16 18 % Possible solutions after step 1: [2,8] [2,12] [2,16] [2,18] [4,6] [4,16] [4,18] [6,8] [6,12] [6,16] [6,18] [8,12] [8,16] % Possible solutions after step 2: [2,12] [4,6] [4,18] [6,12] [6,16] [8,12] % Possible solutions after step 3: [2,12] [4,18] [6,12] [6,16] % Possible solutions after step 4: [2,12] [6,16] % Possible solutions after step 5: [2,12] [6,16] [x,y]=meshgrid([2 4 6 8 12 16 18]); z=[x(:) y(:)]; valid=y>x; assert(fivesteps(z(valid,:))==false);

24   Pass
% X,Y X<Y in 4 6 8 12 16 18 % Possible solutions after step 1: [4,16] [4,18] [6,16] [6,18] [8,12] [8,16] % Possible solutions after step 2: [6,16] [8,12] % Possible solutions after step 3: [6,16] % Possible solutions after step 4: [6,16] % Possible solutions after step 5: [6,16] [x,y]=meshgrid([4 6 8 12 16 18]); z=[x(:) y(:)]; valid=y>x; assert(fivesteps(z(valid,:))==true);

25   Pass
% X,Y X<Y in 2 3 10 14 15 20 21 % Possible solutions after step 1: [2,15] [2,21] [3,14] [3,20] [3,21] [10,14] [14,21] [15,20] % Possible solutions after step 2: [2,21] [3,14] % Possible solutions after step 3: [3,14] % Possible solutions after step 4: [3,14] % Possible solutions after step 5: [3,14] [x,y]=meshgrid([2 3 10 14 15 20 21]); z=[x(:) y(:)]; valid=y>x; assert(fivesteps(z(valid,:))==true);

26   Pass
% X,Y X<Y in 2 3 5 8 10 14 15 20 21 % Possible solutions after step 1: [2,15] [2,20] [2,21] [3,10] [3,14] [3,15] [3,20] [3,21] [5,8] [5,20] [8,10] [8,14] [8,15] [8,21] [10,14] [10,15] [14,15] [14,21] [15,20] % Possible solutions after step 2: [2,15] [2,20] [2,21] [3,10] [3,14] [5,8] % Possible solutions after step 3: [2,15] [3,10] [3,14] [5,8] % Possible solutions after step 4: [3,14] [5,8] % Possible solutions after step 5: [3,14] [5,8] [x,y]=meshgrid([2 3 5 8 10 14 15 20 21]); z=[x(:) y(:)]; valid=y>x; assert(fivesteps(z(valid,:))==false);

27   Fail
% a few random cases to discourage look-up table solutions lines=textread('fivesteps.m','%s'); id=str2num(regexp(lines{end},'\d+','match','once')); if ~ismember(id,[6316133,3397427,7164325,1948447,3021298,6472157]) % badge-safe data={[2 5 6 7 9 10 12 16 23 25 26 27 28 29 31],[49 94 97 109 112 113 154 157 158 161 184 187 188 191 193 199 202 203 206 208 209 214 217 218 221 223 224 225];... [2 4 6 9 10 11 12 13 14 20 22 23 25 26 28],[49 64 79 81 109 111 113 124 125 126 128 129 154 156 158 159 161 169 171 173 174 176 177 184 186 188 189 191 192 193 199 201 203 204 206 207 208 209 214 216 218 219 221 222 223 224 225];... [2 3 4 6 7 9 10 11 12 14 19 20 21 24 25 28 31],[19 35 87 89 108 109 121 124 126 127 142 144 145 155 156 171 174 175 177 180 206 215 223 230 240 241 245 247 253 257 262 263 264 270 271 274 278 279 280 281 285 288 289];... [2 4 5 6 8 9 10 11 15 16 18 19 20 21 23 24 25 26 27 28 29],[45 66 67 87 109 111 150 152 153 171 174 177 214 219 221 234 235 237 240 242 243 256 258 261 263 264 265 276 277 279 282 284 285 286 287 297 298 300 303 305 306 307 308 309 319 321 324 326 327 328 329 330 331 339 340 342 345 347 348 349 350 351 352 353 360 361 363 366 368 369 370 371 372 373 374 375 381 382 384 387 389 390 391 392 393 394 395 396 397 402 403 405 408 410 411 412 413 414 415 416 417 418 419 423 424 426 429 431 432 433 434 435 436 437 438 439 440 441];... [2 4 5 6 8 10 11 12 14 16 17 25 27 28 29 30 31],[1 54 89 109 125 137 140 144 145 154 156 171 177 179 181 188 194 196 198 199 205 208 211 213 216 217 222 225 228 229 230 232 233 234 235 239 245 247 248 250 251 252 253 256 262 264 266 267 268 269 270 271 273 279 281 283 284 285 286 287 288 289];... [2 5 6 7 10 14 15 16 17 20 21 23 24 25 29 30],[120 152 154 168 170 171 184 185 186 187 188 200 202 203 204 205 216 218 219 220 221 222 232 234 235 236 237 238 239 248 250 251 252 253 254 255 256];... [4 5 7 8 9 11 12 15 16 17 20 21 24 27 28 30],[18 68 82 85 86 98 100 102 103 116 118 119 120 129 130 136 146 150 151 152 153 162 166 168 169 171 194 196 198 199 202 203 205 212 226 230 231 232 233 235 237 239 244 249 250];... [2 3 4 6 8 9 11 12 13 15 17 19 20 21 22 23 25 28 29 31],[22 43 102 122 123 127 147 148 162 163 168 169 182 187 188 190 202 203 207 208 209 210 211 222 223 227 228 229 230 231 232 242 243 247 248 249 250 251 252 253 262 263 267 268 269 270 271 272 273 274 282 283 287 288 289 290 291 292 293 294 295 302 303 307 308 309 310 311 312 313 314 315 316 322 323 327 328 329 330 331 332 333 334 335 336 337 342 343 347 348 349 350 351 352 353 354 355 356 357 358 362 363 367 368 369 370 371 372 373 374 375 376 377 378 379 382 383 387 388 389 390 391 392 393 394 395 396 397 398 399 400];... [3 4 5 6 8 9 10 11 13 14 18 19 21 22 23 25 26 28 29 30 31],[111 150 153 154 155 174 176 177 195 197 198 199 216 218 219 220 221 237 239 240 242 243 258 260 261 262 263 264 265 279 281 282 283 284 285 286 287 300 302 303 304 305 306 307 308 309 321 323 324 325 326 327 328 329 330 331 342 344 345 346 347 348 349 350 351 352 353 363 365 366 367 368 369 370 371 372 373 374 375 384 386 387 388 389 390 391 392 393 394 395 396 397 405 407 408 409 410 411 412 413 414 415 416 417 418 419 426 428 429 430 431 432 433 434 435 436 437 438 439 440 441];... [2 4 5 6 8 10 11 13 14 15 16 17 20 22 28 31],[51 52 83 100 103 132 135 136 137 148 151 153 154 168 183 185 187 188 196 199 200 201 202 204 205 212 215 217 218 220 221 222 228 231 232 233 234 236 237 238 239 244 247 249 250 252 253 254 255 256];... [2 4 5 8 10 11 12 15 20 21 22 26 28 29 30 31],[1 65 82 103 119 120 129 145 151 152 154 177 183 184 186 188 193 199 200 204 205 209 215 216 218 220 221 222 225 231 232 234 236 237 238 239 241 247 248 250 252 253 254 255 256];... [2 4 5 7 8 12 13 17 18 19 22 26 28 29 30],[49 64 65 109 110 113 124 125 128 129 139 140 143 144 145 154 155 158 159 160 161 184 185 188 189 191 193 199 200 203 204 205 206 208 209];... [2 3 6 8 9 12 15 17 18 19 21 22 23 24 25 27 28 29 30],[81 96 119 121 137 138 140 141 157 159 160 161 176 180 195 197 198 199 201 214 216 217 218 220 221 233 235 237 239 240 241 254 255 256 258 259 260 261 271 273 274 275 277 278 279 280 281 290 292 293 294 296 297 298 299 300 301 309 311 312 313 315 316 317 318 319 320 321 328 330 331 332 334 335 336 337 338 339 340 341 347 349 350 351 352 353 354 355 356 357 358 359 360 361];... [6 7 9 11 17 18 21 22 23 27 28 29],[53 101 105 125 129 131 137 141 143 144];... [2 3 4 6 8 9 11 12 15 16 18 19 20 22 24 25 27 28 29 30],[22 81 83 102 103 121 122 127 147 148 161 164 166 167 168 188 189 190 202 203 208 210 211 222 231 232 242 247 248 250 251 252 253 262 263 267 268 269 270 271 272 273 274 285 287 288 290 291 292 293 294 295 310 314 315 316 322 323 327 328 330 331 332 333 334 335 336 337 347 348 350 351 352 353 354 355 356 357 358 362 367 368 370 371 372 373 374 375 376 377 378 379 382 387 388 390 391 392 393 394 395 396 397 398 399 400];... [3 4 5 6 10 11 13 17 20 21 25 26 30],[57 70 71 96 97 99 161 162 164 169];... [2 3 4 10 12 15 16 18 19 20 21 22 25 26 28 30 31],[1 52 55 120 123 127 140 144 145 157 161 162 163 171 174 178 179 180 181 188 191 195 196 197 198 199 205 208 212 213 214 215 216 217 222 225 229 230 231 232 233 234 235 239 242 246 247 248 249 250 251 252 253 256 259 263 264 266 267 268 269 270 271 273 276 280 281 282 283 284 285 286 287 288 289];... [2 4 5 7 10 15 16 18 20 24 25 27 28 29 30 31],[17 18 82 86 98 102 103 114 118 119 120 146 150 151 152 154 178 182 183 186 187 188 209 210 214 215 216 218 220 222 226 230 231 232 234 236 238 239 242 246 247 248 250 252 254 255 256];... [4 6 7 10 11 12 18 20 21 22 24 28],[26 27 40 51 52 88 97 99 101 103 105 112 113 117 123 124 131 133 134 136 139 141 143];... [2 3 4 6 8 10 12 14 15 17 18 19 20 21 22 24 26 28 30],[20 41 79 80 117 118 119 121 137 138 141 156 157 160 174 178 181 193 197 198 200 201 212 213 214 220 221 229 231 232 233 235 238 239 240 241 251 252 255 269 272 274 276 277 279 281 288 292 293 295 296 297 298 300 301 307 311 312 314 315 316 317 319 320 321 326 330 331 333 334 335 336 338 339 340 341 345 349 350 352 353 354 355 357 358 359 360 361];... [2 3 4 6 8 10 12 13 15 16 18 19 20 22 25 26 29],[18 35 37 70 72 88 91 105 106 107 121 124 139 140 141 144 145 160 161 163 173 176 179 180 181 190 195 197 207 208 209 211 214 215 216 217 224 227 230 231 232 234 235 241 247 248 249 251 252 253 258 259 260 275 278 281 282 283 285 286 287 289];... [3 4 5 8 9 12 14 21 23 24 28 30],[1 49 53 97 101 105 121 125 129 131];... [2 3 6 7 8 9 12 13 15 16 18 19 22 23 24 26 28],[52 55 89 103 120 124 140 145 157 159 174 179 181 191 196 198 199 208 213 215 216 217 230 232 235 242 245 247 249 250 251 252 253 259 261 276 278];... [2 4 6 8 9 10 11 12 21 22 24 25 26 27 28 29 31],[1 19 37 55 73 86 87 89 90 104 121 123 124 125 127 137 139 140 141 144 145 155 159 172 174 178 179 181 188 189 190 192 194 195 198 199 205 206 207 208 212 215 216 217 222 224 226 227 239 241 242 243 246 247 249 250 251 253 256 257 258 259 260 263 264 266 267 268 270 271 273 274 275 276 277 280 281 283 284 285 287 288 289]}; for ndata=randi(size(data,1),1,20) a=data{ndata,1}; N=numel(a); A=zeros(N); A(data{ndata,2})=1;A=A|A'; if rand<.5, idx=find(A); else idx=find(~A); end [b,c]=ind2sub(size(A),idx(randi(numel(idx)))); d=a;d([b c])=[]; [x,y]=meshgrid(d); z=[x(:) y(:)]; valid=y>x; assert(fivesteps(z(valid,:))==A(b,c),'failed on d = %s (correct output = %s)',mat2str(d),mat2str(A(b,c))); end end

failed on d = [2 3 4 6 8 10 12 14 15 18 19 20 21 22 26 28 30] (correct output = true)

Suggested Problems

More from this Author38