iphone

Printing every possible combinations of ABC (Swift 2.2 )

Posted on Updated on

I had time this evening .. so I figured why not dig up some example code I copied from a tutorial online and modify it to show every possible combinations of the letters A, B and C.

Only this time instead of showing through a terminal I would print it on an iPhone app. So here it is ..

スクリーンショット 2016-03-28 21.19.43

Source code:

import UIKit

class ViewController: UIViewController
{
    @IBOutlet weak  var totalPermutations: UILabel!         // print total permutations count of ABC
    @IBOutlet weak  var _comboTextView: UITextView!         // print every combination of ABC
    @IBOutlet       var _outputLabel: UILabel!
                    var _currentCount = 0

    let combinationsArray: [String] = ["A", "B", "C"]

    /**
     * Initialization
     */
    override func viewDidLoad()
    {
        super.viewDidLoad()
        printCombinations()
    }

    /**
     * Print every combination of ABC
     */
    func printCombinations()
    {
        var totalCombinations = 0
        var str: String = ""
        for letter in combinationsArray {
            for nextLetter in combinationsArray {
                for nextNextLetter in combinationsArray {
                    totalCombinations++
                    str += (letter + nextLetter + nextNextLetter + "\n")
                }
            }
        }
        totalPermutations.text = ("Permutations: " + String(totalCombinations))
        _comboTextView.text = str
    }

    /**
     * Memory warning
     */
    override func didReceiveMemoryWarning()
    {
        super.didReceiveMemoryWarning()
    }

    /**
     * Start counting
     */
    @IBAction func addOneButton(sender: UIButton)
    {
        _currentCount++
        _outputLabel.text = "クリック回数は:\(_currentCount)"
        _outputLabel.textColor = UIColor.redColor()
    }
}

Edit: Added total permutations counter
Github: https://github.com/benji011/counterApp

Samurai Gunship website finally released!

Posted on

Working at Pamprepps Games in Fukuoka Japan is awesome!
Today the official website for the game I developed for Android (iOS is coming soon) has been released!

スクリーンショット 2015-09-14 11.45.37

Link → http://pamprepps.com/samuraigunship/

“ERROR: Failed to build gem native extension” while installing DeployGate

Posted on Updated on

Being a fan of Github helped boost my interest in DeployGate purely because of using the Mac terminal to upload files is (while geeky) fun. All you do is login with a Github account (or Twitter or just sign up the old fashion way), then install the package into your library.

On the top of the page, click Developer Tools > Developer Center and you get to a page like this below:

スクリーンショット 2015-06-17 11.32.46

then click “Read How-Tos” ( https://deploygate.com/docs/cli )

The problem
I had a problem installing mine because of missing Ruby header file libraries like below

スクリーンショット 2015-06-17 11.37.40

Strange …

Solution / steps taken
After taking a few minutes to Google around I came across this webpage (Japanese):
http://qiita.com/yuku_t/items/30015dba2b6497b80074

Looks like we have to install XCode again and agree to their license. So go ahead and hit the command below in your terminal.

xcode-select --install

Now I try to install dgate again but no luck.
スクリーンショット 2015-06-17 11.41.03

After googling again ( http://ameblo.jp/siroikinoko/entry-11059282205.html ) it turns out I need to update my Ruby library:

sudo gem install rubygems-update

This time I finally got somewhere after hitting the same command to install dgate:

スクリーンショット 2015-06-17 11.43.43

Sweet!