Sha256: b64579a5e30ab79c181c76a7b07098d3e33ff280544d93ba2a16ae4429f1518f

Contents?: true

Size: 850 Bytes

Versions: 159

Compression:

Stored size: 850 Bytes

Contents

#import "RNATranscriptionExample.h"

@implementation RNATranscription

- (NSString *)rnaFromDNAStrand:(NSString *)dnaStrand
{
    NSDictionary *dnaToRNADict = @{ @"G" : @"C",
                                    @"C" : @"G",
                                    @"T" : @"A",
                                    @"A" : @"U" };

    NSMutableString *rnaStrand = [NSMutableString stringWithString:dnaStrand];

    for (NSUInteger i = 0; i < [dnaStrand length]; i++) {
        NSRange charRange = [dnaStrand rangeOfComposedCharacterSequenceAtIndex:i];
        NSString *dnaNucleotide = [dnaStrand substringWithRange:charRange];
        NSString *rnaNucleotide = dnaToRNADict[dnaNucleotide];
        if (!rnaNucleotide) return nil;
        [rnaStrand replaceCharactersInRange:charRange withString:rnaNucleotide];
    }

    return [rnaStrand copy];
}

@end

Version data entries

159 entries across 159 versions & 1 rubygems

Version Path
trackler-2.2.1.159 tracks/objective-c/exercises/rna-transcription/RNATranscriptionExample.m
trackler-2.2.1.158 tracks/objective-c/exercises/rna-transcription/RNATranscriptionExample.m
trackler-2.2.1.157 tracks/objective-c/exercises/rna-transcription/RNATranscriptionExample.m
trackler-2.2.1.156 tracks/objective-c/exercises/rna-transcription/RNATranscriptionExample.m
trackler-2.2.1.155 tracks/objective-c/exercises/rna-transcription/RNATranscriptionExample.m
trackler-2.2.1.154 tracks/objective-c/exercises/rna-transcription/RNATranscriptionExample.m
trackler-2.2.1.153 tracks/objective-c/exercises/rna-transcription/RNATranscriptionExample.m
trackler-2.2.1.152 tracks/objective-c/exercises/rna-transcription/RNATranscriptionExample.m
trackler-2.2.1.151 tracks/objective-c/exercises/rna-transcription/RNATranscriptionExample.m
trackler-2.2.1.150 tracks/objective-c/exercises/rna-transcription/RNATranscriptionExample.m
trackler-2.2.1.149 tracks/objective-c/exercises/rna-transcription/RNATranscriptionExample.m
trackler-2.2.1.148 tracks/objective-c/exercises/rna-transcription/RNATranscriptionExample.m
trackler-2.2.1.147 tracks/objective-c/exercises/rna-transcription/RNATranscriptionExample.m
trackler-2.2.1.146 tracks/objective-c/exercises/rna-transcription/RNATranscriptionExample.m
trackler-2.2.1.145 tracks/objective-c/exercises/rna-transcription/RNATranscriptionExample.m
trackler-2.2.1.144 tracks/objective-c/exercises/rna-transcription/RNATranscriptionExample.m
trackler-2.2.1.143 tracks/objective-c/exercises/rna-transcription/RNATranscriptionExample.m
trackler-2.2.1.142 tracks/objective-c/exercises/rna-transcription/RNATranscriptionExample.m
trackler-2.2.1.141 tracks/objective-c/exercises/rna-transcription/RNATranscriptionExample.m
trackler-2.2.1.140 tracks/objective-c/exercises/rna-transcription/RNATranscriptionExample.m