Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
.NET
.NET Core
.NET MAUI
.NET Standard
Active Directory
ADO.NET
Agile Development
AI
AJAX
AlbertAGPT
Alchemy
Alexa Skills
Algorand
Algorithms in C#
Android
Angular
ArcObject
ASP.NET
ASP.NET Core
Augmented Reality
Avalanche
AWS
Azure
Backbonejs
Big Data
BizTalk Server
Blazor
Blockchain
Bootstrap
Bot Framework
Business
Business Intelligence(BI)
C#
C# Corner
C# Strings
C, C++, MFC
Career Advice
Careers and Jobs
Chapters
ChatGPT
Cloud
Coding Best Practices
Cognitive Services
COM Interop
Compact Framework
Copilot
Cortana Development
Cosmos DB
Cryptocurrency
Cryptography
Crystal Reports
CSS
Current Affairs
Custom Controls
Cyber Security
Data Mining
Data Science
Databases & DBA
Databricks
Design Patterns & Practices
DevExpress
DevOps
DirectX
Dynamics CRM
Enterprise Development
Entity Framework
Error Zone
Exception Handling
F#
Files, Directory, IO
Flutter
Games Programming
GDI+
General
Generative AI
GO
Google Cloud
Google Development
Graphics Design
Graphite Studio
Hardware
Hiring and Recruitment
HoloLens
How do I
HTML 5
Infragistics
Internet & Web
Internet of Things
Ionic
Java
Java and .NET
JavaScript
JQuery
JSON
JSP
Knockout
Kotlin
Langchain
Leadership
Learn .NET
Learn iOS Programming
LINQ
Machine Learning
Metaverse
Microsoft 365
Microsoft Fabric
Microsoft Office
Microsoft Phone
Microsoft Teams
Mobile Development
MongoDB
MuleSoft
MySQL
NEAR
NetBeans
Networking
NFT
NoCode LowCode
Node.js
Office Development
OOP/OOD
Open Source
Operating Systems
Oracle
Outsourcing
Philosophy
PHP
Polygon
PostgreSQL
Power Apps
Power Automate
Power BI
Power Pages
Printing in C#
Products
Progress
Progressive Web Apps
Project Management
Public Speaking
Python
Q#
QlikView
Quantum Computing
R
React
React Native
Reports using C#
Robotics & Hardware
RPA
Ruby on Rails
RUST
Salesforce
Security
Servers
ServiceNow
SharePoint
Sharp Economy
SignalR
Smart Devices
Snowflake
Software Architecture/Engineering
Software Testing
Solana
Solidity
Sports
SQL
SQL Server
Startups
Stratis Blockchain
Swift
SyncFusion
Threading
Tools
TypeScript
Unity
UWP
Visual Basic .NET
Visual Studio
Vue.js
WCF
Wearables
Web API
Web Design
Web Development
Web3
Windows
Windows Controls
Windows Forms
Windows PowerShell
Windows Services
Workflow Foundation
WPF
Xamarin
XAML
XML
XNA
XSharp
Register
Login
2
Answers
Problem in C#: You must get fully dressed before leaving the house !!!
avanthika rachael
12y
3.7k
1
Reply
Can anyone please tell me how should I approach this problem in
C#
, what would be best way
to solve this problem by keeping in mind the best possible design (pattern) approach, any help is greatly appreciated.
Problem: You must get fully dressed before leaving the house
Rules:
At the start, assume you have PJ's on
Only 1 piece of each item of clothing may be put on
You cannot put on socks when it is hot
You cannot put on jacket when it is hot
Socks must be put on before footwear
Shirt must be put on before headwear and jacket
Pants must be put on before footwear
Pajamas must be taken off before anything can be put on
You cannot leave the house until all items of clothing are on (except socks and a jacket when it's hot)
If an invalid command is issued, please respond with "fail"
Input: Temperature type (HOT|COLD) and a comma separated list of numeric commands
Command | Description | Hot Response | Cold Response
—————————————————————————————-
1 | Put on footwear | "sandals" | "boots"
2 | Put on headwear
| "sunglasses" | "hat"
3 | Put on socks | fail | "socks"
4 | Put on shirt | "shirt" | "shirt"
5 | Put on jacket | fail | "jacket"
6 | Put on pants | "shorts" | "pants"
7 | Leave house | "leaving house" | "leaving house"
8 | Take off pajamas| "Removing PJs" | "Removing PJs"
Here are some example scenarios
Successful
———-
Input: HOT 8, 6, 4, 2, 1, 7
Output: Removing PJs, shorts, shirt, sunglasses, sandals, leaving house
Input: COLD 8, 6, 3, 4, 2, 5, 1, 7
Output: Removing PJs, pants, socks, shirt, hat, jacket, boots, leaving house
Failure
——-
Input: HOT 7
Output: failure
Input: HOT 8, 6, 6
Output: Removing PJs, shorts, fail
Input: HOT 8, 6, 3
Output: Removing PJs, shorts, fail
Input: COLD 8, 6, 3, 4, 2, 5, 7
Output: Removing PJs, pants, socks, shirt, hat, jacket, fail
Input: COLD 8, 6, 3, 4, 2, 5, 1
Output: Removing PJs, pants, socks, shirt, hat, jacket, boots, fail
Input: COLD 6
Output: fail
someone please help ASAP ..please
Post
Reset
Cancel
Answers (
2
)
Next Recommended Forum
Help Saving Settings?
Setting for Form Focus