Characters and Words:
Week 1
Lesson 1:
1. yī 2. èr 3. sān 4. liù 5. bā 6. shí (shí yī, shí èr, shí sān, shí liù, shí bā, èr shí, sān shí, liù shí, bā shí)
Lesson 2:
1. sì (shí
sì, sì shí) 2. wǔ (shí wǔ, wǔ shí) 3. qī (shí
qī, qī shí) 4. jiǔ (shí jiǔ, jiǔ shí) 5. gè
6. liǎng (liǎng gè)
Lesson 3:
1. jǐ (jǐ
gè) 2. bàn (bàn gè, yí bàn) 3. bǎi (yì bǎi,
sān bǎi) 4. qiān (yì qiān, wǔ qiān) 5. wàn (yí wàn)
6. rén
Lesson 4:
1. gōng (gōng
rén) 2. gān 3. tiān (yì
tiān, liǎng tiān, bàn tiān) 4. jīn (jīn tiān) 5, fū
6. zhàng (zhàng fu)
Next
from Coursera Chinese Characters for beginner 汉字 by Peking University
Link: https://www.coursera.org/learn/hanzi/home
21 April 2017
12 April 2017
deleteDigit
My solution:
Previous Next
int deleteDigit(int n) { return int.Parse(n.ToString().Select((c, i) => n.ToString().Remove(i, 1)).Max());; }
Previous Next
Labels:
Arcade,
C#,
CodeSignal,
Intro,
Rainbow of Clarity
chessKnight
My solution:
Previous Next
int chessKnight(string cell) { var possible_moves = new List<string>(); // Upward if (int.Parse(cell[1].ToString()) + 2 <= 8) { if (cell[0] >= 'b') possible_moves.Add((char)(cell[0] - 1) + ((char) (cell[1] + 2)).ToString()); if (cell[0] <= 'g') possible_moves.Add((char)(cell[0] + 1) + ((char)(cell[1] + 2)).ToString()); } // Rightward if (cell[0] <= 'f') { if (int.Parse(cell[1].ToString()) <= 7) possible_moves.Add((char)(cell[0] + 2) + ((char)(cell[1] + 1)).ToString()); if (int.Parse(cell[1].ToString()) >= 2) possible_moves.Add((char)(cell[0] + 2) + ((char)(cell[1] - 1)).ToString()); } // Downward if (int.Parse(cell[1].ToString()) - 2 >= 1) { if (cell[0] >= 'b') possible_moves.Add((char)(cell[0] - 1) + ((char)(cell[1] - 2)).ToString()); if (cell[0] <= 'g') possible_moves.Add((char)(cell[0] + 1) + ((char)(cell[1] - 2)).ToString()); } // Leftward if (cell[0] >= 'c') { if (int.Parse(cell[1].ToString()) <= 7) possible_moves.Add((char)(cell[0] - 2) + ((char)(cell[1] + 1)).ToString()); if (int.Parse(cell[1].ToString()) >= 2) possible_moves.Add((char)(cell[0] - 2) + ((char)(cell[1] - 1)).ToString()); } return possible_moves.Count; }
Previous Next
Labels:
Arcade,
C#,
CodeSignal,
Intro,
Rainbow of Clarity
lineEncoding
My solution:
Previous Next
string lineEncoding(string s) { var c = new char(); var answer = string.Empty; var counter = 0; for (var i = 0; i < s.Length; i++) { if (c == '\0') { c = s[i]; counter++; } else if (c == s[i]) { counter++; if (i == s.Length - 1) answer += counter.ToString() + c; } else { if (counter > 1) answer += counter.ToString() + c; else answer += c; c = s[i]; counter = 1; if (i == s.Length - 1) answer += c; } } return answer; }
Previous Next
Labels:
Arcade,
C#,
CodeSignal,
Intro,
Rainbow of Clarity
11 April 2017
Is MAC48 Address?
My solution:
Previous Next
bool isMAC48Address(string inputString) { return Regex.IsMatch(inputString, "^([0-9A-F]{2}-){5}[0-9A-F]{2}$"); }
Previous Next
Labels:
Arcade,
C#,
CodeSignal,
Eruption of Light,
Intro
Elections Winners
My solution:
Previous Next
int electionsWinners(int[] votes, int k) { var max = votes.Max(); return k == 0 && votes.Where(d => d == votes.Max()).Count() == 1 ? 1 : votes.Count(t => t + k > max); }
Previous Next
Labels:
Arcade,
C#,
CodeSignal,
Eruption of Light,
Intro
Subscribe to:
Posts (Atom)