Skip to content

Commit

Permalink
Setup all days
Browse files Browse the repository at this point in the history
  • Loading branch information
MinThaMie committed Nov 24, 2023
1 parent e51bafa commit 1c3a57a
Show file tree
Hide file tree
Showing 139 changed files with 7,294 additions and 3,940 deletions.
3 changes: 3 additions & 0 deletions app/components/code-snippet.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.button {
float: right;
}
6 changes: 6 additions & 0 deletions app/components/code-snippet.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<button type="button" local-class="button" {{on "click" this.toggle}}>{{if this.show "Hide code" "Show code"}}</button>
{{#if this.show}}
{{#let (get-code-snippet @name) as |snippet|}}
<CodeBlock @code= {{snippet.source}} @language={{snippet.language}} />
{{/let}}
{{/if}}
12 changes: 12 additions & 0 deletions app/components/code-snippet.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';
import { action } from '@ember/object';

export default class CodeSnippetComponent extends Component {
@tracked show = false;

@action
toggle() {
this.show = !this.show;
}
}
21 changes: 21 additions & 0 deletions app/components/day.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
.container {
display: flex;
justify-content: space-between;
}

.solution1, .solution2, .description {
width: 30vw;
}

.description h2 {
margin-top: 0px;
}

@media (max-width: 900px) {
.container {
flex-direction: column;
}
.solution1, .solution2, .description {
width: 100%;
}
}
21 changes: 21 additions & 0 deletions app/components/day.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<div local-class="intro">
<h2>Day {{@number}}</h2>
<p>The puzzle can be found <a href='https://adventofcode.com/2022/day/{{@number}}'>here</a>.<br>
The puzzle always has example input and a personalised input.<br>
You can use the toggle below to toggle between the example solution and the personalised solution
<Inputtoggle @toggle={{this.toggle}}/>
</p>
</div>
<div local-class="container">
<div local-class="solution1">
Solution 1 is {{if this.input @solution1 @example1}}
<CodeSnippet @name="day{{ @number}}-solution1.js"/>
</div>
<div local-class="solution2">
Solution 2 is {{if this.input @solution2 @example2}}
<CodeSnippet @name="day{{ @number}}-solution2.js"/>
</div>
<div local-class="description">
{{yield}}
</div>
</div>
12 changes: 12 additions & 0 deletions app/components/day.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';
import { action } from '@ember/object';

export default class DayComponent extends Component {
@tracked input = false;

@action
toggle(val) {
this.input = val;
}
}
46 changes: 46 additions & 0 deletions app/components/inputtoggle.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
.container {
display: flex;
}

.container input[type="checkbox"] {
position: absolute;
opacity: 0;
width: 250px;
height: 25px;
cursor: pointer;
}

.switch {
margin: 0px 5px;
display: flex;
align-items: center;
width: 40px;
}

.circle.right {
transform: translateX(24px)
}


.bar {
width: 40px;
height: 5px;
border-radius: 5px;
background-color: var(--base0);
position: absolute;
}

.circle {
height: 16px;
width: 16px;
border-radius: 50%;
background-color: var(--theme-color);
z-index: 1;
transition: transform .8s;
}

.circle.focused {
box-shadow: 0 0 8px var(--blue);
}


9 changes: 9 additions & 0 deletions app/components/inputtoggle.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<label local-class="container" for="input">
<span>example</span>
<div local-class="switch">
<div local-class="bar"></div>
<div local-class="circle {{if this.input "right" "left"}} {{if this.focused "focused" ""}}"></div>
</div>
<input type="checkbox" id="input" name="input" value="input" checked={{this.input}} {{on 'click' this.toggle}} {{on 'focusin' this.handleFocusIn}}
{{on 'focusout' this.handleFocusOut}}>personalised input
</label>
23 changes: 23 additions & 0 deletions app/components/inputtoggle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';
import { action } from '@ember/object';

export default class InputtoggleComponent extends Component {
@tracked input = true;
@tracked focused = false;
@action
toggle() {
this.input = !this.input;
this.args.toggle?.(this.input);
}

@action
handleFocusIn() {
this.focused = true;
}

@action
handleFocusOut() {
this.focused = false;
}
}
15 changes: 15 additions & 0 deletions app/controllers/puzzles/1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import PuzzlesBaseController from './base';

export default class Puzzles1Controller extends PuzzlesBaseController {
// BEGIN-SNIPPET day1-solution1
solve1(input) {
return 'Solution 1';
}
// END-SNIPPET

// BEGIN-SNIPPET day1-solution2
solve2(input) {
return 'Solution 1';
}
// END-SNIPPET
}
15 changes: 15 additions & 0 deletions app/controllers/puzzles/10.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import PuzzlesBaseController from './base';

export default class Puzzles10Controller extends PuzzlesBaseController {
// BEGIN-SNIPPET day10-solution1
solve1(input) {
return 'Solution 1';
}
// END-SNIPPET

// BEGIN-SNIPPET day10-solution2
solve2(input) {
return 'Solution 1';
}
// END-SNIPPET
}
15 changes: 15 additions & 0 deletions app/controllers/puzzles/11.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import PuzzlesBaseController from './base';

export default class Puzzles11Controller extends PuzzlesBaseController {
// BEGIN-SNIPPET day11-solution1
solve1(input) {
return 'Solution 1';
}
// END-SNIPPET

// BEGIN-SNIPPET day11-solution2
solve2(input) {
return 'Solution 1';
}
// END-SNIPPET
}
15 changes: 15 additions & 0 deletions app/controllers/puzzles/12.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import PuzzlesBaseController from './base';

export default class Puzzles12Controller extends PuzzlesBaseController {
// BEGIN-SNIPPET day12-solution1
solve1(input) {
return 'Solution 1';
}
// END-SNIPPET

// BEGIN-SNIPPET day12-solution2
solve2(input) {
return 'Solution 1';
}
// END-SNIPPET
}
15 changes: 15 additions & 0 deletions app/controllers/puzzles/13.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import PuzzlesBaseController from './base';

export default class Puzzles13Controller extends PuzzlesBaseController {
// BEGIN-SNIPPET day13-solution1
solve1(input) {
return 'Solution 1';
}
// END-SNIPPET

// BEGIN-SNIPPET day13-solution2
solve2(input) {
return 'Solution 1';
}
// END-SNIPPET
}
15 changes: 15 additions & 0 deletions app/controllers/puzzles/14.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import PuzzlesBaseController from './base';

export default class Puzzles14Controller extends PuzzlesBaseController {
// BEGIN-SNIPPET day14-solution1
solve1(input) {
return 'Solution 1';
}
// END-SNIPPET

// BEGIN-SNIPPET day14-solution2
solve2(input) {
return 'Solution 1';
}
// END-SNIPPET
}
15 changes: 15 additions & 0 deletions app/controllers/puzzles/15.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import PuzzlesBaseController from './base';

export default class Puzzles15Controller extends PuzzlesBaseController {
// BEGIN-SNIPPET day15-solution1
solve1(input) {
return 'Solution 1';
}
// END-SNIPPET

// BEGIN-SNIPPET day15-solution2
solve2(input) {
return 'Solution 1';
}
// END-SNIPPET
}
15 changes: 15 additions & 0 deletions app/controllers/puzzles/16.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import PuzzlesBaseController from './base';

export default class Puzzles16Controller extends PuzzlesBaseController {
// BEGIN-SNIPPET day16-solution1
solve1(input) {
return 'Solution 1';
}
// END-SNIPPET

// BEGIN-SNIPPET day16-solution2
solve2(input) {
return 'Solution 1';
}
// END-SNIPPET
}
15 changes: 15 additions & 0 deletions app/controllers/puzzles/17.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import PuzzlesBaseController from './base';

export default class Puzzles17Controller extends PuzzlesBaseController {
// BEGIN-SNIPPET day17-solution1
solve1(input) {
return 'Solution 1';
}
// END-SNIPPET

// BEGIN-SNIPPET day17-solution2
solve2(input) {
return 'Solution 1';
}
// END-SNIPPET
}
15 changes: 15 additions & 0 deletions app/controllers/puzzles/18.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import PuzzlesBaseController from './base';

export default class Puzzles18Controller extends PuzzlesBaseController {
// BEGIN-SNIPPET day18-solution1
solve1(input) {
return 'Solution 1';
}
// END-SNIPPET

// BEGIN-SNIPPET day18-solution2
solve2(input) {
return 'Solution 1';
}
// END-SNIPPET
}
15 changes: 15 additions & 0 deletions app/controllers/puzzles/19.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import PuzzlesBaseController from './base';

export default class Puzzles19Controller extends PuzzlesBaseController {
// BEGIN-SNIPPET day19-solution1
solve1(input) {
return 'Solution 1';
}
// END-SNIPPET

// BEGIN-SNIPPET day19-solution2
solve2(input) {
return 'Solution 1';
}
// END-SNIPPET
}
15 changes: 15 additions & 0 deletions app/controllers/puzzles/2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import PuzzlesBaseController from './base';

export default class Puzzles2Controller extends PuzzlesBaseController {
// BEGIN-SNIPPET day2-solution1
solve1(input) {
return 'Solution 1';
}
// END-SNIPPET

// BEGIN-SNIPPET day2-solution2
solve2(input) {
return 'Solution 1';
}
// END-SNIPPET
}
15 changes: 15 additions & 0 deletions app/controllers/puzzles/20.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import PuzzlesBaseController from './base';

export default class Puzzles20Controller extends PuzzlesBaseController {
// BEGIN-SNIPPET day20-solution1
solve1(input) {
return 'Solution 1';
}
// END-SNIPPET

// BEGIN-SNIPPET day20-solution2
solve2(input) {
return 'Solution 1';
}
// END-SNIPPET
}
15 changes: 15 additions & 0 deletions app/controllers/puzzles/21.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import PuzzlesBaseController from './base';

export default class Puzzles21Controller extends PuzzlesBaseController {
// BEGIN-SNIPPET day21-solution1
solve1(input) {
return 'Solution 1';
}
// END-SNIPPET

// BEGIN-SNIPPET day21-solution2
solve2(input) {
return 'Solution 1';
}
// END-SNIPPET
}
Loading

0 comments on commit 1c3a57a

Please sign in to comment.