トップページ > プログラム > 2014年10月06日 > 77oiHa01

書き込み順位&時間帯一覧

17 位/187 ID中時間01234567891011121314151617181920212223Total
書き込み数0000000001000000100010003



使用した名前一覧書き込んだスレッド一覧
デフォルトの名無しさん
プログラミングのお題スレ Part5

書き込みレス一覧

プログラミングのお題スレ Part5
220 :デフォルトの名無しさん[sage]:2014/10/06(月) 09:49:03.45 ID:77oiHa01
>>164 Squeak Smalltalk

| qib |
qib := OrderedCollection withAll: #(0 1 2 3).
qib assureUniClass class compile: 'at: idx
 [idx > self size] whileTrue: [self add: (self last: 4) sum].
 ^super at: idx'.
(1 to: 10) collect: [:idx | qib at: idx]. "=> #(0 1 2 3 6 12 23 44 85 164) "
((qib at: 10000) asString first: 10), '...'. "=> 2805856676... "
((qib at: 9999) asString first: 10), '...'. "=> 1455650563... "
プログラミングのお題スレ Part5
224 :デフォルトの名無しさん[sage]:2014/10/06(月) 16:06:14.38 ID:77oiHa01
>>206 Squeak Smalltalk

| rotateNumRight |
rotateNumRight := [:str |
 | others nums |
 others := str findTokens: ($0 to: $9).
 nums := str findBetweenSubStrs: others concatenation.
 nums addFirst: nums removeLast.
 str first isDigit ifTrue: [others addFirst: ''].
 nums size < others size ifTrue: [nums add: ''].
 (others with: nums collect: #,) concatenation as: String
].

rotateNumRight value: '2014-10-03 00:17:21'. "=> '21-2014-10 03:00:17' "
rotateNumRight value: '1 2 3 4'. "=> '4 1 2 3' "
rotateNumRight value: 'a0=0;a1=1;a2=2;a3=3'. "=> 'a3=0;a0=1;a1=2;a2=3' "
プログラミングのお題スレ Part5
227 :デフォルトの名無しさん[sage]:2014/10/06(月) 20:38:47.71 ID:77oiHa01
>>175 Squeak Smalltalk

| gettingGiftCircles |
gettingGiftCircles := [:giftPositions |
 | grids rest queue |
 rest := giftPositions.
 grids := [
  | rect points |
  rect := Rectangle encompassing: rest.
  points := (rect top to: rect bottom) gather: [:y | (rect left to: rect right) collect: [:x | x@y]].
  points := points sort reject: [:cpt | rest noneSatisfy: [:pt | (pt dist: cpt) <= 5]]].
 queue := OrderedCollection with: #()->rest.
 [:exit | [queue notEmpty] whileTrue: [
  queue first value ifEmpty: [exit value] ifNotEmpty: [
   | circles next |
   circles := queue first key.
   rest := queue removeFirst value.
   next := grids value detectMax: [:cpt | rest count: [:pt | (cpt dist: pt) <= 5]].
   queue add: (circles copyWith: next)->(rest reject: [:pt | (next dist: pt) <= 5])]
 ]] valueWithExit.
 queue first key].

gettingGiftCircles value: {-5@0. 5@0}.
"=> {0@0} "
gettingGiftCircles value: {0@5. 3@3. 4@4. 10@ -1. -9@0. -7@0. -6@2. 0@ -5. 3@ -3}.
"=> {0@0 . -9@ -1 . 6@0} "
gettingGiftCircles value: {-4@8. 6@8. 14@8. -12@4. 10@4. -6@0. -10@ -2. -2@ -4. 0@ -4. 8@ -4}.
"=> {-11@0 . 3@ -4 . 9@8 . -4@8} "
gettingGiftCircles value: {-7@ -15. -7@ -15. 5@ -2. 7@ -3. -8@ -10. 2@ -9. -3@ -3. -7@ -2. -10@ -9. 6@ -3. 9@ -12. 6@ -7. -1@ -5. -10@ -11. -6@ -8. -5@ -3}.
"=> {-10@ -11 . 3@ -6 . -7@ -6 . 9@ -12} "
gettingGiftCircles value: {7@4. 12@11. 11@13. 31@27. 14@15. 30@28. 34@21. 37@8. 24@27. 2@20. 20@20. 36@7. 33@21. 22@5. 15@28. 15@7}
"=> {12@11 . 30@23 . 17@24 . 32@8 . 2@4 . 2@15 . 22@5 . 24@27} "


※このページは、『2ちゃんねる』の書き込みを基に自動生成したものです。オリジナルはリンク先の2ちゃんねるの書き込みです。
※このサイトでオリジナルの書き込みについては対応できません。
※何か問題のある場合はメールをしてください。対応します。