Skip to main content
Commonmark migration
Source Link

Jelly, 26 25 bytes

2ṗ⁵’µ×“wØ][:koR¶{‘^/=µÐfḢ

Try it online!

Takes input as a 7-bit integer. Returns the binary form of a 10-bit integer.

This just brute forces all possibilities. Remove the to get all possible outputs or replace it with an X to get a random possible output.

Magic Visualization Program!

###How it works 2ṗ⁵’µ×“wØ][:koR¶{‘^/=µÐfḢ - main link, takes one integer 2ṗ⁵’ - generate all length-10 binary arrays µ µÐf - now we find those arrays which correspond to digit- sequences which work to switch off all segments: Filter (keep) those arrays which: × - multiplied by “wØ][:koR¶{‘ - [119, 18, 93, 91, 58, 107, 111, 82, 127, 123] (encoding for turned-on segments given number) ^/ - reduced by XOR = - are equal to (implicit) the program's input Ḣ - output the first of these valid arrays

How it works

2ṗ⁵’µ×“wØ][:koR¶{‘^/=µÐfḢ  - main link, takes one integer
2ṗ⁵’                       - generate all length-10 binary arrays
    µ                µÐf   - now we find those arrays which correspond to digit-
                              sequences which work to switch off all segments:
                              Filter (keep) those arrays which:
     ×                      - multiplied by 
      “wØ][:koR¶{‘          - [119, 18, 93, 91, 58, 107, 111, 82, 127, 123] 
                               (encoding for turned-on segments given number)
                  ^/        - reduced by XOR
                    =      - are equal to (implicit) the program's input
                        Ḣ  - output the first of these valid arrays
                                 

Jelly, 26 25 bytes

2ṗ⁵’µ×“wØ][:koR¶{‘^/=µÐfḢ

Try it online!

Takes input as a 7-bit integer. Returns the binary form of a 10-bit integer.

This just brute forces all possibilities. Remove the to get all possible outputs or replace it with an X to get a random possible output.

Magic Visualization Program!

###How it works 2ṗ⁵’µ×“wØ][:koR¶{‘^/=µÐfḢ - main link, takes one integer 2ṗ⁵’ - generate all length-10 binary arrays µ µÐf - now we find those arrays which correspond to digit- sequences which work to switch off all segments: Filter (keep) those arrays which: × - multiplied by “wØ][:koR¶{‘ - [119, 18, 93, 91, 58, 107, 111, 82, 127, 123] (encoding for turned-on segments given number) ^/ - reduced by XOR = - are equal to (implicit) the program's input Ḣ - output the first of these valid arrays

Jelly, 26 25 bytes

2ṗ⁵’µ×“wØ][:koR¶{‘^/=µÐfḢ

Try it online!

Takes input as a 7-bit integer. Returns the binary form of a 10-bit integer.

This just brute forces all possibilities. Remove the to get all possible outputs or replace it with an X to get a random possible output.

Magic Visualization Program!

How it works

2ṗ⁵’µ×“wØ][:koR¶{‘^/=µÐfḢ  - main link, takes one integer
2ṗ⁵’                       - generate all length-10 binary arrays
    µ                µÐf   - now we find those arrays which correspond to digit-
                              sequences which work to switch off all segments:
                              Filter (keep) those arrays which:
     ×                      - multiplied by 
      “wØ][:koR¶{‘          - [119, 18, 93, 91, 58, 107, 111, 82, 127, 123] 
                               (encoding for turned-on segments given number)
                  ^/        - reduced by XOR
                    =      - are equal to (implicit) the program's input
                        Ḣ  - output the first of these valid arrays
                                 
Fixed 9's bottom segment
Source Link
fireflame241
  • 16.3k
  • 2
  • 29
  • 72

Jelly, 26 25 bytes

2ṗ⁵’µ×“wØ][:koR¶z‘^koR¶{‘^/=µÐfḢ

Try it online!Try it online!

Takes input as a 7-bit integer. Returns the binary form of a 10-bit integer.

This just brute forces all possibilities. Remove the to get all possible outputs or replace it with an X to get a random possible output.

Magic Visualization Program!Magic Visualization Program!

###How it works 2ṗ⁵’µ×“wØ][:koR¶z‘^koR¶{‘^/=µÐfḢ - main link, takes one integer 2ṗ⁵’ - generate all length-10 binary arrays µ µÐf - now we find those arrays which correspond to digit- sequences which work to switch off all segments: Filter (keep) those arrays which: × - multiplied by “wØ][:koR¶z‘koR¶{‘ - [119, 18, 93, 91, 58, 107, 111, 82, 127, 122]123] (encoding for turned-on segments given number) ^/ - reduced by XOR = - are equal to (implicit) the program's input Ḣ - output the first of these valid arrays

Jelly, 26 25 bytes

2ṗ⁵’µ×“wØ][:koR¶z‘^/=µÐfḢ

Try it online!

Takes input as a 7-bit integer. Returns the binary form of a 10-bit integer.

This just brute forces all possibilities. Remove the to get all possible outputs or replace it with an X to get a random possible output.

Magic Visualization Program!

###How it works 2ṗ⁵’µ×“wØ][:koR¶z‘^/=µÐfḢ - main link, takes one integer 2ṗ⁵’ - generate all length-10 binary arrays µ µÐf - now we find those arrays which correspond to digit- sequences which work to switch off all segments: Filter (keep) those arrays which: × - multiplied by “wØ][:koR¶z‘ - [119, 18, 93, 91, 58, 107, 111, 82, 127, 122] (encoding for turned-on segments given number) ^/ - reduced by XOR = - are equal to (implicit) the program's input Ḣ - output the first of these valid arrays

Jelly, 26 25 bytes

2ṗ⁵’µ×“wØ][:koR¶{‘^/=µÐfḢ

Try it online!

Takes input as a 7-bit integer. Returns the binary form of a 10-bit integer.

This just brute forces all possibilities. Remove the to get all possible outputs or replace it with an X to get a random possible output.

Magic Visualization Program!

###How it works 2ṗ⁵’µ×“wØ][:koR¶{‘^/=µÐfḢ - main link, takes one integer 2ṗ⁵’ - generate all length-10 binary arrays µ µÐf - now we find those arrays which correspond to digit- sequences which work to switch off all segments: Filter (keep) those arrays which: × - multiplied by “wØ][:koR¶{‘ - [119, 18, 93, 91, 58, 107, 111, 82, 127, 123] (encoding for turned-on segments given number) ^/ - reduced by XOR = - are equal to (implicit) the program's input Ḣ - output the first of these valid arrays

-1 byte +1 explanation
Source Link
fireflame241
  • 16.3k
  • 2
  • 29
  • 72

Jelly, 2626 25 bytes

2ṗ⁵’µ×“wØ][:koR¶z‘^/=³µÐfḢ=µÐfḢ

Try it online!Try it online!

Takes input as a 7-bit integer. Returns the binary form of a 10-bit integer.

This just brute forces all possibilities. Remove the to get all possible outputs or replace it with an X to get a random possible output.

Magic Visualization Program!

I think I can save a byte by restructuring control flow###How it works 2ṗ⁵’µ×“wØ][:koR¶z‘^/=µÐfḢ - main link, takes one integer 2ṗ⁵’ - generate all length-10 binary arrays µ µÐf - now we find those arrays which correspond to avoid usage of a ³ but howdigit- sequences which work to do it evades me at the momentswitch off all segments: Filter (keep) those arrays which: × - multiplied by “wØ][:koR¶z‘ - [119, 18, 93, 91, 58, 107, 111, 82, 127, 122] (.encoding for turned-on segments given number) ^/ - reduced by XOR = - are equal to (implicit) the program's input Ḣ - output the first of these valid arrays

Jelly, 26 bytes

2ṗ⁵’µ×“wØ][:koR¶z‘^/=³µÐfḢ

Try it online!

Takes input as a 7-bit integer. Returns the binary form of a 10-bit integer.

This just brute forces all possibilities. Remove the to get all possible outputs or replace it with an X to get a random possible output.

Magic Visualization Program!

I think I can save a byte by restructuring control flow to avoid usage of a ³ but how to do it evades me at the moment :(.

Jelly, 26 25 bytes

2ṗ⁵’µ×“wØ][:koR¶z‘^/=µÐfḢ

Try it online!

Takes input as a 7-bit integer. Returns the binary form of a 10-bit integer.

This just brute forces all possibilities. Remove the to get all possible outputs or replace it with an X to get a random possible output.

Magic Visualization Program!

###How it works 2ṗ⁵’µ×“wØ][:koR¶z‘^/=µÐfḢ - main link, takes one integer 2ṗ⁵’ - generate all length-10 binary arrays µ µÐf - now we find those arrays which correspond to digit- sequences which work to switch off all segments: Filter (keep) those arrays which: × - multiplied by “wØ][:koR¶z‘ - [119, 18, 93, 91, 58, 107, 111, 82, 127, 122] (encoding for turned-on segments given number) ^/ - reduced by XOR = - are equal to (implicit) the program's input Ḣ - output the first of these valid arrays

Source Link
fireflame241
  • 16.3k
  • 2
  • 29
  • 72
Loading