aboutsummaryrefslogtreecommitdiff
path: root/challenge-195
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-195')
-rw-r--r--challenge-195/robert-dicicco/julia/ch-1.jl79
-rw-r--r--challenge-195/robert-dicicco/python/ch-1.py63
-rw-r--r--challenge-195/robert-dicicco/ruby/ch-1.rb63
3 files changed, 205 insertions, 0 deletions
diff --git a/challenge-195/robert-dicicco/julia/ch-1.jl b/challenge-195/robert-dicicco/julia/ch-1.jl
new file mode 100644
index 0000000000..b6a7563a28
--- /dev/null
+++ b/challenge-195/robert-dicicco/julia/ch-1.jl
@@ -0,0 +1,79 @@
+#!/usr/bin/env julia
+
+#=
+
+AUTHOR: Robert DiCicco
+
+DATE : 2022-12-13
+
+Challenge 195 Special Integers ( Julia )
+
+
+SAMPLE OUTPUT
+
+julia .\SpecialIntegers.jl
+
+Input: $n = 15
+
+Output: 14
+
+
+Input: $n = 35
+
+Output: 32
+
+----------------------------------------------------
+
+=#
+
+using Printf
+
+
+narray = [15, 35]
+
+
+function CheckUniqueDigits(n)
+
+ seen = Dict()
+
+ digs = digits(n)
+
+ for onedig in digs
+
+ if(haskey(seen,onedig))
+
+ return 0
+
+ else
+
+ seen[onedig] = 1
+
+ end
+
+ end
+
+ return 1
+
+end
+
+
+for n in narray
+
+ println("Input: \$n = ", n)
+
+ output = 0
+
+ for nval = 1:n
+
+ output += CheckUniqueDigits(nval)
+
+ end
+
+ @printf("Output: %d\n\n",output)
+
+end
diff --git a/challenge-195/robert-dicicco/python/ch-1.py b/challenge-195/robert-dicicco/python/ch-1.py
new file mode 100644
index 0000000000..1a1678775e
--- /dev/null
+++ b/challenge-195/robert-dicicco/python/ch-1.py
@@ -0,0 +1,63 @@
+#!/usr/bin/env python
+
+'''
+
+AUTHOR: Robert DiCicco
+
+DATE : 2022-12-13
+
+Challenge 195 Special Integers ( Python )
+
+
+SAMPLE OUTPUT
+
+python .\SpecialIntegers.py
+
+Input: $n = 15
+
+Output: 14
+
+
+Input: $n = 35
+
+Output: 32
+
+-------------------------------------------------
+
+'''
+
+
+def CheckUniqueDigits(n) :
+
+ seen = {}
+
+ my_list = [int(x) for x in str(n)]
+
+ for onedig in my_list:
+
+ if onedig in seen:
+
+ return 0
+
+ else :
+
+ seen[onedig] = 1
+
+ return 1
+
+
+for n in [15, 35] :
+
+ output = 0
+
+ print("Input: $n = ", n)
+
+ for x in range(0,n):
+
+ output += CheckUniqueDigits(x)
+
+ print(f"Output: {output}\n")
diff --git a/challenge-195/robert-dicicco/ruby/ch-1.rb b/challenge-195/robert-dicicco/ruby/ch-1.rb
new file mode 100644
index 0000000000..ce0585e91e
--- /dev/null
+++ b/challenge-195/robert-dicicco/ruby/ch-1.rb
@@ -0,0 +1,63 @@
+#!/usr/bin/env ruby
+
+=begin
+
+AUTHOR: Robert DiCicco
+
+DATE : 2022-12-13
+
+Challenge 195 Special Integers ( Ruby )
+
+
+SAMPLE OUTPUT
+
+ ruby .\SpecialIntegers.rb
+
+Input: $n = 15
+
+Output: 14
+
+
+Input: $n = 35
+
+Output: 32
+
+------------------------------------------------
+
+=end
+
+def CheckUniqDigits(n)
+
+ h1 = Hash.new
+
+ arr = n.digits
+
+ for onedig in arr
+
+ h1.key?(onedig) ? (return 0) : (h1[onedig] = 1)
+
+ end
+
+ return 1
+
+end
+
+
+[15,35].each do |n|
+
+ output = 0
+
+ puts("Input: \$n = #{n}")
+
+ for x in (1..n) do
+
+ output += CheckUniqDigits(x)
+
+ end
+
+ print("Output: #{output}\n\n")
+
+end