-
Notifications
You must be signed in to change notification settings - Fork 5
/
index-33.html
1564 lines (1325 loc) · 67.8 KB
/
index-33.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html prefix="
og: http://ogp.me/ns#
article: http://ogp.me/ns/article#
" lang="en">
<head>
<meta charset="utf-8">
<meta name="description" content="C'est la Z">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>C'est la Z (old posts, page 33) | C'est la Z</title>
<link href="assets/css/bootstrap.min.css" rel="stylesheet" type="text/css">
<link href="assets/css/rst.css" rel="stylesheet" type="text/css">
<link href="assets/css/code.css" rel="stylesheet" type="text/css">
<link href="assets/css/colorbox.css" rel="stylesheet" type="text/css">
<link href="assets/css/theme.css" rel="stylesheet" type="text/css">
<link href="assets/css/custom.css" rel="stylesheet" type="text/css">
<meta content="#5670d4" name="theme-color">
<link rel="alternate" type="application/rss+xml" title="RSS" href="rss.xml">
<link rel="alternate" type="application/atom+xml" title="Atom" href="index.atom">
<link rel="canonical" href="http://cestlaz.github.io/index-33.html">
<link rel="prev" href="index-34.html" type="text/html">
<link rel="next" href="index-32.html" type="text/html">
<!--[if lt IE 9]><script src="assets/js/html5.js"></script><![endif]-->
</head>
<body>
<a href="#content" class="sr-only sr-only-focusable">Skip to main content</a>
<!-- Menubar -->
<nav class="navbar navbar-static-top"><div class="container">
<!-- This keeps the margins nice -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-navbar" aria-controls="bs-navbar" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="http://cestlaz.github.io/">
<img class="zlogo" src="assets/images/thluffy.jpg" id="logo"><span class="zname" id="blog-title">C'est la Z</span>
</a>
</div>
<!-- /.navbar-header -->
<div class="collapse navbar-collapse" id="bs-navbar" aria-expanded="false">
<ul class="nav navbar-nav navbar-right zmenu">
<li class="zitem">
<a href="categories">Tags</a>
</li>
<li class="zitem">
<a href="stories/emacs">Emacs</a>
</li>
<li class="zitem">
<a href="stories/flask">Flask</a>
</li>
<li class="zitem">
<a href="http://github.com/zamansky">GitHub</a>
</li>
<li class="zitem">
<a href="archive.html">Archive</a>
</li>
<li class="zitem">
<a href="stories/about">About</a>
</li>
<li class="zitem">
<a href="rss.xml">RSS feed</a>
</li>
</ul>
<ul class="nav navbar-nav navbar-right"></ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container -->
</nav><h2 class="text-center">
Musings about education, computer science,</h2>
<h3 class="text-center">and maybe a few other miscellaneous topics.
</h3>
<!-- End of Menubar -->
<div class="container" id="content" role="main">
<div class="body-content">
<!--Body content-->
<div class="row">
<div class="col-md-1"></div>
<div class="col-md-8">
<div class="postindex">
<article class="h-entry post-text"><header><h1 class="p-name entry-title"><a href="posts/happy_ladybug/" class="u-url">Early Interesting Problems - Happy Ladybugs</a></h1>
<div class="metadata">
<p class="byline author vcard"><span class="byline-name fn" itemprop="author">
Mike Zamansky
</span></p>
<p class="dateline"><a href="posts/happy_ladybug/" rel="bookmark"><time class="published dt-published" datetime="2017-10-23T08:47:46-04:00" title="2017-10-23 08:47">2017-10-23 08:47</time></a></p>
<p class="commentline"> <a href="posts/happy_ladybug/#disqus_thread" data-disqus-identifier="cache/posts/happy_ladybug.html">Comments</a>
</p>
</div>
</header><div class="e-content entry-content">
<div id="outline-container-sec-1" class="outline-2">
<h2 id="sec-1"></h2>
<div class="outline-text-2" id="text-1">
<p>
We all love interesting problems. The trouble is that it's hard to
find suitably interesting problems for students when they're just
learning the basics. In the very beginning the problems practically
dictate the solution:
</p>
<ul class="org-ul">
<li>loop over a list and add all the elements or calculate the sum of a
list of integers.
</li>
<li>Determine if number is prime
</li>
<li>Convert a word into pig-Latin
</li>
</ul>
<p>
It's not that there's no thought involved in solving these but the
students already know the mechanics of solving these by hand so it's a
direct translation into a program.
</p>
<p>
This isn't a bad thing and it is important but it's fun when we get to the next
level. I've found that a number of the <a href="http://hackerrank.com">Hacker Rank</a> archived
competitions have "easy" problems that can be a good fit for
beginners. One that I found and really like is <a href="https://www.hackerrank.com/challenges/happy-ladybugs">Happy Ladybugs</a> problem.
</p>
<p>
The problems is basically as follows:
</p>
<p>
You get a string of letters. Each letter represents a ladybug of a
different color. Each letter also represents a location of the
ladybug. A space (or underscore in the actual problem) represents a
free space. For example "AABC DDA" is a line of 2 A colored ladybugs
followed by a B colored one, C colored one, a blank space, 2 D colored and then one
more A colored.
</p>
<p>
You can rearrange the line of ladybugs by swapping any ladybug with a
blank space.
</p>
<p>
A ladybug is happy if it is next to another ladybug of the same
color. The challenge is to determine if all the ladybugs can be made
happy.
</p>
<p>
I like this problem because while it is non-trivial it is very
approachable.
</p>
<p>
To me, the key is that while you can rearrange the list you
don't have to. You only have to determine if it is possible to make
the ladybugs happy. You don't actually have to do so.
</p>
<p>
The edge cases are pretty easy to deal with - a string of length one
or two but then a little thought is required.
</p>
<p>
The first insight is that if there are no spaces, you can't rearrange
the ladybugs so all you have to do is scan through the string to test
to see if every ladybug has a neighbor of the same color.
</p>
<p>
The next insight, and the big one is that if you have at least one
space you can arbitrarily re-order the string. You can show this is
possible by using a single space to swap any two elements.
</p>
<div class="highlight"><pre><span></span><span class="n">space</span> <span class="o">=</span> <span class="n">someletter</span>
<span class="n">someletter</span> <span class="o">=</span> <span class="n">someotherletter</span>
<span class="n">someotherletter</span> <span class="o">=</span> <span class="n">space</span>
</pre></div>
<p>
The final insight is that since you can arbitrarily re-order the
ladybugs as long as you have at least 2 of each color, you can make
them all happy.
</p>
<p>
Since my class is currently just starting dictionaries in Python we
solved this with lists and then transitioned to dictionaries.
</p>
<p>
Here's a dictionary based solution:
</p>
<div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">are_happy</span><span class="p">(</span><span class="n">s</span><span class="p">):</span>
<span class="sd">'''</span>
<span class="sd"> This might miss some of the real edge cases in the hackerrank</span>
<span class="sd"> problem. I haven't read the problem carefully in over a year and </span>
<span class="sd"> forget what it specified for things like lists of only spaces,</span>
<span class="sd"> lists with only one bug etc.</span>
<span class="sd"> Also, the Hackerrank question uses an underscore (_) instead of a space.</span>
<span class="sd"> '''</span>
<span class="c1"># handle a string of less than 2 ladybugs</span>
<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">s</span><span class="p">)</span><span class="o"><</span><span class="mi">2</span><span class="p">:</span>
<span class="k">return</span> <span class="bp">False</span>
<span class="c1"># handle the string of 2 ladybugs - both must be the same and not a space</span>
<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">s</span><span class="p">)</span><span class="o">==</span><span class="mi">2</span><span class="p">:</span>
<span class="k">return</span> <span class="n">s</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">==</span><span class="n">s</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="ow">and</span> <span class="n">s</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">!=</span> <span class="s1">' '</span>
<span class="c1"># handle the case of no spaces </span>
<span class="k">if</span> <span class="n">s</span><span class="o">.</span><span class="n">count</span><span class="p">(</span><span class="s1">' '</span><span class="p">)</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
<span class="c1"># no spaces, every item must be next to one of the same color</span>
<span class="c1"># so we loop from 1 to len-1 and for each item</span>
<span class="c1"># check the one before and the one after</span>
<span class="c1"># if we ever have an unhappy bug, we can just return False</span>
<span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span><span class="nb">len</span><span class="p">(</span><span class="n">s</span><span class="p">)</span><span class="o">-</span><span class="mi">1</span><span class="p">):</span>
<span class="k">if</span> <span class="n">s</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">!=</span> <span class="n">s</span><span class="p">[</span><span class="n">i</span><span class="o">+</span><span class="mi">1</span><span class="p">]</span> <span class="ow">and</span> <span class="n">s</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">!=</span> <span class="n">s</span><span class="p">[</span><span class="n">i</span><span class="o">-</span><span class="mi">1</span><span class="p">]:</span>
<span class="k">return</span> <span class="bp">False</span>
<span class="c1"># if we ever get here every bug has at least one neighbor of the same color</span>
<span class="k">return</span> <span class="bp">True</span>
<span class="c1"># if we get here it means there's at least one space so we can rearrange the bugs</span>
<span class="c1"># however we please so as long as there are at least 2 bugs of each color</span>
<span class="c1"># we can make them all happy</span>
<span class="c1"># replace the spaces with "" since we don't want to count them</span>
<span class="c1"># Since we know they were in the string we can rearrange but</span>
<span class="c1"># they're no longer needed</span>
<span class="n">s</span> <span class="o">=</span> <span class="n">s</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s2">" "</span><span class="p">,</span><span class="s2">""</span><span class="p">)</span>
<span class="c1"># tally up all the bugs to see if there are at least 2 of each</span>
<span class="n">bugcounts</span> <span class="o">=</span> <span class="p">{}</span>
<span class="k">for</span> <span class="n">bug</span> <span class="ow">in</span> <span class="n">s</span><span class="p">:</span>
<span class="n">bugcounts</span><span class="o">.</span><span class="n">setdefault</span><span class="p">(</span><span class="n">bug</span><span class="p">,</span><span class="mi">0</span><span class="p">)</span> <span class="c1"># set to 0 the first time we see this key</span>
<span class="n">bugcounts</span><span class="p">[</span><span class="n">bug</span><span class="p">]</span><span class="o">=</span><span class="n">bugcounts</span><span class="p">[</span><span class="n">bug</span><span class="p">]</span><span class="o">+</span><span class="mi">1</span>
<span class="n">counts</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="n">bugcounts</span><span class="o">.</span><span class="n">values</span><span class="p">())</span>
<span class="c1"># if there is any value of 1 in the counts then there's a lone ladybug</span>
<span class="c1"># that can't be made happy</span>
<span class="c1"># so we return True (happy) if there are 0 counts of 1 in our list </span>
<span class="k">return</span> <span class="n">counts</span><span class="o">.</span><span class="n">count</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span> <span class="o">==</span> <span class="mi">0</span>
<span class="n">bugs</span><span class="o">=</span><span class="s2">"abaccbe ff eggggggg"</span>
<span class="k">print</span><span class="p">(</span><span class="n">bugs</span><span class="p">)</span>
<span class="n">are_happy</span><span class="p">(</span><span class="n">bugs</span><span class="p">)</span>
</pre></div>
<p>
I love problems like these.
</p>
<p>
I just wish there was an easy way to find all contest problems of a
certain level like "easy" or "medium." If anybody knows please share
in the comments.
</p>
</div>
</div>
</div>
</article><article class="h-entry post-text"><header><h1 class="p-name entry-title"><a href="posts/catskills-2017/" class="u-url">Catskills Conf 2017</a></h1>
<div class="metadata">
<p class="byline author vcard"><span class="byline-name fn" itemprop="author">
Mike Zamansky
</span></p>
<p class="dateline"><a href="posts/catskills-2017/" rel="bookmark"><time class="published dt-published" datetime="2017-10-21T20:46:49-04:00" title="2017-10-21 20:46">2017-10-21 20:46</time></a></p>
<p class="commentline"> <a href="posts/catskills-2017/#disqus_thread" data-disqus-identifier="cache/posts/catskills-2017.html">Comments</a>
</p>
</div>
</header><div class="e-content entry-content">
<div id="outline-container-sec-1" class="outline-2">
<h2 id="sec-1"></h2>
<div class="outline-text-2" id="text-1">
<div class="figure">
<p><img src="img/cc-2017/cc1.JPG" alt="cc1.JPG"></p>
</div>
<p>
Fall in the northeast is a special time. It's the apple harvest, the
leaves change colors, and the
air is crisp and clean. One of the best places to enjoy it is up in the
Hudson Valley. That's why I love going to <a href="http://catskillsconf.com">Catskills Conf</a> each year.
</p>
<p>
I've written about Catksills Conf before and I usually describe it as
"light tech conference meets summer camp." I love the event but I
love being able to bring my students even more.
</p>
<p>
Hunter's a great place but it's a commuter school. That makes it
harder for the students to get to know each other than if they all
lived in the dorms. Getting away as a group for the weekend helps us
jumpstart the process.
</p>
<div class="figure">
<p><img src="img/cc-2017/cc-group.JPG" alt="cc-group.JPG"></p>
</div>
<div class="figure">
<p><img src="img/cc-2017/cc-bunkhouse.JPG" alt="cc-bunkhouse.JPG"></p>
</div>
<p>
Then there's the conference itself. In addition to a great assortment
of talks it has all the amazing extras.
</p>
<p>
<a href="https://twitter.com/songadaymann">Jonathan "Song a Day" Mann</a> has been with us all three years of the
conference to write summary songs for each day.
</p>
<div class="export">
<p>
<iframe width="560" height="315" src="<a href="https://www.youtube.com/embed/iM2RmmJrBTI">https://www.youtube.com/embed/iM2RmmJrBTI</a>" frameborder="0" allowfullscreen></iframe>
</p>
</div>
<p>
There are hikes
</p>
<div class="figure">
<p><img src="img/cc-2017/cc-hike.JPG" alt="cc-hike.JPG"></p>
</div>
<p>
Workshops like blacksmithing
</p>
<div class="figure">
<p><img src="img/cc-2017/cc-blacksmith.JPG" alt="cc-blacksmith.JPG"></p>
</div>
<p>
a live birds of prey show
</p>
<div class="figure">
<p><img src="img/cc-2017/cc-bop.JPG" alt="cc-bop.JPG"></p>
</div>
<p>
not to mention folk music and square dancing.
</p>
<p>
All of this makes for a great experience but maybe the best part is
that everyone is living together in the <a href="http://ashokancenter.org/">Ashokan Center</a>. The conference
doesn't allow questions after talks because the speakers are all
living with the attendees for the weekend. We eat in the same
cafeteria, go on the same hikes, relax at the same bonfire, and sleep
in the same bunkhouses. As one of my students said:
</p>
<blockquote>
<p>
</p>
<p>
There’s just something about sharing a conversation on the cloud
computing network with someone who’s visiting from London while
shooting basketball hoops in the middle of the woods that makes for a
real take away experience!
</p>
</blockquote>
<p>
I've had the good fortune to be able to bring my students up to
Catskills Conf in the Fall for each of the last three years. Here's
hoping that the tradition can continue for many more.
</p>
</div>
</div>
</div>
</article><article class="h-entry post-text"><header><h1 class="p-name entry-title"><a href="posts/nice-appreciated/" class="u-url">It's nice to be appreciated</a></h1>
<div class="metadata">
<p class="byline author vcard"><span class="byline-name fn" itemprop="author">
Mike Zamansky
</span></p>
<p class="dateline"><a href="posts/nice-appreciated/" rel="bookmark"><time class="published dt-published" datetime="2017-10-19T17:27:53-04:00" title="2017-10-19 17:27">2017-10-19 17:27</time></a></p>
<p class="commentline"> <a href="posts/nice-appreciated/#disqus_thread" data-disqus-identifier="cache/posts/nice-appreciated.html">Comments</a>
</p>
</div>
</header><div class="e-content entry-content">
<div id="outline-container-sec-1" class="outline-2">
<h2 id="sec-1"></h2>
<div class="outline-text-2" id="text-1">
<p>
Today was my 50th Birthday. I'm usually pretty low key on birthdays
and today was no different. I got up, exercised, went to work, taught
my class and went back to my office for office hours.
</p>
<p>
What a great surprise when all of a sudden my students from last year
appeared at my office with a Happy Birthday a card and a cake:
<img src="img/cake.jpg" alt="cake.jpg"></p>
<p>
It felt pretty terrific. I wasn't expecting this and was really moved.
</p>
<p>
We don't make the big bucks but little things like this make me feel
pretty terrific as a teacher.
</p>
</div>
</div>
</div>
</article><article class="h-entry post-text"><header><h1 class="p-name entry-title"><a href="posts/when-they-change-the-script/" class="u-url">There's always something to learn (from your students)</a></h1>
<div class="metadata">
<p class="byline author vcard"><span class="byline-name fn" itemprop="author">
Mike Zamansky
</span></p>
<p class="dateline"><a href="posts/when-they-change-the-script/" rel="bookmark"><time class="published dt-published" datetime="2017-10-18T11:41:49-04:00" title="2017-10-18 11:41">2017-10-18 11:41</time></a></p>
<p class="commentline"> <a href="posts/when-they-change-the-script/#disqus_thread" data-disqus-identifier="cache/posts/when-they-change-the-script.html">Comments</a>
</p>
</div>
</header><div class="e-content entry-content">
<div id="outline-container-sec-1" class="outline-2">
<h2 id="sec-1"></h2>
<div class="outline-text-2" id="text-1">
<p>
One thing I've learned from teaching is that there's always something
new to learn. For the kids, yes, but I'm talking about for the
teacher.
</p>
<p>
The other day, I taught a lesson I've taught many times. Find the mode
of a data set. That's the problem that they solve but the lesson is
really about run time complexity, hidden complexity and using data
structures in alternate ways.
</p>
<p>
I blogged about this <a href="https://cestlaz.github.io/posts/2013-03-23-Who_won_the_election-Quadratic_to_Linear_Time.md">before</a> so you can get an earlier take there
although the code isn't formatted correctly due to blog conversions.
</p>
<p>
As with the last time, the students had already written code to find
the largest value in a list and also to find the frequency of an item
in a list.
</p>
<div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">random</span>
<span class="k">def</span> <span class="nf">build_list</span><span class="p">(</span><span class="n">size</span><span class="p">,</span><span class="n">low</span><span class="p">,</span><span class="n">high</span><span class="p">):</span>
<span class="n">l</span><span class="o">=</span><span class="p">[]</span>
<span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">size</span><span class="p">):</span>
<span class="n">l</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">random</span><span class="o">.</span><span class="n">randrange</span><span class="p">(</span><span class="n">low</span><span class="p">,</span><span class="n">high</span><span class="p">))</span>
<span class="k">return</span> <span class="n">l</span>
<span class="k">def</span> <span class="nf">get_max_value</span><span class="p">(</span><span class="n">l</span><span class="p">):</span>
<span class="n">max_index</span><span class="o">=</span><span class="mi">0</span>
<span class="n">max_val</span><span class="o">=</span><span class="n">l</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
<span class="k">for</span> <span class="n">index</span><span class="p">,</span><span class="n">value</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">l</span><span class="p">):</span>
<span class="k">if</span> <span class="n">value</span> <span class="o">></span> <span class="n">max_val</span><span class="p">:</span>
<span class="n">max_index</span> <span class="o">=</span> <span class="n">index</span>
<span class="n">max_val</span> <span class="o">=</span> <span class="n">value</span>
<span class="k">return</span> <span class="n">max_val</span>
<span class="k">def</span> <span class="nf">get_freq</span><span class="p">(</span><span class="n">l</span><span class="p">,</span><span class="n">requested_val</span><span class="p">):</span>
<span class="n">count</span><span class="o">=</span><span class="mi">0</span>
<span class="k">for</span> <span class="n">value</span> <span class="ow">in</span> <span class="n">l</span><span class="p">:</span>
<span class="k">if</span> <span class="n">requested_val</span> <span class="o">==</span> <span class="n">value</span><span class="p">:</span>
<span class="n">count</span> <span class="o">=</span> <span class="n">count</span> <span class="o">+</span> <span class="mi">1</span>
<span class="k">return</span> <span class="n">count</span>
</pre></div>
<p>
They had to write mode prior to the class. In the past, students would
generally come up with something like this:
</p>
<div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">get_mode_1</span><span class="p">(</span><span class="n">l</span><span class="p">):</span>
<span class="n">mode_val</span> <span class="o">=</span> <span class="n">l</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
<span class="n">mode_freq</span> <span class="o">=</span> <span class="n">get_freq</span><span class="p">(</span><span class="n">l</span><span class="p">,</span><span class="n">mode_val</span><span class="p">)</span>
<span class="k">for</span> <span class="n">index</span><span class="p">,</span><span class="n">value</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">l</span><span class="p">):</span>
<span class="n">f</span> <span class="o">=</span> <span class="n">get_freq</span><span class="p">(</span><span class="n">l</span><span class="p">,</span><span class="n">value</span><span class="p">)</span>
<span class="k">if</span> <span class="n">f</span> <span class="o">></span> <span class="n">mode_freq</span><span class="p">:</span>
<span class="n">mode_freq</span> <span class="o">=</span> <span class="n">f</span>
<span class="n">mode_val</span> <span class="o">=</span> <span class="n">value</span>
<span class="k">return</span> <span class="n">mode_val</span>
<span class="n">l</span><span class="o">=</span><span class="n">build_list</span><span class="p">(</span><span class="mi">20</span><span class="p">,</span><span class="mi">1</span><span class="p">,</span><span class="mi">20</span><span class="p">)</span>
<span class="n">m</span><span class="o">=</span><span class="n">get_mode_1</span><span class="p">(</span><span class="n">l</span><span class="p">)</span>
</pre></div>
<p>
They'd use their existing knowledge and the 'find the largest' idiom
to find the mode by:
</p>
<ul class="org-ul">
<li>find the frequency of the first item and assume it's the mode so far
</li>
<li>for each item in the list
<ul class="org-ul">
<li>find the frequency of that idem
</li>
<li>if it occurs more than the mode so far then it becomes the new
mode so far
</li>
</ul>
</li>
</ul>
<p>
There's a lot of good in this solution. The kids incrementally develop
a solution, they use and exctend code and concepts they already know
and understand and it's clear and understandable.
</p>
<p>
We would then run the code on larger and larger data sets and notice
that it gets slow pretty quickly. This leads to an informal discussion
of run time and the fact that there's hidden complexity – the call to
<code>freq</code> in the main loop introduces a linear component so we have a
loop within a loop and an N<sup>2</sup> routine.
</p>
<p>
The big takeaway is get a feel for run time and to be aware of hidden
complexity. We then move to a linear solution by using a list as
buckets. You can read more about that in the <a href="https://cestlaz.github.io/posts/2013-03-23-Who_won_the_election-Quadratic_to_Linear_Time.md">original post</a>.
</p>
<p>
What was interesting this time around was that most of the kids came
up with a solution more like this:
</p>
<div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">get_mode_2</span><span class="p">(</span><span class="n">l</span><span class="p">):</span>
<span class="n">freqs</span> <span class="o">=</span> <span class="p">[]</span>
<span class="k">for</span> <span class="n">item</span> <span class="ow">in</span> <span class="n">l</span><span class="p">:</span>
<span class="n">f</span> <span class="o">=</span> <span class="n">get_freq</span><span class="p">(</span><span class="n">l</span><span class="p">,</span><span class="n">item</span><span class="p">)</span>
<span class="n">freqs</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">f</span><span class="p">)</span>
<span class="n">mode_count</span> <span class="o">=</span> <span class="n">freqs</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
<span class="n">mode_value</span> <span class="o">=</span> <span class="n">l</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
<span class="k">for</span> <span class="n">index</span><span class="p">,</span><span class="n">value</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">freqs</span><span class="p">):</span>
<span class="k">if</span> <span class="n">value</span> <span class="o">></span> <span class="n">mode_count</span><span class="p">:</span>
<span class="n">mode_count</span> <span class="o">=</span> <span class="n">value</span>
<span class="n">mode_value</span> <span class="o">=</span> <span class="n">l</span><span class="p">[</span><span class="n">index</span><span class="p">]</span>
<span class="k">return</span> <span class="n">mode_value</span>
<span class="n">l</span> <span class="o">=</span> <span class="n">build_list</span><span class="p">(</span><span class="mi">20</span><span class="p">,</span><span class="mi">1</span><span class="p">,</span><span class="mi">20</span><span class="p">)</span>
<span class="k">print</span><span class="p">(</span><span class="n">l</span><span class="p">)</span>
<span class="n">m</span> <span class="o">=</span> <span class="n">get_mode_2</span><span class="p">(</span><span class="n">l</span><span class="p">)</span>
<span class="k">print</span><span class="p">(</span><span class="n">m</span><span class="p">)</span>
</pre></div>
<p>
Instead of calculating the frequency inside the loop they made a list
of frequencies. <code>freq[0]</code> had the frequency of <code>l[0]</code>, <code>freq[1]</code> the
frequency of <code>l[1]</code> etc. They then loop through that <code>freq</code> list to
find the largest element and that's the index of the mode value in the
original list.
</p>
<p>
It's functionally the same as the first solution but in some ways it's
very different. They built the data set they needed ahead of time
instead of calculating the data on the fly and they used the concept
of parallel lists.
</p>
<p>
I like the solution and it didn't prevent us from getting to the run
time stuff but this did give me something to think about.
</p>
<p>
Why did this class led them largely to a different solution than the
classes I've taught in the class. There are a lot of things to ponder
since it's a college class that meets twice a week with kids from a
range of backgrounds (CS and otherwise) vs a high school class that
meets 5 days a week and the kids all had the same in class experience
prior to this lesson. Did I do something differently before hand? Some
assignments? Something I modeled? I'm not sure but it's something I'm
going to ponder.
</p>
<p>
It will interesting to see if this was a one shot deal and my current
class will solve problems as I predict moving forward or if I'm going
to get to see a lot of new things.
</p>
</div>
</div>
</div>
</article><article class="h-entry post-text"><header><h1 class="p-name entry-title"><a href="posts/ap-results-measure-of-curriculum/" class="u-url">A test result is just a test result</a></h1>
<div class="metadata">
<p class="byline author vcard"><span class="byline-name fn" itemprop="author">
Mike Zamansky
</span></p>
<p class="dateline"><a href="posts/ap-results-measure-of-curriculum/" rel="bookmark"><time class="published dt-published" datetime="2017-10-15T20:17:21-04:00" title="2017-10-15 20:17">2017-10-15 20:17</time></a></p>
<p class="commentline"> <a href="posts/ap-results-measure-of-curriculum/#disqus_thread" data-disqus-identifier="cache/posts/ap-results-measure-of-curriculum.html">Comments</a>
</p>
</div>
</header><div class="e-content entry-content">
<div id="outline-container-sec-1" class="outline-2">
<h2 id="sec-1"></h2>
<div class="outline-text-2" id="text-1">
<p>
This past weekend was <a href="http://catskillsconf.com">Catskillsconf</a> - my favorite event of the
year. I spent the weekend up in Ulster County with a bunch of my
students. some great friends old and new, and Devorah. It was a great
weekend but I was mostly offline.
</p>
<p>
As a result I missed a rather heated discussion in the CS Ed Facebook
groups. The debate was over whether or not Strong AP CSP exam results
are indicative of a good curriculum or good professional development (PD).
</p>
</div>
</div>
<div id="outline-container-sec-2" class="outline-2">
<h2 id="sec-2">TL;DR - NO!!!!!</h2>
<div class="outline-text-2" id="text-2">
<p>
Further, anyone who thinks that a set of exam results can tell you
that a particular PD sequence or curriculum is good shouldn't be
allowed to call themselves a teacher and I don't want them anywhere
near my kids.
</p>
<p>
I guess that language is strong, even for me but it's true.
</p>
<p>
Tests are designed to assess students and many tests don't even do
that well. They shouldn't be used to measure something further
removed.
</p>
<p>
The last time this idea made its rounds was using student test results
for teacher evaluation. They do that in NY. A judge called the
practice "capricious" and "arbitrary." My friend and former
colleague Gary Rubinstein showed a year or so ago that standardized
test scores varied enough from year to year so as to make the ratings
useless <sup><a id="fnr.1" name="fnr.1" class="footref" href="posts/ap-results-measure-of-curriculum/#fn.1">1</a></sup></p>
<p>
Using test scores to say a PD sequence is good? What if that PD
focused on test prep? What if it did nothing in particular? When I was
at Stuy and when I was at Seward Park the Calc teachers' students had
great AP results. I can tell you that none of those teachers had any
quality PD specific to AP Calc.
</p>
<p>
Curriculum? My mentor and friend Danny Jaye told me many times - "A
great teacher can save a class from a horrible curriculum but a great
curriculum will do nothing for a class with a horrible teacher." He
was right. Again, what if the curriculum encourages test prep. What if
pressure on the teacher encourages them to focus on test prep
regardless of curriculum or PD (see my recent <a href="http://cestlaz.github.io/posts/standards-who-for">post</a>).
</p>
<p>
An AP test measures one thing - how well the student did on the AP
test. There are so many variables that go into a class:
</p>
<ul class="org-ul">
<li>Is it first period at 8:00am?
</li>
<li>Is it the last class of the day?
</li>
<li>Is it before lunch or right afterwards?
</li>
<li>What about right after Gym.
</li>
<li>What's the mix of students - every class is different
</li>
<li>Is the teacher teaching the subject once a day? Two times? Five
times?
</li>
<li>How large is the class
</li>
<li>How many other classes are the kids taking?
</li>
</ul>
<p>
The list goes on and on. There are so many contributing factors that
you just can't say "Good test results = good curriculum" or "good test
results = good PD."
</p>
<p>
Want to know if a curriculum is good - have experienced teachers who
know their subject run it a few times through and ask them. Same for
PD.
</p>
<p>
Teachers know education a lot better than test makers, curriculum
developers and PD providers. How about listening to them for a change?
</p>
</div>
</div>
<div id="footnotes">
<h2 class="footnotes">Footnotes: </h2>
<div id="text-footnotes">
<div class="footdef">
<sup><a id="fn.1" name="fn.1" class="footnum" href="posts/ap-results-measure-of-curriculum/#fnr.1">1</a></sup><p>sorry, I just got back from the weekend trip and am too tired
to find the link. You can go to his site and search and while you're
there, there's lots of good stuff to read.</p>
</div>
</div>
</div>
</div>
</article><article class="h-entry post-text"><header><h1 class="p-name entry-title"><a href="posts/standards-who-for/" class="u-url">Standards - Who are they for?</a></h1>
<div class="metadata">
<p class="byline author vcard"><span class="byline-name fn" itemprop="author">
Mike Zamansky
</span></p>
<p class="dateline"><a href="posts/standards-who-for/" rel="bookmark"><time class="published dt-published" datetime="2017-10-10T14:05:35-04:00" title="2017-10-10 14:05">2017-10-10 14:05</time></a></p>
<p class="commentline"> <a href="posts/standards-who-for/#disqus_thread" data-disqus-identifier="cache/posts/standards-who-for.html">Comments</a>
</p>
</div>
</header><div class="e-content entry-content">
<div id="outline-container-sec-1" class="outline-2">
<h2 id="sec-1"></h2>
<div class="outline-text-2" id="text-1">
<p>
The big push at last year's CSTA conference was the release of the new
CSTA K12 standards. It seemed that every other session was pushing
them in one way or another. I've been meaning to share my thoughts
about them or, more specifically, learning standards in general for a
while but with announcement about federal funding for CS coming from
the White House last week I thought it was time.
</p>
<p>
Before diving into CS standards lets talk about math.
</p>
<p>
To start I have yet to meet a math teacher that needs
"the Standards" to know what to teach. Some how or other math teachers know
they're supposed to teach in an algebra or geometry class. When NY
moved to "integrated math" teachers were able to re-sequence classes
without the benefit of "the standards" and when NY went back to
Algebra, Geometry, then Alg 2 and Trig, teachers had no problem
reorganizing classes again.
</p>
<p>
New teachers didn't go to "the Standards" to learn the ropes. Schools
defined syllabi, teachers observed each other, shared resources, used
lesson plan books and in general knew what they were supposed to teach
and at what level.
</p>
<p>
In my quarter century of teaching, always in a math department we
spent a lot of time talking about what we taught, when we taught it,
how we taught it and at what level but until common core was forced
down our throats we NEVER discussed "the Standards." We discussed our
students, where we thought we could take them, and how to get them
there. Somehow our students did alright.
</p>
<p>
More recently, the push has been on "The Standards," common core in particular.
</p>
<p>
Common standards sound good - kids in every school will learn the same
things at the same level - but I contend that they aren't about
learning. They're about testing.
</p>
<p>
Let's look at a few of the math standards. These were pulled directly
from the Common Core:
</p>
<blockquote>
<p>
Derive the equation of a circle of given center and radius using the
Pythagorean Theorem; complete the square to find the center and radius
of a circle given by an equation.
</p>
</blockquote>
<blockquote>
<p>
Use coordinates to prove simple geometric theorems algebraically. For
example, prove or disprove that a figure defined by four given points
in the coordinate plane is a rectangle; prove or disprove that the
point (1, √3) lies on the circle centered at the origin and containing
the point (0, 2).
</p>
</blockquote>
<blockquote>
<p>
</p>
<p>
Derive using similarity the fact that the length of the arc
intercepted by an angle is proportional to the radius, and define the
radian measure of the angle as the constant of proportionality; derive
the formula for the area of a sector.
</p>
</blockquote>
<p>
These aren't about deep thinking and problem solving. They're about
very specific skills or techniques. They're also easy to put on a
test. Much easier then assessing a students real problem solving ability.
</p>
<p>
Common Core comes hand in hand with standardized testing which is then
used to punish students, teachers, and schools.
</p>
<p>
We keep hearing about individualized instruction - meeting the kids
where they are but the standards tell us that kids MUST know specific
things at specific times. You can't have both. In the best case, with
"the standards" we can only meet students "where they are" within
annual bands.
</p>
<p>
What has this led to? Narrowing curriculum for one thing. Since schools are
evaluated based on the standardized exam in core subjects focus
narrows and other subjects fall by the wayside.
</p>
<p>
Arguably worse is selective teaching within common core subjects.
</p>
<p>
Take for example, Geometry. The course is really "Logic and Deductive
Reasoning using Euclidean Geometry as a Platform" but it's generally
called Geometry. This class is supposed to be about getting kids to
think. I've already shared a few standards above but let me tell you
about an open secret - many schools don't really teach proof -
arguably the most important part of the class.
</p>
<p>
In my last year at Stuy I graded Geometry regents for the city. I
graded exams for two highly regarded unscreened schools. One that was
lauded in a State of the Union address and the other equally hyped. I
graded all of each school's students geometry regents so it wasn't
just a sampling. Out of all the papers, only two or three scored more
than 2 out of 9 points for the proof question and most were entirely
left blank.
</p>
<p>
What happened? Proof is hard to teach and hard to learn but it's also
only a small part of the standardized exam. It's critical for a
school's survival and for the student to graduate that a passing score
is earned. Rather than spending a large amount of time on few points
and probably get a limited return I've been told that many schools
spend much more time on topics that area easier to teach and have more
weight on the exam. This makes the school look better and helps the
student graduate but arguably the most important aspect of the course
has been minimized.
</p>
<p>
High stakes testing leads to gaming the system. Common core standards
come hand in hand with high stakes testing. We see the same with AP
exams - there are schools that force students to take exams even when
they are woefully prepared and mostly fail because this helps the
school shoot up in the ratings.
</p>
<p>
This is what the common core math standards have given us. They're not
for teachers - we don't need them - we know what to teach and only
wish that the bean counters would indeed allow us to meet students
where they are. Standards are about testing.
</p>
<p>
Let's move on to CS standards.
</p>
<p>
It might not be fair to compare CS to math since K12 math education
has been around much longer and is more well defined and in theory
having a set of standards gives us a common language to discuss,
compare, and contrast all the content providers and curriculum
developers out there. On the other hand, I also believe that with well
prepared teachers who understand content and pedagogy the value isn't
all that great. It's also worth considering the fact that nothing
really makes the CSTA Standard writers special. There's no reason to
think that another group - be they a handful of teachers or a content
provider can't do a comparable job.
</p>
<p>
Here are some selections from the CSTA standards:
</p>
<blockquote>
<p>
Design and develop a software artifact working in a team.
</p>
<p>
Compare and contrast various software licensing schemes (e.g., open source, freeware,
commercial).
</p>
<p>
Design, develop, and implement a computing artifact that responds to an event (e.g., robot
that responds to a sensor, mobile app that responds to a text message, sprite that responds
to a broadcas
</p>
<p>
Demonstrate the value of abstraction for managing problem complexity (e.g., using a list
instead of discrete variables).
</p>
<p>
Design algorithms u sing sequence, selection, and iteration.
</p>
<p>
Discuss techniques used to store, process, and retrieve different amounts of information
(e.g., files, databases, data warehouses).
</p>
<p>
Compare and debate the positive and negative impacts of computing on behavior and
culture (e.g., evolution from hitchhiking to ridesharing apps, online accommodation rental
services).
</p>
<p>
Use simple encryption and decryption algorithms to transmit/receive an encrypted
message.
</p>