scheduling 2 week vacation time to 70 employees

时间:2017-08-30 20:38:57

标签: list filter tuples repeat itertools

General idea:

  1. Number are 1 to 6
  2. Each Person chooses 5 number.
  3. If number repeat after 3 times, select next available from the chosen one
  4. First chosen number is the prefered and last one the least preferred

    • Jean chose 1,2,3,4,5
    • Claude chose 1,2,3,4,5
    • Van chose 1,2,3,4,5
    • Dam chose 1,2,3,4,5

I would like to have the final result giving those result :

  • Jean = 1,2
  • Claude = 1,2
  • Van = 1,2
  • Dam = 3,4

UPDATE 1:

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Effects - Animate demo</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<link rel="stylesheet" href="/resources/demos/style.css">
<style>
.toggler { width: 500px; height: 200px; position: relative; }
#button { padding: .5em 1em; text-decoration: none; }
#effect { width: 240px; height: 170px; padding: 0.4em; position: relative; background: #fff; }
#effect h3 { margin: 0; padding: 0.4em; text-align: center; }
</style>
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script>
$( function() {
  var state = true;
 $( "#button" ).on( "click", function() {
  if ( state ) {
    $( "#effect" ).animate({
      backgroundColor: "#aa0000",
      color: "#fff",
      width: 500
    }, 1000 );
  } else {
    $( "#effect" ).animate({
      backgroundColor: "#fff",
      color: "#000",
      width: 240
      }, 1000 );
    }
    state = !state;
  });
   } );
  </script>
 </head>
 <body>

 <div class="toggler">
 <div id="effect" class="ui-widget-content ui-corner-all">
  <h3 class="ui-widget-header ui-corner-all">Animate</h3>
  <p>
  Etiam libero neque, luctus a, eleifend nec, semper at, lorem. Sed pede. Nulla lorem metus, adipiscing ut, luctus sed, hendrerit vitae, mi.
  </p>
  </div>
  </div>

   <button id="button" class="ui-state-default ui-corner-all">Toggle Effect</button>


   </body>
   </html>

Traceback (most recent call last): line 30, in if tracking[week_pool] < 3: TypeError: unhashable type: 'list'

UPDATE THAT WORK !

 @override
 public void onAttach(Context context) {
 super.onAttach(context);

context1=this.getActivity();
}

1 个答案:

答案 0 :(得分:0)

<强>修订

from collections import OrderedDict

# Translate employe ids
ids_names = {
    ("01", "Jean"),
    ("02", "Claude"),
    ("03", "Van"),
    ("04", "Damme"),
    ("05", "Kristopher"),
    ("06", "Bianca"),
}

week_pool = list(range(1, 53))
employee_choices = OrderedDict([
    ("01", [1,2,3,4,5]),
    ("02", [1,2,3,4,5]),
    ("03", [1,2,3,4,5]),
    ("04", [1,2,3,4,5]),
    ("05", [2,3,4,5,6]),
    ("06", [1,2,3]),
])

说明

08-31:你有个好的开始。我会在这里更新说明并给你提示。一些小调:

  1. 如果两个人的名字相同,那么编程就会让人感到困惑。您最好为员工分配号码,因为这些号码是独一无二的。因此,不要将ids数量与周数混淆,让我们使用数字字符串。如果我们命名以查找名称,我们可以稍后搜索翻译词典。
  2. range()是获取整数范围的较短方法,但您的方法也有效。
  3. OrderedDict是一个很好的电话。您可以使用它来订购资历。您只需要确保您的周数在一个单独的容器中,例如一个列表。我稍后添加了一些额外的名字。
  4. 在样式上,我们对变量名使用小写。我们也保持线条短(79个字符),所以使用返回。
  5. <强>目标

    1. 构建输入数据(确定
    2. 制作一个调度功能:
      • 处理员工和可用周数
      • ...