コード例 #1
0
ファイル: TDL.cs プロジェクト: gutmet/TDL
		// try a greedy assignment of plates to the weight
		public static Tuple<string, string> AssignPlates(double weight, Lift lift)
		{
			Tuple<string, string> ret;

			if (!parser.printplates || lift.noPlates)
				return Tuple.Create(string.Empty, string.Empty);

			var assignment = DFSNode.InitiateDFS(weight - lift.barWeight, parser.plates);
			var plates = assignment
				.GroupBy(d => d)
				.Select(grp => $"{grp.Key}{grp.Count() >= 2? $"x{grp.Count()}" : String.Empty}");



			if (assignment.Count() > 0)
			{
				ret = Tuple.Create($"{String.Join(", ", plates)}",
					String.Format("-> {0} {1}{2}",
						(assignment.Sum() * 2.0 + lift.barWeight).ToString("0.00"),
						parser.lbs? "lbs" : "kg",
						parser.startingstrength ? " + bar" : String.Empty
					)
				);
			}
			else
			{
				ret = Tuple.Create("No plates", string.Empty);
			}	

			return ret;
		}
コード例 #2
0
ファイル: TDL.cs プロジェクト: gutmet/TDL
		public Tuple<string, string, string> ToStrings(Lift lift)
		{
			double weight = intensity*lift.max + intensityConstant;
			var firstCol = $"{weight.ToString("00.00")} {Program.parser.lbs? "lbs" : "kg"} x {reps}{plus? "+":""} {comment}";
			var secondAndThirdCol = Program.AssignPlates(weight, lift);
			return Tuple.Create(firstCol, secondAndThirdCol.Item1, secondAndThirdCol.Item2);
		}