This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.HashSet; | |
import java.util.Set; | |
/** | |
* Happy number (https://en.wikipedia.org/wiki/Happy_number) : A happy number is a number defined by the following process: | |
* Starting with any positive integer, replace the number by the sum of the squares of its digits, | |
* and repeat the process until the number either equals 1 (where it will stay), | |
* or it loops endlessly in a cycle which does not include 1. | |
* Those numbers for which this process ends in 1 are happy numbers, | |
* while those that do not end in 1 are unhappy numbers (or sad numbers). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Created by Daehee Han(@daniel_booknara) on 4/21/16. | |
*/ | |
public class Power3 { | |
public static void main(String[] args) { | |
for (int i = 1; i < 1000; i++) { | |
if (isPower3(i)) | |
System.out.println(i + " is power of 3"); | |
else | |
System.out.println(i + " is NOT power of 3"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Created by Daehee Han(@daniel_booknara) on 4/21/16. | |
*/ | |
public class PowerN { | |
public static void main(String[] args) { | |
int base = 3; | |
for (int i = 1; i < 100; i++) { | |
if (isPowerN(base, i)) | |
System.out.println(i + " is power of " + base); | |
else |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Power4 { | |
public static void main(String[] args) { | |
for (int i = 1; i < 30; i++) { | |
if (isPower4(i)) | |
System.out.println(i + " is power of 4"); | |
else | |
System.out.println(i + " is NOT power of 4"); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Created by Daehee Han(@daniel_booknara) on 4/21/16. | |
*/ | |
public class Power2 { | |
public static void main(String[] args) { | |
for (int i = 1; i < 10; i++) { | |
if (isPower2(i)) | |
System.out.println(i + " is power of 2"); | |
else | |
System.out.println(i + " is NOT power of 2"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:orientation="vertical" | |
android:layout_weight="100" | |
tools:context=".DecoderActivity" > | |
<LinearLayout | |
android:layout_width="match_parent" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/********************************************************************************************** | |
* Copyright 2009 Amazon.com, Inc. or its affiliates. All Rights Reserved. | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file | |
* except in compliance with the License. A copy of the License is located at | |
* | |
* http://aws.amazon.com/apache2.0/ | |
* | |
* or in the "LICENSE.txt" file accompanying this file. This file is distributed on an "AS IS" | |
* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/********************************************************************************************** | |
* Copyright 2009 Amazon.com, Inc. or its affiliates. All Rights Reserved. | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file | |
* except in compliance with the License. A copy of the License is located at | |
* | |
* http://aws.amazon.com/apache2.0/ | |
* | |
* or in the "LICENSE.txt" file accompanying this file. This file is distributed on an "AS IS" | |
* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void setClickableMessage(TextView textView) { | |
String message = "By signing up, you agree to our Terms of Service"; | |
String linkText = "Terms of Service"; | |
int indexStart = message.indexOf(linkText); | |
textView.setMovementMethod(LinkMovementMethod.getInstance()); | |
textView.setText(message, TextView.BufferType.SPANNABLE); | |
Spannable spannable = (Spannable)textView.getText(); | |
ClickableSpan clickableSpan = new ClickableSpan() { | |
@Override | |
public void onClick(View textView) { |