回答編集履歴
5
追加
answer
CHANGED
@@ -59,10 +59,12 @@
|
|
59
59
|
if(!isset($current[$day])) { continue; } //その日がない、スキップ
|
60
60
|
for($i = 0; $i < count($current[$day]); $i++) {
|
61
61
|
if($current[$day][$i]['action'] !== $content['action']) {continue;} //action違い、スキップ
|
62
|
-
$current[$day][$i]['time'] = array_slice(array_merge($current[$day][$i]['time'],[$content['time']]), 0, 20);
|
62
|
+
//$current[$day][$i]['time'] = array_slice(array_merge($current[$day][$i]['time'],[$content['time']]), 0, 20);
|
63
|
-
rsort($current[$day][$i]['time']);
|
63
|
+
//rsort($current[$day][$i]['time']);
|
64
|
+
$current[$day][$i]['time'] = array_slice(array_merge([$content['time']], $current[$day][$i]['time']), 0, 20);
|
64
|
-
$current[$day][$i]['actorID'] = array_slice(array_merge($current[$day][$i]['actorID'],[$content['actorID']]), 0, 4);
|
65
|
+
//$current[$day][$i]['actorID'] = array_slice(array_merge($current[$day][$i]['actorID'],[$content['actorID']]), 0, 4);
|
65
|
-
rsort($current[$day][$i]['actorID']);
|
66
|
+
//rsort($current[$day][$i]['actorID']);
|
67
|
+
$current[$day][$i]['actorID'] = array_slice(array_merge([$content['actorID']], $current[$day][$i]['actorID']), 0, 4);
|
66
68
|
$current[$day][$i]['allow'] = 'undone';
|
67
69
|
}
|
68
70
|
$sortkey = array_map(function($ar) { return $ar[0];}, array_column($current[$day], 'time'));
|
4
修正
answer
CHANGED
@@ -54,7 +54,6 @@
|
|
54
54
|
|
55
55
|
);
|
56
56
|
|
57
|
-
|
58
57
|
foreach($new as $day => $contents) {
|
59
58
|
foreach($contents as $content) {
|
60
59
|
if(!isset($current[$day])) { continue; } //その日がない、スキップ
|
@@ -66,7 +65,8 @@
|
|
66
65
|
rsort($current[$day][$i]['actorID']);
|
67
66
|
$current[$day][$i]['allow'] = 'undone';
|
68
67
|
}
|
68
|
+
$sortkey = array_map(function($ar) { return $ar[0];}, array_column($current[$day], 'time'));
|
69
|
-
array_multisort(
|
69
|
+
array_multisort($sortkey, SORT_DESC,$current[$day]);
|
70
70
|
}
|
71
71
|
}
|
72
72
|
var_export($current);
|
3
修正
answer
CHANGED
@@ -1,5 +1,9 @@
|
|
1
|
-
|
1
|
+
独自解釈につきご容赦ください
|
2
2
|
|
3
|
+
* 20個まで付くやつ降順ソートで20個ではないのか?
|
4
|
+
* newのやつが上にくるとのことだが、actionだけでみたとき、$current側に、appleが複数いる可能性が否定されていない。またallowをundoneにするという意図からしても、newがついたやつが上にくるのではなく、undoneがうえからならんでいればいいのではないかと考え、そうコード化した。
|
5
|
+
(doneよりも下にundoneがいることは対処が必要だと思ったが、今回の例の1/2においてcurrentでundoneのorangeよりappleが上にくることに実用上の必然性を見出せなかった)
|
6
|
+
|
3
7
|
```php
|
4
8
|
<?php
|
5
9
|
/*
|
@@ -56,12 +60,13 @@
|
|
56
60
|
if(!isset($current[$day])) { continue; } //その日がない、スキップ
|
57
61
|
for($i = 0; $i < count($current[$day]); $i++) {
|
58
62
|
if($current[$day][$i]['action'] !== $content['action']) {continue;} //action違い、スキップ
|
59
|
-
$current[$day][$i]['time'][] = $content['time'];
|
60
|
-
$current[$day][$i]['time'] = array_slice($current[$day][$i]['time'], 0, 20);
|
63
|
+
$current[$day][$i]['time'] = array_slice(array_merge($current[$day][$i]['time'],[$content['time']]), 0, 20);
|
61
|
-
$current[$day][$i]['
|
64
|
+
rsort($current[$day][$i]['time']);
|
62
|
-
$current[$day][$i]['actorID'] = array_slice($current[$day][$i]['actorID'], 0,
|
65
|
+
$current[$day][$i]['actorID'] = array_slice(array_merge($current[$day][$i]['actorID'],[$content['actorID']]), 0, 4);
|
66
|
+
rsort($current[$day][$i]['actorID']);
|
63
67
|
$current[$day][$i]['allow'] = 'undone';
|
64
68
|
}
|
69
|
+
array_multisort(array_column($current[$day], 'allow'), SORT_DESC,$current[$day]);
|
65
70
|
}
|
66
71
|
}
|
67
72
|
var_export($current);
|
2
修正
answer
CHANGED
@@ -2,7 +2,6 @@
|
|
2
2
|
|
3
3
|
```php
|
4
4
|
<?php
|
5
|
-
// Your code here!
|
6
5
|
/*
|
7
6
|
* 新しい配列 $new
|
8
7
|
*/
|
1
修正
answer
CHANGED
@@ -60,7 +60,7 @@
|
|
60
60
|
$current[$day][$i]['time'][] = $content['time'];
|
61
61
|
$current[$day][$i]['time'] = array_slice($current[$day][$i]['time'], 0, 20);
|
62
62
|
$current[$day][$i]['actorID'][] = $content['actorID'];
|
63
|
-
$current[$day][$i]['actorID'] = array_slice($current[$day][$i]['actorID'], 0,
|
63
|
+
$current[$day][$i]['actorID'] = array_slice($current[$day][$i]['actorID'], 0, 20);
|
64
64
|
$current[$day][$i]['allow'] = 'undone';
|
65
65
|
}
|
66
66
|
}
|