[Challenge] Integer to Roman Numerals

  • (2 Pages)
  • +
  • 1
  • 2

29 Replies - 7693 Views - Last Post: 15 April 2015 - 10:58 PM Rate Topic: -----

#16 atraub  Icon User is offline

  • Pythoneer
  • member icon

Reputation: 828
  • View blog
  • Posts: 2,235
  • Joined: 23-December 08

Re: [Challenge] Integer to Roman Numerals

Posted 08 April 2015 - 06:12 PM

I missed the maximum line length by a tad, mine's 375 characters excluding indentation and the return statement.
Was This Post Helpful? 0
  • +
  • -

#17 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 13553
  • View blog
  • Posts: 54,090
  • Joined: 12-June 08

Re: [Challenge] Integer to Roman Numerals

Posted 08 April 2015 - 07:03 PM

Woohoo! Look at me! I can do the pythons, and has one recursions.

Spoiler


Posted Image
Was This Post Helpful? 0
  • +
  • -

#18 atraub  Icon User is offline

  • Pythoneer
  • member icon

Reputation: 828
  • View blog
  • Posts: 2,235
  • Joined: 23-December 08

Re: [Challenge] Integer to Roman Numerals

Posted 08 April 2015 - 07:06 PM

Your number is spread out onto many lines, but I think it counts :) Lovin the recursion... and hat.

UPDATE: I Just upped the ante and added a second, more difficult test that you probably have never done before!! Who's ready to take the challenge? Check out the first post to see the new Advanced challenge :)

This post has been edited by atraub: 08 April 2015 - 07:15 PM

Was This Post Helpful? 0
  • +
  • -

#19 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 13553
  • View blog
  • Posts: 54,090
  • Joined: 12-June 08

Re: [Challenge] Integer to Roman Numerals

Posted 08 April 2015 - 07:07 PM

Ha.. well.. yeah.. writing a tutorial at the minute.

As for more challenging - calculate the roman numerals for math!
Was This Post Helpful? 0
  • +
  • -

#20 Dogstopper  Icon User is offline

  • The Ninjaducky
  • member icon

Reputation: 2965
  • View blog
  • Posts: 11,222
  • Joined: 15-July 08

Re: [Challenge] Integer to Roman Numerals

Posted 08 April 2015 - 07:45 PM

View Postatraub, on 08 April 2015 - 07:46 PM, said:

View PostDogstopper, on 08 April 2015 - 07:32 PM, said:

I did it in 2 lines:

Spoiler

I seriously opened up my interpreter to see if that would work


There is seriously a package for it
pip install roman
Was This Post Helpful? 1
  • +
  • -

#21 atraub  Icon User is offline

  • Pythoneer
  • member icon

Reputation: 828
  • View blog
  • Posts: 2,235
  • Joined: 23-December 08

Re: [Challenge] Integer to Roman Numerals

Posted 08 April 2015 - 08:26 PM

Definitely deserve some credit for the obscure library haha
Was This Post Helpful? 0
  • +
  • -

#22 cfoley  Icon User is offline

  • Cabbage
  • member icon

Reputation: 2386
  • View blog
  • Posts: 5,009
  • Joined: 11-December 07

Re: [Challenge] Integer to Roman Numerals

Posted 09 April 2015 - 05:48 AM

Whee:

Spoiler


I can collapse this into one line for 280 chars:

Spoiler

This post has been edited by cfoley: 09 April 2015 - 05:48 AM

Was This Post Helpful? 3
  • +
  • -

#23 atraub  Icon User is offline

  • Pythoneer
  • member icon

Reputation: 828
  • View blog
  • Posts: 2,235
  • Joined: 23-December 08

Re: [Challenge] Integer to Roman Numerals

Posted 09 April 2015 - 06:05 AM

That's a really, really clever idea. My one liner feels bad now haha. When I'm at my pc I'll post it.

Here's my epic one liner :P

Spoiler


EDIT: Added a minor optimization

This post has been edited by atraub: 09 April 2015 - 07:45 PM

Was This Post Helpful? 0
  • +
  • -

#24 baavgai  Icon User is offline

  • Dreaming Coder
  • member icon


Reputation: 6995
  • View blog
  • Posts: 14,630
  • Joined: 16-October 07

Re: [Challenge] Integer to Roman Numerals

Posted 09 April 2015 - 09:14 AM

My one liner:
Spoiler


Still the shortest and the most arcane, I think. I also liked cfoley's idea and thought I'd fuse it with mine to see what happened:
Spoiler


Now, for less silly code. And, a helpful function:
Spoiler

This post has been edited by baavgai: 09 April 2015 - 09:17 AM
Reason for edit:: damn smilie code munger strikes again

Was This Post Helpful? 1
  • +
  • -

#25 atraub  Icon User is offline

  • Pythoneer
  • member icon

Reputation: 828
  • View blog
  • Posts: 2,235
  • Joined: 23-December 08

Re: [Challenge] Integer to Roman Numerals

Posted 09 April 2015 - 10:54 AM

my more realistic function

Spoiler

This post has been edited by atraub: 11 April 2015 - 06:52 PM

Was This Post Helpful? 0
  • +
  • -

#26 atraub  Icon User is offline

  • Pythoneer
  • member icon

Reputation: 828
  • View blog
  • Posts: 2,235
  • Joined: 23-December 08

Re: [Challenge] Integer to Roman Numerals

Posted 14 April 2015 - 10:06 AM

I'd say that this thread has reached its conclusion. While there were some great submissions, especially mine, I think the clear winner is cfoley with his unique string replacement strategy! His style of solving the problem was very original and took a counter-intuitive yet elegantly simple approach. It won't win any speed tests, but it definitely wins this Challenge and our hearts!

Congratulations cfoley!

This post has been edited by atraub: 14 April 2015 - 10:07 AM

Was This Post Helpful? 1
  • +
  • -

#27 cfoley  Icon User is offline

  • Cabbage
  • member icon

Reputation: 2386
  • View blog
  • Posts: 5,009
  • Joined: 11-December 07

Re: [Challenge] Integer to Roman Numerals

Posted 14 April 2015 - 10:28 AM

Haha. Thank you very much. I've never been declared winner of a challenge before. :)
Was This Post Helpful? 0
  • +
  • -

#28 atraub  Icon User is offline

  • Pythoneer
  • member icon

Reputation: 828
  • View blog
  • Posts: 2,235
  • Joined: 23-December 08

Re: [Challenge] Integer to Roman Numerals

Posted 15 April 2015 - 04:44 PM

Now we just need a mod/admin to give you your chellenge winner badge :)
Was This Post Helpful? 1
  • +
  • -

#29 jon.kiparsky  Icon User is online

  • Chinga la migra
  • member icon


Reputation: 10720
  • View blog
  • Posts: 18,353
  • Joined: 19-March 11

Re: [Challenge] Integer to Roman Numerals

Posted 15 April 2015 - 06:59 PM

Done.
Was This Post Helpful? 2
  • +
  • -

#30 cfoley  Icon User is offline

  • Cabbage
  • member icon

Reputation: 2386
  • View blog
  • Posts: 5,009
  • Joined: 11-December 07

Re: [Challenge] Integer to Roman Numerals

Posted 15 April 2015 - 10:58 PM

Woo! Thanks!
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2