File tree Expand file tree Collapse file tree 1 file changed +10
-7
lines changed Expand file tree Collapse file tree 1 file changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -41,8 +41,17 @@ def score_round_part1(line)
41
41
opp_choice , my_choice = line . split ( " " )
42
42
opp_shape = OPPONENT_MAP . fetch ( opp_choice )
43
43
my_shape = PART1_MAP . fetch ( my_choice )
44
+
45
+ outcome = case opp_shape
46
+ when my_shape
47
+ :draw
48
+ when WHAT_LOSES_TO . fetch ( my_shape )
49
+ :win
50
+ else
51
+ :lose
52
+ end
44
53
45
- SHAPE_SCORES . fetch ( my_shape ) + OUTCOME_SCORES . fetch ( against ( opp_shape , my_shape ) )
54
+ SHAPE_SCORES . fetch ( my_shape ) + OUTCOME_SCORES . fetch ( outcome )
46
55
end
47
56
48
57
# @example
@@ -68,12 +77,6 @@ def score_round_part2(line)
68
77
SHAPE_SCORES . fetch ( my_shape ) + OUTCOME_SCORES . fetch ( target_outcome )
69
78
end
70
79
71
- def against ( opp_shape , my_shape )
72
- return :draw if opp_shape == my_shape
73
- return :win if opp_shape == WHAT_LOSES_TO . fetch ( my_shape )
74
- return :lose
75
- end
76
-
77
80
# the name seems backwards here, but consider:
78
81
#
79
82
# WHAT_LOSES_TO.fetch(:rock) => :scissors
You can’t perform that action at this time.
0 commit comments