-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add `robot-name` exercise * Add `robot-name` exercise
- Loading branch information
1 parent
37337a2
commit 3e1484b
Showing
7 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Instructions append | ||
|
||
```exercism/note | ||
As Uiua does **not** have mutable state, the exercise only expects you to generate random names. | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Instructions | ||
|
||
Manage robot factory settings. | ||
|
||
When a robot comes off the factory floor, it has no name. | ||
|
||
The first time you turn on a robot, a random name is generated in the format of two uppercase letters followed by three digits, such as RX837 or BC811. | ||
|
||
Every once in a while we need to reset a robot to its factory settings, which means that its name gets wiped. | ||
The next time you ask, that robot will respond with a new random name. | ||
|
||
The names must be random: they should not follow a predictable sequence. | ||
Using random names means a risk of collisions. | ||
Your solution must ensure that every existing robot has a unique name. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"authors": [ | ||
"erikschierboom" | ||
], | ||
"files": { | ||
"solution": [ | ||
"robot-name.ua" | ||
], | ||
"test": [ | ||
"tests.ua" | ||
], | ||
"example": [ | ||
".meta/example.ua" | ||
] | ||
}, | ||
"blurb": "Manage robot factory settings.", | ||
"source": "A debugging session with Paul Blackwell at gSchool." | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
RandomRange ← + ⌊× ⊙[⍥⚂] | ||
RandomLetters ← (RandomRange 26 2 @A) | ||
RandomDigits ← (RandomRange 10 3 @0) | ||
GenerateName ← (⊂ RandomLetters RandomDigits) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Generate a random name for a robot | ||
# Name | ||
GenerateName ← |0 (⍤. "Please implement GenerateName" 0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
~ "robot-name.ua" ~ GenerateName | ||
|
||
# Name has correct format | ||
⍤⤙≍ 1 ±⧻♭ regex "^[A-Z]{2}\\d{3}$" GenerateName() | ||
|
||
# Name is generated randomly | ||
⍤⤙≍ 25 ⧻◴ [⍥GenerateName] 25 |