bsc

Comprehensive codebase and cou...
Log | Files | Refs | README | LICENSE

commit b98e031f4b20872648491804a9c3871c8971472f
parent 5e03b10a9ef1087b3638f2513e9721443722e2a4
Author: Amit Dutta <amitdutta4255@gmail.com>
Date:   Wed, 15 Oct 2025 17:23:37 +0530

update _index/template

Diffstat:
Mdocs/index.html | 75++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
Mdocs/template.html | 3++-
2 files changed, 74 insertions(+), 4 deletions(-)

diff --git a/docs/index.html b/docs/index.html @@ -55,7 +55,8 @@ BSc Repository Contents </h1> <p class="text-gray-500 mt-2"> - A quick navigation guide to the files in the repository. + A quick navigation guide to the files in the repository. <br><br> + <b>For optimal viewing and experience, please use a desktop browser.</b> </p> </div> <div class="space-y-4"> @@ -400,7 +401,7 @@ int main() { <div class="flex items-center"> <svg class="w-6 h-6 text-blue-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z"></path></svg> <span class="font-medium text-gray-800">challange</span> - <span class="ml-2 text-sm text-gray-500">(1 files)</span> + <span class="ml-2 text-sm text-gray-500">(2 files)</span> </div> <div class="flex items-center space-x-4"> <a href="https://github.com/notamitgamer/bsc/tree/main/challange" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" onclick="event.stopPropagation()" title="View folder on GitHub"> @@ -568,7 +569,7 @@ int main() break; } - // discarding extra characters (if any) + // discarding extra characters (if any) left while (getchar() != &#x27;\n&#x27;) ; @@ -579,6 +580,74 @@ int main() }</code></pre> </div> </li> + + <li> + <div class="flex items-center p-3 pl-8 hover:bg-gray-50 transition-colors duration-200"> + <svg class="w-6 h-6 text-green-500 mr-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path></svg> + <span class="text-gray-700">sudiptoown01.c</span> + <div class="ml-auto flex items-center space-x-4"> + <a href="https://github.com/notamitgamer/bsc/blob/main/challange/sudiptoown01.c" target="_blank" class="p-1 rounded-full text-gray-500 hover:bg-gray-200 hover:text-gray-800 transition-colors" title="View file on GitHub"> + <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12c0 4.418 2.865 8.168 6.839 9.492.5.092.682-.217.682-.482 0-.237-.009-.868-.014-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.031-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.03 1.595 1.03 2.688 0 3.848-2.338 4.695-4.566 4.942.359.308.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.001 10.001 0 0022 12c0-5.523-4.477-10-10-10z" clip-rule="evenodd"></path></svg> + </a> + <button onclick="showCode('code-challange-sudiptoown01_c', 'sudiptoown01.c')" class="text-green-600 font-semibold text-sm hover:underline">View Code</button> + </div> + </div> + <div id="code-challange-sudiptoown01_c" class="hidden" data-github-url="https://github.com/notamitgamer/bsc/blob/main/challange/sudiptoown01.c"> + <pre><code class="language-c">/* + * A smart home security controller monitors the state of several sensors to decide what action to take. + * Each second, the system reads data from sensors that are either an active or inactive. Based on the current + * state of all sensors, the controller must perform exactly one action, such as activating a warning, checking + * a specific zone, or declaring an intrusion. Write a C program that reads the sensor status as input and + * prints the corresponding system action. + * Hints: + * 1. The most determinative action wins for every possible combination of sensor states. + * 2. You are not allowed to use any conditional statements (if, else if, else, or the ternary operator?). + * 3. You are not allowed to use logical operators. + * 4. You must use a single switch statement to control the program&#x27;s behavior. + * 5. The program should handle all possible combinations of the sensors&#x27; active/inactive states and print the appropriate response each time. + * 6. All sensors are inactive, the system should remain idle. + * 7. If some sensors are active, the system should issue warnings or alerts based on the situation. + * 8. If all sensors are active, the system should declare a confirmed intrusion. + * Solution: + * We can solve this problem simply by assigning each case its own distinct integer. + * There are 2 possibilities for a sensor and therefore there are 2^4 = 16 cases. + * Using arrays we can assign each case its own index value and print it as per the encoded binary integer. + */ +#include &lt;stdio.h&gt; + +int casekey(int door, int window, int motion, int glass) { + int key = (door &lt;&lt; 3) | (window &lt;&lt; 2) | (motion &lt;&lt; 1) | glass; + return key; +} + +int main() { + int door, window, motion, glass, key; + char choice; + + static const char *action[16] = { + &quot;IDLE&quot;, &quot;CHECK WINDOW&quot;, &quot;WARN MOTION&quot;, &quot;WARN MOTION WINDOW&quot;, + &quot;CHECK DOOR&quot;, &quot;WARN DOOR WINDOW&quot;, &quot;INTRUSION SUSPECTED&quot;, &quot;INTRUSION CONFIRMED&quot;, + &quot;GLASS ONLY&quot;, &quot;DOOR GLASS&quot;, &quot;MOTION GLASS&quot;, &quot;MOTION WINDOW GLASS&quot;, + &quot;DOOR WINDOW&quot;, &quot;DOOR WINDOW GLASS&quot;, &quot;DOOR MOTION GLASS&quot;, &quot;ALL SENSORS&quot; + }; + + do { + printf(&quot;Sensors: Door, Window, Motion, Glass\n&quot;); + printf(&quot;Enter the state of each sensor in binary (0 or 1): &quot;); + scanf(&quot;%d %d %d %d&quot;, &amp;door, &amp;window, &amp;motion, &amp;glass); + + key = casekey(door, window, motion, glass); + printf(&quot;Action: %s\n&quot;, action[key]); + + printf(&quot;Want to continue? (y/n): &quot;); + scanf(&quot; %c&quot;, &amp;choice); + printf(&quot;\n&quot;); + } while (choice == &#x27;y&#x27; || choice == &#x27;Y&#x27;); + + return 0; +}</code></pre> + </div> + </li> </ul> </div> </li> diff --git a/docs/template.html b/docs/template.html @@ -55,7 +55,8 @@ BSc Repository Contents </h1> <p class="text-gray-500 mt-2"> - A quick navigation guide to the files in the repository. + A quick navigation guide to the files in the repository. <br><br> + <b>For optimal viewing and experience, please use a desktop browser.</b> </p> </div> <div class="space-y-4">
© notamitgamer • Site Built: 2026-07-21 13:58:23 UTC • git-mirror commit: 1037f62 [view raw info]
Originally created with stagit • modified by notamitgamer
Forked from github.com/notamitgamer/git-mirror