-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 660b622
Showing
10 changed files
with
194 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Ignore all | ||
* | ||
|
||
# Unignore anything with extention | ||
!*/ | ||
!*.* | ||
|
||
# Except for the following | ||
*.DS_Store | ||
*.class |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
public class unique { | ||
|
||
public static void main(String[] args) { | ||
System.out.println(is_unique( "abcdefghijklmnopqrstuvwxyz" )); // true | ||
System.out.println(is_unique( "abcdefghijklmnopqrstuvwxyzz" )); // false | ||
System.out.println(is_unique( "aa" )); // false | ||
System.out.println(is_unique( "aba" )); // false | ||
System.out.println(is_unique( "aaaaaaaaaaaaaaaaaaaaaaaaaaa" )); // false | ||
System.out.println(is_unique( " " )); // false | ||
System.out.println(is_unique( " " )); // true | ||
} | ||
|
||
public static boolean is_unique(String str) { | ||
if (str.length() > 128) { // assume ascii, not unicode | ||
return false; | ||
} | ||
|
||
boolean[] alf = new boolean[128]; | ||
for (int i = 0; i < str.length(); i++) { | ||
int val = str.charAt(i); | ||
if (alf[val]) { | ||
return false; | ||
} | ||
alf[val] = true; | ||
} | ||
return true; | ||
} | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
echo is_unique( 'abcdefghijklmnopqrstuvwxyz' ) . "\n"; // true | ||
echo is_unique( 'abcdefghijklmnopqrstuvwxyzz' ) . "\n"; // false | ||
echo is_unique( 'aa' ) . "\n"; // false | ||
echo is_unique( 'aba' ) . "\n"; // false | ||
echo is_unique( 'aaaaaaaaaaaaaaaaaaaaaaaaaaa' ) . "\n"; // false | ||
echo is_unique( ' ' ) . "\n"; // false | ||
echo is_unique( ' ' ) . "\n"; // true | ||
|
||
function is_unique( $string ) { | ||
$strlen = strlen( $string ); // calculate once instead of twice | ||
|
||
if ( 128 < $strlen ) { // TODO understand the difference between ascii and unicode | ||
return 'false'; | ||
} | ||
|
||
$alf = array(); | ||
for ( $i = 0; $i <= $strlen; $i++ ) { // not foreach | ||
$char = substr( $string, $i, 1 ); | ||
|
||
if ( ! $alf[ $char ] ) { // true (already set) | ||
$alf[ $char ] = 'true'; | ||
} else { // false | ||
return 'false'; | ||
} | ||
} | ||
|
||
return 'true'; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
def is_unique( str ): | ||
strlen = len( str ); | ||
|
||
if strlen > 128: | ||
return; | ||
|
||
checker = [] | ||
|
||
for letter in str: | ||
checker.append( letter ); | ||
|
||
if len(checker) > len(set(checker)): | ||
return 'false' | ||
|
||
return 'true' | ||
|
||
print is_unique("abcdefghijklmnopqrstuvwxyz"); # true | ||
print is_unique("abcdefghijklmnopqrstuvwxyzz"); # false | ||
print is_unique("aa"); # false | ||
print is_unique("aba"); # false | ||
print is_unique("aaaaaaaaaaaaaaaaaaaaaaaaaaa"); # false | ||
print is_unique(" "); # false | ||
print is_unique(" "); # true |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// gcc -o single single.c | ||
|
||
#include <stdio.h> | ||
#include <string.h> | ||
#include <stdlib.h> | ||
#include <stdbool.h> | ||
|
||
struct node { | ||
int data; | ||
int key; | ||
struct node *next; | ||
}; | ||
|
||
struct node *head = NULL; | ||
struct node *current = NULL; | ||
|
||
int main(void) { | ||
printf("Original List: "); | ||
printf("Coming Soon!\n"); | ||
return 0; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import java.util.*; | ||
|
||
public class single { | ||
public static void main(String args[]) { | ||
LinkedList<String> ll = new LinkedList<String>(); // You should use <String> here | ||
|
||
// add | ||
ll.add("J"); | ||
ll.add("U"); | ||
ll.add("S"); | ||
ll.add("T"); | ||
ll.add("I"); | ||
ll.add("C"); | ||
ll.add("E"); | ||
ll.addLast("Parsons"); | ||
ll.addFirst("David"); | ||
ll.add(1, "to the"); | ||
ll.addLast("III"); | ||
ll.addLast("III"); | ||
System.out.println("Linked List after add: " + ll); | ||
|
||
// remove | ||
ll.remove("III"); // this only removes one of the III node's above | ||
ll.remove(1); // remove from position 1 (the second node) | ||
System.out.println("Linked List after remove: " + ll); | ||
|
||
// remove first and last | ||
ll.removeFirst(); | ||
ll.removeLast(); | ||
System.out.println("Linked List after removing first and last: " + ll); | ||
|
||
// get and set a value | ||
Object temp = ll.get(2); | ||
ll.set(2, (String) temp + " is same same but different but still same"); | ||
System.out.println("Linked List after changing second element: " + ll); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Empty list | ||
thelist = [] | ||
|
||
# add values to list | ||
for i in range(0, 6): | ||
thelist.append(i) # add value to array | ||
|
||
thelist.append(1234) | ||
thelist.append(1235) | ||
thelist.append(1236) | ||
thelist.append(1237) | ||
thelist.append(1238) | ||
thelist.append(1239) | ||
|
||
# print list | ||
for i in thelist: | ||
print "Current Value: %d" % i |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
$input = '[wibbitz id="b40d336b69af74f6ca51416b177a23858" autoplay="false"]'; | ||
|
||
if ( preg_match( '\[[a-z]+.*\]', $input ) ) { | ||
echo 'pass'; | ||
} else { | ||
echo 'fail'; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
$input = '[wibbitz id="b40d336b69af74f6ca51416b177a23858" autoplay="false"]'; | ||
|
||
if ( 0 === strpos( $input, '[' ) && strlen( $input ) - 1 === strpos( $input, ']' ) ) { | ||
echo 'pass'; | ||
} else { | ||
echo 'fail'; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
$input = '[wibbitz id="b40d336b69af74f6ca51416b177a23858" autoplay="false"]'; | ||
|
||
if ( '[' === substr( $input, 0, 1 ) && ']' === substr( $input, -1 ) ) { | ||
echo 'pass'; | ||
} else { | ||
echo 'fail'; | ||
} |