Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vampire Conundrum Puzzle #85

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,20 @@ Download or clone this repo and open the `csharp-101` folder in VS Code to get s
14 | Methods and Members | [14 Notebook](https://ntbk.io/csharp101-notebook14) | [14 Video](https://www.youtube.com/watch?v=xLhm3bEG__c&list=PLdo4fOcmZ0oVxKLQCHpiUWun7vlJJvUiN&index=17) | [Object Oriented Coding in C#](https://docs.microsoft.com/dotnet/csharp/fundamentals/tutorials/classes?WT.mc_id=csharpnotebook-35129-website)
15 | Methods and Exceptions | [15 Notebook](https://ntbk.io/csharp101-notebook15) | [15 Video](https://www.youtube.com/watch?v=8YsoBBiVVzQ&list=PLdo4fOcmZ0oVxKLQCHpiUWun7vlJJvUiN&index=18) | [Object Oriented Coding in C#](https://docs.microsoft.com/dotnet/csharp/fundamentals/tutorials/classes?WT.mc_id=csharpnotebook-35129-website)


## Puzzles (C# Scenarios)

Here are a list of the scenarios / programming puzzles in this repository.

These are a good next thing after working through the csharp-101 notebooks.

### Puzzles

| # | Topic | Notebook Link |
|---|--------------------------------------------|------------------------------------------------|
| 1 | Alien Translation | [Alien Translation](./csharp-scenarios/01-Alien-Translator.ipynb)
| 2 | Vampire Conundrum | [Vampire Conundrum](./csharp-scenarios/02-Vampire-Conundrum.ipynb)

## Machine Learning

Download or clone this repo and open the `machine-learning` folder to get started with the machine-learning notebooks.
Expand Down
205 changes: 205 additions & 0 deletions csharp-scenarios/02-Vampire-Conundrum.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,205 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# The Enigmatic Night Adventure: A Vampire's Conundrum\n",
"\n",
"![Vampire Image](./images/vampire-conundrum.webp)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"You're dozing off into dreamland in your comfy bed when, whoosh! The wind rattles your windows, and a mysterious presence swirls in your room. Suddenly, everything fades to black, and you're whisked away on a whirlwind adventure through time and space! You soar over oceans, dart through clouds, feeling the elements in a dizzying, exhilarating rush.\n",
"\n",
"Blinking awake, you find yourself in a grand, candlelit chamber, straight out of a gothic tale! The stone walls echo with ancient secrets, and sitting across from you is a figure with teeth as sharp as a wolf's and eyes glowing a fiery red - a vampire, no less!\n",
"\n",
"\"Ah, the famed problem-solver!\" the vampire exclaims with a grin. \"We, the eclectic vampire community, are in a bit of a pickle. Counting vampires isn't as easy as it sounds, especially when they're as varied as stars in the sky! We need your sharp mind to tally our numbers. Here's the fascinating array of our vampire species:\"\n",
"\n",
"```\n",
"-6 = Disfigured Vampire\n",
"-5 = Insane Vampire\n",
"-4 = Soul Vampire\n",
"-3 = Psi-Vampire\n",
"-2 = Emphatic Vampire\n",
"-1 = Half-Vampire\n",
"0 = Regular Human\n",
"+1 = Blood Drinkers Vampire\n",
"+2 = Genetic Vampire\n",
"+3 = Moonbane Vampire\n",
"+4 = Psychic Vampire\n",
"+5 = Vampyre\n",
"+6 = Origin Lord Vampire\n",
"```\n",
"\n",
"## Puzzle 1: The Vampire Census\n",
"\n",
"\"First challenge!\" the vampire announces. \"Can you sum up the types from this whimsical list? For example:\"\n",
"\n",
"```\n",
"Vampyre\n",
"Vampyre\n",
"Regular Human\n",
"Moonbane Vampire\n",
"Regular Human\n",
"Soul Vampire\n",
"Soul Vampire\n",
"Vampyre\n",
"```\n",
"\n",
"\"In this case, you'd add +5, +5, 0, +3, 0, -4, -4, and +5 to get a total of 10. Try it with our full registry!\""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## The registry\n",
"\n",
"Run the code below to get the full registry of Vampires. "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"dotnet_interactive": {
"language": "csharp"
},
"polyglot_notebook": {
"kernelName": "csharp"
},
"vscode": {
"languageId": "polyglot-notebook"
}
},
"outputs": [],
"source": [
"using System.IO;\n",
"using System.Linq;\n",
"\n",
"// Replace with the correct path to your file\n",
"string filePath = \"./inputs/02-Vampire-Conundrum.txt\";\n",
"string fileContent;\n",
"\n",
"// Read the content of the file\n",
"if (File.Exists(filePath))\n",
"{\n",
" fileContent = File.ReadAllText(filePath);\n",
"}\n",
"else\n",
"{\n",
" fileContent = \"File not found.\";\n",
"}\n",
"\n",
"var vampires = fileContent.Split(\"\\n\").ToArray<string>();\n",
"foreach(var vampire in vampires) {\n",
" Console.WriteLine(vampire);\n",
"}"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"As you can see above all Vampires are available in the \"vampires\" variable.\n",
"\n",
"**Now solve the problem and click below to compare your answer with the actual answer!**\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"dotnet_interactive": {
"language": "csharp"
},
"polyglot_notebook": {
"kernelName": "csharp"
},
"vscode": {
"languageId": "polyglot-notebook"
}
},
"outputs": [],
"source": [
"// Write your solution here and click below to compare with the actual answer when you think you are right!"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
"<details>\n",
" <summary>Click to expand to see the correct answer</summary>\n",
" \n",
" \n",
" **Answer to the puzzle is: 16**\n",
"\n",
" ## Puzzle 2: Extremes of the Night\n",
"\n",
" The Vampire looks happy of your correct answer:\n",
"\n",
"\"Bravo on the counting! But there's more. We need to know the most and least common vampires among us. \n",
"\n",
"Balance is key in our world! Multiply the numbers of the most and least common vampires.\"\n",
"\n",
"\"For instance, if the most common vampire are 3 Vampyres and the least common vampire are 2 Soul Vampires, it's 2*3, making 6. \n",
"\n",
"What's the answer for our extensive list?\"\n",
"\n",
"</details>"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"dotnet_interactive": {
"language": "csharp"
},
"polyglot_notebook": {
"kernelName": "csharp"
},
"vscode": {
"languageId": "polyglot-notebook"
}
},
"outputs": [],
"source": [
"// Write your solution here and click below to compare with the actual answer when you think you are right!"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
"<details>\n",
" <summary>Click to expand to see the correct answer</summary>\n",
" \n",
" \n",
" **Answer to the puzzle is: 708**\n",
"\n",
" ## Conclusion\n",
"\n",
"\"Phew, you're a lifesaver - quite literally!\" the vampire chuckles mischievously. \n",
"\n",
"\"You've saved not just our night but your own neck too. Otherwise, well, let's just say we might have had a more... bloodthirsty conclusion to our meeting, muahaha!\"\n",
"\n",
"</details>"
]
}
],
"metadata": {
"language_info": {
"name": "csharp"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Binary file added csharp-scenarios/images/vampire-conundrum.webp
Binary file not shown.
Loading