読者です 読者をやめる 読者になる 読者になる

Trend Micro CTF Asia Pacific & Japan 2015に参加しました。

概要

トレンドマイクロ社主催のCTFであるTrend Micro CTF Asia Pacific & Japan 2015に参加しました。 自分は、Prog200を1問解いて、Prog300は挑戦したものの結局、手動回答用の補助ツールを作成しました。 Prog300はチームで分担して解いていたのですが、時間的に間に合いそうにないため断念。 それぞれの問題について問題概要と回答方針について記録します。

内容

Porg200

問題は、ソケット通信で数式が送られてくるので計算結果を送り返すというもの。 10問解く毎に問題が難しくなり、後半はローマ数字、英語表記が出てくる。

基本計算は、Rubyのeval関数を使うことでどろくさい実装はしなくて済んだ。 ローマ数字は、ライブラリが存在したため、それを拝借して、数字に置換。 英単語については、数字から英単語に変更するプログラムNum2EngがGithub上があったため、それを参考にしました。

ソースコードと実行結果は以下。

#!/usr/bin/env ruby
require 'socket'

module Eng2Num
  # 数字と英語を結びつける
  ENG_NUM = {
      'zero' => '0',
      'one' => '1',
      'two' => '2',
      'three' => '3',
      'four' => '4',
      'five' => '5',
      'six' => '6',
      'seven' => '7',
      'eight' => '8',
      'nine' => '9',
      'ten' => '10',
      'eleven' => '11',
      'twelve' => '12',
      'thirteen' => '13',
      'fourteen' => '14',
      'fifteen' => '15',
      'sixteen' => '16',
      'seventeen' => '17',
      'eighteen' => '18',
      'nineteen' => '19',
      'twenty' => '20',
      'thirty' => '30',
      'forty' => '40',
      'fifty' => '50',
      'sixty' => '60',
      'seventy' => '70',
      'eighty' => '80',
      'ninety' => '90',
      'hundred' => '100',
      'thousand' => '1000',
      'million' => '1000000',
      'billion' => '1000000000',
  }

  def self.get_num (word)

    splited = word.split(' ')
    sum = 0

    set = []
    splited.each do |w|
      set << ENG_NUM[w]
    end

    if set.length > 1
      million = '0'
      billion  = '0'

      p set

      (set.length).times do |t|
        if set[t] == '100'
          set[t-1] = (set[t-1].to_i * 100).to_s
          set[t] = '0'
        end
        if set[t] == '1000'
          sum2 = 0
          t.times do |ti|
            sum2 += set[ti].to_i
            set[ti] = '0'
          end
          set[t] = (sum2 * 1000).to_s
        end

        if set[t] == '1000000'
          sum2 = 0
          t.times do |ti|
            sum2 += set[ti].to_i
          set[ti] = '0'
          end
          million = (sum2 * 1000000).to_s
          set[t] = '0'
        end

        if set[t] == '1000000000'
          sum2 = 0
          t.times do |ti|
            sum2 += set[ti].to_i
            set[ti] = '0'
          end
          billion = (sum2 * 1000000000).to_s
          set[t] = '0'
        end

      end
      set << billion
      set << million
      set.map{|n| n.to_i}.inject(:+).to_s
    else
      set[0]
    end
  end
end

# Ruby - Hashクラス(ローマ数字を数値に変換) | Kamimura's blog
# http://sitekamimura.blogspot.jp/2013/03/ruby-hash.html
def roman_to_integer roman
    result = 0
    pre = 0
    r_n = {
      'M' => 1000,
      'D' => 500,
      'C' => 100,
      'L' => 50,
      'X' => 10,
      'V' => 5,
      'I' => 1}
  (roman.length - 1).downto(0) do |i|
        n = r_n[roman[i].upcase]
        if n >= pre
            result += n
            pre = n
        else
            result -= n
        end
    end
    result
end


sock = TCPSocket.open('210.237.145.230', 51740)
while true
  siki =  sock.recvfrom(10000)[0]
  # 正当だった場合にフラグを受け取る
  if siki.include?('Congratulations!')
    p siki
    p sock.recvfrom(10000)[0]
    p sock.recvfrom(10000)[0]
    exit 0
  end
  puts ""
  puts "============================================================================"
  puts "式:#{siki}"
  puts "============================================================================"
  seikei = siki.gsub(/=.*/,'').gsub(',','')

  roman_flag = false
  gsubed_roman = seikei.gsub(/[A-Z]+/) {|word|
    puts "hit roman #{word}"
    roman_flag = true
    roman_to_integer word
  }
  puts "gsubed_roman #{gsubed_roman}" if roman_flag

  english_flag = false
  gsubed_english = gsubed_roman.gsub(/[a-z ]+/) {|word|
    Eng2Num.get_num(word)
  }
  puts "gsubed_english: #{gsubed_english}" if english_flag

  kotae = eval(gsubed_english)
  puts kotae
  sock.write(kotae)
end

sock.close
$ ruby prog200.rb
============================================================================
式:8 * 1 = 
============================================================================
8
============================================================================
式:33 * 3 + 0 = 
============================================================================
99
============================================================================
式:51 * 3 + 309 - 36 = 
============================================================================
426
============================================================================
式:8 + 70 - 1915 + 98 - 7 = 
============================================================================
-1746
============================================================================
式:6363 - 5234 + 679 - 784 * 30 + 319 = 
============================================================================
-21393
============================================================================
式:27818 + 285 - 583849 * 605 + 960 - 372590 * 463 = 
============================================================================
-525708752
============================================================================
式:99813 * 94397 - 38955 + 284 * 10351 - 4834113 * 7 - 5 = 
============================================================================
9391109694
============================================================================
式:270 - 2112796 + 8 - 9712176 + 19537249 - 3247840 * 7253830 + 77806247 - 3910185 = 
============================================================================
-23559197618583
============================================================================
式:9 - 24717 + 4017 * 780892 + 361 - 48 * 819408 + 941167710 - 933 + 6397 = 
============================================================================
4038660407
============================================================================
式:333945771 + 98199292 * 71810445 - 904 * 6 - 6 * 5335986819 + 83379 * 9 + 7 * 9092 = 
============================================================================
7051703176038428
============================================================================
式:5 - 2 = 
============================================================================
3
============================================================================
式:8 + 86 - 35 = 
============================================================================
59
============================================================================
式:66 + 4 * ( 435 + 160 ) = 
============================================================================
2446
============================================================================
式:8 * 842 + 675 - 473 * 7009 = 
============================================================================
-3307846
============================================================================
式:0 - ( 9020 + 6239 ) * ( 34 - 283 ) * 5997 = 
============================================================================
22785547527
============================================================================
式:( 5071 - 3932 ) * ( 7 + 65111 ) - 327862 * 8 + 92191 = 
============================================================================
71638697
============================================================================
式:6921 * 74783 + 1 - ( 52337 + 4 ) * ( 414450 - 8 ) * 0 = 
============================================================================
517573144
============================================================================
式:4 - 18658124 + 1917784 - 65 + 818 - 17162555 * 4675 - 54050182 * 1 = 
============================================================================
-80305734390
============================================================================
式:424103 * 2 - 526950465 + 3915528 * ( 44 + 1957185 ) * ( 987691159 + 213403429 ) * 43 + 8387686 = 
============================================================================
395801687648048450732435
============================================================================
式:5612631 * ( 130 - 447 ) * ( 8 + 242729270 ) - ( 24 + 16 ) * ( 2 - 6698975 ) + 1307378 * 5779 = 
============================================================================
-431864901065106124
============================================================================
式:7 * 9 = 
============================================================================
63
============================================================================
式:4 - 22 * 13 = 
============================================================================
-282
============================================================================
式:7 * 70 + 7 - 7 = 
============================================================================
490
============================================================================
式:521 + 8 - 635 + 2 - 97 = 
============================================================================
-201
============================================================================
式:8,290 + 880 - 7,967 + 167 - 31,279 + 7 = 
============================================================================
-29902
============================================================================
式:2,990 + 29,853 - ( 497 + 844,013 ) * ( 73 - 461,607 ) * 756 = 
============================================================================
294666179257883
============================================================================
式:817,813 * 46,071 - 9,413 + 0 - ( 79,223 + 3,034 ) * ( 98 + 68,981 ) = 
============================================================================
31995222007
============================================================================
式:( 91,359 + 12,822 ) * ( 13 + 3,219,984 ) - 968,247 * ( 952,071 - 43 ) * ( 37 + 4,448,450 ) = 
============================================================================
-4100607218154004635
============================================================================
式:35,890 * 246,603 + 97,545,493 - 14,570 * 11 - 893,133 + 24,641,899 - 434,288,966 + 97,433,479 - 826,484,711 = 
============================================================================
7808375461
============================================================================
式:( 2 + 1,549 ) * 6,882,611,820 + 4,258 * ( 8,029,641,830 + 4,901,606 ) * ( 7,245,397 + 9,004,996 ) * ( 678,784 + 5 ) * 578,672 = 
============================================================================
218372523659652404068128227015892
============================================================================
式:IV + I = 
============================================================================
hit roman IV
hit roman I
gsubed_roman 4 + 1 
5
============================================================================
式:XVII - LXXXI + LXIX = 
============================================================================
hit roman XVII
hit roman LXXXI
hit roman LXIX
gsubed_roman 17 - 81 + 69 
5
============================================================================
式:XXXI + XLII - DLXXVII + I = 
============================================================================
hit roman XXXI
hit roman XLII
hit roman DLXXVII
hit roman I
gsubed_roman 31 + 42 - 577 + 1 
-503
============================================================================
式:II - III * ( DCCCLXII - MMMDCCCLXXXIII ) + 6546 = 
============================================================================
hit roman II
hit roman III
hit roman DCCCLXII
hit roman MMMDCCCLXXXIII
gsubed_roman 2 - 3 * ( 862 - 3883 ) + 6546 
15611
============================================================================
式:6662 - ( 8699 + LXXXI ) * ( 8118 + CLXI ) - VIII = 
============================================================================
hit roman LXXXI
hit roman CLXI
hit roman VIII
gsubed_roman 6662 - ( 8699 + 81 ) * ( 8118 + 161 ) - 8 
-72682966
============================================================================
式:( 79636 + II ) * LX + DXLIII - VII + 957363 * XLVII = 
============================================================================
hit roman II
hit roman LX
hit roman DXLIII
hit roman VII
hit roman XLVII
gsubed_roman ( 79636 + 2 ) * 60 + 543 - 7 + 957363 * 47 
49774877
============================================================================
式:651680 + ( CCCXXXII - 4988 ) * ( 0 + 258628 ) - XXIX + XXVII * 746349 = 
============================================================================
hit roman CCCXXXII
hit roman XXIX
hit roman XXVII
gsubed_roman 651680 + ( 332 - 4988 ) * ( 0 + 258628 ) - 29 + 27 * 746349 
-1183368894
============================================================================
式:LXIX * 4494 + ( CMXLVI - IX ) * ( XXXVIII - 35645202 ) * 89406813 + 1404907 * DCCCII = 
============================================================================
hit roman LXIX
hit roman CMXLVI
hit roman IX
hit roman XXXVIII
hit roman DCCCII
gsubed_roman 69 * 4494 + ( 946 - 9 ) * ( 38 - 35645202 ) * 89406813 + 1404907 * 802 
-2986144518712839584
============================================================================
式:34268 + LXXIII - 7230 * ( 19547 - 65937301 ) + 740123849 - LXXVI + 896488 - 58985 + 7394 = 
============================================================================
hit roman LXXIII
hit roman LXXVI
gsubed_roman 34268 + 73 - 7230 * ( 19547 - 65937301 ) + 740123849 - 76 + 896488 - 58985 + 7394 
477326364431
============================================================================
式:2888259 * IX - 1959091 + 987031 * ( DCL + II ) - XXVIII * 3637807178 - 7262 + CI * 690657108 = 
============================================================================
hit roman IX
hit roman DCL
hit roman II
hit roman XXVIII
hit roman CI
gsubed_roman 2888259 * 9 - 1959091 + 987031 * ( 650 + 2 ) - 28 * 3637807178 - 7262 + 101 * 690657108 
-31434660886
============================================================================
式:four * seven = 
============================================================================
28
============================================================================
式:two + fifty one * five = 
============================================================================
["50", "1"]
257
============================================================================
式:( nine hundred eighty three - 752 ) * ( 980 + 724 ) = 
============================================================================
["9", "100", "80", "3"]
393624
============================================================================
式:5 * 1 - 4,484 + nine thousand, four hundred thirty three - 6 = 
============================================================================
["9", "1000", "4", "100", "30", "3"]
4948
============================================================================
式:forty thousand ninety six - ( 312 + 3,358 ) * twenty eight + eight hundred forty three - 93 = 
============================================================================
["40", "1000", "90", "6"]
["20", "8"]
["8", "100", "40", "3"]
-61914
============================================================================
式:( 80,180 + 56,906 ) * ( 7,062 - four thousand, one hundred ninety one ) * 538 - 468 + four hundred three = 
============================================================================
["4", "1000", "1", "100", "90", "1"]
["4", "100", "3"]
211742761363
============================================================================
式:612 - two * 65,515 - five + two hundred fifty four * four + 924,281 * zero = 
============================================================================
["2", "100", "50", "4"]
-129407
============================================================================
式:seven hundred sixty two thousand, eight hundred forty two * ( 44,059 - four hundred seventy three ) * ( six million, seven hundred fifty six thousand sixty eight - sixty three thousand, four hundred forty two ) * 8 + three hundred ninety seven thousand, four hundred three * nineteen million, thirty one thousand, eight hundred eighty eight + four hundred thirty five = 
============================================================================
["7", "100", "60", "2", "1000", "8", "100", "40", "2"]
["4", "100", "70", "3"]
["6", "1000000", "7", "100", "50", "6", "1000", "60", "8"]
["60", "3", "1000", "4", "100", "40", "2"]
["3", "100", "90", "7", "1000", "4", "100", "3"]
["19", "1000000", "30", "1", "1000", "8", "100", "80", "8"]
["4", "100", "30", "5"]
1780204928353130595
============================================================================
式:three hundred fifty nine million, nine hundred seventy one thousand, six hundred thirty one * 3,005,337 + 50,573 - 3 + seven hundred fifteen thousand, two hundred fifty six * ( 64 - 386,358,403 ) + seventy two thousand, three hundred twenty four - 940,406 + two thousand, four hundred eight = 
============================================================================
["3", "100", "50", "9", "1000000", "9", "100", "70", "1", "1000", "6", "100", "30", "1"]
["7", "100", "15", "1000", "2", "100", "50", "6"]
["70", "2", "1000", "3", "100", "20", "4"]
["2", "1000", "4", "100", "8"]
805490940659759
============================================================================
式:three thousand, three hundred twenty three * 516 + ( five - six ) * five hundred thirty seven + three hundred forty nine million, one hundred fifty nine thousand, nine hundred sixty six - 4 + five hundred * twenty six - ninety six million, forty nine thousand, six hundred ninety five + 1,064 = 
============================================================================
["3", "1000", "3", "100", "20", "3"]
["5", "100", "30", "7"]
["3", "100", "40", "9", "1000000", "1", "100", "50", "9", "1000", "9", "100", "60", "6"]
["5", "100"]
["20", "6"]
["90", "6", "1000000", "40", "9", "1000", "6", "100", "90", "5"]
254838462
============================================================================
式:VI - two = 
============================================================================
hit roman VI
gsubed_roman 6 - two 
4
============================================================================
式:four * III - 0 = 
============================================================================
hit roman III
gsubed_roman four * 3 - 0 
12
============================================================================
式:45 - 495 + 9 - seven hundred seventy four = 
============================================================================
["7", "100", "70", "4"]
-1215
============================================================================
式:XVI - 26 * ( 0 - 1 ) * CXCII = 
============================================================================
hit roman XVI
hit roman CXCII
gsubed_roman 16 - 26 * ( 0 - 1 ) * 192 
5008
============================================================================
式:4803 * thirty one thousand, five hundred eighty six + 6 * ( 78458 - 7 ) + 5 = 
============================================================================
["30", "1", "1000", "5", "100", "80", "6"]
152178269
============================================================================
式:152854 - six hundred sixty seven + 82 * ( 845,857 + 178545 ) * ninety thousand, four hundred four - 65 = 
============================================================================
["6", "100", "60", "7"]
["90", "1000", "4", "100", "4"]
7594023301578
============================================================================
式:( 9,454,809 + MVII ) * five thousand, seven hundred ninety one + nine thousand, five hundred forty five - XIV + eight - 634 + 2023 = 
============================================================================
hit roman MVII
hit roman XIV
gsubed_roman ( 9454809 + 1007 ) * five thousand seven hundred ninety one + nine thousand five hundred forty five - 14 + eight - 634 + 2023 
["5", "1000", "7", "100", "90", "1"]
["9", "1000", "5", "100", "40", "5"]
54758641384
============================================================================
式:two * 69853 - 9,791,127 + 3 * four million, eight hundred fifty seven thousand thirty eight - 829419 + 46,725 - I * 6,260 = 
============================================================================
hit roman I
gsubed_roman two * 69853 - 9791127 + 3 * four million eight hundred fifty seven thousand thirty eight - 829419 + 46725 - 1 * 6260 
["4", "1000000", "8", "100", "50", "7", "1000", "30", "8"]
4130739
============================================================================
式:forty seven - III * ( 29 - 748 ) * CCXIX + 91967 - I + 5499722 - XLIII * 42 = 
============================================================================
hit roman III
hit roman CCXIX
hit roman I
hit roman XLIII
gsubed_roman forty seven - 3 * ( 29 - 748 ) * 219 + 91967 - 1 + 5499722 - 43 * 42 
["40", "7"]
6062312
============================================================================
式:five - ( 812,285 + 450146196 ) * ( one thousand, seven hundred ninety two - 7 ) + 3705749289 * ( 181,723,358 - nine billion, seven hundred seventy five million, nine hundred seventy eight thousand, seven hundred thirty ) + 6168514720 * ( six million, one hundred two thousand, five hundred sixty seven - nine thousand, seven hundred fifty three ) = 
============================================================================
["1", "1000", "7", "100", "90", "2"]
["9", "1000000000", "7", "100", "70", "5", "1000000", "9", "100", "70", "8", "1000", "7", "100", "30"]
["6", "1000000", "1", "100", "2", "1000", "5", "100", "60", "7"]
["9", "1000", "7", "100", "50", "3"]
-35516322215389097008
============================================================================
式:five + 5 = 
============================================================================
10
============================================================================
式:4 - 6 + II = 
============================================================================
hit roman II
gsubed_roman 4 - 6 + 2 
0
============================================================================
式:2 - 0 * 3 - XXXVIII = 
============================================================================
hit roman XXXVIII
gsubed_roman 2 - 0 * 3 - 38 
-36
============================================================================
式:2 + five thousand, one hundred nine * ( DCCCLXXIX - DCI ) * DCCCXLVIII = 
============================================================================
hit roman DCCCLXXIX
hit roman DCI
hit roman DCCCXLVIII
gsubed_roman 2 + five thousand one hundred nine * ( 879 - 601 ) * 848 
["5", "1000", "1", "100", "9"]
1204416098
============================================================================
式:91 - 296 * ( MMDCXXXIX + II ) * 9048 - eighteen thousand, one hundred seventy two = 
============================================================================
hit roman MMDCXXXIX
hit roman II
gsubed_roman 91 - 296 * ( 2639 + 2 ) * 9048 - eighteen thousand one hundred seventy two 
["18", "1000", "1", "100", "70", "2"]
-7073165409
============================================================================
式:( three hundred forty - forty six thousand, two hundred thirty four ) * ( 42,600 + 22660 ) * 81 + 615308 - 7640 = 
============================================================================
["3", "100", "40"]
["40", "6", "1000", "2", "100", "30", "4"]
-242597829972
============================================================================
式:( thirteen thousand, one hundred fifty four + eight ) * ( 8 - 72 ) * MCCXLVI + LXXVIII * ( 1963 + one hundred seventy five thousand, four hundred ninety three ) = 
============================================================================
hit roman MCCXLVI
hit roman LXXVIII
gsubed_roman ( thirteen thousand one hundred fifty four + eight ) * ( 8 - 72 ) * 1246 + 78 * ( 1963 + one hundred seventy five thousand four hundred ninety three ) 
["13", "1000", "1", "100", "50", "4"]
["1", "100", "70", "5", "1000", "4", "100", "90", "3"]
-1035748960
============================================================================
式:DLXVIII * 4592 - 7,135 + 9 * ( ten thousand, five hundred three - 3 ) * 8 + 9245066 * 39341 = 
============================================================================
hit roman DLXVIII
gsubed_roman 568 * 4592 - 7135 + 9 * ( ten thousand five hundred three - 3 ) * 8 + 9245066 * 39341 
["10", "1000", "5", "100", "3"]
363713498627
============================================================================
式:595087796 * 6000112 - nine hundred sixty nine + ( forty five thousand eight - two hundred nine million, seven hundred sixty seven thousand, three hundred forty two ) * ( 5,030,734 - four thousand, five hundred eighty five ) + 511,852 * 177 - VI = 
============================================================================
hit roman VI
gsubed_roman 595087796 * 6000112 - nine hundred sixty nine + ( forty five thousand eight - two hundred nine million seven hundred sixty seven thousand three hundred forty two ) * ( 5030734 - four thousand five hundred eighty five ) + 511852 * 177 - 6 
["9", "100", "60", "9"]
["40", "5", "1000", "8"]
["2", "100", "9", "1000000", "7", "100", "60", "7", "1000", "3", "100", "40", "2"]
["4", "1000", "5", "100", "80", "5"]
2516497817118215
============================================================================
式:85756 + ( two hundred sixty nine million, eleven thousand, eight hundred thirty - 635 ) * 71134285 - 4240608161 * ( 4972 - 693,695,300 ) + 825 - 37704860 * 323 + II = 
============================================================================
hit roman II
gsubed_roman 85756 + ( two hundred sixty nine million eleven thousand eight hundred thirty - 635 ) * 71134285 - 4240608161 * ( 4972 - 693695300 ) + 825 - 37704860 * 323 + 2 
["2", "100", "60", "9", "1000000", "11", "1000", "8", "100", "30"]
2960804772958304186
============================================================================
式:three * four = 
============================================================================
12
============================================================================
式:79 * XXIV + 3 = 
============================================================================
hit roman XXIV
gsubed_roman 79 * 24 + 3 
1899
============================================================================
式:272 * XLIV - one hundred one * three hundred ninety nine = 
============================================================================
hit roman XLIV
gsubed_roman 272 * 44 - one hundred one * three hundred ninety nine 
["1", "100", "1"]
["3", "100", "90", "9"]
-28331
============================================================================
式:7,634 - ten + III * ( 40 + forty ) = 
============================================================================
hit roman III
gsubed_roman 7634 - ten + 3 * ( 40 + forty ) 
7864
============================================================================
式:three thousand twenty nine * thirteen + ninety nine * 315 - 5709 * 3 = 
============================================================================
["3", "1000", "20", "9"]
["90", "9"]
53435
============================================================================
式:4,935 + II - ( 58,908 + MMCCLXII ) * ( 7224 - 3 ) * 90958 = 
============================================================================
hit roman II
hit roman MMCCLXII
gsubed_roman 4935 + 2 - ( 58908 + 2262 ) * ( 7224 - 3 ) * 90958 
-40176928105123
============================================================================
式:97144 + 1435895 * 92251 - one thousand, nine hundred seventy nine + DCCCLXXX - 3 * ( 5871 + four ) = 
============================================================================
hit roman DCCCLXXX
gsubed_roman 97144 + 1435895 * 92251 - one thousand nine hundred seventy nine + 880 - 3 * ( 5871 + four ) 
["1", "1000", "9", "100", "70", "9"]
132462828065
============================================================================
式:two hundred thirty nine * 63 + 913,948 - 6923679 + 4691 - twelve * 659872 - four hundred nine * 56 = 
============================================================================
["2", "100", "30", "9"]
["4", "100", "9"]
-13931351
============================================================================
式:eight thousand, one hundred eighteen - 470,115,517 * ( 7630052 + 567 ) * seven hundred ninety - XLIV + 501804440 - 81652366 + zero - MMMCCXCI = 
============================================================================
hit roman XLIV
hit roman MMMCCXCI
gsubed_roman eight thousand one hundred eighteen - 470115517 * ( 7630052 + 567 ) * seven hundred ninety - 44 + 501804440 - 81652366 + zero - 3291 
["8", "1000", "1", "100", "18"]
["7", "100", "90"]
-2833945192589711313
============================================================================
式:13,391,520 * 2816811756 - 4181072 + ( six thousand, eight hundred nine - 33849519 ) * 290 - ( 47,941 + 6422 ) * ( 5 - 28,394,594 ) + 8 = 
============================================================================
["6", "1000", "8", "100", "9"]
37722924763183963
============================================================================
式:6 + 6 = 
============================================================================
12
============================================================================
式:I + zero * 1 = 
============================================================================
hit roman I
gsubed_roman 1 + zero * 1 
1
============================================================================
式:eight * 5 + 1 - 49 = 
============================================================================
-8
============================================================================
式:nine thousand, eight hundred five + 893 - VIII + VIII * 538 = 
============================================================================
hit roman VIII
hit roman VIII
gsubed_roman nine thousand eight hundred five + 893 - 8 + 8 * 538 
["9", "1000", "8", "100", "5"]
14994
============================================================================
式:91 + one hundred seventy one - ( DCLXXVI + I ) * six - CCCXXVI = 
============================================================================
hit roman DCLXXVI
hit roman I
hit roman CCCXXVI
gsubed_roman 91 + one hundred seventy one - ( 676 + 1 ) * six - 326 
["1", "100", "70", "1"]
-4126
============================================================================
式:eighty eight thousand, five hundred fifty one + five hundred seventy one thousand thirty one * 2,442 - 494,944 + 165 - 68486 + 556 = 
============================================================================
["80", "8", "1000", "5", "100", "50", "1"]
["5", "100", "70", "1", "1000", "30", "1"]
1393983544
============================================================================
式:( LXXXVIII - 7,053 ) * ( 1954 - 2 ) + 510237 - 811 + one thousand, five hundred forty five - 69 = 
============================================================================
hit roman LXXXVIII
gsubed_roman ( 88 - 7053 ) * ( 1954 - 2 ) + 510237 - 811 + one thousand five hundred forty five - 69 
["1", "1000", "5", "100", "40", "5"]
-13084778
============================================================================
式:7640 + III * ( seventeen - five thousand, nine hundred seventy five ) + 2765 * ( 0 - five hundred seventy four ) + 1 * 551,953 = 
============================================================================
hit roman III
gsubed_roman 7640 + 3 * ( seventeen - five thousand nine hundred seventy five ) + 2765 * ( 0 - five hundred seventy four ) + 1 * 551953 
["5", "1000", "9", "100", "70", "5"]
["5", "100", "70", "4"]
-1045391
============================================================================
式:155,347 * ( 713,879 + 5,586,992 ) * ( 453225348 - LXXXIX ) + ( 60575977 - 4174 ) * ( twelve million, two hundred ninety four thousand, five hundred twenty two - 50887 ) * ten = 
============================================================================
hit roman LXXXIX
gsubed_roman 155347 * ( 713879 + 5586992 ) * ( 453225348 - 89 ) + ( 60575977 - 4174 ) * ( twelve million two hundred ninety four thousand five hundred twenty two - 50887 ) * ten 
["12", "1000000", "2", "100", "90", "4", "1000", "5", "100", "20", "2"]
443634002000206038433
============================================================================
式:517317057 - thirty six * ( 26 + two billion, sixteen million, forty four thousand, seven hundred sixty one ) - 408010 * ( 5 - 43297787 ) + 75,845 * 483454973 + seventy three million, six hundred fifty eight thousand, eight hundred fourteen - twenty four thousand, nine hundred fifty eight = 
============================================================================
["30", "6"]
["2", "1000000000", "16", "1000000", "40", "4", "1000", "7", "100", "60", "1"]
["70", "3", "1000000", "6", "100", "50", "8", "1000", "8", "100", "14"]
["20", "4", "1000", "9", "100", "50", "8"]
54261583799586
============================================================================
式:2 - eight = 
============================================================================
-6
============================================================================
式:1 - 0 + 8 = 
============================================================================
9
============================================================================
式:4 + 93 * 79 + 12 = 
============================================================================
7363
============================================================================
式:XII * 8,256 - sixty one + 4 - CMIV = 
============================================================================
hit roman XII
hit roman CMIV
gsubed_roman 12 * 8256 - sixty one + 4 - 904 
["60", "1"]
98111
============================================================================
式:( CCXI - 1 ) * ( MMCCXCIV + 5 ) - 32 * 4 = 
============================================================================
hit roman CCXI
hit roman MMCCXCIV
gsubed_roman ( 211 - 1 ) * ( 2294 + 5 ) - 32 * 4 
482662
============================================================================
式:3 - five thousand, two hundred ninety four * ( LXXVI - 1,938 ) * 6 - forty one thousand, seven hundred seven * 325180 = 
============================================================================
hit roman LXXVI
gsubed_roman 3 - five thousand two hundred ninety four * ( 76 - 1938 ) * 6 - forty one thousand seven hundred seven * 325180 
["5", "1000", "2", "100", "90", "4"]
["40", "1", "1000", "7", "100", "7"]
-13503137689
============================================================================
式:5329 + 16 - 8,898,092 * 5014619 + 2 - 6406920 + 37 * five hundred fifty nine thousand, nine hundred thirty = 
============================================================================
["5", "100", "50", "9", "1000", "9", "100", "30"]
-44620526891111
============================================================================
式:six hundred eight - 81239 * ( two hundred sixty seven thousand, six hundred four - 685436 ) + 2,899,923 * ( 27,498,819 + zero ) * ninety six thousand, nine hundred fifty six + 527677 = 
============================================================================
["6", "100", "8"]
["2", "100", "60", "7", "1000", "6", "100", "4"]
["90", "6", "1000", "9", "100", "50", "6"]
7731703673827269905
============================================================================
式:( 7170 + 919 ) * ( XCV - 78,796,156 ) * 991,574,352 + five hundred seven million, six hundred ninety two thousand, two hundred thirty eight - 499007 + 7 * ( 326 + 31227114 ) = 
============================================================================
hit roman XCV
gsubed_roman ( 7170 + 919 ) * ( 95 - 78796156 ) * 991574352 + five hundred seven million six hundred ninety two thousand two hundred thirty eight - 499007 + 7 * ( 326 + 31227114 ) 
["5", "100", "7", "1000000", "6", "100", "90", "2", "1000", "2", "100", "30", "8"]
-632010986637328235697
============================================================================
式:6,453,952,557 - ( four thousand, six hundred forty five + 946,470,069 ) * 48409 + 67104642 - 57,751,996 + five thousand, three hundred sixty three * 7309069 + 4,937,628,341 - 19,083,895 + four = 
============================================================================
["4", "1000", "6", "100", "40", "5"]
["5", "1000", "3", "100", "60", "3"]
-45767314043326
"Congratulations!\nThe flag is TMCTF{U D1D 17!}\n"
""
""

Prog300

Prog300は迷路の問題。 単純にスタートからゴールまで行くだけではなく、チェックポイントを通ること、 一度通った道はエネルギーが消費されること。エネルギーが補充できるポイントもあって、 手持ちのエネルギーを最後まで使い切らずにゴールまでの軌跡を残すもの。

通常の解放では、自分のやる気が足りず挑戦を途中でやめてしまった。 そのため、代替案として、人手でEmacsを使って迷路を解いて軌跡を残す方法を取ろうとした。 結果としては、時間かかり断念した。

ソースコードを残しておく。

(global-set-key [right] 'my-forward-char)
(global-set-key [left] 'my-backward-char)
(global-set-key [up] 'my-previous-line)
(global-set-key [down] 'my-next-line)
(global-set-key [return] 'next-problem)
(global-set-key [backspace] 'reset-problem)

(defun my-forward-char ()
  (interactive)
  (forward-char)
  (setq current (current-buffer))
  (set-buffer answar-buffer-name)
  (insert "R")
  (set-buffer current))

(defun my-backward-char ()
  (interactive)
  (backward-char)
  (setq current (current-buffer))
  (set-buffer answar-buffer-name)
  (insert "L")
  (set-buffer current))

(defun my-next-line ()
  (interactive)
  (next-line)
  (setq current (current-buffer))
  (set-buffer answar-buffer-name)
  (insert "D")
  (set-buffer current))

(defun my-previous-line ()
  (interactive)
  (previous-line)
  (setq current (current-buffer))
  (set-buffer answar-buffer-name)
  (insert "U")
  (set-buffer current))

(defun next-problem ()
  (interactive)
  (re-search-forward "\n\n")
  (re-search-forward "S")
  (backward-char)
  (setq current (current-buffer))
  (set-buffer answar-buffer-name)
  (goto-char (point-max))
  (insert "\n")
  (set-buffer current)
  (recenter))

(defun reset-problem ()
  (interactive)
  (re-search-backward "\n\n")
  (re-search-forward "S")
  (backward-char)
  (setq current (current-buffer))
  (set-buffer answar-buffer-name)
  (move-beginning-of-line 1)
  (kill-line)
  (set-buffer current))

まとめ

全体の進め方について、個人に任せて進めていたので 次回は、参加メンバーのスキルを事前に確認して、定期的に話をして優先順位や 戦略を考えてリソースの配分を考えたい。

個人に関しては、もうすこし正攻法で解く努力をする。