Okay, here is a fun one. We've all seen Fibonacci sequences. But they are all played out. Let's look at a different sequence. They are called Hamming Numbers after Richard Hamming, who proposed the problem of finding computer algorithms for generating these numbers in ascending order.
For number H is equal to 2**i * 3**j * 2**k where i,k,k are all non negative.
So hopefully that explains what the sequence looks like. Your challenge, if you choose to accept it is to generate the first 25 of them. An arbitrary nth one such as 1700th. And given a number X determine if it is or is not a valid hamming number.
Conway's Game of Life. It is a simple concept. Set up some cool patterns and let it run on a good cycle. I just did it, using '*' and ' ' but feel free to do it graphically if you prefer. Here are the rules, and my code is in the same repo so let that be a spoiler warning:
Snail Sort Given an n x n array, return the array elements arranged from outermost elements to the middle element, traveling clockwise.
array = [[1,2,3], [4,5,6], [7,8,9]] snail(array) #=> [1,2,3,6,9,8,7,4,5] For better understanding, please follow the numbers of the next array consecutively:
array = [[1,2,3], [8,9,4], [7,6,5]] snail(array) #=> [1,2,3,4,5,6,7,8,9] This image will illustrate things more clearly:
NOTE: The idea is not sort the elements from the lowest value to the highest; the idea is to traverse the 2-d array in a clockwise snailshell pattern.
Given a list of integers S and a target number k, write a function that returns a subset of S that adds up to k. If such a subset cannot be made, then return null.
Integers can appear more than once in the list. You may assume all numbers in the list are positive.
For example, given S = [12, 1, 61, 5, 9, 2] and k = 24, return [12, 9, 2, 1] since it sums up to 24.
Okay, here's one. I just finished helping someone worth through this. So it's pretty fun.
Write a program in Python, that can accept a paragraph string and and page width and return an array of left AND right justified strings. NOTE: No words should be broken, the beginning and end of the line should be characters).
You should provide instructions on how to execute your program and provide a sample output.
Example:
Sample input:
Paragraph = "This is a sample text but a complicated problem to be solved, so we are adding more text to see that it actually works."
Page Width = 20
Output should look like this:
Array [1] = "This is a sample" Array [2] = "text but a" Array [3] = "complicated problem" Array [4] = "to be solved, so we" Array [5] = "are adding more text" Array [6] = "to see that it" Array [7] = "actually works.”
If you are interested in any of my coding challenges they should all be tagged with : #toyprogrammingchallenge
If you put that in your search and scroll to to bottom you will see my original proposal. Here is a link with the explanation of where my head is at. The ones I post that I call freebies, are from a subscription to Job Interview problems, and they should be a little tricky, but are usually rated as easy, medium or hard.
Run-length encoding is a fast and simple method of encoding strings. The basic idea is to represent repeated successive characters as a single count and character. For example, the string "AAAABBBCCDAA" would be encoded as "4A3B2C1D2A".
Implement run-length encoding and decoding. You can assume the string to be encoded have no digits and consists solely of alphabetic characters. You can assume the string to be decoded is valid.