Skip to content

Use simpler method for computing letter from number #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: travis-no-submodule
Choose a base branch
from

Conversation

livecodeali
Copy link
Owner

@livecodeali livecodeali commented May 10, 2019

Use a simpler method for computing the uppercase letter corresponding to a given number between 1 and 26

@livecodeali livecodeali force-pushed the travis-no-submodule branch from 9e8e55c to b009d0f Compare May 10, 2019 08:40
@livecodeali livecodeali force-pushed the travis-no-submodule-fail branch from 707b510 to 440b47a Compare May 10, 2019 08:45
@@ -12,7 +12,7 @@ end toNumber

function fromNumber pNum
local tNum
put ((pNum - 1) mod 26) + 65 into tNum
put (pNum mod 27) + 64 into tNum
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not wrap around correctly. For example shifting U by 6 will cause fromNumber(27) to be called, which gives 64, (@ in ascii).

@livecodeali
Copy link
Owner Author

From the test log:

not ok - abjurer <-> nowhere (13)
# abjurer <-> nowhere (13) failed
# Expected result: nowhere
# Actual result: NOWGDRD

not ok - fusion <-> layout (6)
# fusion <-> layout (6) failed
# Expected result: layout
# Actual result: L@YOUT

not ok - manful <-> thumbs (7)
# manful <-> thumbs (7) failed
# Expected result: thumbs
# Actual result: THUMAS

Notice the letters that are shifted past Z and wrap around are all out by one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant