Cody

# Problem 2126. Split bread like the Pharaohs - Egyptian fractions and greedy algorithm

Solution 2130359

Submitted on 16 Feb 2020
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   Fail
% Updated test suite to remove trivial solutions; % Small Vmin = 10; Vmax = 55; denom = floor(unique(egyptian_fraction(Vmin,Vmax))); egyptian_value = sum(1./denom); rel_tol = Vmin/Vmax*1e-6; actual_error = abs( egyptian_value - Vmin/Vmax ); assert(isequal(actual_error < rel_tol ,true))

a = 5 a = 1 a = 7 a = 6 a = 1 a = 0

Assertion failed.

2   Fail
% Pie Vmin = 113; Vmax = 355; denom = floor(unique(egyptian_fraction(Vmin,Vmax))); egyptian_value = sum(1./denom); rel_tol = Vmin/Vmax*1e-6; actual_error = abs( egyptian_value - Vmin/Vmax ); assert(isequal(actual_error < rel_tol ,true))

a = 16 a = 19 a = 22 a = 25 a = 28 a = 31 a = 34 a = 37 a = 40 a = 43 a = 46 a = 49 a = 52 a = 55 a = 58 a = 61 a = 64 a = 67 a = 70 a = 73 a = 76 a = 79 a = 82 a = 85 a = 88 a = 3 a = 7 a = 11 a = 15 a = 19 a = 23 a = 27 a = 31 a = 35 a = 39 a = 43 a = 47 a = 51 a = 55 a = 59 a = 63 a = 67 a = 0

Assertion failed.

3   Fail
% Ramanujan Vmin = 1023; Vmax = 1729; denom = floor(unique(egyptian_fraction(Vmin,Vmax))); egyptian_value = sum(1./denom); rel_tol = Vmin/Vmax*1e-6; actual_error = abs( egyptian_value - Vmin/Vmax ); assert(isequal(actual_error < rel_tol ,true))

a = 706 a = 707 a = 708 a = 709 a = 710 a = 711 a = 712 a = 713 a = 714 a = 715 a = 716 a = 717 a = 718 a = 719 a = 720 a = 721 a = 722 a = 723 a = 724 a = 725 a = 726 a = 727 a = 728 a = 729 a = 730 a = 731 a = 732 a = 733 a = 734 a = 735 a = 736 a = 737 a = 738 a = 739 a = 740 a = 741 a = 742 a = 743 a = 744 a = 745 a = 746 a = 747 a = 748 a = 749 a = 750 a = 751 a = 752 a = 753 a = 754 a = 755 a = 756 a = 757 a = 758 a = 759 a = 760 a = 761 a = 762 a = 763 a = 764 a = 765 a = 766 a = 767 a = 768 a = 769 a = 770 a = 771 a = 772 a = 773 a = 774 a = 775 a = 776 a = 777 a = 778 a = 779 a = 780 a = 781 a = 782 a = 783 a = 784 a = 785 a = 786 a = 787 a = 788 a = 789 a = 790 a = 791 a = 792 a = 793 a = 794 a = 795 a = 796 a = 797 a = 798 a = 799 a = 800 a = 801 a = 802 a = 803 a = 804 a = 805 a = 806 a = 807 a = 808 a = 809 a = 810 a = 811 a = 812 a = 813 a = 814 a = 815 a = 816 a = 817 a = 818 a = 819 a = 820 a = 821 a = 822 a = 823 a = 824 a = 825 a = 826 a = 827 a = 828 a = 829 a = 830 a = 831 a = 832 a = 833 a = 834 a = 835 a = 836 a = 837 a = 838 a = 839 a = 840 a = 841 a = 842 a = 843 a = 844 a = 845 a = 846 a = 847 a = 848 a = 849 a = 850 a = 851 a = 852 a = 853 a = 854 a = 855 a = 856 a = 857 a = 858 a = 859 a = 860 a = 861 a = 862 a = 863 a = 864 a = 1 a = 3 a = 5 a = 7 a = 9 a = 11 a = 13 a = 15 a = 17 a = 19 a = 21 a = 23 a = 25 a = 27 a = 29 a = 31 a = 33 a = 35 a = 37 a = 39 a = 41 a = 43 a = 45 a = 47 a = 49 a = 51 a = 53 a = 55 a = 57 a = 59 a = 61 a = 63 a = 65 a = 67 a = 69 a = 71 a = 73 a = 75 a = 77 a = 79 a = 81 a = 83 a = 85 a = 87 a = 89 a = 91 a = 93 a = 95 a = 97 a = 99 a = 101 a = 103 a = 105 a = 107 a = 109 a = 111 a = 113 a = 115 a = 117 a = 119 a = 121 a = 123 a = 125 a = 127 a = 129 a = 131 a = 133 a = 135 a = 137 a = 139 a = 141 a = 143 a = 145 a = 147 a = 149 a = 151 a = 153 a = 155 a = 157 a = 159 a = 161 a = 163 a = 165 a = 167 a = 169 a = 171 a = 173 a = 175 a = 177 a = 179 a = 181 a = 183 a = 185 a = 187 a = 189 a = 191 a = 193 a = 195 a = 197 a = 199 a = 201 a = 203 a = 205 a = 207 a = 209 a = 211 a = 213 a = 215 a = 217 a = 219 a = 221 a = 223 a = 225 a = 227 a = 229 a = 231 a = 233 a = 235 a = 237 a = 239 a = 241 a = 243 a = 245 a = 247 a = 249 a = 251 a = 253 a = 255 a = 257 a = 259 a = 261 a = 263 a = 265 a = 267 a = 269 a = 271 a = 273 a = 275 a = 277 a = 279 a = 281 a = 283 a = 285 a = 287 a = 289 a = 291 a = 293 a = 295 a = 297 a = 299 a = 301 a = 303 a = 305 a = 307 a = 309 a = 311 a = 313 a = 315 a = 317 a = 319 a = 321 a = 323 a = 325 a = 327 a = 329 a = 331 a = 333 a = 335 a = 337 a = 339 a = 341 a = 343 a = 345 a = 347 a = 349 a = 351 a = 353 a = 355 a = 357 a = 359 a = 361 a = 363 a = 365 a = 367 a = 369 a = 371 a = 373 a = 375 a = 377 a = 379 a = 381 a = 383 a = 385 a = 387 a = 389 a = 391 a = 393 a = 395 a = 397 a = 399 a = 401 a = 403 a = 405 a = 407 a = 409 a = 411 a = 413 a = 415 a = 417 a = 419 a = 421 a = 423 a = 425 a = 427 a = 429 a = 431 a = 433 a = 435 a = 437 a = 439 a = 441 a = 443 a = 445 a = 447 a = 449 a = 451 a = 453 a = 455 a = 457 a = 459 a = 461 a = 463 a = 465 a = 467 a = 469 a = 471 a = 473 a = 475 a = 477 a = 479 a = 481 a = 483 a = 485 a = 487 a = 489 a = 491 a = 493 a = 495 a = 497 a = 499 a = 501 a = 503 a = 505 a = 507 a = 509 a = 511 a = 513 a = 515 a = 517 a = 519 a = 521 a = 523 a = 525 a = 527 a = 529 a = 531 a = 533 a = 535 a = 537 a = 539 a = 541 a = 543 a = 545 a = 547 a = 549 a = 551 a = 553 a = 555 a = 557 a = 559 a = 561 a = 563 a = 565 a = 567 a = 569 a = 571 a = 573 a = 575 a = 1 a = 4 a = 7 a = 10 a = 13 a = 16 a = 19 a = 22 a = 25 a = 28 a = 31 a = 34 a = 37 a = 40 a = 43 a = 46 a = 49 a = 52 a = 55 a = 58 a = 61 a = 64 a = 67 a = 70 a = 73 a = 76 a = 79 a = 82 a = 85 a = 88 a = 91 a = 94 a = 97 a = 100 a = 103 a = 106 a = 109 a = 112 a = 115 a = 118 a = 121 a = 124 a = 127 a = 130 a = 133 a = 136 a = 139 a = 142 a = 145 a = 148 a = 151 a = 154 a = 157 a = 160 a = 163 a = 166 a = 169 a = 172 a = 175 a = 178 a = 181 a = 184 a = 187 a = 190 a = 193 a = 196 a = 199 a = 202 a = 205 a = 208 a = 211 a = 214 a = 217 a = 220 a = 223 a = 226 a = 229 a = 232 a = 235 a = 238 a = 241 a = 244 a = 247 a = 250 a = 253 a = 256 a = 259 a = 262 a = 265 a = 268 a = 271 a = 274 a = 277 a = 280 a = 283 a = 286 a = 289 a = 292 a = 295 a = 298 a = 301 a = 304 a = 307 a = 310 a = 313 a = 316 a = 319 a = 322 a = 325 a = 328 a = 331 a = 334 a = 337 a = 340 a = 343 a = 346 a = 349 a = 352 a = 355 a = 358 a = 361 a = 364 a = 367 a = 370 a = 373 a = 376 a = 379 a = 382 a = 385 a = 388 a = 391 a = 394 a = 397 a = 400 a = 403 a = 406 a = 409 a = 412 a = 415 a = 418 a = 421 a = 424 a = 427 a = 430 a = 1 a = 5 a = 9 a = 13 a = 17 a = 21 a = 25 a = 29 a = 33 a = 37 a = 41 a = 45 a = 49 a = 53 a = 57 a = 61 a = 65 a = 69 a = 73 a = 77 a = 81 a = 85 a = 89 a = 93 a = 97 a = 101 a = 105 a = 109 a = 113 a = 117 a = 121 a = 125 a = 129 a = 133 a = 137 a = 141 a = 145 a = 149 a = 153 a = 157 a = 161 a = 165 a = 169 a = 173 a = 177 a = 181 a = 185 a = 189 a = 193 a = 197 a = 201 a = 205 a = 209 a = 213 a = 217 a = 221 a = 225 a = 229 a = 233 a = 237 a = 241 a = 245 a = 249 a = 253 a = 257 a = 261 a = 265 a = 269 a = 273 a = 277 a = 281 a = 285 a = 289 a = 293 a = 297 a = 301 a = 305 a = 309 a = 313 a = 317 a = 321 a = 325 a = 329 a = 333 a = 337 a = 341 a = 345 a = 4 a = 9 a = 14 a = 19 a = 24 a = 29 a = 34 a = 39 a = 44 a = 49 a = 54 a = 59 a = 64 a = 69 a = 74 a = 79 a = 84 a = 89 a = 94 a = 99 a = 104 a = 109 a = 114 a = 119 a = 124 a = 129 a = 134 a = 139 a = 144 a = 149 a = 154 a = 159 a = 164 a = 169 a = 174 a = 179 a = ...

Assertion failed.

4   Fail
% E Vmin = 27; Vmax = 183; denom = floor(unique(egyptian_fraction(Vmin,Vmax))); egyptian_value = sum(1./denom); rel_tol = Vmin/Vmax*1e-6; actual_error = abs( egyptian_value - Vmin/Vmax ); assert(isequal(actual_error < rel_tol ,true))

a = 21 a = 1 a = 8 a = 15 a = 22 a = 7 a = 15 a = 3 a = 12 a = 3 a = 13 a = 7 a = 3 a = 1 a = 1 a = 3 a = 7 a = 3 a = 3 a = 7 a = 1 a = 3 a = 3 a = 3 a = 0

Assertion failed.