Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am helixspiral on github.
  • I am shawn (https://keybase.io/shawn) on keybase.
  • I have a public key ASDTH57Dxc__WY96zkYSWwuMhVpMc8_L-qY9HsJOpynn5go

To claim this, I am signing this object:

@HelixSpiral
HelixSpiral / int.rb
Created May 19, 2014 01:18
How many integers between 1500 and 8000 (inclusive) contain no repeated digits?
#!/usr/bin/env ruby
# Author: Shawn Smith
# Purpose: Do nins math work
# Problem: How many integers between 1500 and 8000 (inclusive) contain no repeated digits?
total = 0
for x in 1500..8000 do
number = x.to_s
@HelixSpiral
HelixSpiral / passgen.rb
Last active December 27, 2015 00:59
Generate random passwords from inside Weechat.
# Copyright (c) 2013 Shawn Smith <ShawnSmith0828@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@HelixSpiral
HelixSpiral / Sieve.cpp
Last active December 14, 2015 02:29
First time using std::vector<bool>. Decided to make a Sieve of Eratosthenes for practice. Takes a number for input and finds all the primes up to that number. Sieve[x] will return true if x is prime, false if not.
#include <iostream> // Needed for std::cin/cout
#include <vector> // Needed for std::vector
#include <cmath> // Needed for sqrt and ceil
int main()
{
/* Will be the sieve */
std::vector<bool> Sieve;
unsigned int x, y, limit;
@HelixSpiral
HelixSpiral / IntegerSort.cpp
Last active December 12, 2015 07:29
Challenge: Take input from a user and print the lowest number possible using the digits from the given input.
#include <iostream> // Needed for std::cout/cin
#include <vector> // Needed for std::vector
#include <string> // Needed for std::string
#include <algorithm> // Needed for std::sort
int main()
{
std::string user_input;
std::vector<int> digits;
bool negative;
@HelixSpiral
HelixSpiral / HTSBasic-6.rb
Created February 7, 2013 22:00
This solves the HackThisSite 'basic' mission number 6.
# Enter the encoded password from HackThisSite
encoded_password = "a9;96j6i"
# empty string for the decoded password
password = ""
# Loop for the length of the encoded password
0.upto(encoded_password.length-1) do |x|
password += ((encoded_password[x].ord)-x).chr
end
@HelixSpiral
HelixSpiral / Prime.cpp
Created February 7, 2013 19:55
Challenge: If a number, 'X' is prime then 2^X-1 should also be prime, find at which prime this fails to be true. This uses the trial and error method of finding prime numbers.
#include <iostream>
#include <cmath>
#include "Prime.h"
int main()
{
int x;
bool Failure = false;
for (x = 1; Failure != true; ++x)
@HelixSpiral
HelixSpiral / SumOfDigits.cpp
Created February 8, 2012 03:49
Returns the sum of the digits to the given number.
/** Write a program that prompts the user for a positive
* integer and then computes the sum of all the digits of
* the number. For example, if the user enters 2784,
* then the program reports 21. If the user enters 59,
* then the program reports 14. The program should work
* for any number having one to ten digits.
*/
#include <iostream>
#include <string>
@HelixSpiral
HelixSpiral / PerfectSquare.c
Last active September 30, 2015 09:38
Determines the closest number to the users input that is a perfect square.
/** Write a program that prompts the user for a positive integer
* and then reports the closest integer having a whole number square root.
* For example if the user enters 8 then the program reports 9.
* The program should work for any number having one to seven digits.
*/
#include <stdio.h>
/* Checks to see if the number is a perfect square.
returns 1 for yes, 0 for no. */
@HelixSpiral
HelixSpiral / Bottles.c
Created January 10, 2012 07:25
99 Bottles of beer on the wall
/* http://rosettacode.org/wiki/99_Bottles_of_Beer */
#include <stdio.h>
int main()
{
int bottles;
for(bottles = 99; bottles > 0; --bottles)
{