Objective-C 习题(五)
Objective-C 练习题,题目来源 exercism.io,一共 50 题,见 GitHub。
第五篇共 10 题,完。
- # Pascals Triangle
- # Say
- # Bracket Push
- # Roman Numerals
- # Strain
- # Run Length Encoding
- # Luhn
- # Rna Transcription
- # Grains
- # Nth Prime
# Pascals Triangle
题目和测试用例见链接,下同。Pascals Triangle
Compute Pascal’s triangle up to a given number of rows.
1 | // PascalsTriangle.h |
# Say
Say
Given a number from 0 to 999,999,999,999, spell out that number in English.
1 | // Say.h |
# Bracket Push
Bracket Push
Make sure the brackets and braces all match.
1 | // BracketPushExample.h |
# Roman Numerals
Roman Numerals
Write a function to convert from normal numbers to Roman Numerals.
1 | // RomanNumerals.h |
# Strain
Strain
Implement thekeep
anddiscard
operation on collections. Given a collection and a predicate on the collection’s elements,keep
returns a new collection containing those elements where the predicate is true, whilediscard
returns a new collection containing those elements where the predicate is false.
1 | // Strain.h |
# Run Length Encoding
Run Length Encoding
Implement run-length encoding and decoding.
1 | // RunLengthEncoding.h |
# Luhn
Luhn
Given a number determine whether or not it is valid per the Luhn formula.
1 | // Luhn.h |
# Rna Transcription
Rna Transcription
Given a DNA strand, return its RNA Complement Transcription.
1 | // RNATranscription.h |
# Grains
Grains
Calculate the number of grains of wheat on a chessboard given that the number on each square doubles.
1 | // Grains.h |
# Nth Prime
Nth Prime
Given a number n, determine what the nth prime is.
1 | // NthPrime.h |