Spaces:
Running
Running
File size: 80,376 Bytes
5ef1c06 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ADHD Linear Programming Study Buddy</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
@keyframes float {
0%, 100% { transform: translateY(0); }
50% { transform: translateY(-10px); }
}
@keyframes shake {
0%, 100% { transform: rotate(0deg); }
25% { transform: rotate(5deg); }
75% { transform: rotate(-5deg); }
}
@keyframes pulse {
0%, 100% { opacity: 1; }
50% { opacity: 0.5; }
}
.floating {
animation: float 3s ease-in-out infinite;
}
.shaking {
animation: shake 0.5s ease-in-out infinite;
}
.pulsing {
animation: pulse 1.5s ease-in-out infinite;
}
.progress-bar {
transition: width 0.5s ease-in-out;
}
.constraint-line {
stroke-dasharray: 5;
animation: dash 30s linear infinite;
}
@keyframes dash {
to {
stroke-dashoffset: 1000;
}
}
.feasible-region {
fill-opacity: 0.3;
animation: colorChange 10s infinite alternate;
}
@keyframes colorChange {
0% { fill: #3B82F6; }
25% { fill: #10B981; }
50% { fill: #F59E0B; }
75% { fill: #EC4899; }
100% { fill: #8B5CF6; }
}
.highlight-box {
transition: all 0.3s ease;
}
.highlight-box:hover {
transform: scale(1.02);
box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}
.tab-content {
display: none;
}
.tab-content.active {
display: block;
animation: fadeIn 0.5s ease-in;
}
@keyframes fadeIn {
from { opacity: 0; }
to { opacity: 1; }
}
.confetti {
position: absolute;
width: 10px;
height: 10px;
background-color: #f00;
opacity: 0;
}
</style>
</head>
<body class="bg-gray-50 min-h-screen font-sans">
<div class="container mx-auto px-4 py-8">
<!-- Header with progress tracker -->
<header class="mb-8">
<div class="flex justify-between items-center mb-6">
<h1 class="text-4xl font-bold text-indigo-800 flex items-center">
<i class="fas fa-brain mr-3 text-pink-500 floating"></i>
LP Study Buddy
</h1>
<div class="flex items-center space-x-4">
<div class="relative">
<div class="h-4 w-32 bg-gray-200 rounded-full overflow-hidden">
<div id="progress-bar" class="progress-bar h-full bg-green-500" style="width: 0%"></div>
</div>
<span id="progress-text" class="text-xs font-semibold text-gray-600 absolute -bottom-5 right-0">0% Complete</span>
</div>
<button id="focus-mode" class="px-3 py-1 bg-blue-100 text-blue-700 rounded-full text-sm flex items-center">
<i class="fas fa-crosshairs mr-1"></i> Focus Mode
</button>
</div>
</div>
<div class="bg-white p-4 rounded-xl shadow-md mb-6">
<div class="flex items-center">
<div class="mr-4">
<div class="w-16 h-16 bg-yellow-100 rounded-full flex items-center justify-center">
<i class="fas fa-lightbulb text-yellow-500 text-2xl shaking"></i>
</div>
</div>
<div>
<h2 class="text-xl font-bold text-gray-800">ADHD Study Tips</h2>
<p class="text-gray-600" id="study-tip">Work in short bursts (10-15 min) with breaks in between!</p>
<div class="flex space-x-2 mt-2">
<button id="prev-tip" class="px-2 py-1 bg-gray-100 rounded text-sm">
<i class="fas fa-arrow-left"></i>
</button>
<button id="next-tip" class="px-2 py-1 bg-gray-100 rounded text-sm">
<i class="fas fa-arrow-right"></i>
</button>
</div>
</div>
</div>
</div>
</header>
<!-- Main content area with tabs -->
<div class="grid grid-cols-1 lg:grid-cols-4 gap-6">
<!-- Sidebar with navigation -->
<div class="lg:col-span-1">
<div class="bg-white p-4 rounded-xl shadow-md sticky top-4">
<h3 class="font-bold text-lg mb-4 text-indigo-700 flex items-center">
<i class="fas fa-list-ul mr-2"></i> Topics
</h3>
<ul class="space-y-2">
<li>
<button data-tab="formulating" class="tab-btn w-full text-left px-3 py-2 rounded-lg bg-indigo-50 text-indigo-700 font-medium flex items-center justify-between">
<span>1. Formulating Problems</span>
<i class="fas fa-check-circle text-green-500 opacity-0"></i>
</button>
</li>
<li>
<button data-tab="graphical" class="tab-btn w-full text-left px-3 py-2 rounded-lg hover:bg-indigo-50 text-gray-700 flex items-center justify-between">
<span>2. Graphical Solutions</span>
<i class="fas fa-check-circle text-green-500 opacity-0"></i>
</button>
</li>
<li>
<button data-tab="standard-form" class="tab-btn w-full text-left px-3 py-2 rounded-lg hover:bg-indigo-50 text-gray-700 flex items-center justify-between">
<span>3. Standard Form</span>
<i class="fas fa-check-circle text-green-500 opacity-0"></i>
</button>
</li>
<li>
<button data-tab="simplex" class="tab-btn w-full text-left px-3 py-2 rounded-lg hover:bg-indigo-50 text-gray-700 flex items-center justify-between">
<span>4. Simplex Method</span>
<i class="fas fa-check-circle text-green-500 opacity-0"></i>
</button>
</li>
<li>
<button data-tab="duality" class="tab-btn w-full text-left px-3 py-2 rounded-lg hover:bg-indigo-50 text-gray-700 flex items-center justify-between">
<span>5. Duality</span>
<i class="fas fa-check-circle text-green-500 opacity-0"></i>
</button>
</li>
</ul>
<div class="mt-6 pt-4 border-t border-gray-200">
<h3 class="font-bold text-lg mb-3 text-indigo-700 flex items-center">
<i class="fas fa-gamepad mr-2"></i> Quick Games
</h3>
<button id="flashcards-btn" class="w-full mb-2 px-3 py-2 bg-purple-100 text-purple-700 rounded-lg flex items-center">
<i class="fas fa-layer-group mr-2"></i> Flashcards
</button>
<button id="quiz-btn" class="w-full px-3 py-2 bg-green-100 text-green-700 rounded-lg flex items-center">
<i class="fas fa-question-circle mr-2"></i> Pop Quiz
</button>
</div>
<div class="mt-6 pt-4 border-t border-gray-200">
<h3 class="font-bold text-lg mb-3 text-indigo-700 flex items-center">
<i class="fas fa-tools mr-2"></i> Tools
</h3>
<div class="flex space-x-2">
<button id="timer-btn" class="flex-1 px-3 py-2 bg-blue-100 text-blue-700 rounded-lg flex items-center justify-center">
<i class="fas fa-stopwatch mr-2"></i> Timer
</button>
<button id="distraction-btn" class="flex-1 px-3 py-2 bg-pink-100 text-pink-700 rounded-lg flex items-center justify-center">
<i class="fas fa-headphones mr-2"></i> Sounds
</button>
</div>
</div>
</div>
</div>
<!-- Main content -->
<div class="lg:col-span-3">
<!-- Formulating Problems Tab -->
<div id="formulating" class="tab-content active">
<div class="bg-white rounded-xl shadow-md overflow-hidden highlight-box">
<div class="p-5">
<div class="flex justify-between items-start">
<div>
<h2 class="text-2xl font-bold text-gray-800 mb-2">1. Formulating Linear Programming Problems</h2>
<p class="text-gray-600 mb-4">Turning real-world problems into mathematical equations</p>
</div>
<button class="complete-topic px-4 py-2 bg-green-500 text-white rounded-lg flex items-center">
<i class="fas fa-check mr-2"></i> Mark Complete
</button>
</div>
<div class="grid grid-cols-1 md:grid-cols-2 gap-6 mb-6">
<div>
<h3 class="font-bold text-lg mb-3 text-indigo-700 flex items-center">
<i class="fas fa-lightbulb mr-2 text-yellow-500"></i> Key Concepts
</h3>
<ul class="space-y-2">
<li class="flex items-start">
<i class="fas fa-arrow-right text-indigo-500 mt-1 mr-2"></i>
<span><strong>Objective Function:</strong> What you want to maximize or minimize</span>
</li>
<li class="flex items-start">
<i class="fas fa-arrow-right text-indigo-500 mt-1 mr-2"></i>
<span><strong>Constraints:</strong> Limitations or requirements</span>
</li>
<li class="flex items-start">
<i class="fas fa-arrow-right text-indigo-500 mt-1 mr-2"></i>
<span><strong>Decision Variables:</strong> What you can control</span>
</li>
</ul>
<h3 class="font-bold text-lg mt-6 mb-3 text-indigo-700 flex items-center">
<i class="fas fa-bolt mr-2 text-purple-500"></i> ADHD Tips
</h3>
<div class="bg-blue-50 p-3 rounded-lg">
<p class="text-blue-800"><i class="fas fa-star mr-2 text-yellow-500"></i> <strong>Make it fun:</strong> Use examples from your life (tacos, video games, etc.)</p>
<p class="text-blue-800 mt-2"><i class="fas fa-star mr-2 text-yellow-500"></i> <strong>Quick sketch:</strong> Jot down variables and constraints without perfection</p>
</div>
</div>
<div>
<h3 class="font-bold text-lg mb-3 text-indigo-700 flex items-center">
<i class="fas fa-pencil-alt mr-2 text-green-500"></i> Example
</h3>
<div class="bg-gray-50 p-4 rounded-lg">
<p class="font-semibold">Taco & Burger Stand:</p>
<p class="text-sm text-gray-600 mb-2">You have 10 buns and 5 patties. Tacos need 1 bun, burgers need 1 bun + 1 patty. Profit: $2/taco, $3/burger.</p>
<div class="space-y-2">
<div class="flex items-center">
<span class="bg-indigo-100 text-indigo-800 px-2 py-1 rounded mr-2 text-sm">Goal</span>
<span>Maximize Profit: <span class="font-mono">P = 2x + 3y</span></span>
</div>
<div class="flex items-center">
<span class="bg-pink-100 text-pink-800 px-2 py-1 rounded mr-2 text-sm">Constraints</span>
<span>Buns: <span class="font-mono">x + y ≤ 10</span></span>
</div>
<div class="flex items-center">
<span class="bg-pink-100 text-pink-800 px-2 py-1 rounded mr-2 text-sm">Constraints</span>
<span>Patties: <span class="font-mono">y ≤ 5</span></span>
</div>
<div class="flex items-center">
<span class="bg-green-100 text-green-800 px-2 py-1 rounded mr-2 text-sm">Variables</span>
<span><span class="font-mono">x ≥ 0, y ≥ 0</span></span>
</div>
</div>
</div>
<button id="example-animation-btn" class="mt-4 px-4 py-2 bg-indigo-600 text-white rounded-lg flex items-center">
<i class="fas fa-play mr-2"></i> Show Animation
</button>
</div>
</div>
<div class="border-t border-gray-200 pt-4">
<h3 class="font-bold text-lg mb-3 text-indigo-700 flex items-center">
<i class="fas fa-dumbbell mr-2 text-red-500"></i> Practice
</h3>
<div class="bg-orange-50 p-4 rounded-lg">
<p class="font-medium mb-2">Pizza & Wings:</p>
<p class="text-sm text-gray-600 mb-3">You have 20 slices of pizza and 30 wings. A pizza party needs 4 slices, a wing party needs 10 wings. Profit: $15/pizza party, $20/wing party.</p>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4 mb-4">
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Objective Function:</label>
<input type="text" class="practice-input w-full px-3 py-2 border border-gray-300 rounded-md" placeholder="P = ...">
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Constraints:</label>
<input type="text" class="practice-input w-full px-3 py-2 border border-gray-300 rounded-md" placeholder="Pizza slices...">
<input type="text" class="practice-input w-full mt-2 px-3 py-2 border border-gray-300 rounded-md" placeholder="Wings...">
</div>
</div>
<button id="check-practice" class="px-4 py-2 bg-orange-500 text-white rounded-lg flex items-center">
<i class="fas fa-check-circle mr-2"></i> Check Answer
</button>
<div id="practice-feedback" class="mt-3 hidden"></div>
</div>
</div>
</div>
</div>
</div>
<!-- Graphical Solutions Tab -->
<div id="graphical" class="tab-content">
<div class="bg-white rounded-xl shadow-md overflow-hidden highlight-box">
<div class="p-5">
<div class="flex justify-between items-start">
<div>
<h2 class="text-2xl font-bold text-gray-800 mb-2">2. Graphical Solutions (2D Problems)</h2>
<p class="text-gray-600 mb-4">Visualizing and solving LP problems with two variables</p>
</div>
<button class="complete-topic px-4 py-2 bg-green-500 text-white rounded-lg flex items-center">
<i class="fas fa-check mr-2"></i> Mark Complete
</button>
</div>
<div class="grid grid-cols-1 md:grid-cols-2 gap-6 mb-6">
<div>
<h3 class="font-bold text-lg mb-3 text-indigo-700 flex items-center">
<i class="fas fa-lightbulb mr-2 text-yellow-500"></i> Key Concepts
</h3>
<ul class="space-y-2">
<li class="flex items-start">
<i class="fas fa-arrow-right text-indigo-500 mt-1 mr-2"></i>
<span><strong>Plot constraints:</strong> Draw each inequality as a line</span>
</li>
<li class="flex items-start">
<i class="fas fa-arrow-right text-indigo-500 mt-1 mr-2"></i>
<span><strong>Feasible region:</strong> Where all constraints overlap</span>
</li>
<li class="flex items-start">
<i class="fas fa-arrow-right text-indigo-500 mt-1 mr-2"></i>
<span><strong>Optimal solution:</strong> At a corner point of the feasible region</span>
</li>
</ul>
<h3 class="font-bold text-lg mt-6 mb-3 text-indigo-700 flex items-center">
<i class="fas fa-bolt mr-2 text-purple-500"></i> ADHD Tips
</h3>
<div class="bg-blue-50 p-3 rounded-lg">
<p class="text-blue-800"><i class="fas fa-star mr-2 text-yellow-500"></i> <strong>Use colors:</strong> Different colors for each constraint</p>
<p class="text-blue-800 mt-2"><i class="fas fa-star mr-2 text-yellow-500"></i> <strong>Interactive tools:</strong> Try online graphing calculators</p>
</div>
</div>
<div>
<h3 class="font-bold text-lg mb-3 text-indigo-700 flex items-center">
<i class="fas fa-chart-line mr-2 text-green-500"></i> Interactive Graph
</h3>
<div class="bg-gray-100 p-4 rounded-lg">
<div id="graph-container" class="w-full h-64 relative">
<svg id="graph-svg" width="100%" height="100%" viewBox="0 0 400 300" class="bg-white rounded">
<!-- Axes -->
<line x1="50" y1="250" x2="350" y2="250" stroke="black" stroke-width="2" />
<line x1="50" y1="250" x2="50" y2="50" stroke="black" stroke-width="2" />
<!-- X axis labels -->
<text x="350" y="265" text-anchor="middle">x</text>
<text x="60" y="265" text-anchor="middle">0</text>
<text x="110" y="265" text-anchor="middle">2</text>
<text x="160" y="265" text-anchor="middle">4</text>
<text x="210" y="265" text-anchor="middle">6</text>
<text x="260" y="265" text-anchor="middle">8</text>
<text x="310" y="265" text-anchor="middle">10</text>
<!-- Y axis labels -->
<text x="35" y="60" text-anchor="middle">10</text>
<text x="35" y="110" text-anchor="middle">8</text>
<text x="35" y="160" text-anchor="middle">6</text>
<text x="35" y="210" text-anchor="middle">4</text>
<text x="35" y="260" text-anchor="middle">0</text>
<text x="30" y="40" text-anchor="middle">y</text>
<!-- Constraints will be added here by JavaScript -->
</svg>
</div>
<div class="mt-4 grid grid-cols-1 md:grid-cols-2 gap-2">
<button id="add-constraint-btn" class="px-3 py-2 bg-blue-100 text-blue-700 rounded flex items-center justify-center">
<i class="fas fa-plus mr-2"></i> Add Constraint
</button>
<button id="find-optimal-btn" class="px-3 py-2 bg-green-100 text-green-700 rounded flex items-center justify-center">
<i class="fas fa-bullseye mr-2"></i> Find Optimal
</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Standard Form Tab -->
<div id="standard-form" class="tab-content">
<div class="bg-white rounded-xl shadow-md overflow-hidden highlight-box">
<div class="p-5">
<div class="flex justify-between items-start">
<div>
<h2 class="text-2xl font-bold text-gray-800 mb-2">3. Conversion to Standard Form</h2>
<p class="text-gray-600 mb-4">Rewriting LP problems for the simplex method</p>
</div>
<button class="complete-topic px-4 py-2 bg-green-500 text-white rounded-lg flex items-center">
<i class="fas fa-check mr-2"></i> Mark Complete
</button>
</div>
<div class="mb-6">
<h3 class="font-bold text-lg mb-3 text-indigo-700 flex items-center">
<i class="fas fa-exchange-alt mr-2 text-purple-500"></i> Conversion Rules
</h3>
<div class="grid grid-cols-1 md:grid-cols-3 gap-4">
<div class="bg-gray-50 p-4 rounded-lg">
<h4 class="font-bold text-blue-700 mb-2 flex items-center">
<i class="fas fa-less-than-equal mr-2"></i> ≤ Constraints
</h4>
<p class="text-sm">Add a <span class="font-mono bg-blue-100 px-1">slack variable</span>:</p>
<p class="font-mono mt-1">x + y ≤ 10 → x + y + s = 10</p>
<p class="text-xs text-gray-500 mt-2">s ≥ 0</p>
</div>
<div class="bg-gray-50 p-4 rounded-lg">
<h4 class="font-bold text-green-700 mb-2 flex items-center">
<i class="fas fa-greater-than-equal mr-2"></i> ≥ Constraints
</h4>
<p class="text-sm">Add a <span class="font-mono bg-green-100 px-1">surplus variable</span>:</p>
<p class="font-mono mt-1">x + y ≥ 10 → x + y - s = 10</p>
<p class="text-xs text-gray-500 mt-2">s ≥ 0</p>
</div>
<div class="bg-gray-50 p-4 rounded-lg">
<h4 class="font-bold text-red-700 mb-2 flex items-center">
<i class="fas fa-random mr-2"></i> Free Variables
</h4>
<p class="text-sm">Replace with difference:</p>
<p class="font-mono mt-1">x unrestricted → x = x⁺ - x⁻</p>
<p class="text-xs text-gray-500 mt-2">x⁺ ≥ 0, x⁻ ≥ 0</p>
</div>
</div>
</div>
<div class="border-t border-gray-200 pt-4">
<h3 class="font-bold text-lg mb-3 text-indigo-700 flex items-center">
<i class="fas fa-dumbbell mr-2 text-red-500"></i> Practice
</h3>
<div class="bg-orange-50 p-4 rounded-lg">
<div class="mb-4">
<p class="font-medium">Convert to standard form:</p>
<p class="text-sm font-mono bg-white p-2 rounded mt-1">Maximize z = 3x₁ + 2x₂</p>
<p class="text-sm font-mono bg-white p-2 rounded">Subject to: x₁ + x₂ ≤ 4</p>
<p class="text-sm font-mono bg-white p-2 rounded">x₁ - x₂ ≥ 1</p>
<p class="text-sm font-mono bg-white p-2 rounded">x₁ ≥ 0, x₂ unrestricted</p>
</div>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4 mb-4">
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Objective:</label>
<input type="text" class="std-form-input w-full px-3 py-2 border border-gray-300 rounded-md" placeholder="Maximize...">
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Constraints:</label>
<input type="text" class="std-form-input w-full px-3 py-2 border border-gray-300 rounded-md" placeholder="First constraint...">
<input type="text" class="std-form-input w-full mt-2 px-3 py-2 border border-gray-300 rounded-md" placeholder="Second constraint...">
</div>
</div>
<button id="check-std-form" class="px-4 py-2 bg-orange-500 text-white rounded-lg flex items-center">
<i class="fas fa-check-circle mr-2"></i> Check Answer
</button>
<div id="std-form-feedback" class="mt-3 hidden"></div>
</div>
</div>
</div>
</div>
</div>
<!-- Simplex Method Tab -->
<div id="simplex" class="tab-content">
<div class="bg-white rounded-xl shadow-md overflow-hidden highlight-box">
<div class="p-5">
<div class="flex justify-between items-start">
<div>
<h2 class="text-2xl font-bold text-gray-800 mb-2">4. Simplex Method</h2>
<p class="text-gray-600 mb-4">Step-by-step algorithm for solving LP problems</p>
</div>
<button class="complete-topic px-4 py-2 bg-green-500 text-white rounded-lg flex items-center">
<i class="fas fa-check mr-2"></i> Mark Complete
</button>
</div>
<div class="mb-6">
<h3 class="font-bold text-lg mb-3 text-indigo-700 flex items-center">
<i class="fas fa-list-ol mr-2 text-purple-500"></i> Steps
</h3>
<div class="space-y-4">
<div class="flex items-start">
<div class="bg-indigo-100 text-indigo-800 rounded-full w-8 h-8 flex items-center justify-center flex-shrink-0 mr-3">1</div>
<div>
<p class="font-medium">Set up initial tableau</p>
<p class="text-sm text-gray-600">Include slack/surplus variables and objective function</p>
</div>
</div>
<div class="flex items-start">
<div class="bg-indigo-100 text-indigo-800 rounded-full w-8 h-8 flex items-center justify-center flex-shrink-0 mr-3">2</div>
<div>
<p class="font-medium">Choose pivot column</p>
<p class="text-sm text-gray-600">Most negative entry in bottom row (for minimization)</p>
</div>
</div>
<div class="flex items-start">
<div class="bg-indigo-100 text-indigo-800 rounded-full w-8 h-8 flex items-center justify-center flex-shrink-0 mr-3">3</div>
<div>
<p class="font-medium">Choose pivot row</p>
<p class="text-sm text-gray-600">Smallest non-negative ratio (RHS ÷ pivot column)</p>
</div>
</div>
<div class="flex items-start">
<div class="bg-indigo-100 text-indigo-800 rounded-full w-8 h-8 flex items-center justify-center flex-shrink-0 mr-3">4</div>
<div>
<p class="font-medium">Perform row operations</p>
<p class="text-sm text-gray-600">Make pivot element 1, others in column 0</p>
</div>
</div>
<div class="flex items-start">
<div class="bg-indigo-100 text-indigo-800 rounded-full w-8 h-8 flex items-center justify-center flex-shrink-0 mr-3">5</div>
<div>
<p class="font-medium">Repeat until optimal</p>
<p class="text-sm text-gray-600">No negatives in bottom row (minimization)</p>
</div>
</div>
</div>
</div>
<div class="border-t border-gray-200 pt-4">
<h3 class="font-bold text-lg mb-3 text-indigo-700 flex items-center">
<i class="fas fa-table mr-2 text-green-500"></i> Interactive Tableau
</h3>
<div class="bg-gray-100 p-4 rounded-lg">
<div class="overflow-x-auto">
<table id="simplex-table" class="w-full bg-white border border-gray-200">
<thead>
<tr>
<th class="border px-4 py-2">Basic</th>
<th class="border px-4 py-2">x₁</th>
<th class="border px-4 py-2">x₂</th>
<th class="border px-4 py-2">s₁</th>
<th class="border px-4 py-2">s₂</th>
<th class="border px-4 py-2">RHS</th>
</tr>
</thead>
<tbody>
<tr>
<td class="border px-4 py-2">s₁</td>
<td class="border px-4 py-2">1</td>
<td class="border px-4 py-2">1</td>
<td class="border px-4 py-2">1</td>
<td class="border px-4 py-2">0</td>
<td class="border px-4 py-2">4</td>
</tr>
<tr>
<td class="border px-4 py-2">s₂</td>
<td class="border px-4 py-2">1</td>
<td class="border px-4 py-2">-1</td>
<td class="border px-4 py-2">0</td>
<td class="border px-4 py-2">-1</td>
<td class="border px-4 py-2">1</td>
</tr>
<tr class="bg-gray-50">
<td class="border px-4 py-2">z</td>
<td class="border px-4 py-2">-3</td>
<td class="border px-4 py-2">-2</td>
<td class="border px-4 py-2">0</td>
<td class="border px-4 py-2">0</td>
<td class="border px-4 py-2">0</td>
</tr>
</tbody>
</table>
</div>
<div class="mt-4 grid grid-cols-2 md:grid-cols-4 gap-2">
<button id="step-simplex" class="px-3 py-2 bg-blue-500 text-white rounded flex items-center justify-center">
<i class="fas fa-forward mr-2"></i> Next Step
</button>
<button id="reset-simplex" class="px-3 py-2 bg-gray-500 text-white rounded flex items-center justify-center">
<i class="fas fa-undo mr-2"></i> Reset
</button>
<button id="hint-simplex" class="px-3 py-2 bg-yellow-500 text-white rounded flex items-center justify-center">
<i class="fas fa-lightbulb mr-2"></i> Hint
</button>
<button id="auto-simplex" class="px-3 py-2 bg-green-500 text-white rounded flex items-center justify-center">
<i class="fas fa-robot mr-2"></i> Auto Solve
</button>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Duality Tab -->
<div id="duality" class="tab-content">
<div class="bg-white rounded-xl shadow-md overflow-hidden highlight-box">
<div class="p-5">
<div class="flex justify-between items-start">
<div>
<h2 class="text-2xl font-bold text-gray-800 mb-2">5. Duality</h2>
<p class="text-gray-600 mb-4">Understanding the dual problem and its relationship to the primal</p>
</div>
<button class="complete-topic px-4 py-2 bg-green-500 text-white rounded-lg flex items-center">
<i class="fas fa-check mr-2"></i> Mark Complete
</button>
</div>
<div class="grid grid-cols-1 md:grid-cols-2 gap-6 mb-6">
<div>
<h3 class="font-bold text-lg mb-3 text-indigo-700 flex items-center">
<i class="fas fa-project-diagram mr-2 text-purple-500"></i> Primal to Dual Rules
</h3>
<div class="space-y-4">
<div class="bg-gray-50 p-3 rounded-lg">
<p class="font-medium text-blue-700">Maximization → Minimization</p>
<p class="text-sm">(and vice versa)</p>
</div>
<div class="bg-gray-50 p-3 rounded-lg">
<p class="font-medium text-green-700">Constraints → Variables</p>
<p class="text-sm">Each primal constraint becomes a dual variable</p>
</div>
<div class="bg-gray-50 p-3 rounded-lg">
<p class="font-medium text-red-700">Variables → Constraints</p>
<p class="text-sm">Each primal variable becomes a dual constraint</p>
</div>
<div class="bg-gray-50 p-3 rounded-lg">
<p class="font-medium text-yellow-700">Coefficients transpose</p>
<p class="text-sm">Constraint matrix flips rows and columns</p>
</div>
</div>
</div>
<div>
<h3 class="font-bold text-lg mb-3 text-indigo-700 flex items-center">
<i class="fas fa-balance-scale mr-2 text-green-500"></i> Example
</h3>
<div class="bg-gray-100 p-4 rounded-lg">
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<div>
<p class="font-medium text-center mb-2">Primal</p>
<div class="bg-white p-3 rounded">
<p class="text-sm font-mono">Max z = 3x₁ + 2x₂</p>
<p class="text-sm font-mono mt-1">x₁ + x₂ ≤ 4</p>
<p class="text-sm font-mono">x₁ - x₂ ≤ 1</p>
<p class="text-sm font-mono">x₁, x₂ ≥ 0</p>
</div>
</div>
<div>
<p class="font-medium text-center mb-2">Dual</p>
<div class="bg-white p-3 rounded">
<p class="text-sm font-mono">Min w = 4y₁ + y₂</p>
<p class="text-sm font-mono mt-1">y₁ + y₂ ≥ 3</p>
<p class="text-sm font-mono">y₁ - y₂ ≥ 2</p>
<p class="text-sm font-mono">y₁, y₂ ≥ 0</p>
</div>
</div>
</div>
<button id="duality-animation-btn" class="mt-4 w-full px-4 py-2 bg-indigo-600 text-white rounded-lg flex items-center justify-center">
<i class="fas fa-magic mr-2"></i> Show Transformation
</button>
</div>
</div>
</div>
<div class="border-t border-gray-200 pt-4">
<h3 class="font-bold text-lg mb-3 text-indigo-700 flex items-center">
<i class="fas fa-dumbbell mr-2 text-red-500"></i> Practice
</h3>
<div class="bg-orange-50 p-4 rounded-lg">
<p class="font-medium mb-2">Find the dual of:</p>
<div class="bg-white p-3 rounded mb-4">
<p class="text-sm font-mono">Min z = 2x₁ + 5x₂</p>
<p class="text-sm font-mono mt-1">3x₁ + x₂ ≥ 6</p>
<p class="text-sm font-mono">x₁ + 2x₂ ≥ 4</p>
<p class="text-sm font-mono">x₁, x₂ ≥ 0</p>
</div>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4 mb-4">
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Objective:</label>
<input type="text" class="dual-input w-full px-3 py-2 border border-gray-300 rounded-md" placeholder="Min/Max...">
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Constraints:</label>
<input type="text" class="dual-input w-full px-3 py-2 border border-gray-300 rounded-md" placeholder="First constraint...">
<input type="text" class="dual-input w-full mt-2 px-3 py-2 border border-gray-300 rounded-md" placeholder="Second constraint...">
</div>
</div>
<button id="check-dual" class="px-4 py-2 bg-orange-500 text-white rounded-lg flex items-center">
<i class="fas fa-check-circle mr-2"></i> Check Answer
</button>
<div id="dual-feedback" class="mt-3 hidden"></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Modals -->
<div id="flashcards-modal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 hidden">
<div class="bg-white rounded-xl shadow-xl w-full max-w-md mx-4">
<div class="p-5">
<div class="flex justify-between items-center mb-4">
<h3 class="text-xl font-bold">Flashcards</h3>
<button id="close-flashcards" class="text-gray-500 hover:text-gray-700">
<i class="fas fa-times"></i>
</button>
</div>
<div class="bg-blue-50 p-6 rounded-lg h-64 flex items-center justify-center">
<div id="flashcard-content" class="text-center">
<p class="text-lg font-medium">Click "Next" to start!</p>
</div>
</div>
<div class="flex justify-between mt-6">
<button id="prev-card" class="px-4 py-2 bg-gray-200 rounded-lg">
<i class="fas fa-arrow-left mr-2"></i> Previous
</button>
<button id="next-card" class="px-4 py-2 bg-indigo-600 text-white rounded-lg">
Next <i class="fas fa-arrow-right ml-2"></i>
</button>
</div>
</div>
</div>
</div>
<div id="quiz-modal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 hidden">
<div class="bg-white rounded-xl shadow-xl w-full max-w-md mx-4">
<div class="p-5">
<div class="flex justify-between items-center mb-4">
<h3 class="text-xl font-bold">Pop Quiz</h3>
<button id="close-quiz" class="text-gray-500 hover:text-gray-700">
<i class="fas fa-times"></i>
</button>
</div>
<div id="quiz-question" class="mb-4">
<p class="font-medium mb-3">What is the first step in formulating an LP problem?</p>
<div class="space-y-2">
<label class="flex items-center space-x-2 p-2 border rounded-lg hover:bg-gray-50 cursor-pointer">
<input type="radio" name="quiz-answer" class="form-radio" value="A">
<span>Draw a graph</span>
</label>
<label class="flex items-center space-x-2 p-2 border rounded-lg hover:bg-gray-50 cursor-pointer">
<input type="radio" name="quiz-answer" class="form-radio" value="B">
<span>Identify the objective function</span>
</label>
<label class="flex items-center space-x-2 p-2 border rounded-lg hover:bg-gray-50 cursor-pointer">
<input type="radio" name="quiz-answer" class="form-radio" value="C">
<span>Add slack variables</span>
</label>
</div>
</div>
<div class="flex justify-between mt-6">
<div id="quiz-score" class="text-sm text-gray-600">Score: 0/0</div>
<button id="submit-quiz" class="px-4 py-2 bg-indigo-600 text-white rounded-lg">
Submit <i class="fas fa-check ml-2"></i>
</button>
</div>
</div>
</div>
</div>
<div id="timer-modal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 hidden">
<div class="bg-white rounded-xl shadow-xl w-full max-w-md mx-4">
<div class="p-5">
<div class="flex justify-between items-center mb-4">
<h3 class="text-xl font-bold">Focus Timer</h3>
<button id="close-timer" class="text-gray-500 hover:text-gray-700">
<i class="fas fa-times"></i>
</button>
</div>
<div class="text-center mb-6">
<div class="text-5xl font-bold mb-2" id="timer-display">25:00</div>
<div class="text-gray-500">Minutes Remaining</div>
</div>
<div class="grid grid-cols-3 gap-2 mb-4">
<button data-minutes="5" class="timer-preset px-3 py-2 bg-blue-100 text-blue-700 rounded-lg">
5 min
</button>
<button data-minutes="15" class="timer-preset px-3 py-2 bg-blue-100 text-blue-700 rounded-lg">
15 min
</button>
<button data-minutes="25" class="timer-preset px-3 py-2 bg-blue-100 text-blue-700 rounded-lg">
25 min
</button>
</div>
<div class="flex justify-center space-x-4 mt-6">
<button id="start-timer" class="px-4 py-2 bg-green-500 text-white rounded-lg">
<i class="fas fa-play mr-2"></i> Start
</button>
<button id="pause-timer" class="px-4 py-2 bg-yellow-500 text-white rounded-lg">
<i class="fas fa-pause mr-2"></i> Pause
</button>
<button id="reset-timer" class="px-4 py-2 bg-red-500 text-white rounded-lg">
<i class="fas fa-stop mr-2"></i> Stop
</button>
</div>
</div>
</div>
</div>
<div id="distraction-modal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 hidden">
<div class="bg-white rounded-xl shadow-xl w-full max-w-md mx-4">
<div class="p-5">
<div class="flex justify-between items-center mb-4">
<h3 class="text-xl font-bold">Focus Sounds</h3>
<button id="close-distraction" class="text-gray-500 hover:text-gray-700">
<i class="fas fa-times"></i>
</button>
</div>
<div class="space-y-3">
<label class="flex items-center space-x-3 p-3 border rounded-lg hover:bg-gray-50 cursor-pointer">
<input type="radio" name="sound" class="form-radio" value="rain">
<div class="flex-1">
<div class="font-medium">Rain</div>
<div class="text-sm text-gray-500">Gentle rainfall</div>
</div>
<i class="fas fa-volume-up text-gray-400"></i>
</label>
<label class="flex items-center space-x-3 p-3 border rounded-lg hover:bg-gray-50 cursor-pointer">
<input type="radio" name="sound" class="form-radio" value="coffee">
<div class="flex-1">
<div class="font-medium">Coffee Shop</div>
<div class="text-sm text-gray-500">Ambient chatter</div>
</div>
<i class="fas fa-volume-up text-gray-400"></i>
</label>
<label class="flex items-center space-x-3 p-3 border rounded-lg hover:bg-gray-50 cursor-pointer">
<input type="radio" name="sound" class="form-radio" value="white">
<div class="flex-1">
<div class="font-medium">White Noise</div>
<div class="text-sm text-gray-500">Static sound</div>
</div>
<i class="fas fa-volume-up text-gray-400"></i>
</label>
<label class="flex items-center space-x-3 p-3 border rounded-lg hover:bg-gray-50 cursor-pointer">
<input type="radio" name="sound" class="form-radio" value="none">
<div class="flex-1">
<div class="font-medium">None</div>
<div class="text-sm text-gray-500">Silence</div>
</div>
</label>
</div>
<div class="mt-6">
<label class="flex items-center space-x-2">
<input type="range" id="volume-control" min="0" max="1" step="0.1" value="0.5" class="w-full">
<span class="text-sm text-gray-600 w-10 text-right">50%</span>
</label>
</div>
</div>
</div>
</div>
<script>
// Study tips
const studyTips = [
"Work in short bursts (10-15 min) with breaks in between!",
"Use colorful pens or markers to make notes more engaging.",
"Try explaining concepts out loud to an imaginary friend.",
"Create silly mnemonics to remember key concepts.",
"Reward yourself after completing each topic.",
"Use movement - pace while reviewing or sit on an exercise ball.",
"Chew gum or have a fidget toy to help focus.",
"Make up real-world examples that interest you.",
"Record yourself explaining concepts and listen back.",
"Change study locations frequently to stay engaged."
];
let currentTipIndex = 0;
document.getElementById('study-tip').textContent = studyTips[currentTipIndex];
document.getElementById('next-tip').addEventListener('click', () => {
currentTipIndex = (currentTipIndex + 1) % studyTips.length;
document.getElementById('study-tip').textContent = studyTips[currentTipIndex];
});
document.getElementById('prev-tip').addEventListener('click', () => {
currentTipIndex = (currentTipIndex - 1 + studyTips.length) % studyTips.length;
document.getElementById('study-tip').textContent = studyTips[currentTipIndex];
});
// Tab navigation
document.querySelectorAll('.tab-btn').forEach(btn => {
btn.addEventListener('click', () => {
const tabId = btn.getAttribute('data-tab');
// Hide all tab contents
document.querySelectorAll('.tab-content').forEach(tab => {
tab.classList.remove('active');
});
// Show selected tab
document.getElementById(tabId).classList.add('active');
// Update active tab button
document.querySelectorAll('.tab-btn').forEach(t => {
t.classList.remove('bg-indigo-50', 'text-indigo-700');
t.classList.add('hover:bg-indigo-50', 'text-gray-700');
});
btn.classList.remove('hover:bg-indigo-50', 'text-gray-700');
btn.classList.add('bg-indigo-50', 'text-indigo-700');
});
});
// Mark topic complete
document.querySelectorAll('.complete-topic').forEach(btn => {
btn.addEventListener('click', function() {
const topicId = this.closest('.tab-content').id;
const tabBtn = document.querySelector(`.tab-btn[data-tab="${topicId}"]`);
// Add checkmark
const checkIcon = tabBtn.querySelector('i');
checkIcon.classList.remove('opacity-0');
// Update progress
updateProgress();
// Confetti effect
createConfetti(this);
});
});
function updateProgress() {
const completedTopics = document.querySelectorAll('.tab-btn i:not(.opacity-0)').length;
const totalTopics = document.querySelectorAll('.tab-btn').length;
const percentage = Math.round((completedTopics / totalTopics) * 100);
document.getElementById('progress-bar').style.width = `${percentage}%`;
document.getElementById('progress-text').textContent = `${percentage}% Complete`;
}
function createConfetti(element) {
const rect = element.getBoundingClientRect();
const colors = ['#f00', '#0f0', '#00f', '#ff0', '#f0f', '#0ff'];
for (let i = 0; i < 50; i++) {
const confetti = document.createElement('div');
confetti.className = 'confetti';
confetti.style.backgroundColor = colors[Math.floor(Math.random() * colors.length)];
confetti.style.left = `${rect.left + rect.width/2}px`;
confetti.style.top = `${rect.top}px`;
confetti.style.transform = `rotate(${Math.random() * 360}deg)`;
document.body.appendChild(confetti);
const animation = confetti.animate([
{ transform: `translate(0, 0) rotate(0)`, opacity: 1 },
{ transform: `translate(${Math.random() * 200 - 100}px, ${window.innerHeight}px) rotate(${Math.random() * 360}deg)`, opacity: 0 }
], {
duration: 1000 + Math.random() * 2000,
easing: 'cubic-bezier(0.1, 0.8, 0.3, 1)'
});
animation.onfinish = () => confetti.remove();
}
}
// Example animation
document.getElementById('example-animation-btn').addEventListener('click', function() {
const exampleDiv = this.previousElementSibling;
exampleDiv.classList.add('pulsing');
setTimeout(() => {
exampleDiv.classList.remove('pulsing');
}, 1500);
});
// Graphical solutions
let constraints = [];
document.getElementById('add-constraint-btn').addEventListener('click', function() {
const newConstraint = prompt("Enter constraint (e.g., x + y ≤ 10):");
if (newConstraint) {
constraints.push(newConstraint);
updateGraph();
}
});
document.getElementById('find-optimal-btn').addEventListener('click', function() {
alert("Finding optimal solution at corner points...");
// In a real implementation, we would calculate the optimal solution
});
function updateGraph() {
const svg = document.getElementById('graph-svg');
// Clear existing constraints
svg.querySelectorAll('.constraint-line, .feasible-region').forEach(el => el.remove());
// Add new constraints
constraints.forEach((constraint, index) => {
const color = ['#3B82F6', '#10B981', '#F59E0B', '#EC4899', '#8B5CF6'][index % 5];
// This is a simplified version - in a real app, we'd parse the constraint
const line = document.createElementNS("http://www.w3.org/2000/svg", "line");
line.setAttribute('x1', '50');
line.setAttribute('y1', '250');
line.setAttribute('x2', '350');
line.setAttribute('y2', '50');
line.setAttribute('stroke', color);
line.setAttribute('stroke-width', '2');
line.setAttribute('stroke-dasharray', '5');
line.classList.add('constraint-line');
svg.appendChild(line);
// Add label
const text = document.createElementNS("http://www.w3.org/2000/svg", "text");
text.setAttribute('x', '300');
text.setAttribute('y', '40');
text.setAttribute('fill', color);
text.setAttribute('font-size', '12');
text.textContent = constraint;
svg.appendChild(text);
});
// Add feasible region (simplified)
if (constraints.length >= 2) {
const polygon = document.createElementNS("http://www.w3.org/2000/svg", "polygon");
polygon.setAttribute('points', '150,150 200,100 250,150 200,200');
polygon.setAttribute('fill', '#3B82F6');
polygon.classList.add('feasible-region');
svg.appendChild(polygon);
}
}
// Flashcards
const flashcards = [
{ question: "What is the objective function?", answer: "The function you want to maximize or minimize in an LP problem." },
{ question: "What are constraints?", answer: "Limitations or requirements in an LP problem, expressed as inequalities or equations." },
{ question: "What is the feasible region?", answer: "The set of all possible points that satisfy all constraints." },
{ question: "What is the simplex method?", answer: "An algorithm for solving LP problems by moving from one vertex of the feasible region to another." },
{ question: "What is duality in LP?", answer: "Every LP problem has a corresponding dual problem with interesting relationships." }
];
let currentCardIndex = 0;
let showingAnswer = false;
document.getElementById('flashcards-btn').addEventListener('click', function() {
document.getElementById('flashcards-modal').classList.remove('hidden');
showFlashcardQuestion();
});
document.getElementById('close-flashcards').addEventListener('click', function() {
document.getElementById('flashcards-modal').classList.add('hidden');
});
document.getElementById('next-card').addEventListener('click', function() {
if (showingAnswer) {
currentCardIndex = (currentCardIndex + 1) % flashcards.length;
showFlashcardQuestion();
} else {
showFlashcardAnswer();
}
});
document.getElementById('prev-card').addEventListener('click', function() {
if (!showingAnswer) {
currentCardIndex = (currentCardIndex - 1 + flashcards.length) % flashcards.length;
showFlashcardQuestion();
}
});
function showFlashcardQuestion() {
const card = flashcards[currentCardIndex];
document.getElementById('flashcard-content').innerHTML = `
<p class="text-lg font-medium mb-4">${card.question}</p>
<button id="show-answer" class="px-3 py-1 bg-blue-100 text-blue-700 rounded-full text-sm">
Show Answer
</button>
`;
showingAnswer = false;
document.getElementById('show-answer').addEventListener('click', showFlashcardAnswer);
}
function showFlashcardAnswer() {
const card = flashcards[currentCardIndex];
document.getElementById('flashcard-content').innerHTML = `
<p class="text-lg font-medium mb-2">${card.question}</p>
<p class="text-gray-700">${card.answer}</p>
`;
showingAnswer = true;
}
// Quiz
const quizQuestions = [
{
question: "What is the first step in formulating an LP problem?",
options: ["Draw a graph", "Identify the objective function", "Add slack variables"],
answer: "B"
},
{
question: "Where is the optimal solution found in graphical LP?",
options: ["At the center of the feasible region", "At a corner point", "Anywhere on a constraint line"],
answer: "B"
},
{
question: "What do you add to convert a ≤ constraint to standard form?",
options: ["Surplus variable", "Slack variable", "Artificial variable"],
answer: "B"
}
];
let currentQuestionIndex = 0;
let quizScore = 0;
document.getElementById('quiz-btn').addEventListener('click', function() {
document.getElementById('quiz-modal').classList.remove('hidden');
showQuizQuestion();
});
document.getElementById('close-quiz').addEventListener('click', function() {
document.getElementById('quiz-modal').classList.add('hidden');
});
document.getElementById('submit-quiz').addEventListener('click', function() {
const selectedOption = document.querySelector('input[name="quiz-answer"]:checked');
if (selectedOption) {
if (selectedOption.value === quizQuestions[currentQuestionIndex].answer) {
quizScore++;
alert("Correct! 🎉");
} else {
alert(`Incorrect. The correct answer is ${quizQuestions[currentQuestionIndex].answer}.`);
}
currentQuestionIndex++;
if (currentQuestionIndex < quizQuestions.length) {
showQuizQuestion();
} else {
alert(`Quiz complete! Your score: ${quizScore}/${quizQuestions.length}`);
document.getElementById('quiz-modal').classList.add('hidden');
currentQuestionIndex = 0;
quizScore = 0;
}
document.getElementById('quiz-score').textContent = `Score: ${quizScore}/${currentQuestionIndex}`;
} else {
alert("Please select an answer!");
}
});
function showQuizQuestion() {
const question = quizQuestions[currentQuestionIndex];
document.getElementById('quiz-question').innerHTML = `
<p class="font-medium mb-3">${question.question}</p>
<div class="space-y-2">
${question.options.map((opt, i) => `
<label class="flex items-center space-x-2 p-2 border rounded-lg hover:bg-gray-50 cursor-pointer">
<input type="radio" name="quiz-answer" class="form-radio" value="${String.fromCharCode(65 + i)}">
<span>${opt}</span>
</label>
`).join('')}
</div>
`;
}
// Timer
let timerInterval;
let timeLeft = 25 * 60; // 25 minutes in seconds
document.getElementById('timer-btn').addEventListener('click', function() {
document.getElementById('timer-modal').classList.remove('hidden');
updateTimerDisplay();
});
document.getElementById('close-timer').addEventListener('click', function() {
document.getElementById('timer-modal').classList.add('hidden');
});
document.querySelectorAll('.timer-preset').forEach(btn => {
btn.addEventListener('click', function() {
const minutes = parseInt(this.getAttribute('data-minutes'));
timeLeft = minutes * 60;
updateTimerDisplay();
});
});
document.getElementById('start-timer').addEventListener('click', function() {
if (!timerInterval) {
timerInterval = setInterval(() => {
timeLeft--;
updateTimerDisplay();
if (timeLeft <= 0) {
clearInterval(timerInterval);
timerInterval = null;
alert("Time's up! Take a break!");
}
}, 1000);
}
});
document.getElementById('pause-timer').addEventListener('click', function() {
if (timerInterval) {
clearInterval(timerInterval);
timerInterval = null;
}
});
document.getElementById('reset-timer').addEventListener('click', function() {
if (timerInterval) {
clearInterval(timerInterval);
timerInterval = null;
}
timeLeft = 25 * 60;
updateTimerDisplay();
});
function updateTimerDisplay() {
const minutes = Math.floor(timeLeft / 60);
const seconds = timeLeft % 60;
document.getElementById('timer-display').textContent =
`${minutes}:${seconds < 10 ? '0' : ''}${seconds}`;
}
// Distraction sounds
document.getElementById('distraction-btn').addEventListener('click', function() {
document.getElementById('distraction-modal').classList.remove('hidden');
});
document.getElementById('close-distraction').addEventListener('click', function() {
document.getElementById('distraction-modal').classList.add('hidden');
});
document.getElementById('volume-control').addEventListener('input', function() {
document.querySelector('.text-right').textContent = `${this.value * 100}%`;
});
// Focus mode
document.getElementById('focus-mode').addEventListener('click', function() {
document.body.classList.toggle('bg-gray-900');
document.querySelector('.container').classList.toggle('text-white');
document.querySelectorAll('.bg-white').forEach(el => el.classList.toggle('bg-gray-800'));
document.querySelectorAll('.text-gray-800').forEach(el => el.classList.toggle('text-gray-200'));
document.querySelectorAll('.text-gray-600').forEach(el => el.classList.toggle('text-gray-400'));
if (document.body.classList.contains('bg-gray-900')) {
this.innerHTML = '<i class="fas fa-sun mr-1"></i> Light Mode';
} else {
this.innerHTML = '<i class="fas fa-crosshairs mr-1"></i> Focus Mode';
}
});
// Practice feedback
document.getElementById('check-practice').addEventListener('click', function() {
const feedback = document.getElementById('practice-feedback');
feedback.classList.remove('hidden');
feedback.innerHTML = `
<div class="bg-green-100 border border-green-400 text-green-700 px-4 py-3 rounded">
<p>Good attempt! Here's the correct formulation:</p>
<p class="font-mono mt-1">Max P = 15x + 20y</p>
<p class="font-mono">4x ≤ 20</p>
<p class="font-mono">10y ≤ 30</p>
<p class="font-mono">x, y ≥ 0</p>
</div>
`;
});
document.getElementById('check-std-form').addEventListener('click', function() {
const feedback = document.getElementById('std-form-feedback');
feedback.classList.remove('hidden');
feedback.innerHTML = `
<div class="bg-green-100 border border-green-400 text-green-700 px-4 py-3 rounded">
<p>Correct standard form would be:</p>
<p class="font-mono mt-1">Maximize z = 3x₁ + 2x₂⁺ - 2x₂⁻</p>
<p class="font-mono">x₁ + x₂⁺ - x₂⁻ + s₁ = 4</p>
<p class="font-mono">x₁ - x₂⁺ + x₂⁻ - s₂ = 1</p>
<p class="font-mono">x₁, x₂⁺, x₂⁻, s₁, s₂ ≥ 0</p>
</div>
`;
});
document.getElementById('check-dual').addEventListener('click', function() {
const feedback = document.getElementById('dual-feedback');
feedback.classList.remove('hidden');
feedback.innerHTML = `
<div class="bg-green-100 border border-green-400 text-green-700 px-4 py-3 rounded">
<p>The dual problem is:</p>
<p class="font-mono mt-1">Max w = 6y₁ + 4y₂</p>
<p class="font-mono">3y₁ + y₂ ≤ 2</p>
<p class="font-mono">y₁ + 2y₂ ≤ 5</p>
<p class="font-mono">y₁, y₂ ≥ 0</p>
</div>
`;
});
// Simplex method interaction
document.getElementById('step-simplex').addEventListener('click', function() {
alert("Performing next simplex iteration...");
// In a real implementation, we would update the tableau
});
document.getElementById('hint-simplex').addEventListener('click', function() {
alert("Hint: Look for the most negative number in the bottom row to choose the pivot column.");
});
document.getElementById('auto-simplex').addEventListener('click', function() {
alert("Automatically solving the problem...");
// In a real implementation, we would solve the entire problem
});
document.getElementById('reset-simplex').addEventListener('click', function() {
alert("Resetting the tableau to initial state...");
// In a real implementation, we would reset the tableau
});
// Duality animation
document.getElementById('duality-animation-btn').addEventListener('click', function() {
const exampleDiv = this.closest('.bg-gray-100');
exampleDiv.classList.add('pulsing');
setTimeout(() => {
exampleDiv.classList.remove('pulsing');
}, 1500);
});
</script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=raayraay/study-buddy-site" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html> |