Skip to content

Instantly share code, notes, and snippets.

@Shaun420
Shaun420 / csharp-console-game
Created June 11, 2024 13:34
C# console game
using System;
Random random = new Random();
Console.CursorVisible = false;
int height = Console.WindowHeight - 1;
int width = Console.WindowWidth - 5;
Console.WriteLine($"Height: {height}, Width: {width}");
bool shouldExit = false;
// Console position of the player
@Shaun420
Shaun420 / csharp-pets-app.cs
Created June 10, 2024 14:54
C# Pets console app which displays information about pet animals and searching functionality for finding specific pets.
using System;
// ourAnimals array will store the following:
string animalSpecies = "";
string animalID = "";
string animalAge = "";
string animalPhysicalDescription = "";
string animalPersonalityDescription = "";
string animalNickname = "";
string suggestedDonation = "";
@Shaun420
Shaun420 / reverse-words-in-sentence.cs
Created June 10, 2024 07:53
C# program code to reverse the words in a sentence keeping their position same.
string pangram = "The quick brown fox jumps over the lazy dog";
string[] words = pangram.Split(" ");
string answer = "";
string reverse = "";
char[] charArray;
for (int i = 0; i < words.Length; i++) {
charArray = words[i].ToCharArray();
Array.Reverse(charArray);
reverse = new string(charArray);
@Shaun420
Shaun420 / time-since.py
Last active February 27, 2021 18:59
Returns the time passed since an unix timestamp as a formatted string.
import time, math
# Sample timestamp to test.
dTs = 1610033721
def returnTimeSince(unixtimestamp: int) -> str:
# String which will contain formatted time.
timesince = ""
# Get the difference between the argument timestamp and current timestamp.
# Note: time.time() returns a float.