Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › 2-digit mirror problem
New Posts  All Forums:Forum Nav:

2-digit mirror problem

Can you guys help me with this program.
Quote:
2-Digit Mirror
Given:
What is the smallest number, which, when multiplied by 2, and 2 added to the project, has its digits
reversed?
That is:
if A is a digit between 0 and 9, and if B is a digit between 0 and 9,
2*(AB)+2=BA
Find:
Use a for loop that goes from a range of 10 to 50.
Print out the value of the loop, and the value of the loop times 2 plus 2 on the same line.
Print out the value of the difference BA-AB on this same line.
Add an if statement to identify the correct pairing based on the value of the difference.
Write your own unique text message to identify the correct pairing of numbers.

I know the answer is 10:
Quote:
Given:
A =1
B=0
AB=10

2*10+2=22

A=2
B=2

AB = 22
BA = 22

I Just need help putting it in Python. Here's what I have so far:
Code:
``````range (10,50)
for (a=1)```
```

It specifically wants a loop, well I haven't read the chapters that deal with loops yet so if you won't want to help me until then, I understand.

Edit
: The answer was actually 25 52... I misunderstood what was meant by mirror.
Edited by BizzareRide - 2/8/12 at 2:38am
 Po' Pimpin' (11 items)
CPUMotherboardRAMHard Drive
i5 2500k @ stock Biostar TZ68K+ [A3] 4GB  Sandforce 1222 64GB SSD
Optical DriveCoolingOSMonitor
LG 22x DVD-+RW  Stock Windows 7 x64 Acer S211HL 1080p
PowerCaseMouse
 Po' Pimpin' (11 items)
CPUMotherboardRAMHard Drive
i5 2500k @ stock Biostar TZ68K+ [A3] 4GB  Sandforce 1222 64GB SSD
Optical DriveCoolingOSMonitor
LG 22x DVD-+RW  Stock Windows 7 x64 Acer S211HL 1080p
PowerCaseMouse
http://lmgtfy.com/?q=For+Loop+Python

Allow me to clarify. Want to be a programmer? Learn how to teach yourself. It's the best thing you could do if you're serious about it. Asking for help is one thing, asking for code when you haven't bothered is another.
Edited by Satsukeshi - 2/6/12 at 3:24pm
 College Rig (13 items)
CPUMotherboardGraphicsRAM
Intel i7-930 @ 4.2Ghz, Stable ASUS P6X58D-E EVGA GTX 460 SSC 1024MB & EVGA GTX 460 SC 1024MB OCZ Gold 6GB (3 x 2GB) 240-Pin DDR3 1600
Hard DriveOptical DriveOSMonitor
Intel X25-M Mainstream 80GB SATA II SSD ASUS USB 2.0 External Slim DVD±R/RW Windows 7 Ultimate 64-Bit 3x SAMSUNG P2570HD Black 24.6" 4ms HDMI Widescreen
KeyboardPowerCaseMouse
Eclipse Lite-Touch (Wired) CORSAIR 850HX Corsair 800D Razer Naga
 College Rig (13 items)
CPUMotherboardGraphicsRAM
Intel i7-930 @ 4.2Ghz, Stable ASUS P6X58D-E EVGA GTX 460 SSC 1024MB & EVGA GTX 460 SC 1024MB OCZ Gold 6GB (3 x 2GB) 240-Pin DDR3 1600
Hard DriveOptical DriveOSMonitor
Intel X25-M Mainstream 80GB SATA II SSD ASUS USB 2.0 External Slim DVD±R/RW Windows 7 Ultimate 64-Bit 3x SAMSUNG P2570HD Black 24.6" 4ms HDMI Widescreen
KeyboardPowerCaseMouse
Eclipse Lite-Touch (Wired) CORSAIR 850HX Corsair 800D Razer Naga
Quote:
Originally Posted by Satsukeshi

http://lmgtfy.com/?q=For+Loop+Python
Allow me to clarify. Want to be a programmer? Learn how to teach yourself. It's the best thing you could do if you're serious about it. Asking for help is one thing, asking for code when you haven't bothered is another.

Who says I haven't bothered? The mere fact that I haven't read the chapters, but am hacking away at the code that I do know should show initiative.

The chapter on assignment variables I did without reading the chapters and I did pretty well on it, grade-wise.

To answer your question: No, I don't want to be a programmer. That's such a belittling and condescending title to give oneself. I would actually like to design and develop.

FYI that is a cool site you linked.
 Po' Pimpin' (11 items)
CPUMotherboardRAMHard Drive
i5 2500k @ stock Biostar TZ68K+ [A3] 4GB  Sandforce 1222 64GB SSD
Optical DriveCoolingOSMonitor
LG 22x DVD-+RW  Stock Windows 7 x64 Acer S211HL 1080p
PowerCaseMouse
 Po' Pimpin' (11 items)
CPUMotherboardRAMHard Drive
i5 2500k @ stock Biostar TZ68K+ [A3] 4GB  Sandforce 1222 64GB SSD
Optical DriveCoolingOSMonitor
LG 22x DVD-+RW  Stock Windows 7 x64 Acer S211HL 1080p
PowerCaseMouse
Belittling and condescending eh? That's quite a... Interesting viewpoint, to say the least. Good luck with your inept hacking away at code.
 College Rig (13 items)
CPUMotherboardGraphicsRAM
Intel i7-930 @ 4.2Ghz, Stable ASUS P6X58D-E EVGA GTX 460 SSC 1024MB & EVGA GTX 460 SC 1024MB OCZ Gold 6GB (3 x 2GB) 240-Pin DDR3 1600
Hard DriveOptical DriveOSMonitor
Intel X25-M Mainstream 80GB SATA II SSD ASUS USB 2.0 External Slim DVD±R/RW Windows 7 Ultimate 64-Bit 3x SAMSUNG P2570HD Black 24.6" 4ms HDMI Widescreen
KeyboardPowerCaseMouse
Eclipse Lite-Touch (Wired) CORSAIR 850HX Corsair 800D Razer Naga
 College Rig (13 items)
CPUMotherboardGraphicsRAM
Intel i7-930 @ 4.2Ghz, Stable ASUS P6X58D-E EVGA GTX 460 SSC 1024MB & EVGA GTX 460 SC 1024MB OCZ Gold 6GB (3 x 2GB) 240-Pin DDR3 1600
Hard DriveOptical DriveOSMonitor
Intel X25-M Mainstream 80GB SATA II SSD ASUS USB 2.0 External Slim DVD±R/RW Windows 7 Ultimate 64-Bit 3x SAMSUNG P2570HD Black 24.6" 4ms HDMI Widescreen
KeyboardPowerCaseMouse
Eclipse Lite-Touch (Wired) CORSAIR 850HX Corsair 800D Razer Naga
Quote:
Originally Posted by Satsukeshi

Belittling and condescending eh? That's quite a... Interesting viewpoint, to say the least. Good luck with your inept hacking away at code.

I solved it with my 'ineptitude.'
Code:
``````import math

aNumber = 25
for aNumber in range(10,51):  #aNumber prints 10 through 50 in first column
for bNumber in range(10,51): #bNumber prints 10 through 50 on second collumn
bNumber = aNumber*2+2  #An expression that * 2 and + 2 to aNumber
print "This is a pair:", aNumber, bNumber #Prints aNumber + bNumber on same row
if aNumber == 25: #Identifies correct pairing
if bNumber == 52:
print "This is the correct mirrored pair", aNumber,\
bNumber```
```

Thanks for nothing.
Edited by BizzareRide - 2/8/12 at 3:21am
 Po' Pimpin' (11 items)
CPUMotherboardRAMHard Drive
i5 2500k @ stock Biostar TZ68K+ [A3] 4GB  Sandforce 1222 64GB SSD
Optical DriveCoolingOSMonitor
LG 22x DVD-+RW  Stock Windows 7 x64 Acer S211HL 1080p
PowerCaseMouse
 Po' Pimpin' (11 items)
CPUMotherboardRAMHard Drive
i5 2500k @ stock Biostar TZ68K+ [A3] 4GB  Sandforce 1222 64GB SSD
Optical DriveCoolingOSMonitor
LG 22x DVD-+RW  Stock Windows 7 x64 Acer S211HL 1080p
PowerCaseMouse
That wasn't so hard now, was it.
 College Rig (13 items)
CPUMotherboardGraphicsRAM
Intel i7-930 @ 4.2Ghz, Stable ASUS P6X58D-E EVGA GTX 460 SSC 1024MB & EVGA GTX 460 SC 1024MB OCZ Gold 6GB (3 x 2GB) 240-Pin DDR3 1600
Hard DriveOptical DriveOSMonitor
Intel X25-M Mainstream 80GB SATA II SSD ASUS USB 2.0 External Slim DVD±R/RW Windows 7 Ultimate 64-Bit 3x SAMSUNG P2570HD Black 24.6" 4ms HDMI Widescreen
KeyboardPowerCaseMouse
Eclipse Lite-Touch (Wired) CORSAIR 850HX Corsair 800D Razer Naga
 College Rig (13 items)
CPUMotherboardGraphicsRAM
Intel i7-930 @ 4.2Ghz, Stable ASUS P6X58D-E EVGA GTX 460 SSC 1024MB & EVGA GTX 460 SC 1024MB OCZ Gold 6GB (3 x 2GB) 240-Pin DDR3 1600
Hard DriveOptical DriveOSMonitor
Intel X25-M Mainstream 80GB SATA II SSD ASUS USB 2.0 External Slim DVD±R/RW Windows 7 Ultimate 64-Bit 3x SAMSUNG P2570HD Black 24.6" 4ms HDMI Widescreen
KeyboardPowerCaseMouse
Eclipse Lite-Touch (Wired) CORSAIR 850HX Corsair 800D Razer Naga
Quote:
Originally Posted by Satsukeshi

That wasn't so hard now, was it.

You still could've help me!

I slapped myself on the head when the code worked and it was so obvious.

It took hours, but it was rewarding to do
 Po' Pimpin' (11 items)
CPUMotherboardRAMHard Drive
i5 2500k @ stock Biostar TZ68K+ [A3] 4GB  Sandforce 1222 64GB SSD
Optical DriveCoolingOSMonitor
LG 22x DVD-+RW  Stock Windows 7 x64 Acer S211HL 1080p
PowerCaseMouse
 Po' Pimpin' (11 items)
CPUMotherboardRAMHard Drive
i5 2500k @ stock Biostar TZ68K+ [A3] 4GB  Sandforce 1222 64GB SSD
Optical DriveCoolingOSMonitor
LG 22x DVD-+RW  Stock Windows 7 x64 Acer S211HL 1080p
PowerCaseMouse
That's the best part about coding, makes all the frustration worthwhile.

fwtw I don't start Python till next week.
 College Rig (13 items)
CPUMotherboardGraphicsRAM
Intel i7-930 @ 4.2Ghz, Stable ASUS P6X58D-E EVGA GTX 460 SSC 1024MB & EVGA GTX 460 SC 1024MB OCZ Gold 6GB (3 x 2GB) 240-Pin DDR3 1600
Hard DriveOptical DriveOSMonitor
Intel X25-M Mainstream 80GB SATA II SSD ASUS USB 2.0 External Slim DVD±R/RW Windows 7 Ultimate 64-Bit 3x SAMSUNG P2570HD Black 24.6" 4ms HDMI Widescreen
KeyboardPowerCaseMouse
Eclipse Lite-Touch (Wired) CORSAIR 850HX Corsair 800D Razer Naga
 College Rig (13 items)
CPUMotherboardGraphicsRAM
Intel i7-930 @ 4.2Ghz, Stable ASUS P6X58D-E EVGA GTX 460 SSC 1024MB & EVGA GTX 460 SC 1024MB OCZ Gold 6GB (3 x 2GB) 240-Pin DDR3 1600
Hard DriveOptical DriveOSMonitor
Intel X25-M Mainstream 80GB SATA II SSD ASUS USB 2.0 External Slim DVD±R/RW Windows 7 Ultimate 64-Bit 3x SAMSUNG P2570HD Black 24.6" 4ms HDMI Widescreen
KeyboardPowerCaseMouse
Eclipse Lite-Touch (Wired) CORSAIR 850HX Corsair 800D Razer Naga
Quote:
Originally Posted by Satsukeshi

That's the best part about coding, makes all the frustration worthwhile.
fwtw I don't start Python till next week.

So you're a n00b programmer like me or do you have experience in another language?
 Po' Pimpin' (11 items)
CPUMotherboardRAMHard Drive
i5 2500k @ stock Biostar TZ68K+ [A3] 4GB  Sandforce 1222 64GB SSD
Optical DriveCoolingOSMonitor
LG 22x DVD-+RW  Stock Windows 7 x64 Acer S211HL 1080p
PowerCaseMouse
 Po' Pimpin' (11 items)
CPUMotherboardRAMHard Drive
i5 2500k @ stock Biostar TZ68K+ [A3] 4GB  Sandforce 1222 64GB SSD
Optical DriveCoolingOSMonitor
LG 22x DVD-+RW  Stock Windows 7 x64 Acer S211HL 1080p
PowerCaseMouse
Been doing Java and C/C++ for about 5 years now. Decided to go to uni for it, where I've learned web dev (HTML, PHP, Javascript, etc), and random languages like ML, Prologue, ASM, etc over the past year or so. For the most part, self taught. Focusing on game development for Android at the moment.

Didn't mean to go on a tirade, however. Beer and stupid compilation errors make for a nasty mix. My apologies.
 College Rig (13 items)
CPUMotherboardGraphicsRAM
Intel i7-930 @ 4.2Ghz, Stable ASUS P6X58D-E EVGA GTX 460 SSC 1024MB & EVGA GTX 460 SC 1024MB OCZ Gold 6GB (3 x 2GB) 240-Pin DDR3 1600
Hard DriveOptical DriveOSMonitor
Intel X25-M Mainstream 80GB SATA II SSD ASUS USB 2.0 External Slim DVD±R/RW Windows 7 Ultimate 64-Bit 3x SAMSUNG P2570HD Black 24.6" 4ms HDMI Widescreen
KeyboardPowerCaseMouse
Eclipse Lite-Touch (Wired) CORSAIR 850HX Corsair 800D Razer Naga
 College Rig (13 items)
CPUMotherboardGraphicsRAM
Intel i7-930 @ 4.2Ghz, Stable ASUS P6X58D-E EVGA GTX 460 SSC 1024MB & EVGA GTX 460 SC 1024MB OCZ Gold 6GB (3 x 2GB) 240-Pin DDR3 1600
Hard DriveOptical DriveOSMonitor
Intel X25-M Mainstream 80GB SATA II SSD ASUS USB 2.0 External Slim DVD±R/RW Windows 7 Ultimate 64-Bit 3x SAMSUNG P2570HD Black 24.6" 4ms HDMI Widescreen
KeyboardPowerCaseMouse
Eclipse Lite-Touch (Wired) CORSAIR 850HX Corsair 800D Razer Naga
New Posts  All Forums:Forum Nav:
Return Home
Back to Forum: Coding and Programming