Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added Tasks/.DS_Store
Binary file not shown.
Binary file added Tasks/Task2/.DS_Store
Binary file not shown.
2 changes: 2 additions & 0 deletions Tasks/Task2/RSSchool_T2/RSSchool_T2.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic;
INFOPLIST_FILE = "$(SRCROOT)/RSSchool_T2/Irrelevant/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 12.1;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand All @@ -471,6 +472,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic;
INFOPLIST_FILE = "$(SRCROOT)/RSSchool_T2/Irrelevant/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 12.1;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down
Binary file not shown.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>RSSchool_T2.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
</dict>
</plist>
Binary file added Tasks/Task2/RSSchool_T2/RSSchool_T2/.DS_Store
Binary file not shown.
23 changes: 22 additions & 1 deletion Tasks/Task2/RSSchool_T2/RSSchool_T2/1/KidnapperNote.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
#import "KidnapperNote.h"

@implementation KidnapperNote
// your code here
- (BOOL)checkMagazine:(NSString *)magazine note:(NSString *)note{
NSMutableArray *words = [[NSMutableArray alloc] initWithArray:[[note lowercaseString] componentsSeparatedByString:@" "] ];
NSInteger countOfWords = [words count] ;
NSMutableArray *wordsInMagazine = [[NSMutableArray alloc] initWithArray:[[magazine lowercaseString] componentsSeparatedByString:@" "]];
NSMutableArray *copyOfmag = [NSMutableArray arrayWithArray:wordsInMagazine];


for(NSString *str in wordsInMagazine){
[words enumerateObjectsUsingBlock:^(NSString *obj, NSUInteger idx, BOOL * _Nonnull jj) {

if([obj isEqualToString:str]&& [words count]!=0){
[copyOfmag removeObject:str];
[words removeObject:str];
}
}];
}
NSInteger countOfwordsInMag = [wordsInMagazine count];
NSInteger checkforEmpty = [words count];
[wordsInMagazine release];
[words release];
return !checkforEmpty && (countOfwordsInMag-[copyOfmag count]>= countOfWords);
}
@end
74 changes: 73 additions & 1 deletion Tasks/Task2/RSSchool_T2/RSSchool_T2/2/RomanTranslator.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,77 @@
#import "RomanTranslator.h"

@implementation RomanTranslator
// your code here
- (NSString *)romanFromArabic:(NSString *)arabicString{
NSArray *roman = @[@"I",@"V",@"X",@"L",@"C",@"D",@"M"];
NSArray *arabic = @[@"1",@"5",@"10",@"50",@"100",@"500",@"1000"];
NSMutableString *str = [[[NSMutableString alloc] init] autorelease];

NSInteger value = [arabicString integerValue];

NSInteger reminder, intPart;

for(int i = 6;i>=0;i--){
reminder = value % [[arabic objectAtIndex:i] integerValue];
intPart = value / [[arabic objectAtIndex:i] integerValue];
if(intPart==0 && i%2 ==0 && i!=0){
intPart = (value + [[arabic objectAtIndex:i-2] integerValue])/ [[arabic objectAtIndex:i] integerValue];
if (intPart ==1){
[str appendString:[roman objectAtIndex:i-2]];
reminder = (value + [[arabic objectAtIndex:i-2] integerValue]) ;
i++;
}
}
else if(intPart==0 && i-1%2==0 &&i>=1){
intPart = (value + [[arabic objectAtIndex:i-1] integerValue])/ [[arabic objectAtIndex:i] integerValue];
if (intPart ==1){
[str appendString:[roman objectAtIndex:i-1]];
reminder = (value + [[arabic objectAtIndex:i-1] integerValue]) ;
i++;
}
}
else{
for(int j = 0;j<intPart;j++){
[str appendString:[roman objectAtIndex:i]];
}
if( i>2 && i%2 ==0 && value + [[arabic objectAtIndex:i-2]integerValue] / [[arabic objectAtIndex:i] integerValue] !=0 )
i++;
}
value = reminder;
}

return str;
}


- (NSString *)arabicFromRoman:(NSString *)romanString{
NSMutableString *reverseRoman = [[NSMutableString alloc] init ];
NSArray *roman = @[@"I",@"V",@"X",@"L",@"C",@"D",@"M"];
NSArray *arabic = @[@"1",@"5",@"10",@"50",@"100",@"500",@"1000"];
while ([romanString length]!=[reverseRoman length]) {
NSRange range = NSMakeRange([romanString length]-[reverseRoman length]-1, 1);
[reverseRoman appendString: [romanString substringWithRange:range]];
}
NSMutableArray *reverseRomanArr = [[NSMutableArray alloc] init];
[reverseRoman enumerateSubstringsInRange:NSMakeRange(0, [reverseRoman length])
options:(NSStringEnumerationByComposedCharacterSequences)
usingBlock:^(NSString *substring, NSRange substringRange, NSRange enclosingRange, BOOL *stop) {
[reverseRomanArr addObject:substring];
}];
[reverseRoman release];

NSInteger answer =0;
for(int i =1;i<= [reverseRomanArr count];i++){
answer += [[arabic objectAtIndex: [roman indexOfObject:[reverseRomanArr objectAtIndex:i-1]]] integerValue];
if(i<[reverseRomanArr count]&&[[arabic objectAtIndex: [roman indexOfObject:[reverseRomanArr objectAtIndex:i-1]]] integerValue]>[[arabic objectAtIndex: [roman indexOfObject:[reverseRomanArr objectAtIndex:i]]] integerValue]){
answer-=[[arabic objectAtIndex: [roman indexOfObject:[reverseRomanArr objectAtIndex:i]]] integerValue];
i++;
}
}
[reverseRomanArr release];
NSString *answ = [[[NSString alloc] initWithFormat:@"%li", (long)answer] autorelease];
return answ;
}



@end
2 changes: 1 addition & 1 deletion Tasks/Task2/RSSchool_T2/RSSchool_T2/3/DoomsdayMachine.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
@property (nonatomic, readonly) NSInteger minutes;
@property (nonatomic, readonly) NSInteger seconds;
@end
@interface DoomsdayMachine : NSObject
@interface DoomsdayMachine : NSObject<AssimilationInfo>
/**
Returns AssimilationInfo for a gived date string

Expand Down
55 changes: 54 additions & 1 deletion Tasks/Task2/RSSchool_T2/RSSchool_T2/3/DoomsdayMachine.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,58 @@
#import "DoomsdayMachine.h"
@interface DoomsdayMachine ()

@property (nonatomic, readwrite) NSInteger years;
@property (nonatomic, readwrite) NSInteger months;
@property (nonatomic, readwrite) NSInteger weeks;
@property (nonatomic, readwrite) NSInteger days;
@property (nonatomic, readwrite) NSInteger hours;
@property (nonatomic, readwrite) NSInteger minutes;
@property (nonatomic, readwrite) NSInteger seconds;
@property (retain, nonatomic) NSDateFormatter* dateFormarter;

@end
NSString* formatDate = @"yyyy:MM:dd@ss\\mm/H";
NSString* dateOfEndInMachine = @"2208:08:14@37\\13/03";
NSString* dateOfEndInHuman = @"Sunday, August 14, 2208";
@implementation DoomsdayMachine
// your code here
- (instancetype)init
{
self = [super init];
if (self) {
_dateFormarter = [NSDateFormatter new];
[_dateFormarter setDateFormat:formatDate];
}
return self;
}
- (NSString*)doomsdayString {
return dateOfEndInHuman;
}

- (id<AssimilationInfo>)assimilationInfoForCurrentDateString:(NSString *)dateString {
NSDateComponents* CalendarComponents = [[NSCalendar currentCalendar]
components:NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitDay | NSCalendarUnitHour | NSCalendarUnitMinute | NSCalendarUnitSecond
fromDate:[_dateFormarter dateFromString:dateString]
toDate:[_dateFormarter dateFromString:dateOfEndInMachine]
options:0];
return [self convertComponentsToDoom:CalendarComponents];
}

- (DoomsdayMachine*) convertComponentsToDoom:(NSDateComponents*) dateComponents {
DoomsdayMachine* machine = [[[DoomsdayMachine alloc] init] autorelease];
machine.years = dateComponents.year;
machine.months = dateComponents.month;
machine.days = dateComponents.day;
machine.hours = dateComponents.hour;
machine.minutes = dateComponents.minute;
machine.seconds = dateComponents.second;
return machine;
}

- (void)dealloc
{
[_dateFormarter release];
[super dealloc];
}
@synthesize dateString;

@end
28 changes: 27 additions & 1 deletion Tasks/Task2/RSSchool_T2/RSSchool_T2/4/MatrixHacker.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,31 @@
#import "MatrixHacker.h"
// your code here
@implementation MatrixHacker
// your code here
id<Character> (^_Block)(NSString *name);



-(void)injectCode:(id<Character> (^)(NSString *name))theBlock {
_Block = theBlock;
}
- (NSArray<id<Character>> *)runCodeWithData:(NSArray<NSString *> *)names{
NSMutableArray<id<Character>> *array = [[NSMutableArray<id<Character>> alloc] init];
for (NSString *name in names)
{
id<Character> сharacter = _Block(name);
if ([сharacter.class respondsToSelector:@selector(createWithName:isClone:)]) {
if ([name isEqualToString:@"Neo"]){
сharacter = [[сharacter class] createWithName:name isClone:NO];
} else {
сharacter = [[сharacter class] createWithName:name isClone:YES];
}
[array addObject:сharacter];
}
}
NSArray<id<Character>> *unmmutableCopy = [array copy];
[array release];
return [unmmutableCopy autorelease];
}


@end
2 changes: 2 additions & 0 deletions Tasks/Task2/RSSchool_T2/RSSchool_T2/5/TinyURL.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
@return encoded URL
*/
- (NSURL *)encode:(NSURL *)originalURL;


/**
Taken an encoded URL and returns its original form

Expand Down
Loading