Skip to content

Instantly share code, notes, and snippets.

@codepo8
Last active November 13, 2023 00:26
Show Gist options
  • Select an option

  • Save codepo8/31b9ad820c03916941c294c404831829 to your computer and use it in GitHub Desktop.

Select an option

Save codepo8/31b9ad820c03916941c294c404831829 to your computer and use it in GitHub Desktop.
Developer DNA CODE100 Puzzle

Puzzle: Developer DNA

Welcome to another CODE100 puzzle. The challenge is to take this JSON dataset:

{
    "cols": 30,
    "sine": [
     "-0.93", "-0.60", "-0.33", "-0.13", "0.00",
     "0.00", "-0.13", "-0.33", "-0.60", "-0.93"
    ],
    "parts": ["πŸ’»", "πŸ’–"]
}

And turn into this construct:

              πŸ’» πŸ’–             
           πŸ’»       πŸ’–          
         πŸ’»           πŸ’–        
        πŸ’»             πŸ’–       
       πŸ’»               πŸ’–      
       πŸ’»               πŸ’–      
        πŸ’»             πŸ’–       
         πŸ’»           πŸ’–        
           πŸ’»       πŸ’–          
              πŸ’» πŸ’–             
              πŸ’– πŸ’»             
           πŸ’–       πŸ’»          
         πŸ’–           πŸ’»        
        πŸ’–             πŸ’»       
       πŸ’–               πŸ’»      
       πŸ’–               πŸ’»      
        πŸ’–             πŸ’»       
         πŸ’–           πŸ’»        
           πŸ’–       πŸ’»          
              πŸ’– πŸ’»             

Some hints:

  • The cols property is the overall amount of chars on each line and the DNA sequence should be centered in it.
  • At its peak, this wave has 15 characters between the different emoji
@dk5ax

dk5ax commented Nov 9, 2023

Copy link
Copy Markdown

I was just wondering why lines 1 and 11 differ as sin(x) = -sin(x + pi). The same applies to lines 11 and 20, which should also result in the same value in my eyes (just as lines 1 and 9 do). So I just quickly implemented the task and as I thought it has to look like...and guess what, it is just a little different....

          πŸ’» πŸ’–
       πŸ’»       πŸ’–
     πŸ’»           πŸ’–
    πŸ’»             πŸ’–
   πŸ’»               πŸ’–
   πŸ’»               πŸ’–
    πŸ’»             πŸ’–
     πŸ’»           πŸ’–
       πŸ’»       πŸ’–
          πŸ’» πŸ’–
          πŸ’– πŸ’»
       πŸ’–       πŸ’»
     πŸ’–           πŸ’»
    πŸ’–             πŸ’»
   πŸ’–               πŸ’»
   πŸ’–               πŸ’»
    πŸ’–             πŸ’»
     πŸ’–           πŸ’»
       πŸ’–       πŸ’»
          πŸ’– πŸ’»

https://gist.github.com/dk5ax/f7370326a3f615b2694b8fed6e7ce2ae

@codepo8

codepo8 commented Nov 9, 2023

Copy link
Copy Markdown
Author

πŸ’»

In a comment here, anywhere on the web… codepen.io for example.

@codepo8

codepo8 commented Nov 9, 2023

Copy link
Copy Markdown
Author

I was just wondering why lines 1 and 11 differ as sin(x) = -sin(x + pi). The same applies to lines 11 and 20, which should also result in the same value in my eyes (just as lines 1 and 9 do). So I just quickly implemented the task and as I thought it has to look like...and guess what, it is just a little different....

          πŸ’» πŸ’–
       πŸ’»       πŸ’–
     πŸ’»           πŸ’–
    πŸ’»             πŸ’–
   πŸ’»               πŸ’–
   πŸ’»               πŸ’–
    πŸ’»             πŸ’–
     πŸ’»           πŸ’–
       πŸ’»       πŸ’–
          πŸ’» πŸ’–
          πŸ’– πŸ’»
       πŸ’–       πŸ’»
     πŸ’–           πŸ’»
    πŸ’–             πŸ’»
   πŸ’–               πŸ’»
   πŸ’–               πŸ’»
    πŸ’–             πŸ’»
     πŸ’–           πŸ’»
       πŸ’–       πŸ’»
          πŸ’– πŸ’»

https://gist.github.com/dk5ax/f7370326a3f615b2694b8fed6e7ce2ae

There seems to be some rounding and weird emoji display going on. Yours looks cleaner, I admit. And that's what I was expecting, so no need to mimick 100%.

@codepo8

codepo8 commented Nov 9, 2023

Copy link
Copy Markdown
Author

I was just wondering why lines 1 and 11 differ as sin(x) = -sin(x + pi). The same applies to lines 11 and 20, which should also result in the same value in my eyes (just as lines 1 and 9 do). So I just quickly implemented the task and as I thought it has to look like...and guess what, it is just a little different....

          πŸ’» πŸ’–
       πŸ’»       πŸ’–
     πŸ’»           πŸ’–
    πŸ’»             πŸ’–
   πŸ’»               πŸ’–
   πŸ’»               πŸ’–
    πŸ’»             πŸ’–
     πŸ’»           πŸ’–
       πŸ’»       πŸ’–
          πŸ’» πŸ’–
          πŸ’– πŸ’»
       πŸ’–       πŸ’»
     πŸ’–           πŸ’»
    πŸ’–             πŸ’»
   πŸ’–               πŸ’»
   πŸ’–               πŸ’»
    πŸ’–             πŸ’»
     πŸ’–           πŸ’»
       πŸ’–       πŸ’»
          πŸ’– πŸ’»

https://gist.github.com/dk5ax/f7370326a3f615b2694b8fed6e7ce2ae

Dang your solution is pretty.

@dk5ax

dk5ax commented Nov 9, 2023

Copy link
Copy Markdown

I was just wondering why lines 1 and 11 differ as sin(x) = -sin(x + pi). The same applies to lines 11 and 20, which should also result in the same value in my eyes (just as lines 1 and 9 do). So I just quickly implemented the task and as I thought it has to look like...and guess what, it is just a little different....

          πŸ’» πŸ’–
       πŸ’»       πŸ’–
     πŸ’»           πŸ’–
    πŸ’»             πŸ’–
   πŸ’»               πŸ’–
   πŸ’»               πŸ’–
    πŸ’»             πŸ’–
     πŸ’»           πŸ’–
       πŸ’»       πŸ’–
          πŸ’» πŸ’–
          πŸ’– πŸ’»
       πŸ’–       πŸ’»
     πŸ’–           πŸ’»
    πŸ’–             πŸ’»
   πŸ’–               πŸ’»
   πŸ’–               πŸ’»
    πŸ’–             πŸ’»
     πŸ’–           πŸ’»
       πŸ’–       πŸ’»
          πŸ’– πŸ’»

https://gist.github.com/dk5ax/f7370326a3f615b2694b8fed6e7ce2ae

Dang your solution is pretty.

Many thanks! Nice task. Bring up some more, please. Some practice for 'Advent of Code' is always welcome these days.

@shakilkhan496

Copy link
Copy Markdown

@AlenOblak

Copy link
Copy Markdown

@shg228

shg228 commented Nov 10, 2023

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment