qaz@lemmy.world to Programmer Humor@programming.devEnglish · 2 days agoWho cares about time complexitylemmy.worldimagemessage-square68fedilinkarrow-up1431arrow-down12
arrow-up1429arrow-down1imageWho cares about time complexitylemmy.worldqaz@lemmy.world to Programmer Humor@programming.devEnglish · 2 days agomessage-square68fedilink
minus-squarerooroo@feddit.orglinkfedilinkarrow-up2·7 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·7 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·7 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.