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