aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2024-09-11 03:28:16 +0900
committernsfisis <nsfisis@gmail.com>2024-09-11 03:28:16 +0900
commit84bac718cf36291b7bc8004b8e3c0f60fc9ec39d (patch)
treed34051df813d404ef8cf662fd8447de9cec80b27
parent861ef1d0f86b762b6a88f4579d04f1dd9b8f1bab (diff)
downloadmncore-challenge-84bac718cf36291b7bc8004b8e3c0f60fc9ec39d.tar.gz
mncore-challenge-84bac718cf36291b7bc8004b8e3c0f60fc9ec39d.tar.zst
mncore-challenge-84bac718cf36291b7bc8004b8e3c0f60fc9ec39d.zip
13-Mod-3 (incomplete)
-rw-r--r--Makefile2
-rw-r--r--NOTE.md2
-rw-r--r--problems/13-Mod-3/08.vsm34
-rw-r--r--problems/13-Mod-3/a.rb56
4 files changed, 93 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index e16a0ea..aa26e78 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-all: inversion
+all: mod3
matrix_square_testcase_1:
./judge problems/14-Matrix-Square/testcase_1_double_4x4.vsm problems/14-Matrix-Square/answer_1_double_4x4.vsm
diff --git a/NOTE.md b/NOTE.md
index b7057fb..6bc55e1 100644
--- a/NOTE.md
+++ b/NOTE.md
@@ -34,3 +34,5 @@ M = 自分の点
* flat アドレス指定を使う
* PE に broadcast されている場合
* `j` 指定を使う
+* `$t` を間接参照以外にも使う
+* 2倍は `packbit`
diff --git a/problems/13-Mod-3/08.vsm b/problems/13-Mod-3/08.vsm
index 04838b2..6d9783d 100644
--- a/problems/13-Mod-3/08.vsm
+++ b/problems/13-Mod-3/08.vsm
@@ -1,3 +1,37 @@
+# (32 / 8).times do |i|
+# j = i * 8
+# # itof (1)
+# puts "ior $lm#{j}v $lr0 $nowrite"
+# end
+# puts
+# (32 / 8).times do |i|
+# j = i * 8
+# # itof (2)
+# puts "fvadd $aluf -$lr0 $ls#{j}v"
+# end
+# puts
+# (32 / 8).times do |i|
+# j = i * 8
+# # /3
+# puts "fvmul $ls#{j}v $lr4 $nowrite"
+# end
+# puts
+# (32 / 8).times do |i|
+# j = i * 8
+# # ftoi
+# puts "fftoi $mauf $ls#{j+32}v"
+# end
+# puts
+# (32 / 8).times do |i|
+# j = i * 8
+# # x3
+# puts "ipackbit $ls#{j+32}v $lr8 $nowrite"
+# puts "iadd $ls#{j+32}v $aluf $nowrite"
+# # %3
+# puts "isub $lm#{j}v $aluf $ln#{j}v"
+# puts
+# end
+
imm f"8388608" $r0v
imm f"0.3333333333333333333333" $r4v
diff --git a/problems/13-Mod-3/a.rb b/problems/13-Mod-3/a.rb
new file mode 100644
index 0000000..b0e909b
--- /dev/null
+++ b/problems/13-Mod-3/a.rb
@@ -0,0 +1,56 @@
+def f1(n)
+ n = ((n >> 0) & 0b11) +
+ ((n >> 2) & 0b11) +
+ ((n >> 4) & 0b11) +
+ ((n >> 6) & 0b11) +
+ 0
+ n = ((n >> 0) & 0b11) +
+ ((n >> 2) & 0b11) +
+ ((n >> 4) & 0b11) +
+ ((n >> 6) & 0b11) +
+ 0
+ n = ((n >> 0) & 0b11) +
+ ((n >> 2) & 0b11) +
+ ((n >> 4) & 0b11) +
+ ((n >> 6) & 0b11) +
+ 0
+ n == 3 ? 0 : n
+end
+
+def f2(n)
+ n = ((n >> 0) & 0b11) +
+ ((n >> 2) & 0b11) +
+ ((n >> 4) & 0b11) +
+ ((n >> 6) & 0b11) +
+ 0
+ n = ((n >> 0) & 0b11) +
+ ((n >> 2) & 0b11) +
+ 0
+ n = ((n >> 0) & 0b11) +
+ ((n >> 2) & 0b11) +
+ 0
+ n == 3 ? 0 : n
+end
+
+def f3(n)
+ n = ((n >> 0) & 0b1111) +
+ ((n >> 4) & 0b1111) +
+ 0
+ n = ((n >> 0) & 0b11) +
+ ((n >> 2) & 0b11) +
+ ((n >> 4) & 0b11) +
+ 0
+ n = ((n >> 0) & 0b11) +
+ ((n >> 2) & 0b11) +
+ 0
+ n == 3 ? 0 : n
+end
+
+256.times do |n|
+ expected = n % 3
+ actual = f3(n)
+
+ if actual != expected
+ puts "#{actual} != #{expected} (#{n}; #{"%08b" % n})"
+ end
+end