Thứ Tư, 24 tháng 8, 2016

Russian mnemonic keyboard layout usage

This is how to use Russian mnemonic keyboard layout on US keyboard:


Russian Letter Mnemonic Keyboard entry or sequence
А A
Б B
В V
Г G
Д D
Е E
Ё Y O or J O
Ж X
З Z
И I
Й J spacebar or J followed by anything other than A, E, O, U
К K
Л L
М M
Н N
О O
П P
Р R
С S spacebar or A followed by anything other than H or C
Т T
У U
Ф F
Х H
Ц C spacebar or C followed by anything other than H
Ч C H
Ш W
Щ S C
Ъ Tilde/left accent key
Ы Y spacebar or Y followed by anything other than A, E, O, U
Ь apostrophe/quote key
Э Y E or J E
Ю Y U or J U
Я Y A or J A

Thứ Hai, 16 tháng 5, 2016

Luyện lập trình


  1. makeBricks
Link: http://codingbat.com/prob/p183562

Problem:
We want to make a row of bricks that is goal inches long. We have a number of small bricks (1 inch each) and big bricks (5 inches each). Return true if it is possible to make the goal by choosing from the given bricks. This is a little harder than it looks and can be done without any loops.

makeBricks(3, 1, 8) → true
makeBricks(3, 1, 9) → false
makeBricks(3, 2, 10) → true

Answer 1:

public boolean makeBricks(int small, int big, int goal) {
  for (int i = 0; i <= big; i++) {
    if (i * 5 <= goal && i * 5 + small >= goal)
      return true;
  }
  return false;

}

Answer 2:

public boolean makeBricks(int small, int big, int goal) {
  int smallNum = goal % 5; // minimum number of small bricks
  int bigNum = goal / 5;  // maximum number of big bricks
  
  // cannot supply minimum number of small bricks
  if (smallNum > small)
    return false;
  
  // can supply minimum number of small bricks
  // and maximum number of big bricks
  if (bigNum <= big)
    return true;
  
  // must reduce number of big bricks
  // and increase number of small bricks
  if ((bigNum - big) * 5 + smallNum > small)
    return false;
  
  return true;

}

Thứ Bảy, 12 tháng 3, 2016

Gian nhà không mặc kệ gió lung lay

Ruộng nương anh gửi người gieo gặt
Gian nhà không mặc kệ gió lung lay
Giếng nước hàng tre nhớ người đi xa

Thứ Ba, 1 tháng 3, 2016

Con đường xưa

Con đường xưa em đi
Nắng nghiêng nghiêng soi lên bờ má
Con đường xưa ta đi
Hai chiếc bóng nghiêng trong chiều tà.