Created
August 6, 2022 06:20
-
-
Save clr/90b510b21d2dc64536bc62e19e48f65f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 x 12 = _ 12_ | 1 x 9 = _ 9_ | |
2 x 4 = _ 8_ | 2 x 5 = _ 10_ | |
3 x 11 = _ 33_ | 3 x 7 = _ 21_ | |
4 x 8 = _ 32_ | 4 x 5 = _ 20_ | |
5 x 7 = _ 35_ | 5 x 12 = _ 60_ | |
6 x 3 = _ 18_ | 6 x 11 = _ 66_ | |
7 x 10 = _ 70_ | 7 x 3 = _ 21_ | |
8 x 8 = _ 64_ | 8 x 11 = _ 88_ | |
9 x 10 = _ 90_ | 9 x 9 = _ 81_ | |
10 x 11 = _110_ | 10 x 11 = _110_ | |
11 x 12 = _132_ | 11 x 4 = _ 44_ | |
12 x 4 = _ 48_ | 12 x 7 = _ 84_ | |
1 x 11 = _ 11_ | 1 x 3 = _ 3_ | |
2 x 8 = _ 16_ | 2 x 6 = _ 12_ | |
3 x 5 = _ 15_ | 3 x 10 = _ 30_ | |
4 x 3 = _ 12_ | 4 x 9 = _ 36_ | |
5 x 4 = _ 20_ | 5 x 10 = _ 50_ | |
6 x 5 = _ 30_ | 6 x 12 = _ 72_ | |
7 x 11 = _ 77_ | 7 x 8 = _ 56_ | |
8 x 4 = _ 32_ | 8 x 5 = _ 40_ | |
9 x 11 = _ 99_ | 9 x 6 = _ 54_ | |
10 x 4 = _ 40_ | 10 x 7 = _ 70_ | |
11 x 9 = _ 99_ | 11 x 10 = _110_ | |
12 x 3 = _ 36_ | 12 x 6 = _ 72_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
open('answers.txt', 'w') do |f| | |
File.new('problems.txt', chomp: true).readlines.each do |line| | |
m = line.match(/(?<a>\d+)(\D+)(?<b>\d+)(\D+)(?<c>\d+)(\D+)(?<d>\d+)/x) | |
f.puts sprintf("%2d x %2d = _%3d_ | %2d x %2d = _%3d_", m[:a], m[:b], (m[:a].to_i * m[:b].to_i), m[:c], m[:d], (m[:c].to_i * m[:d].to_i)) if m | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment