From 14f5f67c1b3ade42498d8a0988c671fe23a3f46e Mon Sep 17 00:00:00 2001 From: Raphael McSinyx Date: Thu, 10 Aug 2017 20:34:06 +0700 Subject: [PATCH] Add /r/dailyprogrammer Challenge #306 Easy --- daily/306easy/README.md | 24 ++++++++++++++++++++++++ daily/306easy/panroman.pas | 26 ++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 daily/306easy/README.md create mode 100644 daily/306easy/panroman.pas diff --git a/daily/306easy/README.md b/daily/306easy/README.md new file mode 100644 index 0000000..77300de --- /dev/null +++ b/daily/306easy/README.md @@ -0,0 +1,24 @@ +# [[2017-03-13] Challenge #306 [Easy] Pandigital Roman Numbers](https://www.reddit.com/r/dailyprogrammer/comments/5z4f3z/20170313_challenge_306_easy_pandigital_roman/) + +## Description + +1474 is a pandigital in Roman numerals (MCDLXXIV). It uses each of the symbols +I, V, X, L, C, and M at least once. Your challenge today is to find the small +handful of pandigital Roman numbers up to 2000. + +## Output Description + +A list of numbers. Example: + + 1 (I), 2 (II), 3 (III), 8 (VIII) (Examples only, these are not pandigital Roman numbers) + +## Challenge Input + +Find all numbers that are pandigital in Roman numerals using each of the +symbols I, V, X, L, C, D and M *exactly* once. + +## Challenge Input Solution + +1444, 1446, 1464, 1466, 1644, 1646, 1664, 1666 + +See [OEIS sequence A105416](http://oeis.org/A105416) for more information. 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.