about summary refs log tree commit diff
path: root/daily/306easy/panroman.pas
diff options
context:
space:
mode:
authorRaphael McSinyx <vn.mcsinyx@gmail.com>2017-08-10 20:34:06 +0700
committerRaphael McSinyx <vn.mcsinyx@gmail.com>2017-08-10 20:34:40 +0700
commit14f5f67c1b3ade42498d8a0988c671fe23a3f46e (patch)
tree149d5ab473692f550ffc2a0752419e367473bd6f /daily/306easy/panroman.pas
parent4051a87fc1b1772644c647c5c7e7a158f2728108 (diff)
downloadcp-14f5f67c1b3ade42498d8a0988c671fe23a3f46e.tar.gz
Add /r/dailyprogrammer Challenge #306 Easy
Diffstat (limited to 'daily/306easy/panroman.pas')
-rw-r--r--daily/306easy/panroman.pas26
1 files changed, 26 insertions, 0 deletions
diff --git a/daily/306easy/panroman.pas b/daily/306easy/panroman.pas
new file mode 100644
index 0000000..5721f62
--- /dev/null
+++ b/daily/306easy/panroman.pas
@@ -0,0 +1,26 @@
+uses strutils;
+
+var
+  i: int16;
+
+function ivxlcdm(s: string): boolean;
+  var
+    a: array['C'..'X'] of int8;
+    c: char;
+
+  begin
+    for c in 'IVXLCDM' do
+      a[c] := 0;
+    for c in s do
+      inc(a[c]);
+    for c in 'IVXLCDM' do
+      if a[c] <> 1 then
+        exit(false);
+    ivxlcdm := true
+  end;
+
+begin
+  for i := 1000 to 2000 do
+    if ivxlcdm(inttoroman(i)) then
+      writeln(i)
+end.