Skip to content

Instantly share code, notes, and snippets.

Sample Game:
327/XX8/9/4/247/11
How many frames scored a 20 or more?
frame 1 2 3 4 5 6 7 8 9 10
balls 32 7/ X X 8/ 9/ 4/ 24 7/ 11
score 5 20 28 20 19 14 12 6 11 2
In the example above, there are 3.
"(+ 1 1)" calculates to 2
"(if (= 13 46) 88 20)" calculates to 20
"(+ (- (if (= 87 78) 36 41) 53) 64)" calculates to 52
"(- (+ (if (= 63 81) 56 (- (+ 20 84) 45)) 58) 72)" calculates to 45
(if (= 3 4) 6 (+ (- (if (= 2 3) 96 (- (if (= 4 2) 92 (- (- (+ (- (if (= 2 2) 62 (- (if (= 2 4) 17 (+ (+ (+ (- (if (= 3 4) 7 (+ (- (+ (- (- (- (if (= 4 4) 42 (- (+ (- (- (if (= 5 2) 69 (- (- (if (= 5 4) 5 (- (+ (if (= 4 1) 20 (+ (if (= 4 5) 47 (if (= 2 5) 35 (- (if (= 2 2) 68 (if (= 5 5) 52 (+ (+ (+ (- (- (+ (if (= 5 3) 54 (- (- (if (= 2 3) 6 (- (+ (+ (- (if (= 5 5) 69 (if (= 1 1) 56 (- (+ (- (+ (- (- (- (if (= 3 5) 24 (- (- (if (= 3 5) 44 (- (if (= 5 3) 25 (+ (- (+ (- (+ (+ (+ (+ (+ (if (= 2 3) 23 (- (+ (if (= 4 2) 69 (+ (- (if (= 5 4) 56 (if (= 1 4) 85 (- (+ (- (if (= 1 3) 66 (- (if (= 5 3) 28 (if (= 2 2) 4 (if (= 4 2) 6 (if (= 1 4) 92 (if (= 4 4) 79 (+ (if (= 3 5) 13 (if (= 4 3) 47 (- (- (if (= 2 1) 27 (if (= 1 4) 91 (+ (+ (if (= 5 5) 84 (- (+ (- (- (+ (if (= 5 5) 14 (- (+ (+ (+ (+ (- (+ (+ (if (= 1 4) 39 (- (if (= 2 2) 48 (- (- (if (= 5 5) 37 (+ (- (if (= 4 5) 18 (if (= 2 3) 26 (if (= 5 3) 9 (+ (- (+ (if (= 4 4) 50 (+ (- (- (- (- (if (= 2 1) 19 (- (- (+ (- (+ (if (= 2 2) 45 (if (= 5 1) 47 (if (= 4 4) 42 (+
<?php
// Which do you prefer?
return $some . '-' . $thing . '-' . $like . '-' . $this;
// OR
return implode('-', [$some, $thing, $like, $this]);
@ahuggins
ahuggins / EventServiceProvider.php
Last active April 13, 2018 06:39
Add an eventListener and have make: commands open file in editor
<?php
namespace App\Providers;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
class EventServiceProvider extends ServiceProvider
{
// Add the following to the $listen array
protected $listen = [
@ahuggins
ahuggins / ClassWasGenerated.php
Last active April 13, 2018 04:09
`artisan make:?` command would auto-open new file (Controller/Model/etc) in editor.
<?php
namespace App\Events;
class ClassWasGenerated
{
public $path;
public function __construct($path)
{

Trying this thing out

  • Let's
  • See
  • How
  • it Does

This is just a paragraph

A sub heading

<?php
$file = 'some/path/to/file.csv';
$file = new SplFileObject($file);
$file->getBasename();
// file.csv
$file->getBasename('.csv');
@ahuggins
ahuggins / composer.json
Last active May 31, 2017 00:00
The composer.json for the package
// truncated composer.json file for the packge:
"autoload": {
"psr-4": {
"Namespace\\": "src/"
}
}
}
@ahuggins
ahuggins / gist:21d1af3c1e274cfa305d8220fb5303f2
Last active April 17, 2017 18:32
Illuminate\Filesystem question
<?php
//...
dd(collect($this->fs->files('archive/'.$this->date)));
//returns
Illuminate\Support\Collection {#79
#items: array:24 [
0 => "archive/2017-03-23/Something_2017-03-23_03-53-21.tsv"