r/dailyprogrammer • u/rya11111 3 1 • Feb 19 '12
[2/19/2012] Challenge #11 [intermediate]
An “upside up” number is a number that reads the same when it is rotated 180°. For instance, 689 and 1961 are upside up numbers.
Your task is to find the next upside up number greater than 1961, and to count the number of upside up numbers less than ten thousand.
edit: since there is a confusion about 2 and 5, please consider them as "upside up" numbers for this problem. If you have already done without it, its ok. Sorry for the late reply.
source: programmingpraxis.com
9
Upvotes
2
u/_redka 0 0 Feb 19 '12
done in Ruby
pair of 2 and 5 also taken into consideration
http://pastie.org/3416272
result:
2
u/UnreasonableSteve Feb 19 '12 edited Feb 19 '12
Am I wrong or is 2 rotated 180 actually 2 and not 5?
2
u/[deleted] Feb 20 '12 edited Feb 20 '12
Perl, I counted 2's and 5's. It's pretty messy but I didn't have time to spruce it up.
Output:
1
u/fdasdfsdfad Feb 19 '12
Mathematically, or can I use fonts that exhibit the necessary symmetry?
1
u/blisse Feb 19 '12 edited Feb 19 '12
Same idea as _redka and more brute force-y If I put the pairs into an array, it would've been a lot shorter. Also, I'm a noob at programming :D, but I try to make it clear what I do.
Python 2.7 EDIT: better formatting and dictionary try and added 2:5
1
u/drb226 0 0 Feb 19 '12
Haskell:
results:
1
u/prophile Feb 19 '12
So done, making extensive use of Python's itertools:
https://gist.github.com/dbd0385a653c95721096
1
u/[deleted] Feb 20 '12
Do 2 and 5 count as rightside up numbers?
-edit- and do the leading zeros in front of a number count as part of the number? (example: 0001000)
1
u/Crystal_Cuckoo Feb 20 '12 edited Feb 20 '12
Python, generates a list of all upside-up numbers less than 10000: