-2
1
Hehe, see what I did with the title? Anyways...
Your job is to create a sudoku solver that accepts input in Morse code and creates output in Morse code. Here's the Morse code numbers for reference:
0: -----
1: .----
2: ..---
3: ...--
4: ....-
5: .....
6: -....
7: --...
8: ---..
9: ----.
Rules:
The code must define a function
s(x)
which returns the answer.The function must accept a string or character array (whichever is the "string of characters" type of your relevant language) with 81 Morse code numbers (see above) separated by spaces. Each 9 Morse code numbers is one row of the sudoku puzzle. Known numbers should be represented by their appropriate Morse code number, while unknown numbers should be
0
in Morse code.The function must perform calculations and then return a string of Morse code numbers similar to the input but as a solved board (separated by spaces).
Be mindful of the standard loopholes
Here's an example. I have the following input string:
----- -.... ----- ...-- ----- ----- ---.. ----- ....- ..... ...-- --... ----- ----. ----- ----- ----- ----- ----- ....- ----- ----- ----- -.... ...-- ----- --... ----- ----. ----- ----- ..... .---- ..--- ...-- ---.. ----- ----- ----- ----- ----- ----- ----- ----- ----- --... .---- ...-- -.... ..--- ----- ----- ....- ----- ...-- ----- -.... ....- ----- ----- ----- .---- ----- ----- ----- ----- ----- -.... ----- ..... ..--- ...-- .---- ----- ..--- ----- ----- ----. ----- ---.. -----
...which in regular numbers, is this:
0 6 0 3 0 0 8 0 4 5 3 7 0 9 0 0 0 0 0 4 0 0 0 6 3 0 7 0 9 0 0 5 1 2 3 8 0 0 0 0 0 0 0 0 0 7 1 3 6 2 0 0 4 0 3 0 6 4 0 0 0 1 0 0 0 0 0 6 0 5 2 3 1 0 2 0 0 9 0 8 0
And when I put the Morse code string through a correct function, it should then look like this (a solved sudoku board):
..--- -.... .---- ...-- --... ..... ---.. ----. ....- ..... ...-- --... ---.. ----. ....- .---- -.... ..--- ----. ....- ---.. ..--- .---- -.... ...-- ..... --... -.... ----. ....- --... ..... .---- ..--- ...-- ---.. ---.. ..--- ..... ----. ....- ...-- -.... --... .---- --... .---- ...-- -.... ..--- ---.. ----. ....- ..... ...-- ..... -.... ....- ---.. ..--- --... .---- ----. ....- ---.. ----. .---- -.... --... ..... ..--- ...-- .---- --... ..--- ..... ...-- ----. ....- ---.. -....
...which is this in regular numbers:
2 6 1 3 7 5 8 9 4 5 3 7 8 9 4 1 6 2 9 4 8 2 1 6 3 5 7 6 9 4 7 5 1 2 3 8 8 2 5 9 4 3 6 7 1 7 1 3 6 2 8 9 4 5 3 5 6 4 8 2 7 1 9 4 8 9 1 6 7 5 2 3 1 7 2 5 3 9 4 8 6
Any language allowed. Have fun, and golf away!
2So...this is a sudoku solver and a number converter? – J42161217 – 2019-03-19T23:51:49.647
@J42161217 In all essence, yes. – connectyourcharger – 2019-03-19T23:52:22.763
2In this case this is a dupe you know.. – J42161217 – 2019-03-19T23:56:23.573
4
I'm not going to hammer this because of some weirdness about guessing/non-guessing but this is pretty much a dupe of one of this or this. In the future I'd recommend using the sandbox to work on your posts before posting. Good luck!
– FryAmTheEggman – 2019-03-19T23:56:59.0631May we use an array of strings (each being a Morse digit) for I/O, instead of one long space-separated string? – Adám – 2019-03-20T00:09:51.070
Will the input only ever have one solution? If not, what do we do if there are multiple solutions? – Adám – 2019-03-20T00:12:30.847
@Adám Must be one long string. – connectyourcharger – 2019-03-20T00:13:02.867
1May the output have extra spaces (e.g. two spaces between numbers or leading/trailing spaces)? – Adám – 2019-03-20T00:13:54.983
1Relevant Meta post – Adám – 2019-03-20T00:35:57.677
3(I don't actually understand the title) – Jo King – 2019-03-20T07:24:35.937
1@JoKing, I think it's supposed to be a play on "pseudo-code". – Shaggy – 2019-03-20T16:05:47.917
1@JoKing Or an almost-valid bash command? ... ¯\(ツ)/¯ (I think
sudo -ku de command
would mean "run 'command' as user 'de', ignoring the cached credentials") – Arnauld – 2019-03-20T17:12:49.617