根据另一个列表的顺序消除一个列表的组合

时间:2019-02-26 13:40:22

标签: python

我有一个列表,其中包含一个按升序排列的数字因子。我已经生成了该列表的排列,现在我需要消除与原始上升因子列表具有相同顺序的排列。

考虑例如:

Number=9
factors=1,3,9 
l=[1,3,9]

我使用Python中的排列函数将上述列表1的排列存储为列表的列表:

ll=[[1,3,9],[1,9,3],[3,1,9],[3,9,1],[9,1,3],[9,3,1]]

现在,我需要消除具有2个或更多元素的组合,其顺序与9的升序顺序相同: 从组合中删除:

[**[1,3,9]**,[**3,9**,1],[9,**1,3**]]

我只需要:[[1,9,3],[3,1,9],[9,3,1]

请提供解决方案的帮助,集合是无序的,因此不被选择。 谢谢

2 个答案:

答案 0 :(得分:0)

这是一种在生成排列时过滤排列的方法:

  $units = DB::table('units')
  ->select('id', 'name')
  ->get();Title
  $title = 'Create New Dets';
  return view('dets.create', ['title' => $title, 'units' => $units]);

答案 1 :(得分:0)

您可以简单地从原始因子列表中过滤掉排列是否为一对。

declare const APP_D_CONSTANT: any;

@Component({
      selector: 'app-start',
      templateUrl: './start.component.html',
      styleUrls: ['./start.component.scss'],
})

export class StartComponent implements OnInit {
  loadApp: boolean;
  _window: any = this.windowService.nativeWindow;
  constructor (private windowService: WindowService) {
    this.loadApp = false;
  }
  ngOnInit () {
    if (true) {
      // app-dynamics
      if (!!this._window.APP_D_CONSTANT) {
        APP_D_CONSTANT.command ('customData', 'name', 'name');
      }
    }
  }
}
相关问题