What numbers are these?
Clash Royale CLAN TAG#URR8PPP
up vote
4
down vote
favorite
While I was writing numbers I noticed after a while that my keyboard had the Shift key pressed and blocked and all I wrote was $%&
-like characters. And even worse, I had been switching between the English and Spanish keyboard layouts so I don't know which one I used for each number.
Challenge
Given a string containing symbol characters, try to guess which number I wrote. My keyboard produces the following characters for the numbers when the Shift is pressed:
1234567890
----------
!"÷$%&/()= Spanish layout
!@#$%^&*() English layout
- The input will be a non-null, non-empty string composed of the symbols above.
- The output will be a single number if the keyboard layout can be inferred from the string (i.e. if the string contains a
@
an English layout was used, and if the string contains a"
a Spanish layout was used) or if the number is the same for both layouts (i.e. the input is!$
which translates as14
for both layouts); otherwise the output will be the two possible numbers for both layouts if it cannot be inferred and the resulting numbers are different. - The input string will always be written in a single layout. So you don't need to expect
"@
as input.
Examples
Input --> Output
------------------
/() 789 (Spanish layout detected by the use of /)
$%& 456,457 (Layout cannot be inferred)
!@# 123 (English layout detected by the use of @ and #)
()&! 8961,9071 (Layout cannot be inferred)
((÷)) 88399 (Spanish layout detected by the use of ÷)
!$ 14 (Layout cannot be inferred but the result is the same for both)
!!$$%% 114455 (Layout cannot be inferred but the result is the same for both)
==$" 0042/42 (Spanish layout, if a number starts with 0 you can choose to
omit them in the result or not)
Single character translations:
------------------------------
! 1
" 2
÷ 3
$ 4
% 5
& 6,7
/ 7
( 8,9
) 9,0
= 0
@ 2
# 3
^ 6
* 8
This is code-golf, so may the shortest code for each language win!
code-golf keyboard
add a comment |Â
up vote
4
down vote
favorite
While I was writing numbers I noticed after a while that my keyboard had the Shift key pressed and blocked and all I wrote was $%&
-like characters. And even worse, I had been switching between the English and Spanish keyboard layouts so I don't know which one I used for each number.
Challenge
Given a string containing symbol characters, try to guess which number I wrote. My keyboard produces the following characters for the numbers when the Shift is pressed:
1234567890
----------
!"÷$%&/()= Spanish layout
!@#$%^&*() English layout
- The input will be a non-null, non-empty string composed of the symbols above.
- The output will be a single number if the keyboard layout can be inferred from the string (i.e. if the string contains a
@
an English layout was used, and if the string contains a"
a Spanish layout was used) or if the number is the same for both layouts (i.e. the input is!$
which translates as14
for both layouts); otherwise the output will be the two possible numbers for both layouts if it cannot be inferred and the resulting numbers are different. - The input string will always be written in a single layout. So you don't need to expect
"@
as input.
Examples
Input --> Output
------------------
/() 789 (Spanish layout detected by the use of /)
$%& 456,457 (Layout cannot be inferred)
!@# 123 (English layout detected by the use of @ and #)
()&! 8961,9071 (Layout cannot be inferred)
((÷)) 88399 (Spanish layout detected by the use of ÷)
!$ 14 (Layout cannot be inferred but the result is the same for both)
!!$$%% 114455 (Layout cannot be inferred but the result is the same for both)
==$" 0042/42 (Spanish layout, if a number starts with 0 you can choose to
omit them in the result or not)
Single character translations:
------------------------------
! 1
" 2
÷ 3
$ 4
% 5
& 6,7
/ 7
( 8,9
) 9,0
= 0
@ 2
# 3
^ 6
* 8
This is code-golf, so may the shortest code for each language win!
code-golf keyboard
Dang it, that·
is challenging...
â Erik the Outgolfer
1 hour ago
@EriktheOutgolfer in fact the·
is useless for Spanish, it is only used in the Catalan language.
â Charlie
1 hour ago
Is output like(8, 9, 6, 1), (9, 0, 7, 1)
(for the 4th test case) acceptable?
â Lynn
46 mins ago
@Lynn yes, it is.
â Charlie
44 mins ago
add a comment |Â
up vote
4
down vote
favorite
up vote
4
down vote
favorite
While I was writing numbers I noticed after a while that my keyboard had the Shift key pressed and blocked and all I wrote was $%&
-like characters. And even worse, I had been switching between the English and Spanish keyboard layouts so I don't know which one I used for each number.
Challenge
Given a string containing symbol characters, try to guess which number I wrote. My keyboard produces the following characters for the numbers when the Shift is pressed:
1234567890
----------
!"÷$%&/()= Spanish layout
!@#$%^&*() English layout
- The input will be a non-null, non-empty string composed of the symbols above.
- The output will be a single number if the keyboard layout can be inferred from the string (i.e. if the string contains a
@
an English layout was used, and if the string contains a"
a Spanish layout was used) or if the number is the same for both layouts (i.e. the input is!$
which translates as14
for both layouts); otherwise the output will be the two possible numbers for both layouts if it cannot be inferred and the resulting numbers are different. - The input string will always be written in a single layout. So you don't need to expect
"@
as input.
Examples
Input --> Output
------------------
/() 789 (Spanish layout detected by the use of /)
$%& 456,457 (Layout cannot be inferred)
!@# 123 (English layout detected by the use of @ and #)
()&! 8961,9071 (Layout cannot be inferred)
((÷)) 88399 (Spanish layout detected by the use of ÷)
!$ 14 (Layout cannot be inferred but the result is the same for both)
!!$$%% 114455 (Layout cannot be inferred but the result is the same for both)
==$" 0042/42 (Spanish layout, if a number starts with 0 you can choose to
omit them in the result or not)
Single character translations:
------------------------------
! 1
" 2
÷ 3
$ 4
% 5
& 6,7
/ 7
( 8,9
) 9,0
= 0
@ 2
# 3
^ 6
* 8
This is code-golf, so may the shortest code for each language win!
code-golf keyboard
While I was writing numbers I noticed after a while that my keyboard had the Shift key pressed and blocked and all I wrote was $%&
-like characters. And even worse, I had been switching between the English and Spanish keyboard layouts so I don't know which one I used for each number.
Challenge
Given a string containing symbol characters, try to guess which number I wrote. My keyboard produces the following characters for the numbers when the Shift is pressed:
1234567890
----------
!"÷$%&/()= Spanish layout
!@#$%^&*() English layout
- The input will be a non-null, non-empty string composed of the symbols above.
- The output will be a single number if the keyboard layout can be inferred from the string (i.e. if the string contains a
@
an English layout was used, and if the string contains a"
a Spanish layout was used) or if the number is the same for both layouts (i.e. the input is!$
which translates as14
for both layouts); otherwise the output will be the two possible numbers for both layouts if it cannot be inferred and the resulting numbers are different. - The input string will always be written in a single layout. So you don't need to expect
"@
as input.
Examples
Input --> Output
------------------
/() 789 (Spanish layout detected by the use of /)
$%& 456,457 (Layout cannot be inferred)
!@# 123 (English layout detected by the use of @ and #)
()&! 8961,9071 (Layout cannot be inferred)
((÷)) 88399 (Spanish layout detected by the use of ÷)
!$ 14 (Layout cannot be inferred but the result is the same for both)
!!$$%% 114455 (Layout cannot be inferred but the result is the same for both)
==$" 0042/42 (Spanish layout, if a number starts with 0 you can choose to
omit them in the result or not)
Single character translations:
------------------------------
! 1
" 2
÷ 3
$ 4
% 5
& 6,7
/ 7
( 8,9
) 9,0
= 0
@ 2
# 3
^ 6
* 8
This is code-golf, so may the shortest code for each language win!
code-golf keyboard
code-golf keyboard
asked 1 hour ago
Charlie
6,9352081
6,9352081
Dang it, that·
is challenging...
â Erik the Outgolfer
1 hour ago
@EriktheOutgolfer in fact the·
is useless for Spanish, it is only used in the Catalan language.
â Charlie
1 hour ago
Is output like(8, 9, 6, 1), (9, 0, 7, 1)
(for the 4th test case) acceptable?
â Lynn
46 mins ago
@Lynn yes, it is.
â Charlie
44 mins ago
add a comment |Â
Dang it, that·
is challenging...
â Erik the Outgolfer
1 hour ago
@EriktheOutgolfer in fact the·
is useless for Spanish, it is only used in the Catalan language.
â Charlie
1 hour ago
Is output like(8, 9, 6, 1), (9, 0, 7, 1)
(for the 4th test case) acceptable?
â Lynn
46 mins ago
@Lynn yes, it is.
â Charlie
44 mins ago
Dang it, that
·
is challenging...â Erik the Outgolfer
1 hour ago
Dang it, that
·
is challenging...â Erik the Outgolfer
1 hour ago
@EriktheOutgolfer in fact the
·
is useless for Spanish, it is only used in the Catalan language.â Charlie
1 hour ago
@EriktheOutgolfer in fact the
·
is useless for Spanish, it is only used in the Catalan language.â Charlie
1 hour ago
Is output like
(8, 9, 6, 1), (9, 0, 7, 1)
(for the 4th test case) acceptable?â Lynn
46 mins ago
Is output like
(8, 9, 6, 1), (9, 0, 7, 1)
(for the 4th test case) acceptable?â Lynn
46 mins ago
@Lynn yes, it is.
â Charlie
44 mins ago
@Lynn yes, it is.
â Charlie
44 mins ago
add a comment |Â
3 Answers
3
active
oldest
votes
up vote
1
down vote
Python 3, 76 bytes
lambda s:(*map(k.find,s),)for k in['=!"÷$%&/()',')!@#$%^&*(']if*s<=*k
Try it online!
add a comment |Â
up vote
1
down vote
Java (JDK), 173 bytes
Golfed
c->s.contains("#")?e:e.contains("#")?s:s+","+e;
Try it online!
Ungolfed
c->s.contains("#")?e: // If equal or Spanish is invalid return english
e.contains("#")?s: // If English is invalid return Spanish
s+","+e; // If both are valid but not equal, return both
The Magic Hashing Lookup Array
After some experimenting with values I realised that each of the ASCII values of the characters !"÷$%&/()=@#^*
modulo 16 returns a unique number. The 'magic hashing lookup array' stores the English numbers associated with each character at this unique index, and each of the Spanish numbers at this index offset by 16, making fetching the required number from the array trivial for each language. A hash is stored for values that are invalid for either language.
add a comment |Â
up vote
1
down vote
Jelly, 38 bytes
183á»ÂâÂÂ=!"âÂÂ$%&/()âÂÂj,âÂÂ)!@#$%^&*(âÂÂiⱮ≸ẠÃÂâÂÂQ
Try it online!
Note that if the number is the same for both layouts you must return a single number, and not a list, as if you had identified the layout.
â Charlie
25 mins ago
@Charlie Whoops, fixed. :P
â Erik the Outgolfer
23 mins ago
Nice! Just one question, I have tried your code with()
or(())
as input, but your code then return nothing. I suppose that's a limitation with what Jelly receives as input?
â Charlie
20 mins ago
1
@Charlie Try with'()'
and'(())'
respectively. Yes, if you don't quote the argument, it's only inputted as a string if it can't beeval
uated to a Python 3 value.
â Erik the Outgolfer
20 mins ago
add a comment |Â
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
Python 3, 76 bytes
lambda s:(*map(k.find,s),)for k in['=!"÷$%&/()',')!@#$%^&*(']if*s<=*k
Try it online!
add a comment |Â
up vote
1
down vote
Python 3, 76 bytes
lambda s:(*map(k.find,s),)for k in['=!"÷$%&/()',')!@#$%^&*(']if*s<=*k
Try it online!
add a comment |Â
up vote
1
down vote
up vote
1
down vote
Python 3, 76 bytes
lambda s:(*map(k.find,s),)for k in['=!"÷$%&/()',')!@#$%^&*(']if*s<=*k
Try it online!
Python 3, 76 bytes
lambda s:(*map(k.find,s),)for k in['=!"÷$%&/()',')!@#$%^&*(']if*s<=*k
Try it online!
answered 41 mins ago
Lynn
48.3k694223
48.3k694223
add a comment |Â
add a comment |Â
up vote
1
down vote
Java (JDK), 173 bytes
Golfed
c->s.contains("#")?e:e.contains("#")?s:s+","+e;
Try it online!
Ungolfed
c->s.contains("#")?e: // If equal or Spanish is invalid return english
e.contains("#")?s: // If English is invalid return Spanish
s+","+e; // If both are valid but not equal, return both
The Magic Hashing Lookup Array
After some experimenting with values I realised that each of the ASCII values of the characters !"÷$%&/()=@#^*
modulo 16 returns a unique number. The 'magic hashing lookup array' stores the English numbers associated with each character at this unique index, and each of the Spanish numbers at this index offset by 16, making fetching the required number from the array trivial for each language. A hash is stored for values that are invalid for either language.
add a comment |Â
up vote
1
down vote
Java (JDK), 173 bytes
Golfed
c->s.contains("#")?e:e.contains("#")?s:s+","+e;
Try it online!
Ungolfed
c->s.contains("#")?e: // If equal or Spanish is invalid return english
e.contains("#")?s: // If English is invalid return Spanish
s+","+e; // If both are valid but not equal, return both
The Magic Hashing Lookup Array
After some experimenting with values I realised that each of the ASCII values of the characters !"÷$%&/()=@#^*
modulo 16 returns a unique number. The 'magic hashing lookup array' stores the English numbers associated with each character at this unique index, and each of the Spanish numbers at this index offset by 16, making fetching the required number from the array trivial for each language. A hash is stored for values that are invalid for either language.
add a comment |Â
up vote
1
down vote
up vote
1
down vote
Java (JDK), 173 bytes
Golfed
c->s.contains("#")?e:e.contains("#")?s:s+","+e;
Try it online!
Ungolfed
c->s.contains("#")?e: // If equal or Spanish is invalid return english
e.contains("#")?s: // If English is invalid return Spanish
s+","+e; // If both are valid but not equal, return both
The Magic Hashing Lookup Array
After some experimenting with values I realised that each of the ASCII values of the characters !"÷$%&/()=@#^*
modulo 16 returns a unique number. The 'magic hashing lookup array' stores the English numbers associated with each character at this unique index, and each of the Spanish numbers at this index offset by 16, making fetching the required number from the array trivial for each language. A hash is stored for values that are invalid for either language.
Java (JDK), 173 bytes
Golfed
c->s.contains("#")?e:e.contains("#")?s:s+","+e;
Try it online!
Ungolfed
c->s.contains("#")?e: // If equal or Spanish is invalid return english
e.contains("#")?s: // If English is invalid return Spanish
s+","+e; // If both are valid but not equal, return both
The Magic Hashing Lookup Array
After some experimenting with values I realised that each of the ASCII values of the characters !"÷$%&/()=@#^*
modulo 16 returns a unique number. The 'magic hashing lookup array' stores the English numbers associated with each character at this unique index, and each of the Spanish numbers at this index offset by 16, making fetching the required number from the array trivial for each language. A hash is stored for values that are invalid for either language.
answered 36 mins ago
Luke Stevens
639214
639214
add a comment |Â
add a comment |Â
up vote
1
down vote
Jelly, 38 bytes
183á»ÂâÂÂ=!"âÂÂ$%&/()âÂÂj,âÂÂ)!@#$%^&*(âÂÂiⱮ≸ẠÃÂâÂÂQ
Try it online!
Note that if the number is the same for both layouts you must return a single number, and not a list, as if you had identified the layout.
â Charlie
25 mins ago
@Charlie Whoops, fixed. :P
â Erik the Outgolfer
23 mins ago
Nice! Just one question, I have tried your code with()
or(())
as input, but your code then return nothing. I suppose that's a limitation with what Jelly receives as input?
â Charlie
20 mins ago
1
@Charlie Try with'()'
and'(())'
respectively. Yes, if you don't quote the argument, it's only inputted as a string if it can't beeval
uated to a Python 3 value.
â Erik the Outgolfer
20 mins ago
add a comment |Â
up vote
1
down vote
Jelly, 38 bytes
183á»ÂâÂÂ=!"âÂÂ$%&/()âÂÂj,âÂÂ)!@#$%^&*(âÂÂiⱮ≸ẠÃÂâÂÂQ
Try it online!
Note that if the number is the same for both layouts you must return a single number, and not a list, as if you had identified the layout.
â Charlie
25 mins ago
@Charlie Whoops, fixed. :P
â Erik the Outgolfer
23 mins ago
Nice! Just one question, I have tried your code with()
or(())
as input, but your code then return nothing. I suppose that's a limitation with what Jelly receives as input?
â Charlie
20 mins ago
1
@Charlie Try with'()'
and'(())'
respectively. Yes, if you don't quote the argument, it's only inputted as a string if it can't beeval
uated to a Python 3 value.
â Erik the Outgolfer
20 mins ago
add a comment |Â
up vote
1
down vote
up vote
1
down vote
Jelly, 38 bytes
183á»ÂâÂÂ=!"âÂÂ$%&/()âÂÂj,âÂÂ)!@#$%^&*(âÂÂiⱮ≸ẠÃÂâÂÂQ
Try it online!
Jelly, 38 bytes
183á»ÂâÂÂ=!"âÂÂ$%&/()âÂÂj,âÂÂ)!@#$%^&*(âÂÂiⱮ≸ẠÃÂâÂÂQ
Try it online!
edited 23 mins ago
answered 45 mins ago
Erik the Outgolfer
29.8k42899
29.8k42899
Note that if the number is the same for both layouts you must return a single number, and not a list, as if you had identified the layout.
â Charlie
25 mins ago
@Charlie Whoops, fixed. :P
â Erik the Outgolfer
23 mins ago
Nice! Just one question, I have tried your code with()
or(())
as input, but your code then return nothing. I suppose that's a limitation with what Jelly receives as input?
â Charlie
20 mins ago
1
@Charlie Try with'()'
and'(())'
respectively. Yes, if you don't quote the argument, it's only inputted as a string if it can't beeval
uated to a Python 3 value.
â Erik the Outgolfer
20 mins ago
add a comment |Â
Note that if the number is the same for both layouts you must return a single number, and not a list, as if you had identified the layout.
â Charlie
25 mins ago
@Charlie Whoops, fixed. :P
â Erik the Outgolfer
23 mins ago
Nice! Just one question, I have tried your code with()
or(())
as input, but your code then return nothing. I suppose that's a limitation with what Jelly receives as input?
â Charlie
20 mins ago
1
@Charlie Try with'()'
and'(())'
respectively. Yes, if you don't quote the argument, it's only inputted as a string if it can't beeval
uated to a Python 3 value.
â Erik the Outgolfer
20 mins ago
Note that if the number is the same for both layouts you must return a single number, and not a list, as if you had identified the layout.
â Charlie
25 mins ago
Note that if the number is the same for both layouts you must return a single number, and not a list, as if you had identified the layout.
â Charlie
25 mins ago
@Charlie Whoops, fixed. :P
â Erik the Outgolfer
23 mins ago
@Charlie Whoops, fixed. :P
â Erik the Outgolfer
23 mins ago
Nice! Just one question, I have tried your code with
()
or (())
as input, but your code then return nothing. I suppose that's a limitation with what Jelly receives as input?â Charlie
20 mins ago
Nice! Just one question, I have tried your code with
()
or (())
as input, but your code then return nothing. I suppose that's a limitation with what Jelly receives as input?â Charlie
20 mins ago
1
1
@Charlie Try with
'()'
and '(())'
respectively. Yes, if you don't quote the argument, it's only inputted as a string if it can't be eval
uated to a Python 3 value.â Erik the Outgolfer
20 mins ago
@Charlie Try with
'()'
and '(())'
respectively. Yes, if you don't quote the argument, it's only inputted as a string if it can't be eval
uated to a Python 3 value.â Erik the Outgolfer
20 mins ago
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f173942%2fwhat-numbers-are-these%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Dang it, that
·
is challenging...â Erik the Outgolfer
1 hour ago
@EriktheOutgolfer in fact the
·
is useless for Spanish, it is only used in the Catalan language.â Charlie
1 hour ago
Is output like
(8, 9, 6, 1), (9, 0, 7, 1)
(for the 4th test case) acceptable?â Lynn
46 mins ago
@Lynn yes, it is.
â Charlie
44 mins ago