Forums: » Register « |  Free Tools |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support |
 User Name: Password: Remember me

New Free Tools on Dev Shed!
We're Excited to announce that Dev Shed now has 70 free tools on the site. To learn more, click here!

 Dev Shed Forums Sponsor:
#1
April 19th, 2012, 03:04 PM
 Jyncka
We're trapped inside a game!

Join Date: Jul 2008
Location: Maryland
Posts: 303
Time spent in forums: 5 Days 10 h 33 m 58 sec
Reputation Power: 970
Critical thinking

I'm posting here because it's a pretty basic/general question. I found this story and after laughing at the logic behind it, thought it'd be fun to try the puzzle myself. I've figured out some of the meatier logic and what I have so far actually works pretty well, here's an overview:

1. Ask for the number to convert
4. Try to look up the digit in a dictionary of values (using python to write this), if the value is there, just return that, if not continue to step 4
4. Break the digit down, so 23 would be 20 and 3, or XXIII.

And here is where I'm getting stuck. When I look at a number like 23, I realize that that's really 10 + 10 + 3 and then I can write out XXIII. But to write that programmatically I need a way to tell the program to break it down similarly. I thought about just working in 10's. For example:

Divide the number by 10, output the number of X's that would result from that. 44 / 10 would be 4.4 and that would be XXXX and then I'd have to deal with the remaining .4.

This seems like a messy way to go and as I can go up to M or 1000, I would probably want to start by dividing by 1000?

I guess critical thinking is not my strength here, and that's partly why I wanted to try and solve the problem. If anyone has some advice that'd be great. I might end up figuring this out through experimentation, but thought I'd ask.
__________________
"Those who can make you believe absurdities can make you commit atrocities."

#2
April 20th, 2012, 11:54 AM
 ManiacDan
Sarcky

Join Date: Oct 2006
Location: Pennsylvania, USA
Posts: 10,496
Time spent in forums: 2 Months 3 Weeks 5 Days 6 h 55 m 56 sec
Reputation Power: 6300
Do it the same way you do "display the amount of time elapsed in days, hours, minutes, and seconds as necessary." Keep doing subtraction, starting from the largest value.

So for 23:

23 >10? yes

print X, subtract 10.

13 > 10? yes

print X, subtract 10.

3 > 10? no

3 > 5? no

print III

Now, you have to figure out what to do for IV and VX and whatever. You can post-process a string, turning IIII into IV, or you can have a special case for "one unit of this less than the amount of one unit up from this"
__________________
HEY! YOU! Read the New User Guide and Forum Rules

"They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

"The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.

#3
April 20th, 2012, 01:46 PM
 ManiacDan
Sarcky

Join Date: Oct 2006
Location: Pennsylvania, USA
Posts: 10,496
Time spent in forums: 2 Months 3 Weeks 5 Days 6 h 55 m 56 sec
Reputation Power: 6300
I tried to do this, and then got distracted by work. You have to also note that the rules are contradictory. IX is 9, meaning 10-1. However, 99 is NOT IC, like you'd think, it's XCIX. But then 45 is VL. So good luck. Roman->arabic is much easier than arabic->roman.

#4
April 20th, 2012, 04:06 PM
 Jyncka
We're trapped inside a game!

Join Date: Jul 2008
Location: Maryland
Posts: 303
Time spent in forums: 5 Days 10 h 33 m 58 sec
Reputation Power: 970
Haha, work can be distracting. Thank you for the tip, I'll go with the subtraction and post-processing, something I tend to forget about when I work. I think as long as I can make my way through this part, I can do the rest, I just needed a different perspective.

Yeah, Roman->Arabic is way easier, I was doing both conversions at the beginning than got stuck here.

#5
April 20th, 2012, 04:38 PM
 ManiacDan
Sarcky

Join Date: Oct 2006
Location: Pennsylvania, USA
Posts: 10,496
Time spent in forums: 2 Months 3 Weeks 5 Days 6 h 55 m 56 sec
Reputation Power: 6300
The inconsistent rules is why I gave up. Once I realized "99" is not represented the same as "9" and "49" I just said screw it and deleted what I had (which wasn't right anyway)

#6
April 20th, 2012, 05:02 PM
 Jyncka
We're trapped inside a game!

Join Date: Jul 2008
Location: Maryland
Posts: 303
Time spent in forums: 5 Days 10 h 33 m 58 sec
Reputation Power: 970
Yeah, seeing as in the story it was a way to see how new hires think and work and in my case just for fun, I'm not going to lose sleep over it if I can't get it. At the very least I got more familiar with python syntax in the process.

 Viewing: Dev Shed Forums > Other > Beginner Programming > Critical thinking

## Developer Shed Advertisers and Affiliates

 Thread Tools Search this Thread Search this Thread: Advanced Search Display Modes Rate This Thread Linear Mode Rate This Thread: 5 : Excellent 4 : Good 3 : Average 2 : Bad 1 : Terrible

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts vB code is On Smilies are On [IMG] code is On HTML code is Off
 View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox Forum Jump Please select one User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home -------------------- Programming Languages    PHP Development        PHP FAQs and Stickies    Perl Programming        Perl FAQs and Stickies    C Programming        C Programming FAQs and Stickies    Java Help        Java FAQs    Python Programming        Python Programming FAQs    Ruby Programming        Ruby Programming FAQs    Game Development        Game Development FAQs Programming Languages - More    ASP Programming        ASP Programming FAQs    .Net Development        .Net Development FAQs    Visual Basic Programming        Visual Basic Programming FAQs    Software Design        Software Design FAQs    ColdFusion Development        ColdFusion Development FAQs    Delphi Programming        Delphi Programming FAQs    Regex Programming        Regex Programming FAQs    XML Programming        XML Programming FAQs    Other Programming Languages        Other Programming Languages FAQs Web Design    HTML Programming        HTML Programming FAQs    JavaScript Development        JavaScript Development FAQs    CSS Help        CSS Help FAQs    Flash Help        Flash Help FAQs    Photoshop Help        Photoshop Help FAQs    Web Design Help        Web Design Help FAQs    Website Critiques        Website Critiques FAQs    Search Engine Optimization        Search Engine Optimization FAQs Mobile Programming    Mobile Programming        Mobile Programming FAQs    iPhone SDK Development        iPhone SDK Development FAQs    Android Development        Android Development FAQs    BlackBerry Development        BlackBerry Development FAQs Web Site Management    Business Help        Business Help FAQs    Development Software        Development Software FAQs    Scripts        Scripts FAQs Databases    Database Management        Database Management FAQs    DB2 Development        DB2 Development FAQs    MySQL Help        MySQL Help FAQs    PostgreSQL Help        PostgreSQL Help FAQs    Firebird SQL Development        Firebird SQL Development FAQs    MS SQL Development        MS SQL Development FAQs    Oracle Development        Oracle Development FAQs    LDAP Programming        LDAP Programming FAQs System Administration    Mail Server Help        Mail Server Help FAQs    Apache Development        Apache Development FAQs    Security and Cryptography        Security and Cryptography FAQs    Antivirus Protection        Antivirus Protection FAQs    DNS        DNS FAQs    IIS        IIS FAQs    Networking Help        Networking Help FAQs    FTP Help        FTP Help FAQs Operating Systems    BSD Help        BSD Help FAQs    Linux Help        Linux Help FAQs    UNIX Help        UNIX Help FAQs    Windows Help        Windows Help FAQs    Mac Help        Mac Help FAQs Web Hosting    Web Hosting        Web Hosting FAQs    Free Web Hosting        Free Web Hosting FAQs    Web Hosting Requests        Web Hosting Requests FAQs    Web Hosting Offers        Web Hosting Offers FAQs Computer Hardware    Computer Hardware    CPUs        CPUs FAQs    Cooling        Cooling FAQs    Embedded Programming        Embedded Programming FAQs    Motherboards        Motherboards FAQs    Multimedia Hardware        Multimedia Hardware FAQs Other    Dev Shed Lounge        Dev Shed Lounge FAQs    Development Articles        Development Articles FAQs    Beginner Programming        Beginner Programming FAQs    Hire A Programmer        Hire A Programmer FAQs    Project Help Wanted        Project Help Wanted FAQs Latest News Updated Hourly    Technology News    Business News    Science News Forum Information    Forum Rules/Guidelines        Forum Rules/Guidelines FAQs    Forum Announcements        Forum Announcements FAQs    Dev Shed Gaming Center        Go to the Dev Shed Battle Arena        Go to the Dev Shed Arcade Games        Go to the Legend of the Green Dragon    Suggestions & Feedback        Suggestions & Feedback FAQs

 Forums: » Register « |  Free Tools |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support |