qaz@lemmy.world to Programmer Humor@programming.devEnglish · 3 days agoWho cares about time complexitylemmy.worldimagemessage-square57fedilinkarrow-up1385arrow-down11
arrow-up1384arrow-down1imageWho cares about time complexitylemmy.worldqaz@lemmy.world to Programmer Humor@programming.devEnglish · 3 days agomessage-square57fedilink
minus-squarerooroo@feddit.orglinkfedilinkarrow-up2·19 hours agoNo, cause you do the replacement from large to small, I.e. you’d first check for 10 I to replace with X (none found); then replace 9 with IX (check), then check for 5, 4 and so on.
minus-squarelugal@lemmy.dbzer0.comlinkfedilinkarrow-up2·18 hours agoThe original doesn’t have an extra check for 9 and it works for Roman->Indioarabic because it’s: IX ->IVV ->IIIIV ->IIIIIIIII But the other way around, you need an extra step for 9. That’s where our misunderstanding comes from.
minus-squarerooroo@feddit.orglinkfedilinkarrow-up1·19 hours agoI noticed my “and so on” is literally a noop here so yeah.
No, cause you do the replacement from large to small, I.e. you’d first check for 10 I to replace with X (none found); then replace 9 with IX (check), then check for 5, 4 and so on.
The original doesn’t have an extra check for 9 and it works for Roman->Indioarabic because it’s:
IX ->IVV ->IIIIV ->IIIIIIIII
But the other way around, you need an extra step for 9. That’s where our misunderstanding comes from.
Ohhh haha that makes sense. Fun!
I noticed my “and so on” is literally a noop here so yeah.