diff --git a/Cell+mutator.h b/Cell+mutator.h new file mode 100644 index 00000000..61c05ac6 --- /dev/null +++ b/Cell+mutator.h @@ -0,0 +1,16 @@ +// +// Cell+mutator.h +// DNK +// +// Created by evgen on 11/13/12. +// Copyright (c) 2012 evgen. All rights reserved. +// + +#import "Cell.h" + +@interface Cell (mutator) + ++(int) getRandIndex; +-(void) mutate:(int) percent; + +@end diff --git a/Cell+mutator.m b/Cell+mutator.m new file mode 100644 index 00000000..91e97e35 --- /dev/null +++ b/Cell+mutator.m @@ -0,0 +1,33 @@ +// +// Cell+mutator.m +// DNK +// +// Created by evgen on 11/13/12. +// Copyright (c) 2012 evgen. All rights reserved. +// + +#import "Cell+mutator.h" + +@implementation Cell (mutator) + +-(void) mutate:(int)percent { + //array with random numbers to check if the new number repeats + NSMutableArray *repeatCheckArray = [NSMutableArray array]; + + for (int i=1; i + +@interface Cell : NSObject { + NSMutableArray *_DNA; +} + +@property NSMutableArray *DNA; + +-(id)init; +//get random object type NSString for the array ++(NSString*)getRandomCharacter; + +-(int) hammingDistance: (Cell*) number; + +@end diff --git a/Cell.m b/Cell.m new file mode 100644 index 00000000..a13c3b4e --- /dev/null +++ b/Cell.m @@ -0,0 +1,56 @@ +// +// Cell.m +// DNK +// +// Created by evgen on 11/9/12. +// Copyright (c) 2012 evgen. All rights reserved. +// + +#import "Cell.h" + +@implementation Cell + +//Array object initialization +-(id) init{ + self = [super init]; + + _DNA = [[NSMutableArray alloc] init]; + _DNA = [NSMutableArray arrayWithCapacity:100]; + + if(self) + for(int i=1;i<=100;i++) //fill the array with random characters + [_DNA addObject:[Cell getRandomCharacter]]; + + return self; + +} + +-(int)hammingDistance:(Cell*)number{ + int count=0; + + for(int i=0;i<100;i++){ + //compare two arrays + if(!([(NSString*)[[self DNA] objectAtIndex:i] isEqualToString:[[number DNA] objectAtIndex:i]])) + count++; + + } + + return count; +} + + ++(NSString*)getRandomCharacter{ + + switch(random()%4){ + case 0: + return @"A"; + case 1: + return @"T"; + case 2: + return @"G"; + } + return @"C"; +} + + +@end diff --git a/DNK-Prefix.pch b/DNK-Prefix.pch new file mode 100644 index 00000000..aa488ccb --- /dev/null +++ b/DNK-Prefix.pch @@ -0,0 +1,7 @@ +// +// Prefix header for all source files of the 'DNK' target in the 'DNK' project +// + +#ifdef __OBJC__ + #import +#endif diff --git a/DNK.1 b/DNK.1 new file mode 100644 index 00000000..57bb1980 --- /dev/null +++ b/DNK.1 @@ -0,0 +1,79 @@ +.\"Modified from man(1) of FreeBSD, the NetBSD mdoc.template, and mdoc.samples. +.\"See Also: +.\"man mdoc.samples for a complete listing of options +.\"man mdoc for the short list of editing options +.\"/usr/share/misc/mdoc.template +.Dd 11/9/12 \" DATE +.Dt DNK 1 \" Program name and manual section number +.Os Darwin +.Sh NAME \" Section Header - required - don't modify +.Nm DNK, +.\" The following lines are read in generating the apropos(man -k) database. Use only key +.\" words here as the database is built based on the words here and in the .ND line. +.Nm Other_name_for_same_program(), +.Nm Yet another name for the same program. +.\" Use .Nm macro to designate other names for the documented program. +.Nd This line parsed for whatis database. +.Sh SYNOPSIS \" Section Header - required - don't modify +.Nm +.Op Fl abcd \" [-abcd] +.Op Fl a Ar path \" [-a path] +.Op Ar file \" [file] +.Op Ar \" [file ...] +.Ar arg0 \" Underlined argument - use .Ar anywhere to underline +arg2 ... \" Arguments +.Sh DESCRIPTION \" Section Header - required - don't modify +Use the .Nm macro to refer to your program throughout the man page like such: +.Nm +Underlining is accomplished with the .Ar macro like this: +.Ar underlined text . +.Pp \" Inserts a space +A list of items with descriptions: +.Bl -tag -width -indent \" Begins a tagged list +.It item a \" Each item preceded by .It macro +Description of item a +.It item b +Description of item b +.El \" Ends the list +.Pp +A list of flags and their descriptions: +.Bl -tag -width -indent \" Differs from above in tag removed +.It Fl a \"-a flag as a list item +Description of -a flag +.It Fl b +Description of -b flag +.El \" Ends the list +.Pp +.\" .Sh ENVIRONMENT \" May not be needed +.\" .Bl -tag -width "ENV_VAR_1" -indent \" ENV_VAR_1 is width of the string ENV_VAR_1 +.\" .It Ev ENV_VAR_1 +.\" Description of ENV_VAR_1 +.\" .It Ev ENV_VAR_2 +.\" Description of ENV_VAR_2 +.\" .El +.Sh FILES \" File used or created by the topic of the man page +.Bl -tag -width "/Users/joeuser/Library/really_long_file_name" -compact +.It Pa /usr/share/file_name +FILE_1 description +.It Pa /Users/joeuser/Library/really_long_file_name +FILE_2 description +.El \" Ends the list +.\" .Sh DIAGNOSTICS \" May not be needed +.\" .Bl -diag +.\" .It Diagnostic Tag +.\" Diagnostic informtion here. +.\" .It Diagnostic Tag +.\" Diagnostic informtion here. +.\" .El +.Sh SEE ALSO +.\" List links in ascending order by section, alphabetically within a section. +.\" Please do not reference files that do not exist without filing a bug report +.Xr a 1 , +.Xr b 1 , +.Xr c 1 , +.Xr a 2 , +.Xr b 2 , +.Xr a 3 , +.Xr b 3 +.\" .Sh BUGS \" Document known, unremedied bugs +.\" .Sh HISTORY \" Document history if command behaves in a unique manner \ No newline at end of file diff --git a/DNK.xcodeproj/project.pbxproj b/DNK.xcodeproj/project.pbxproj new file mode 100644 index 00000000..20d5ed30 --- /dev/null +++ b/DNK.xcodeproj/project.pbxproj @@ -0,0 +1,256 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 6CE7AF041652736E00392A38 /* Cell+mutator.m in Sources */ = {isa = PBXBuildFile; fileRef = 6CE7AF031652736E00392A38 /* Cell+mutator.m */; }; + 6CEAE4BE164D18DE00E73795 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6CEAE4BD164D18DE00E73795 /* Foundation.framework */; }; + 6CEAE4C1164D18DE00E73795 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 6CEAE4C0164D18DE00E73795 /* main.m */; }; + 6CEAE4C5164D18DE00E73795 /* DNK.1 in CopyFiles */ = {isa = PBXBuildFile; fileRef = 6CEAE4C4164D18DE00E73795 /* DNK.1 */; }; + 6CEAE4CD164D192700E73795 /* Cell.m in Sources */ = {isa = PBXBuildFile; fileRef = 6CEAE4CC164D192700E73795 /* Cell.m */; }; +/* End PBXBuildFile section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 6CEAE4B7164D18DE00E73795 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = /usr/share/man/man1/; + dstSubfolderSpec = 0; + files = ( + 6CEAE4C5164D18DE00E73795 /* DNK.1 in CopyFiles */, + ); + runOnlyForDeploymentPostprocessing = 1; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 6CE7AF021652736E00392A38 /* Cell+mutator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "Cell+mutator.h"; sourceTree = ""; }; + 6CE7AF031652736E00392A38 /* Cell+mutator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "Cell+mutator.m"; sourceTree = ""; }; + 6CEAE4B9164D18DE00E73795 /* DNK */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = DNK; sourceTree = BUILT_PRODUCTS_DIR; }; + 6CEAE4BD164D18DE00E73795 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; + 6CEAE4C0164D18DE00E73795 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + 6CEAE4C3164D18DE00E73795 /* DNK-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "DNK-Prefix.pch"; sourceTree = ""; }; + 6CEAE4C4164D18DE00E73795 /* DNK.1 */ = {isa = PBXFileReference; lastKnownFileType = text.man; path = DNK.1; sourceTree = ""; }; + 6CEAE4CB164D192700E73795 /* Cell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Cell.h; sourceTree = ""; }; + 6CEAE4CC164D192700E73795 /* Cell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Cell.m; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 6CEAE4B6164D18DE00E73795 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 6CEAE4BE164D18DE00E73795 /* Foundation.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 6CEAE4AE164D18DE00E73795 = { + isa = PBXGroup; + children = ( + 6CE7AF021652736E00392A38 /* Cell+mutator.h */, + 6CE7AF031652736E00392A38 /* Cell+mutator.m */, + 6CEAE4BF164D18DE00E73795 /* DNK */, + 6CEAE4BC164D18DE00E73795 /* Frameworks */, + 6CEAE4BA164D18DE00E73795 /* Products */, + ); + sourceTree = ""; + }; + 6CEAE4BA164D18DE00E73795 /* Products */ = { + isa = PBXGroup; + children = ( + 6CEAE4B9164D18DE00E73795 /* DNK */, + ); + name = Products; + sourceTree = ""; + }; + 6CEAE4BC164D18DE00E73795 /* Frameworks */ = { + isa = PBXGroup; + children = ( + 6CEAE4BD164D18DE00E73795 /* Foundation.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; + 6CEAE4BF164D18DE00E73795 /* DNK */ = { + isa = PBXGroup; + children = ( + 6CEAE4C0164D18DE00E73795 /* main.m */, + 6CEAE4C4164D18DE00E73795 /* DNK.1 */, + 6CEAE4C2164D18DE00E73795 /* Supporting Files */, + 6CEAE4CB164D192700E73795 /* Cell.h */, + 6CEAE4CC164D192700E73795 /* Cell.m */, + ); + path = DNK; + sourceTree = ""; + }; + 6CEAE4C2164D18DE00E73795 /* Supporting Files */ = { + isa = PBXGroup; + children = ( + 6CEAE4C3164D18DE00E73795 /* DNK-Prefix.pch */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 6CEAE4B8164D18DE00E73795 /* DNK */ = { + isa = PBXNativeTarget; + buildConfigurationList = 6CEAE4C8164D18DE00E73795 /* Build configuration list for PBXNativeTarget "DNK" */; + buildPhases = ( + 6CEAE4B5164D18DE00E73795 /* Sources */, + 6CEAE4B6164D18DE00E73795 /* Frameworks */, + 6CEAE4B7164D18DE00E73795 /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = DNK; + productName = DNK; + productReference = 6CEAE4B9164D18DE00E73795 /* DNK */; + productType = "com.apple.product-type.tool"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 6CEAE4B0164D18DE00E73795 /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0450; + ORGANIZATIONNAME = evgen; + }; + buildConfigurationList = 6CEAE4B3164D18DE00E73795 /* Build configuration list for PBXProject "DNK" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + ); + mainGroup = 6CEAE4AE164D18DE00E73795; + productRefGroup = 6CEAE4BA164D18DE00E73795 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 6CEAE4B8164D18DE00E73795 /* DNK */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXSourcesBuildPhase section */ + 6CEAE4B5164D18DE00E73795 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 6CEAE4C1164D18DE00E73795 /* main.m in Sources */, + 6CEAE4CD164D192700E73795 /* Cell.m in Sources */, + 6CE7AF041652736E00392A38 /* Cell+mutator.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 6CEAE4C6164D18DE00E73795 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ARCHS = "$(ARCHS_STANDARD_64_BIT)"; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_ENABLE_OBJC_EXCEPTIONS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.8; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + }; + name = Debug; + }; + 6CEAE4C7164D18DE00E73795 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ARCHS = "$(ARCHS_STANDARD_64_BIT)"; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = YES; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_ENABLE_OBJC_EXCEPTIONS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.8; + SDKROOT = macosx; + }; + name = Release; + }; + 6CEAE4C9164D18DE00E73795 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "DNK/DNK-Prefix.pch"; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + 6CEAE4CA164D18DE00E73795 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "DNK/DNK-Prefix.pch"; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 6CEAE4B3164D18DE00E73795 /* Build configuration list for PBXProject "DNK" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 6CEAE4C6164D18DE00E73795 /* Debug */, + 6CEAE4C7164D18DE00E73795 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 6CEAE4C8164D18DE00E73795 /* Build configuration list for PBXNativeTarget "DNK" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 6CEAE4C9164D18DE00E73795 /* Debug */, + 6CEAE4CA164D18DE00E73795 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 6CEAE4B0164D18DE00E73795 /* Project object */; +} diff --git a/DNK.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/DNK.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 00000000..c0588c7d --- /dev/null +++ b/DNK.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/DNK.xcodeproj/project.xcworkspace/xcuserdata/evgen.xcuserdatad/UserInterfaceState.xcuserstate b/DNK.xcodeproj/project.xcworkspace/xcuserdata/evgen.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 00000000..074a2f14 Binary files /dev/null and b/DNK.xcodeproj/project.xcworkspace/xcuserdata/evgen.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/DNK.xcodeproj/xcuserdata/evgen.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist b/DNK.xcodeproj/xcuserdata/evgen.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist new file mode 100644 index 00000000..728e7912 --- /dev/null +++ b/DNK.xcodeproj/xcuserdata/evgen.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist @@ -0,0 +1,85 @@ + + + + + + + + + + + + + + + + + diff --git a/DNK.xcodeproj/xcuserdata/evgen.xcuserdatad/xcschemes/DNK.xcscheme b/DNK.xcodeproj/xcuserdata/evgen.xcuserdatad/xcschemes/DNK.xcscheme new file mode 100644 index 00000000..bb98fa9e --- /dev/null +++ b/DNK.xcodeproj/xcuserdata/evgen.xcuserdatad/xcschemes/DNK.xcscheme @@ -0,0 +1,86 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/DNK.xcodeproj/xcuserdata/evgen.xcuserdatad/xcschemes/xcschememanagement.plist b/DNK.xcodeproj/xcuserdata/evgen.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 00000000..f6fb8a0c --- /dev/null +++ b/DNK.xcodeproj/xcuserdata/evgen.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,22 @@ + + + + + SchemeUserState + + DNK.xcscheme + + orderHint + 0 + + + SuppressBuildableAutocreation + + 6CEAE4B8164D18DE00E73795 + + primary + + + + + diff --git a/NSObject+Cellmutator.h b/NSObject+Cellmutator.h new file mode 100644 index 00000000..4c39edb4 --- /dev/null +++ b/NSObject+Cellmutator.h @@ -0,0 +1,13 @@ +// +// NSObject+Cellmutator.h +// DNK +// +// Created by evgen on 11/13/12. +// Copyright (c) 2012 evgen. All rights reserved. +// + +#import + +@interface NSObject (Cellmutator) + +@end diff --git a/NSObject+Cellmutator.m b/NSObject+Cellmutator.m new file mode 100644 index 00000000..25792442 --- /dev/null +++ b/NSObject+Cellmutator.m @@ -0,0 +1,13 @@ +// +// NSObject+Cellmutator.m +// DNK +// +// Created by evgen on 11/13/12. +// Copyright (c) 2012 evgen. All rights reserved. +// + +#import "NSObject+Cellmutator.h" + +@implementation NSObject (Cellmutator) + +@end diff --git a/main.m b/main.m new file mode 100644 index 00000000..5826c6c4 --- /dev/null +++ b/main.m @@ -0,0 +1,30 @@ +// +// main.m +// DNK +// +// Created by evgen on 11/9/12. +// Copyright (c) 2012 evgen. All rights reserved. +// + +#import +#import "Cell.h" +#import "Cell+mutator.h" + +int main(int argc, const char * argv[]) +{ + + @autoreleasepool { + + + Cell *myArray1 = [[Cell alloc] init]; + Cell *myArray2 = [[Cell alloc] init]; + NSLog(@"Hamming distance is %i",[myArray1 hammingDistance:myArray2]); + + [myArray1 mutate:20]; + [myArray2 mutate:40]; + + NSLog(@"Hamming distance is %i",[myArray1 hammingDistance:myArray2]); + } + return 0; +} +