diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 00000000..7db64117 Binary files /dev/null and b/.DS_Store differ diff --git a/osx-project-1.xcodeproj/project.pbxproj b/osx-project-1.xcodeproj/project.pbxproj new file mode 100644 index 00000000..e40d2482 --- /dev/null +++ b/osx-project-1.xcodeproj/project.pbxproj @@ -0,0 +1,243 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + CC181DD01644AACA0038CFC9 /* Cell.m in Sources */ = {isa = PBXBuildFile; fileRef = CC181DCF1644AACA0038CFC9 /* Cell.m */; }; + CCBE7F0D1644AA6800569B00 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CCBE7F0C1644AA6800569B00 /* Foundation.framework */; }; + CCBE7F101644AA6800569B00 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = CCBE7F0F1644AA6800569B00 /* main.m */; }; + CCBE7F141644AA6800569B00 /* osx_project_1.1 in CopyFiles */ = {isa = PBXBuildFile; fileRef = CCBE7F131644AA6800569B00 /* osx_project_1.1 */; }; +/* End PBXBuildFile section */ + +/* Begin PBXCopyFilesBuildPhase section */ + CCBE7F061644AA6800569B00 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = /usr/share/man/man1/; + dstSubfolderSpec = 0; + files = ( + CCBE7F141644AA6800569B00 /* osx_project_1.1 in CopyFiles */, + ); + runOnlyForDeploymentPostprocessing = 1; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + CC181DCE1644AACA0038CFC9 /* Cell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Cell.h; sourceTree = ""; }; + CC181DCF1644AACA0038CFC9 /* Cell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Cell.m; sourceTree = ""; }; + CCBE7F081644AA6800569B00 /* osx-project-1 */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "osx-project-1"; sourceTree = BUILT_PRODUCTS_DIR; }; + CCBE7F0C1644AA6800569B00 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; + CCBE7F0F1644AA6800569B00 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + CCBE7F121644AA6800569B00 /* osx-project-1-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "osx-project-1-Prefix.pch"; sourceTree = ""; }; + CCBE7F131644AA6800569B00 /* osx_project_1.1 */ = {isa = PBXFileReference; lastKnownFileType = text.man; path = osx_project_1.1; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + CCBE7F051644AA6800569B00 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + CCBE7F0D1644AA6800569B00 /* Foundation.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + CCBE7EFD1644AA6700569B00 = { + isa = PBXGroup; + children = ( + CCBE7F0E1644AA6800569B00 /* osx-project-1 */, + CCBE7F0B1644AA6800569B00 /* Frameworks */, + CCBE7F091644AA6800569B00 /* Products */, + ); + sourceTree = ""; + }; + CCBE7F091644AA6800569B00 /* Products */ = { + isa = PBXGroup; + children = ( + CCBE7F081644AA6800569B00 /* osx-project-1 */, + ); + name = Products; + sourceTree = ""; + }; + CCBE7F0B1644AA6800569B00 /* Frameworks */ = { + isa = PBXGroup; + children = ( + CCBE7F0C1644AA6800569B00 /* Foundation.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; + CCBE7F0E1644AA6800569B00 /* osx-project-1 */ = { + isa = PBXGroup; + children = ( + CCBE7F0F1644AA6800569B00 /* main.m */, + CC181DCE1644AACA0038CFC9 /* Cell.h */, + CC181DCF1644AACA0038CFC9 /* Cell.m */, + CCBE7F131644AA6800569B00 /* osx_project_1.1 */, + CCBE7F111644AA6800569B00 /* Supporting Files */, + ); + path = "osx-project-1"; + sourceTree = ""; + }; + CCBE7F111644AA6800569B00 /* Supporting Files */ = { + isa = PBXGroup; + children = ( + CCBE7F121644AA6800569B00 /* osx-project-1-Prefix.pch */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + CCBE7F071644AA6800569B00 /* osx-project-1 */ = { + isa = PBXNativeTarget; + buildConfigurationList = CCBE7F171644AA6800569B00 /* Build configuration list for PBXNativeTarget "osx-project-1" */; + buildPhases = ( + CCBE7F041644AA6800569B00 /* Sources */, + CCBE7F051644AA6800569B00 /* Frameworks */, + CCBE7F061644AA6800569B00 /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "osx-project-1"; + productName = "osx-project-1"; + productReference = CCBE7F081644AA6800569B00 /* osx-project-1 */; + productType = "com.apple.product-type.tool"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + CCBE7EFF1644AA6700569B00 /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0420; + }; + buildConfigurationList = CCBE7F021644AA6800569B00 /* Build configuration list for PBXProject "osx-project-1" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + ); + mainGroup = CCBE7EFD1644AA6700569B00; + productRefGroup = CCBE7F091644AA6800569B00 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + CCBE7F071644AA6800569B00 /* osx-project-1 */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXSourcesBuildPhase section */ + CCBE7F041644AA6800569B00 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + CCBE7F101644AA6800569B00 /* main.m in Sources */, + CC181DD01644AACA0038CFC9 /* Cell.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + CCBE7F151644AA6800569B00 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ARCHS = "$(ARCHS_STANDARD_64_BIT)"; + CLANG_ENABLE_OBJC_ARC = 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_VERSION = com.apple.compilers.llvm.clang.1_0; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.7; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + }; + name = Debug; + }; + CCBE7F161644AA6800569B00 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ARCHS = "$(ARCHS_STANDARD_64_BIT)"; + CLANG_ENABLE_OBJC_ARC = YES; + COPY_PHASE_STRIP = YES; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_ENABLE_OBJC_EXCEPTIONS = YES; + GCC_VERSION = com.apple.compilers.llvm.clang.1_0; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.7; + SDKROOT = macosx; + }; + name = Release; + }; + CCBE7F181644AA6800569B00 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "osx-project-1/osx-project-1-Prefix.pch"; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + CCBE7F191644AA6800569B00 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "osx-project-1/osx-project-1-Prefix.pch"; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + CCBE7F021644AA6800569B00 /* Build configuration list for PBXProject "osx-project-1" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + CCBE7F151644AA6800569B00 /* Debug */, + CCBE7F161644AA6800569B00 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + CCBE7F171644AA6800569B00 /* Build configuration list for PBXNativeTarget "osx-project-1" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + CCBE7F181644AA6800569B00 /* Debug */, + CCBE7F191644AA6800569B00 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = CCBE7EFF1644AA6700569B00 /* Project object */; +} diff --git a/osx-project-1.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/osx-project-1.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 00000000..40c41437 --- /dev/null +++ b/osx-project-1.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/osx-project-1.xcodeproj/project.xcworkspace/xcuserdata/mg.xcuserdatad/UserInterfaceState.xcuserstate b/osx-project-1.xcodeproj/project.xcworkspace/xcuserdata/mg.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 00000000..180de9b1 Binary files /dev/null and b/osx-project-1.xcodeproj/project.xcworkspace/xcuserdata/mg.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/osx-project-1.xcodeproj/project.xcworkspace/xcuserdata/mg.xcuserdatad/WorkspaceSettings.xcsettings b/osx-project-1.xcodeproj/project.xcworkspace/xcuserdata/mg.xcuserdatad/WorkspaceSettings.xcsettings new file mode 100644 index 00000000..06c7d504 --- /dev/null +++ b/osx-project-1.xcodeproj/project.xcworkspace/xcuserdata/mg.xcuserdatad/WorkspaceSettings.xcsettings @@ -0,0 +1,10 @@ + + + + + IDEWorkspaceUserSettings_HasAskedToTakeAutomaticSnapshotBeforeSignificantChanges + + IDEWorkspaceUserSettings_SnapshotAutomaticallyBeforeSignificantChanges + + + diff --git a/osx-project-1.xcodeproj/xcuserdata/mg.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist b/osx-project-1.xcodeproj/xcuserdata/mg.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist new file mode 100644 index 00000000..f551c3a0 --- /dev/null +++ b/osx-project-1.xcodeproj/xcuserdata/mg.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist @@ -0,0 +1,131 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/osx-project-1.xcodeproj/xcuserdata/mg.xcuserdatad/xcschemes/osx-project-1.xcscheme b/osx-project-1.xcodeproj/xcuserdata/mg.xcuserdatad/xcschemes/osx-project-1.xcscheme new file mode 100644 index 00000000..8fffcd25 --- /dev/null +++ b/osx-project-1.xcodeproj/xcuserdata/mg.xcuserdatad/xcschemes/osx-project-1.xcscheme @@ -0,0 +1,84 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/osx-project-1.xcodeproj/xcuserdata/mg.xcuserdatad/xcschemes/xcschememanagement.plist b/osx-project-1.xcodeproj/xcuserdata/mg.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 00000000..ecb72f48 --- /dev/null +++ b/osx-project-1.xcodeproj/xcuserdata/mg.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,22 @@ + + + + + SchemeUserState + + osx-project-1.xcscheme + + orderHint + 0 + + + SuppressBuildableAutocreation + + CCBE7F071644AA6800569B00 + + primary + + + + + diff --git a/osx-project-1/Cell.h b/osx-project-1/Cell.h new file mode 100644 index 00000000..56942e04 --- /dev/null +++ b/osx-project-1/Cell.h @@ -0,0 +1,33 @@ +// +// Cell.h +// osx-project-1 +// +// Created by m g on 11/3/12. +// Copyright (c) 2012 __MyCompanyName__. All rights reserved. +// + +#import +#define DNA_DIMENTION 100 + +@interface Cell : NSObject +{ + enum DNALetters + { + letterA = 0, + letterC, + letterT, + letterG, + letterLast, // always on end + }; + + NSMutableArray* DNA; +} + +-(id)init; +-(void)initDNA; + +-(enum DNALetters)getLetterByIndex:(int) index; +-(int)hummingDistance: (Cell*) anotherDNA; + +-(void)print; +@end diff --git a/osx-project-1/Cell.m b/osx-project-1/Cell.m new file mode 100644 index 00000000..c89fd0c3 --- /dev/null +++ b/osx-project-1/Cell.m @@ -0,0 +1,86 @@ +// +// Cell.m +// osx-project-1 +// +// Created by m g on 11/3/12. +// Copyright (c) 2012 __MyCompanyName__. All rights reserved. +// + +#import "Cell.h" + +@implementation Cell + +// Constructor +-(id)init +{ + self = [super init]; + if (self) + { + DNA = [NSMutableArray arrayWithCapacity:DNA_DIMENTION]; + if (DNA) + { + [self initDNA]; + } + } + return self; +} + +// init the DNA array +-(void)initDNA +{ + for (int i = 0; i < DNA_DIMENTION; i++) + { + enum DNALetters letter = rand()%letterLast; + [DNA addObject:[NSNumber numberWithInt:letter]]; + } +} + +// +-(enum DNALetters)getLetterByIndex:(int) index +{ + return [[DNA objectAtIndex:index] intValue]; +} + +// Get Distance +-(int)hummingDistance:(Cell *)anotherDNA +{ + int differents = 0; + + for (int i = 0 ; i < DNA_DIMENTION; i++) + { + if ( [self getLetterByIndex:i] != [anotherDNA getLetterByIndex:i] ) differents++; + } + + return differents; +} + +// Print it +-(void)print +{ + NSString *str = [[NSString alloc] init]; + + for ( int i = 0; i < DNA_DIMENTION; i++ ) + { + switch ([self getLetterByIndex:i]) + { + case letterA: + str = [str stringByAppendingString:@"A"]; + break; + case letterC: + str = [str stringByAppendingString:@"C"]; + break; + case letterG: + str = [str stringByAppendingString:@"G"]; + break; + case letterT: + str = [str stringByAppendingString:@"T"]; + break; + default: + break; + } + } + + NSLog(str); +} + +@end diff --git a/osx-project-1/main.m b/osx-project-1/main.m new file mode 100644 index 00000000..8d855a18 --- /dev/null +++ b/osx-project-1/main.m @@ -0,0 +1,78 @@ +// +// main.m +// osx-project-1 +// +// Created by m g on 11/3/12. +// Copyright (c) 2012 __MyCompanyName__. All rights reserved. +// + +#import +#import "Cell.h" + + +@interface Cell (mutator) +-(void)mutate:(int)percent; +@end + +@implementation Cell (mutator) + +-(void)mutate:(int)percent +{ + int forMutate = (int)([DNA count] * percent / 100); + + NSMutableArray* indexForMutate = [NSMutableArray arrayWithCapacity:forMutate]; + for (int i = 0; i < forMutate; i++) + { + NSNumber* wrapInt; + do + { + int index = rand()%forMutate; + wrapInt = [NSNumber numberWithInt:index]; + } + while ( [indexForMutate containsObject:wrapInt]); + [indexForMutate addObject:wrapInt]; + } + + for (int i = 0 ; i < [indexForMutate count]; i++) + { + NSNumber *letter = [DNA objectAtIndex:[[indexForMutate objectAtIndex:i] intValue]]; + int new_letter; + + do + { + new_letter = rand()%letterLast; + } + while (new_letter == [letter intValue]); + + letter = [NSNumber numberWithInt:new_letter]; + [DNA replaceObjectAtIndex:[[indexForMutate objectAtIndex:i] intValue] withObject:letter]; + } +} + +@end + +int main (int argc, const char * argv[]) +{ + + @autoreleasepool { + + Cell *firstCell, *seconCell; + firstCell = [[Cell alloc ] init]; + seconCell = [[Cell alloc] init]; + + [firstCell print]; + [seconCell print]; + int distanse = [firstCell hummingDistance:seconCell]; + NSLog(@"humming distanse = %i", distanse); + [firstCell mutate:50]; + [seconCell mutate:10]; + [firstCell print]; + [seconCell print]; + distanse = [firstCell hummingDistance:seconCell]; + NSLog(@"humming distanse after mutation = %i", distanse); + + // mutate + } + return 0; +} + diff --git a/osx-project-1/osx-project-1-Prefix.pch b/osx-project-1/osx-project-1-Prefix.pch new file mode 100644 index 00000000..a740e598 --- /dev/null +++ b/osx-project-1/osx-project-1-Prefix.pch @@ -0,0 +1,7 @@ +// +// Prefix header for all source files of the 'osx-project-1' target in the 'osx-project-1' project +// + +#ifdef __OBJC__ + #import +#endif diff --git a/osx-project-1/osx_project_1.1 b/osx-project-1/osx_project_1.1 new file mode 100644 index 00000000..996c2399 --- /dev/null +++ b/osx-project-1/osx_project_1.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/3/12 \" DATE +.Dt osx-project-1 1 \" Program name and manual section number +.Os Darwin +.Sh NAME \" Section Header - required - don't modify +.Nm osx-project-1, +.\" 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