Objective-C 习题(三)
Objective-C 练习题,题目来源 exercism.io,一共 50 题,见 GitHub。
第三篇共 10 题。
- # Scrabble Score
- # Phone Number
- # Perfect Numbers
- # Secret Handshake
- # Atbash Cipher
- # Sieve
- # Collatz Conjecture
- # Series
- # Beer Song
- # Word Count
# Scrabble Score
题目和测试用例见链接,下同。Scrabble Score
Given a word, compute the scrabble score for that word.
1 | // ScrabbleScore.h |
# Phone Number
Phone Number
Clean up user-entered phone numbers so that they can be sent SMS messages.
1 | // PhoneNumber.h |
# Perfect Numbers
Perfect Numbers
Determine if a number is perfect, abundant, or deficient based on Nicomachus’ (60 - 120 CE) classification scheme for natural numbers.
1 | // NumberClassifier.h |
# Secret Handshake
Secret Handshake
Given a decimal number, convert it to the appropriate sequence of events for a secret handshake.
1 | // SecretHandshake.h |
# Atbash Cipher
Atbash Cipher
Create an implementation of the atbash cipher, an ancient encryption system created in the Middle East.
1 | // AtbashCipher.h |
# Sieve
Sieve
Use the Sieve of Eratosthenes to find all the primes from 2 up to a given number.
1 | // Sieve.h |
# Collatz Conjecture
Collatz Conjecture
Calculate the number of steps to reach 1 using the Collatz conjecture
1 | // CollatzConjecture.h |
# Series
Series
Given a string of digits, output all the contiguous substrings of lengthn
in that string.
1 | // Series.h |
# Beer Song
Beer Song
Produce the lyrics to that beloved classic, that field-trip favorite: 99 Bottles of Beer on the Wall.
1 | // BeerSongExample.h |
# Word Count
Word Count
Given a phrase, count the occurrences of each word in that phrase.
1 | // WordCount.h |