AI Natural Language

Code is AI's natural language.


Happy Pi Day! Pizza Hut's Math Competition for free pizza for 3.14 years

Three problems, if you are the first to solve any of them, then you win the grand pizza prize.

Calling all math experts and Pizza Hut fans alike! National Pi Day is here and this is your chance to win free “pie,” that’s 3.14 years of Pizza Hut pizza (awarded in Pizza Hut® gift cards)! Take a look at the math problems below and provide your answer to Option A, B, or C in the comments section. Please be sure to note which you are trying to solve. Answers will be time stamped to determine the potential winner and participants can only win once.
Best of luck!
– Pizza Hut & John H. Conway
The three problems:

I’m thinking of a ten-digit integer whose digits are all distinct. It happens that the number formed by the first n of them is divisible by n for each n from 1 to 10. What is my number?

Our school’s puzzle-club meets in one of the schoolrooms every Friday after school.
Last Friday, one of the members said, “I’ve hidden a list of numbers in this envelope that add up to the number of this room.” A girl said, “That’s obviously not enough information to determine the number of the room. If you told us the number of numbers in the envelope and their product, would that be enough to work them all out?”
He (after scribbling for some time): “No.” She (after scribbling for some more time): “well, at least I’ve worked out their product.”
What is the number of the school room we meet in?”

OPTION C: YET TO BE SOLVED, No one has gotten this one exactly right yet! Hint: It helps to show your work!
My key-rings are metal circles of diameter about two inches. They are all linked together in a strange jumble, so that try as I might, I can’t tell any pair from any other pair.
However, I can tell some triple from other triples, even though I’ve never been able to distinguish left from right. What are the possible numbers of key-rings in this jumble?

Since the first two are solved already in the comments. I chose to focus and solve 'Option C'.


The solution to Option C I arrived at is 7 + n, where n is any positive integer. Here's the picture I drew to convince myself:

The numbers represent how many rings each circle represents and 'n' represents any number of set of rings or chain of rings (like a chain of 1 rings). It got a bit messy when I tried to draw each of them individually. ;)

The two at the bottom don't need to be interlinking, especially when n=2. There are other combination of rings, but this seems to provide the simplest answer and largest possible answer space.

The "pairs" are indistinguishable. The triplet is distinguishable from any other triplet. This meets all the requirements of the puzzle.

Thanks for the opportunity to solve it. Pizza Hut and Mr. Conway

The Pizza Hut blog post: National Pi Day Math Contest Problems

~ Danial Goodwin ~


Privacy: Programmatically Identifying Developer Devices

Apps can programmatically identify likely device(s) of app developers.

It's due to the fact that app developers usually install their app many times. And, it's possible to watch for those app installs in Android.

Implementing an app that takes advantage of this requires ZERO permissions.

So, I've created two working proof-of-concept apps: One to programmatically identify developer devices, and one to identify those kinds of apps and stop them. Both are open source and can be found on GitHub, and the later one can be found on Google Play.

I'll explain shortly how this is done.

Imagine, if you are an app developer, then your device(s) can be programmatically identified and have special code ran for them and nobody else will experience the same issue or app changes.


AI not equivalent to Smart

Having AI (Artificial Intelligence) doesn't mean that it is smart. In fact, it is much easier to create "dumb" AI than "smart" AI.

~ Danial Goodwin ~


Static Site Generation

As I've gotten free time, I've researched different popular static site generators and decided to use Jekyll because of their great documentation, support, community, and themes. Also, Jekyll has been really simple to implement and working on my server.

The current host for the site is at danialgoodwin.com/blog. The backend and piping is all complete. All that's left is to update the UI to how I like (it will maintain some minimalist aspects to it).

All my new dev and random posts have been going to the new site. The entire posting process is quite simple as everything is written in Markdown, so I could easily change which technology I'm using. Once I do a 'git commit', I just need a 'git push' and allow the server webhook to automatically compile the raw content data and publish the static site.

Finally, I now have quick loading site with all the internals open to me.

Blogger unfortunately is quite bloated, but it is a good trade-off for simplicity in many cases, just not mine.

~ Danial Goodwin ~


Coming Soon: New Format and Books!

Basically, I really like this domain and I'm going to start adding more stuff to it. Unfortunately, Blogger doesn't support the kind of layout and setup that I would like, I will soon start to be using new tools and write about those specifics later.

One of the first new things that I want to add are about the books I've been thinking about and planning. The goal is to make sure that they have a very high signal to noise ratio for readers. So, the books will be about 500+ pages of content condensed to less than 100 pages. And, if I spend enough time thinking about the words used, I may be able to get some down to around 50 pages or less.

The requirement for these book projects are to be very high quality content. There will be blog posts with extracts from some pages and chapters that also provide useful examples and more side notes.

Some of the first few books that I've been planning:
- How to Learn
- Level Up - Programming

And, as I go through the above process, there will be a book for 'How to write a book'. ;)

I just need to dedicate some time to it and it will get done.

~ Danial Goodwin ~


Level Up - Construct 2: How to use web fonts with the Text object

Just a few steps:

1. Add a Text object to one of your layouts.
2. In the corresponding event sheet, create the event System."On start of layout", then add the action for Text object called "Set web font".
3. Use Google Web Fonts to find a font you like, then click on the icon for "Quick-use". The name/Family of the font will be at the top, and scroll down to find the URL for the stylesheet of where to load the web font from.

More info:
- How to use your own web fonts
- Using web fonts in the Text object
- Manual:Text object

~ Danial Goodwin ~


Level Up - Ruby on Rails: How to create a very minimal blog website (two different ways)

As I was refreshing myself with Ruby on Rails, I've decided to share these notes. To follow these steps, you don't actually need to know any Ruby or Rails, but you should have them installed already. I'm using Ruby 2.1.5p273, Rails 4.2.0, Windows 8.1, but these steps are simple enough to do on any version.

I show two different ways to create a very code minimal blog. It also demonstrates the power of of Rails scaffolding.

Using scaffold

1. Just run the following commands one after another:

    rails new quick-blog
    cd quick-blog
    rails generate scaffold post title:string body:text
    rails generate scaffold comment post_id:integer body:text
    rake db:migrate

2. To create a post or comment, make sure that the `rails server` is started. Then, in browser, navigate to `/posts/new` or `/comments`.
3. Done

Without using scaffold

1. Run `rails new very-minimal-blog`
2. Run `cd very-minimal-blog`, then `rake db:create`
3. Create the model for the posts: Run `rails generate model Post title:string body:text`
4. Run `rake db:migrate`
5. Create a controller for the posts: Run `rails generate controller Posts`
6. In that controller that was just created in `app/controllers/posts_controller.rb`, add some code so that it looks like the following:

    class PostsController < ApplicationController
      def index
        @posts = Post.all

      def show
        @post = Post.find(params[:id])

7. In `app/views/posts/`, create a new file called `index.html.erb` and add the following code:


Very Minimal Blog

    <% @posts.each do |post| %>

<%= post.title %>

      <%= link_to "Read me", post_path(post) %>
    <% end %>

8. Create a way to get to the posts. In `config/routes.rb` add, `resources :posts`
9. In `app/views/posts/`, create a new file called `show.html.erb` and add the following code:


<%= @post.title %>

    <%= @post.body %>

10. Done. :)

## To create a blog post ##
1. Open Rails console by running `rails console`
2. Run `Post.create(title: "My Title", body: "This is my awesome blog post!")`

## To view the blog ##
1. Start the Rails server by running `rails server`
2. Navigate to `localhost:3000/posts`

~ Danial Goodwin ~



Computer Programmers are Perfectionists, by necessity

Computer programmers must be perfectionists. If not, then there's another bug and another crash.

Additionally, writing a fully correct program/app requires programmers to be psychics and able to tell the future. Without so, more code breaks down and programmers wouldn't be able to work together, which ties in with having to be able to read minds.

Furthermore, most times there are more possible logical states in a program than there are atoms in the universe. That would take up quite a lot of the brain's working memory. And, each of them have to be thought through.

I'm surprised any program gets finished. Oh, wait, they never actually are. ;)

Anyways, even with all these impossible hurdles and limitless things to do, programmers have been able to come together and get things done. And, it feels good to know a program is finally running and [most] of the obstacles have been overcome.

Sidnote: So, here's where I would introduce my revolutionary new solution, but, of course it's not finished yet. ;b

~ Danial Goodwin ~


Level Up - Android Dev: How to get started with Robolectric (Android testing)

I'm finally getting around to trying out a few different libraries that claim to make testing Android apps easier. First up is Robolectric.

For this quick walkthrough, I'm going to show how to start from scratch. You'll need no prior knowledge except for how to make a regular Android app.

In my GitHub repo: How to get started with Robolectric

~ Danial Goodwin ~


Quote: Unthinkable Thoughts

"Just as there are odors that dogs can smell and we cannot, as well as sounds that dogs can hear and we cannot, so too there are wavelengths of light we cannot see and flavors we cannot taste. 
Why then, given our brains wired the way they are, does the remark 'Perhaps there are thoughts we cannot think', surprise you? 
Evolution, so far, may possibly have blocked us from being able to think in some directions; there could be unthinkable thoughts."
- Richard Hamming (source) (lecture source)

~ Danial Goodwin ~


How to change functionality of Caps Lock key

Don't use or like the caps lock key? Then, you can map it to any other key or functionality.

I've chosen to use the AutoHotkey scripting language rather than another tool or editing the Windows registry. AutoHotkey is great for quickly adding and changing key mappings. Just download and install to begin using.

My goal was to map the caps lock key to the enter key. So, I created a file called `map-caps-to-enter.ahk` and put in the follow:

    SetCapsLockState, off
    Send, {ENTER}

Basically, that code says when the capslock key is pressed, run the following instructions: set caps lock off, then send the ENTER key to the computer. Then the instructions are over when "return" is written. There's no limit to the number of instructions that can be added.

Here's another example that does the same thing, except that it is mapping caps lock to escape, along with a few more tricks that may be needed in a more complicated environment (like running other AHK scripts):


    SetCapsLockState, off
    Suspend On
    Send, {ESC}
    Suspend Off

Basically, instead of running the instructions directly, pressing caps will call a function that runs the instructions. Both of the "suspend" lines just suspends/prevents other code from running.

Thanks to this source for pointing me in the right direction. Also, more ways of changing the mappings are shown: http://vim.wikia.com/wiki/Map_caps_lock_to_escape_in_Windows

~ Danial Goodwin ~


Level Up - Android Dev: OneTimeAlertDialog = Android AlertDialog that only shows once for a given key

Every single one of my apps need something like this. It's boring to explain in more details what's traditionally needed to make sure an AlertDialog is only shown once. Now, with this OneTimeAlertDialog.java, it's much easier to create new AlertDialogs that are only shown once.

/** Prompt that is only shown once to user. */
OneTimeAlertDialog.Builder(this, "my_dialog_key")
        .setTitle("My Title")
        .setMessage("My Message")

For something I use so often, I was surprised to not find a similar project on GitHub. So, I've added it: Android OneTimeAlertDialog

~ Danial Goodwin ~