From 8b9b031be391ca8371ff34b84dc7ee3d59cf2824 Mon Sep 17 00:00:00 2001 From: "E. Almqvist" Date: Mon, 17 Jan 2022 14:15:38 +0100 Subject: [PATCH] Minor refactor --- prog2/wordle/calc.rb | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/prog2/wordle/calc.rb b/prog2/wordle/calc.rb index cab6dab..fb28df5 100755 --- a/prog2/wordle/calc.rb +++ b/prog2/wordle/calc.rb @@ -46,9 +46,14 @@ end calc_stuff(charpos_count, most_common_pos) -pos1 = ARGV[0].to_i -pos2 = ARGV[1].to_i -(pos1..pos2).each do |i| - print "#{most_common_pos[i][:char]}" +if( ARGV.length >= 2 ) then + pos1 = ARGV[0].to_i + pos2 = ARGV[1].to_i + (pos1..pos2).each do |i| + print "#{most_common_pos[i][:char]}" + end + puts "" +else + p most_common_pos + p char_count end -puts ""