Skip to content

Instantly share code, notes, and snippets.

View PJensen's full-sized avatar

Pete Jensen PJensen

  • New England
View GitHub Profile
@PJensen
PJensen / WordleSolver.py
Last active February 10, 2022 15:39
Solves Wordle Puzzles with Input from User
from functools import reduce
import os, sys, time, string
from turtle import down
import urllib.request
import urllib
class WordleSolver:
"""
Solves Wordle Puzzles with feedback from the user
https://www.powerlanguage.co.uk/wordle/
public static void moveZeros(ref int[] numbers)
{
// Create a new array of the same size, NOTE: it's already initialized with zeros
var newArray = new int[numbers.Length];
// the "otherIndex" is used to separately track non-zero entries in the copy
int otherIndex = 0;
for (int index = 0; index < numbers.Length; index++)
{
@PJensen
PJensen / Perceptron.cs
Last active February 28, 2019 18:49
A refactorted and object oriented version of the procedural Perceptron outlined http://www.codingvision.net/miscellaneous/c-perceptron-tutorial
public class EntryPoint
{
public static void Main(string[] args)
{
var n0 = new Perceptron(2);
do
{
n0.ResetErrorTracking();
@PJensen
PJensen / Sample.cs
Last active December 2, 2016 19:08
Samples the collection using a uniform distribution, do not repeat elements.
/// <summary>
/// SampleService
/// </summary>
public class SampleService
{
private readonly Random _random;
/// <summary>
/// Initializes a new instance of the <see cref="SampleService"/> class.
/// </summary>
@PJensen
PJensen / ByteArray.cs
Created October 30, 2016 18:44
A small command line tool to convert an input file into a C# byte array
using System;
using System.IO;
using System.Linq;
using System.Text;
namespace ByteArray
{
internal class EntryPoint
{
private static readonly string[] helpCmds = { "help", "/?", "--help", "-help", "-h" };
@PJensen
PJensen / Dungeon.xml
Last active April 28, 2016 03:33
Dungeon XML (Experimental)
<?xml version="1.0" encoding="utf-8"?>
<Map>
<Rooms>
<Room Id="Room0" Length="20" Width="20">
<Decorations>
<Decoration Id="Room0_Altar" Type="Altar" OnEvent="Room0_Altar__Pray"/>
</Decorations>
<Thresholds>
<Door Orientation="Right" Alignment="Center" Id="Room0_Door0" Locked="True"/>
<Opening Orientation="Left" Alignment="Center" Id="Room0_Opening0"/>
@PJensen
PJensen / MotleyFoolCapsRatingClient.cs
Last active January 4, 2018 01:54
Downloads CAPS ratings from the Motley Fool API
using System;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net;
using System.Reflection;
using System.Text;
using System.Xml.Serialization;
@PJensen
PJensen / SocketableWeapons.cs
Created October 21, 2015 22:53
The following demonstrates a basic idea for socket-able weapons.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace SocketableWeapons
{
internal class Program
{
private static void Main(string[] args)
<!doctype html>
<title>Site Maintenance</title>
<style>
body { text-align: center; padding: 150px; }
h1 { font-size: 50px; }
body { font: 20px Helvetica, sans-serif; color: #333; }
article { display: block; text-align: left; width: 650px; margin: 0 auto; }
a { color: #dc8100; text-decoration: none; }
a:hover { color: #333; text-decoration: none; }
</style>
/// <summary>
/// Authenticate
/// </summary>
/// <param name="userName">the user name</param>
/// <param name="passwordHash">the password hash</param>
/// <returns>an auth response object containing -1 on auth failure</returns>
DNHAuthResponse DNHService.Iface.Authenticate(string userName, string passwordHash)
{
LogCallback(string.Format("Authenticating {0}", userName));